Recreate the SettingsActivity on theme change

This commit is contained in:
Jakob Nixdorf 2017-07-31 08:52:12 +02:00
parent a5f9ec4efb
commit e9b33edb1a
No known key found for this signature in database
GPG key ID: BE99BF86574A7DBC

View file

@ -24,16 +24,19 @@ package org.shadowice.flocke.andotp;
import android.app.KeyguardManager;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
import android.support.v7.widget.Toolbar;
import android.view.ViewStub;
import org.openintents.openpgp.util.OpenPgpAppPreference;
import org.openintents.openpgp.util.OpenPgpKeyPreference;
public class SettingsActivity extends BaseActivity {
public class SettingsActivity extends BaseActivity
implements SharedPreferences.OnSharedPreferenceChangeListener{
SettingsFragment fragement;
@Override
@ -54,6 +57,9 @@ public class SettingsActivity extends BaseActivity {
getFragmentManager().beginTransaction()
.replace(R.id.container_content, fragement)
.commit();
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
sharedPref.registerOnSharedPreferenceChangeListener(this);
}
public void finishWithResult() {
@ -73,6 +79,12 @@ public class SettingsActivity extends BaseActivity {
super.onBackPressed();
}
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
if (key.equals(getString(R.string.settings_key_theme))) {
recreate();
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);