Check if selected theme it's not the current

This commit is contained in:
Mauricio Colli 2017-02-25 16:04:10 -03:00
parent f8d9e0fa60
commit 6ec393699e
1 changed files with 21 additions and 17 deletions

View File

@ -98,6 +98,8 @@ public class SettingsFragment extends PreferenceFragment
downloadPathAudioPreference = findPreference(DOWNLOAD_PATH_AUDIO_PREFERENCE); downloadPathAudioPreference = findPreference(DOWNLOAD_PATH_AUDIO_PREFERENCE);
themePreference = findPreference(THEME); themePreference = findPreference(THEME);
final String currentTheme = defaultPreferences.getString(THEME, "Light");
prefListener = new SharedPreferences.OnSharedPreferenceChangeListener() { prefListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
@Override @Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
@ -139,9 +141,10 @@ public class SettingsFragment extends PreferenceFragment
} }
else if (key == THEME) else if (key == THEME)
{ {
String theme = sharedPreferences.getString(THEME, "Light"); String selectedTheme = sharedPreferences.getString(THEME, "Light");
themePreference.setSummary(theme); themePreference.setSummary(selectedTheme);
if(!selectedTheme.equals(currentTheme)) { // If it's not the current theme
new AlertDialog.Builder(activity) new AlertDialog.Builder(activity)
.setTitle(R.string.restart_title) .setTitle(R.string.restart_title)
.setMessage(R.string.msg_restart) .setMessage(R.string.msg_restart)
@ -159,6 +162,7 @@ public class SettingsFragment extends PreferenceFragment
.setNegativeButton(R.string.later, null) .setNegativeButton(R.string.later, null)
.create().show(); .create().show();
} }
}
updateSummary(); updateSummary();
} }
}; };