Search in sources :

Example 41 with Preference

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;
}
Also used : OnPreferenceClickListener(android.preference.Preference.OnPreferenceClickListener) ListPreference(android.preference.ListPreference) Preference(android.preference.Preference)

Example 42 with Preference

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;
        }
    });
}
Also used : ListPreference(android.preference.ListPreference) Preference(android.preference.Preference) ATECheckBoxPreference(com.afollestad.appthemeengine.prefs.ATECheckBoxPreference) ATEColorPreference(com.afollestad.appthemeengine.prefs.ATEColorPreference) SwitchPreference(android.preference.SwitchPreference) ColorChooserDialog(com.afollestad.materialdialogs.color.ColorChooserDialog) ATECheckBoxPreference(com.afollestad.appthemeengine.prefs.ATECheckBoxPreference) ATEColorPreference(com.afollestad.appthemeengine.prefs.ATEColorPreference) SettingsActivity(com.naman14.timber.activities.SettingsActivity)

Example 43 with Preference

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();
    }
}
Also used : TwoStatePreference(android.preference.TwoStatePreference) Preference(android.preference.Preference) Resources(android.content.res.Resources)

Example 44 with Preference

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();
}
Also used : Context(android.content.Context) ResolveInfo(android.content.pm.ResolveInfo) PackageManager(android.content.pm.PackageManager) Preference(android.preference.Preference) SwitchPreference(android.preference.SwitchPreference) DictionarySettingsActivity(com.android.inputmethod.dictionarypack.DictionarySettingsActivity) Intent(android.content.Intent)

Example 45 with Preference

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);
            }
        }
    }
}
Also used : Preference(android.preference.Preference) CheckBoxPreference(android.preference.CheckBoxPreference) SwitchPreference(android.preference.SwitchPreference) CheckBoxPreference(android.preference.CheckBoxPreference) ArrayList(java.util.ArrayList) PreferenceGroup(android.preference.PreferenceGroup)

Aggregations

Preference (android.preference.Preference)183 CheckBoxPreference (android.preference.CheckBoxPreference)54 ListPreference (android.preference.ListPreference)54 PreferenceScreen (android.preference.PreferenceScreen)37 Intent (android.content.Intent)33 EditTextPreference (android.preference.EditTextPreference)29 OnPreferenceChangeListener (android.preference.Preference.OnPreferenceChangeListener)23 PreferenceCategory (android.preference.PreferenceCategory)23 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)21 SharedPreferences (android.content.SharedPreferences)19 ChromeSwitchPreference (org.chromium.chrome.browser.preferences.ChromeSwitchPreference)16 PreferenceGroup (android.preference.PreferenceGroup)15 Test (org.junit.Test)15 Uri (android.net.Uri)12 Bundle (android.os.Bundle)12 ArrayList (java.util.ArrayList)11 Resources (android.content.res.Resources)10 SwitchPreference (android.preference.SwitchPreference)10 View (android.view.View)10 ChromeBasePreference (org.chromium.chrome.browser.preferences.ChromeBasePreference)10