Fixes #639 - Unregister shared preference change listener so that we aren't leaving callbacks to a destroyed activity
Make fields in SettingsActivity/SettingsFragment private
This commit is contained in:
parent
aab9c1af00
commit
fef9b4b9c2
1 changed files with 24 additions and 14 deletions
|
@ -66,10 +66,12 @@ import static org.shadowice.flocke.andotp.Utilities.Constants.EncryptionType;
|
||||||
|
|
||||||
public class SettingsActivity extends BaseActivity
|
public class SettingsActivity extends BaseActivity
|
||||||
implements SharedPreferences.OnSharedPreferenceChangeListener{
|
implements SharedPreferences.OnSharedPreferenceChangeListener{
|
||||||
SettingsFragment fragment;
|
|
||||||
|
|
||||||
SecretKey encryptionKey = null;
|
private SettingsFragment fragment;
|
||||||
boolean encryptionChanged = false;
|
private SharedPreferences prefs;
|
||||||
|
|
||||||
|
private SecretKey encryptionKey = null;
|
||||||
|
private boolean encryptionChanged = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -104,8 +106,8 @@ public class SettingsActivity extends BaseActivity
|
||||||
.replace(R.id.container_content, fragment)
|
.replace(R.id.container_content, fragment)
|
||||||
.commit();
|
.commit();
|
||||||
|
|
||||||
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
|
prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
sharedPref.registerOnSharedPreferenceChangeListener(this);
|
prefs.registerOnSharedPreferenceChangeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -277,18 +279,26 @@ public class SettingsActivity extends BaseActivity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
prefs.unregisterOnSharedPreferenceChangeListener(this);
|
||||||
|
prefs = null;
|
||||||
|
|
||||||
|
super.onDestroy();
|
||||||
|
}
|
||||||
|
|
||||||
public static class SettingsFragment extends PreferenceFragment {
|
public static class SettingsFragment extends PreferenceFragment {
|
||||||
PreferenceCategory catSecurity;
|
private PreferenceCategory catSecurity;
|
||||||
|
|
||||||
Settings settings;
|
private Settings settings;
|
||||||
ListPreference encryption;
|
private ListPreference encryption;
|
||||||
Preference backupLocation;
|
private Preference backupLocation;
|
||||||
ListPreference useAutoBackup;
|
private ListPreference useAutoBackup;
|
||||||
CheckBoxPreference useAndroidSync;
|
private CheckBoxPreference useAndroidSync;
|
||||||
|
|
||||||
OpenPgpAppPreference pgpProvider;
|
private OpenPgpAppPreference pgpProvider;
|
||||||
EditTextPreference pgpEncryptionKey;
|
private EditTextPreference pgpEncryptionKey;
|
||||||
OpenPgpKeyPreference pgpSigningKey;
|
private OpenPgpKeyPreference pgpSigningKey;
|
||||||
|
|
||||||
public void encryptionChangeWithDialog(final EncryptionType encryptionType) {
|
public void encryptionChangeWithDialog(final EncryptionType encryptionType) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
|
|
Loading…
Reference in a new issue