예제 #1
0
  @Override
  protected void onResume() {
    super.onPause();

    if (debug) Log.d(TAG, "onResume()");
    if (CategoryList.isSignedIn() == true) {
      if (debug) Log.d(TAG, "already signed in");
      Intent callbackIntent = new Intent();
      setResult(RESULT_OK, callbackIntent);
      finish();
      return;
    }

    if (dbHelper == null) {
      dbHelper = new DBHelper(this);
    }
    if (dbHelper.isDatabaseOpen() == false) {
      if (debug) Log.d(TAG, "eek! database is not open");
      return;
    }
    if (viewMode == VIEW_NORMAL) {
      // clear pbeKey in case user had typed it, strayed
      // to something else, then another person opened
      // the app.   Wouldn't want the password already typed
      pbeKey.setText("");
    }
  }
예제 #2
0
  /** Called when the activity is first created. */
  @SuppressLint("ShowToast")
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    mDistribution.setFirst(MENU_DISTRIBUTION_START, DIALOG_DISTRIBUTION_START);

    // Check whether EULA has been accepted
    // or information about new version can be presented.
    if (mDistribution.showEulaOrNewVersion()) {
      return;
    }

    if (debug) Log.d(TAG, "onCreate(" + icicle + ")");

    dbHelper = new DBHelper(this);
    if (dbHelper.isDatabaseOpen() == false) {
      Dialog dbError =
          new AlertDialog.Builder(this)
              .setIcon(android.R.drawable.ic_dialog_alert)
              .setTitle(R.string.database_error_title)
              .setPositiveButton(
                  android.R.string.ok,
                  new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                      finish();
                    }
                  })
              .setMessage(R.string.database_error_msg)
              .create();
      dbError.show();
      return;
    }

    ch = new CryptoHelper();
    if (dbHelper.needsUpgrade()) {
      switch (dbHelper.fetchVersion()) {
        case 2:
          databaseVersionError();
      }
    }
    dbSalt = dbHelper.fetchSalt();
    dbMasterKey = dbHelper.fetchMasterKey();

    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
    boolean prefKeypad = sp.getBoolean(Preferences.PREFERENCE_KEYPAD, false);
    boolean prefKeypadMute = sp.getBoolean(Preferences.PREFERENCE_KEYPAD_MUTE, false);
    mute = prefKeypadMute;

    if (prefKeypad) {
      viewMode = VIEW_KEYPAD;
    }
    if (dbMasterKey.length() == 0) {
      firstTime = true;
    }
    if ((viewMode == VIEW_NORMAL) || (firstTime)) {
      normalInit();
    } else {
      keypadInit();
    }

    blankPasswordToast =
        Toast.makeText(AskPassword.this, R.string.notify_blank_pass, Toast.LENGTH_SHORT);
    invalidPasswordToast =
        Toast.makeText(AskPassword.this, R.string.invalid_password, Toast.LENGTH_SHORT);
    confirmPasswordFailToast =
        Toast.makeText(AskPassword.this, R.string.confirm_pass_fail, Toast.LENGTH_SHORT);
  }