+
+
+ /**
+ * Processes the pass code entered by the user just after the last digit was in.
+ *
+ * Takes into account the action requested to the activity, the currently saved pass code and the previously
+ * typed pass code, if any.
+ */
+ private void processFullPassCode() {
+ if (ACTION_REQUEST.equals(getIntent().getAction())) {
+ if (checkPassCode()) {
+ /// pass code accepted in request, user is allowed to access the app
+ finish();
+
+ } else {
+ showErrorAndRestart(R.string.common_error, R.string.pass_code_enter_pass_code, View.INVISIBLE);
+ /// TODO better error message
+ }
+
+ } else if (ACTION_DISABLE.equals(getIntent().getAction())) {
+ if (checkPassCode()) {
+ /// pass code accepted when disabling, pass code is removed
+ SharedPreferences.Editor appPrefs = PreferenceManager
+ .getDefaultSharedPreferences(getApplicationContext()).edit();
+ appPrefs.putBoolean("set_pincode", false); // TODO remove; this should be unnecessary, was done before entering in the activity
+ appPrefs.commit();
+
+ Toast.makeText(PassCodeActivity.this, R.string.pass_code_removed, Toast.LENGTH_LONG).show();
+ finish();
+
+ } else {
+ showErrorAndRestart(R.string.common_error, R.string.pass_code_enter_pass_code, View.INVISIBLE);
+ /// TODO better error message
+ }
+
+ } else if (ACTION_ENABLE.equals(getIntent().getAction())) {
+ /// enabling pass code
+ if (!mConfirmingPassCode) {
+ requestPassCodeConfirmation();
+
+ } else if (confirmPassCode()) {
+ /// confirmed: user typed the same pass code twice
+ savePassCodeAndExit();
+
+ } else {
+ showErrorAndRestart(
+ R.string.pass_code_mismatch, R.string.pass_code_configure_your_pass_code, View.VISIBLE
+ );
+ }
+ }
+ }
+