save fragment state when changing theme/langugage

closes #2782
// FREEBIE
This commit is contained in:
Dustin Lim 2015-07-15 14:02:03 +02:00 committed by Moxie Marlinspike
parent 9201d50f05
commit 0cd4cc67af

View File

@ -18,6 +18,7 @@ package org.thoughtcrime.securesms;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.preference.Preference;
import android.support.annotation.NonNull;
@ -70,7 +71,10 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA
@Override
protected void onCreate(Bundle icicle, @NonNull MasterSecret masterSecret) {
this.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
initFragment(android.R.id.content, new ApplicationPreferenceFragment(), masterSecret);
if (icicle == null) {
initFragment(android.R.id.content, new ApplicationPreferenceFragment(), masterSecret);
}
}
@Override
@ -105,9 +109,11 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (key.equals(TextSecurePreferences.THEME_PREF)) {
dynamicTheme.onResume(this);
if (VERSION.SDK_INT >= 11) recreate();
else dynamicTheme.onResume(this);
} else if (key.equals(TextSecurePreferences.LANGUAGE_PREF)) {
dynamicLanguage.onResume(this);
if (VERSION.SDK_INT >= 11) recreate();
else dynamicLanguage.onResume(this);
Intent intent = new Intent(this, KeyCachingService.class);
intent.setAction(KeyCachingService.LOCALE_CHANGE_EVENT);