Android Open Source - trust News Dialog Fragment






From Project

Back to project page trust.

License

The source code is released under:

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCT...

If you think the Android project trust listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package eu.thedarken.trust.dialogs;
//from w w  w . j a v a2 s  . c  om
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentManager;
import android.view.ContextThemeWrapper;
import android.view.View;
import android.widget.Toast;
import eu.thedarken.trust.R;
import eu.thedarken.trust.TrustActivity;

public class NewsDialogFragment extends DialogFragment {
    public static NewsDialogFragment newInstance() {
        return new NewsDialogFragment();
    }

    public void showDialog(FragmentManager fragman) {
        // Create the fragment and show it as a dialog.
        DialogFragment show = NewsDialogFragment.newInstance();
        show.show(fragman, "NewsDialogFragment");
    }

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        ContextThemeWrapper context;
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
            context = new ContextThemeWrapper(getActivity(), android.R.style.Theme_Dialog);
        } else {
            context = new ContextThemeWrapper(getActivity(), R.style.TrustTheme);
        }
        Builder bd = new AlertDialog.Builder(context)
                .setTitle(getString(R.string.app_name) + " " + TrustActivity.sVersionName)
                .setCancelable(true)
                .setPositiveButton(getString(R.string.buy_pro), new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        try {
                            Intent marketIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=eu.thedarken.trust.pro"));
                            startActivity(marketIntent);
                        } catch (Exception e) {
                            Toast.makeText(getActivity(), R.string.no_market_application_found, Toast.LENGTH_SHORT).show();
                        }
                    }
                })
                .setNegativeButton(getString(R.string.hide), new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getActivity());
                        SharedPreferences.Editor prefEditor = settings.edit();
                        prefEditor.putInt("news_version", TrustActivity.sVersionCode);
                        prefEditor.commit();
                        getDialog().dismiss();
                    }
                });
        View dialoglayout = getActivity().getLayoutInflater().inflate(R.layout.news_dialog_fragment, null);
        bd.setView(dialoglayout);

        return bd.create();
    }


}




Java Source Code List

eu.thedarken.trust.AppWatcher.java
eu.thedarken.trust.ApplicationTest.java
eu.thedarken.trust.TestGenerator.java
eu.thedarken.trust.TrustActivity.java
eu.thedarken.trust.TrustAutostart.java
eu.thedarken.trust.TrustListAdapter.java
eu.thedarken.trust.TrustListFragment.java
eu.thedarken.trust.TrustPreferences.java
eu.thedarken.trust.TrustReceivers.java
eu.thedarken.trust.TrustService.java
eu.thedarken.trust.db.TrustDB.java
eu.thedarken.trust.dialogs.AboutDialogFragment.java
eu.thedarken.trust.dialogs.DetailsDialogFragment.java
eu.thedarken.trust.dialogs.ExportDialogFragment.java
eu.thedarken.trust.dialogs.FilterDialogFragment.java
eu.thedarken.trust.dialogs.FollowMeDialog.java
eu.thedarken.trust.dialogs.NewsDialogFragment.java
eu.thedarken.trust.lockpattern.Lists.java
eu.thedarken.trust.lockpattern.LockPatternActivity.java
eu.thedarken.trust.lockpattern.LockPatternUtils.java
eu.thedarken.trust.lockpattern.LockPatternView.java
eu.thedarken.trust.logentries.Descriptions.java
eu.thedarken.trust.logentries.IDMaker.java
eu.thedarken.trust.logentries.IntentHelper.java
eu.thedarken.trust.logentries.LogEntryMaker.java
eu.thedarken.trust.logentries.LogEntry.java
eu.thedarken.trust.pro.TrustPro.java