Android Open Source - Matrix-Mate Simple Eula






From Project

Back to project page Matrix-Mate.

License

The source code is released under:

MIT License

If you think the Android project Matrix-Mate 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 com.RSen.MatrixMate;
/*from   w  w  w  . jav  a  2s. co  m*/
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.preference.PreferenceManager;

public class SimpleEula {

  private String EULA_PREFIX = "eula_";
  private Activity mActivity;

  public SimpleEula(Activity context) {
    mActivity = context;
  }

  private PackageInfo getPackageInfo() {
    PackageInfo pi = null;
    try {
      pi = mActivity.getPackageManager().getPackageInfo(
          mActivity.getPackageName(), PackageManager.GET_ACTIVITIES);
    } catch (PackageManager.NameNotFoundException e) {
      e.printStackTrace();
    }
    return pi;
  }

  public void show() {
    PackageInfo versionInfo = getPackageInfo();

    // the eulaKey changes every time you increment the version number in
    // the AndroidManifest.xml
    final String eulaKey = EULA_PREFIX + versionInfo.versionCode;
    final SharedPreferences prefs = PreferenceManager
        .getDefaultSharedPreferences(mActivity);
    boolean hasBeenShown = prefs.getBoolean(eulaKey, false);
    if (hasBeenShown == false) {

      // Show the Eula
      String title = mActivity.getString(R.string.app_name) + " v"
          + versionInfo.versionName;

      // Includes the updates as well so users know what changed.
      String message = mActivity
          .getString(R.string.EULA);

      AlertDialog.Builder builder = new AlertDialog.Builder(mActivity)
          .setTitle(title)
          .setMessage(message)
          .setPositiveButton(R.string.accept,
              new Dialog.OnClickListener() {

                @Override
                public void onClick(
                    DialogInterface dialogInterface, int i) {
                  // Mark this version as read.
                  SharedPreferences.Editor editor = prefs
                      .edit();
                  editor.putBoolean(eulaKey, true);
                  editor.commit();
                  dialogInterface.dismiss();
                }
              })
          .setNegativeButton(R.string.quit,
              new Dialog.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog,
                    int which) {
                  // Close the activity as they have declined
                  // the EULA
                  mActivity.finish();
                }

              });
      builder.create().show();
    }
  }

}




Java Source Code List

com.RSen.MatrixMate.GmailSender.java
com.RSen.MatrixMate.JSSEProvider.java
com.RSen.MatrixMate.MainSearchLayout.java
com.RSen.MatrixMate.ManipulateActivity.java
com.RSen.MatrixMate.MatrixMateActivity.java
com.RSen.MatrixMate.NumberPickerButton.java
com.RSen.MatrixMate.NumberPickerDialog.java
com.RSen.MatrixMate.NumberPickerPreference.java
com.RSen.MatrixMate.NumberPicker.java
com.RSen.MatrixMate.ReportDialog.java
com.RSen.MatrixMate.SimpleEula.java