Cache the encryption key when recreating the settings activity after settings changes
This commit is contained in:
parent
cdc54028b3
commit
c1d6c6b2b8
1 changed files with 17 additions and 0 deletions
|
@ -85,6 +85,15 @@ public class SettingsActivity extends BaseActivity
|
|||
if (keyMaterial != null && keyMaterial.length > 0)
|
||||
encryptionKey = EncryptionHelper.generateSymmetricKey(keyMaterial);
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
encryptionChanged = savedInstanceState.getBoolean(Constants.EXTRA_SETTINGS_ENCRYPTION_CHANGED, false);
|
||||
|
||||
byte[] encKey = savedInstanceState.getByteArray(Constants.EXTRA_SETTINGS_ENCRYPTION_KEY);
|
||||
if (encKey != null) {
|
||||
encryptionKey = EncryptionHelper.generateSymmetricKey(encKey);
|
||||
}
|
||||
}
|
||||
|
||||
fragment = new SettingsFragment();
|
||||
|
||||
getFragmentManager().beginTransaction()
|
||||
|
@ -95,6 +104,14 @@ public class SettingsActivity extends BaseActivity
|
|||
sharedPref.registerOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
|
||||
outState.putBoolean(Constants.EXTRA_SETTINGS_ENCRYPTION_CHANGED, encryptionChanged);
|
||||
outState.putByteArray(Constants.EXTRA_SETTINGS_ENCRYPTION_KEY, encryptionKey.getEncoded());
|
||||
}
|
||||
|
||||
public void finishWithResult() {
|
||||
Intent data = new Intent();
|
||||
|
||||
|
|
Loading…
Reference in a new issue