mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-11-25 06:16:15 +03:00
Merge pull request #515 from stefan-niedermann/rdtt
Condensed code in PreferencesFragment
This commit is contained in:
commit
81c881d5a6
1 changed files with 2 additions and 10 deletions
|
@ -32,9 +32,9 @@ public class PreferencesFragment extends PreferenceFragment {
|
||||||
|
|
||||||
final SwitchPreference themePref = (SwitchPreference) findPreference(getString(R.string.pref_key_theme));
|
final SwitchPreference themePref = (SwitchPreference) findPreference(getString(R.string.pref_key_theme));
|
||||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext());
|
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext());
|
||||||
Boolean darkTheme = sp.getBoolean(getString(R.string.pref_key_theme), false);
|
|
||||||
|
|
||||||
setThemePreferenceSummary(themePref, darkTheme);
|
themePref.setSummary(sp.getBoolean(getString(R.string.pref_key_theme), false) ?
|
||||||
|
getString(R.string.pref_value_theme_dark) : getString(R.string.pref_value_theme_light));
|
||||||
themePref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
themePref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
@ -47,12 +47,4 @@ public class PreferencesFragment extends PreferenceFragment {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setThemePreferenceSummary(SwitchPreference themePref, Boolean darkTheme) {
|
|
||||||
if (darkTheme) {
|
|
||||||
themePref.setSummary(getString(R.string.pref_value_theme_dark));
|
|
||||||
} else {
|
|
||||||
themePref.setSummary(getString(R.string.pref_value_theme_light));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue