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.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Build.VERSION;
import android.os.Bundle; import android.os.Bundle;
import android.preference.Preference; import android.preference.Preference;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
@ -70,8 +71,11 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA
@Override @Override
protected void onCreate(Bundle icicle, @NonNull MasterSecret masterSecret) { protected void onCreate(Bundle icicle, @NonNull MasterSecret masterSecret) {
this.getSupportActionBar().setDisplayHomeAsUpEnabled(true); this.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
if (icicle == null) {
initFragment(android.R.id.content, new ApplicationPreferenceFragment(), masterSecret); initFragment(android.R.id.content, new ApplicationPreferenceFragment(), masterSecret);
} }
}
@Override @Override
public void onResume() { public void onResume() {
@ -105,9 +109,11 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA
@Override @Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (key.equals(TextSecurePreferences.THEME_PREF)) { 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)) { } 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 intent = new Intent(this, KeyCachingService.class);
intent.setAction(KeyCachingService.LOCALE_CHANGE_EVENT); intent.setAction(KeyCachingService.LOCALE_CHANGE_EVENT);