use of com.afollestad.appthemeengine.prefs.ATEColorPreference in project ListenerMusicPlayer by hefuyicoder.
the class SettingFragment method invalidateSettings.
public void invalidateSettings() {
mAteKey = ((SettingActivity) getActivity()).getATEKey();
ATEColorPreference primaryColorPref = (ATEColorPreference) findPreference("primary_color");
primaryColorPref.setColor(Config.primaryColor(getActivity(), mAteKey), Color.BLACK);
primaryColorPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
new ColorChooserDialog.Builder((SettingActivity) getActivity(), R.string.primary_color).preselect(Config.primaryColor(getActivity(), mAteKey)).show();
return true;
}
});
findPreference("dark_theme").setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
// Marks both theme configs as changed so MainActivity restarts itself on return
Config.markChanged(getActivity(), "light_theme");
Config.markChanged(getActivity(), "dark_theme");
// The dark_theme preference value gets saved by Android in the default PreferenceManager.
// It's used in getATEKey() of both the Activities.
getActivity().recreate();
return true;
}
});
}
use of com.afollestad.appthemeengine.prefs.ATEColorPreference in project Timber by naman14.
the class SettingsFragment method invalidateSettings.
public void invalidateSettings() {
mAteKey = ((SettingsActivity) getActivity()).getATEKey();
ATEColorPreference primaryColorPref = (ATEColorPreference) findPreference("primary_color");
primaryColorPref.setColor(Config.primaryColor(getActivity(), mAteKey), Color.BLACK);
primaryColorPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
new ColorChooserDialog.Builder((SettingsActivity) getActivity(), R.string.primary_color).preselect(Config.primaryColor(getActivity(), mAteKey)).show();
return true;
}
});
ATEColorPreference accentColorPref = (ATEColorPreference) findPreference("accent_color");
accentColorPref.setColor(Config.accentColor(getActivity(), mAteKey), Color.BLACK);
accentColorPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
new ColorChooserDialog.Builder((SettingsActivity) getActivity(), R.string.accent_color).preselect(Config.accentColor(getActivity(), mAteKey)).show();
return true;
}
});
findPreference("dark_theme").setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
// Marks both theme configs as changed so MainActivity restarts itself on return
Config.markChanged(getActivity(), "light_theme");
Config.markChanged(getActivity(), "dark_theme");
// The dark_theme preference value gets saved by Android in the default PreferenceManager.
// It's used in getATEKey() of both the Activities.
getActivity().recreate();
return true;
}
});
final ATECheckBoxPreference statusBarPref = (ATECheckBoxPreference) findPreference("colored_status_bar");
final ATECheckBoxPreference navBarPref = (ATECheckBoxPreference) findPreference("colored_nav_bar");
statusBarPref.setChecked(Config.coloredStatusBar(getActivity(), mAteKey));
statusBarPref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
ATE.config(getActivity(), mAteKey).coloredStatusBar((Boolean) newValue).apply(getActivity());
return true;
}
});
navBarPref.setChecked(Config.coloredNavigationBar(getActivity(), mAteKey));
navBarPref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
ATE.config(getActivity(), mAteKey).coloredNavigationBar((Boolean) newValue).apply(getActivity());
return true;
}
});
}
Aggregations