save the state before rotate

This commit is contained in:
purigarcia 2015-07-09 16:40:29 +02:00
parent d32032fc96
commit 066324f60a

View file

@ -61,7 +61,9 @@ public class PassCodeActivity extends ActionBarActivity {
private EditText[] mPassCodeEditTexts = new EditText[4];
private String [] mPassCodeDigits = {"","","",""};
private static String KEY_PASSCODE_DIGITS = "PASSCODE_DIGITS";
private boolean mConfirmingPassCode = false;
private static String KEY_CONFIRMING_PASSCODE = "CONFIRMING_PASSCODE";
private boolean mBChange = true; // to control that only one blocks jump
@ -96,6 +98,15 @@ public class PassCodeActivity extends ActionBarActivity {
setCancelButtonEnabled(false); // no option to cancel
} else if (ACTION_ENABLE.equals(getIntent().getAction())) {
if (savedInstanceState != null) {
mConfirmingPassCode = savedInstanceState.getBoolean(PassCodeActivity.KEY_CONFIRMING_PASSCODE);
mPassCodeDigits = savedInstanceState.getStringArray(PassCodeActivity.KEY_PASSCODE_DIGITS);
if(mConfirmingPassCode){
//the app was in the passcodeconfirmation
requestPassCodeConfirmation();
}
}
if(savedInstanceState == null || (savedInstanceState != null && !mConfirmingPassCode)){
/// pass code preference has just been activated in Preferences;
// will receive and confirm pass code value
mPassCodeHdr.setText(R.string.pass_code_configure_your_pass_code);
@ -103,6 +114,7 @@ public class PassCodeActivity extends ActionBarActivity {
// TODO choose a header, check iOS
mPassCodeHdrExplanation.setVisibility(View.VISIBLE);
setCancelButtonEnabled(true);
}
} else if (ACTION_DISABLE.equals(getIntent().getAction())) {
/// pass code preference has just been disabled in Preferences;
@ -455,6 +467,13 @@ public class PassCodeActivity extends ActionBarActivity {
finish();
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean(PassCodeActivity.KEY_CONFIRMING_PASSCODE, mConfirmingPassCode);
outState.putStringArray(PassCodeActivity.KEY_PASSCODE_DIGITS, mPassCodeDigits);
}
private class PassCodeDigitTextWatcher implements TextWatcher {