use of android.preference.Preference in project scdl by passy.
the class DownloadPreferencesDelegateImpl method onCreate.
/*
* (non-Javadoc)
*
* @see net.rdrei.android.scdl2.ui.DownloadPreferencesDelegate#onCreate()
*/
@Override
public void onCreate(final ActivityStarter activityStarter) {
mTypePreference = (ListPreference) mPreferenceManager.findPreference(ApplicationPreferences.KEY_STORAGE_TYPE);
mPathPreference = mPreferenceManager.findPreference(ApplicationPreferences.KEY_STORAGE_CUSTOM_PATH);
mPathPreference.setOnPreferenceChangeListener(mCustomPathValidator);
mPathPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(final Preference preference) {
startDownloadDirectoryChooser();
return true;
}
});
setupAboutHandlers();
loadStorageTypeOptions();
mActivityStarter = activityStarter;
}
use of android.preference.Preference 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;
}
});
}
use of android.preference.Preference in project android_packages_inputmethods_LatinIME by CyanogenMod.
the class AccountsSettingsFragment method onCreate.
@Override
public void onCreate(final Bundle icicle) {
super.onCreate(icicle);
addPreferencesFromResource(R.xml.prefs_screen_accounts);
mAccountSwitcher = findPreference(PREF_ACCCOUNT_SWITCHER);
mEnableSyncPreference = (TwoStatePreference) findPreference(PREF_ENABLE_SYNC_NOW);
mSyncNowPreference = findPreference(PREF_SYNC_NOW);
mClearSyncDataPreference = findPreference(PREF_CLEAR_SYNC_DATA);
if (ProductionFlags.IS_METRICS_LOGGING_SUPPORTED) {
final Preference enableMetricsLogging = findPreference(Settings.PREF_ENABLE_METRICS_LOGGING);
final Resources res = getResources();
if (enableMetricsLogging != null) {
final String enableMetricsLoggingTitle = res.getString(R.string.enable_metrics_logging, getApplicationName());
enableMetricsLogging.setTitle(enableMetricsLoggingTitle);
}
} else {
removePreference(Settings.PREF_ENABLE_METRICS_LOGGING);
}
if (!ProductionFlags.ENABLE_USER_HISTORY_DICTIONARY_SYNC) {
removeSyncPreferences();
} else {
// Disable by default till we are sure we can enable this.
disableSyncPreferences();
new ManagedProfileCheckerTask(this).execute();
}
}
use of android.preference.Preference in project android_packages_inputmethods_LatinIME by CyanogenMod.
the class CorrectionSettingsFragment method onCreate.
@Override
public void onCreate(final Bundle icicle) {
super.onCreate(icicle);
addPreferencesFromResource(R.xml.prefs_screen_correction);
final Context context = getActivity();
final PackageManager pm = context.getPackageManager();
final Preference dictionaryLink = findPreference(Settings.PREF_CONFIGURE_DICTIONARIES_KEY);
final Intent intent = dictionaryLink.getIntent();
intent.setClassName(context.getPackageName(), DictionarySettingsActivity.class.getName());
final int number = pm.queryIntentActivities(intent, 0).size();
if (0 >= number) {
removePreference(Settings.PREF_CONFIGURE_DICTIONARIES_KEY);
}
final Preference editPersonalDictionary = findPreference(Settings.PREF_EDIT_PERSONAL_DICTIONARY);
final Intent editPersonalDictionaryIntent = editPersonalDictionary.getIntent();
final ResolveInfo ri = USE_INTERNAL_PERSONAL_DICTIONARY_SETTINGS ? null : pm.resolveActivity(editPersonalDictionaryIntent, PackageManager.MATCH_DEFAULT_ONLY);
if (ri == null) {
overwriteUserDictionaryPreference(editPersonalDictionary);
}
mUseContactsPreference = (SwitchPreference) findPreference(Settings.PREF_KEY_USE_CONTACTS_DICT);
turnOffUseContactsIfNoPermission();
}
use of android.preference.Preference in project android_packages_inputmethods_LatinIME by CyanogenMod.
the class TwoStatePreferenceHelper method replaceAllCheckBoxPreferencesBySwitchPreferences.
private static void replaceAllCheckBoxPreferencesBySwitchPreferences(final PreferenceGroup group) {
final ArrayList<Preference> preferences = new ArrayList<>();
final int count = group.getPreferenceCount();
for (int index = 0; index < count; index++) {
preferences.add(group.getPreference(index));
}
group.removeAll();
for (int index = 0; index < count; index++) {
final Preference preference = preferences.get(index);
if (preference instanceof CheckBoxPreference) {
addSwitchPreferenceBasedOnCheckBoxPreference((CheckBoxPreference) preference, group);
} else {
group.addPreference(preference);
if (preference instanceof PreferenceGroup) {
replaceAllCheckBoxPreferencesBySwitchPreferences((PreferenceGroup) preference);
}
}
}
}
Aggregations