Search in sources :

Example 16 with OnPreferenceChangeListener

use of android.preference.Preference.OnPreferenceChangeListener in project AndroidChromium by JackyAndroid.

the class HomepagePreferences method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    mHomepageManager = HomepageManager.getInstance(getActivity());
    getActivity().setTitle(R.string.options_homepage_title);
    addPreferencesFromResource(R.xml.homepage_preferences);
    mHomepageSwitch = (ChromeSwitchPreference) findPreference(PREF_HOMEPAGE_SWITCH);
    boolean isHomepageEnabled = mHomepageManager.getPrefHomepageEnabled();
    mHomepageSwitch.setChecked(isHomepageEnabled);
    mHomepageSwitch.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            mHomepageManager.setPrefHomepageEnabled((boolean) newValue);
            return true;
        }
    });
    mHomepageEdit = findPreference(PREF_HOMEPAGE_EDIT);
    updateCurrentHomepageUrl();
}
Also used : Preference(android.preference.Preference) OnPreferenceChangeListener(android.preference.Preference.OnPreferenceChangeListener)

Example 17 with OnPreferenceChangeListener

use of android.preference.Preference.OnPreferenceChangeListener in project AndroidChromium by JackyAndroid.

the class AutofillPreferences method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.autofill_preferences);
    getActivity().setTitle(R.string.prefs_autofill);
    ChromeSwitchPreference autofillSwitch = (ChromeSwitchPreference) findPreference(PREF_AUTOFILL_SWITCH);
    autofillSwitch.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            PersonalDataManager.setAutofillEnabled((boolean) newValue);
            return true;
        }
    });
    setPreferenceCategoryIcons();
}
Also used : ChromeSwitchPreference(org.chromium.chrome.browser.preferences.ChromeSwitchPreference) Preference(android.preference.Preference) ChromeSwitchPreference(org.chromium.chrome.browser.preferences.ChromeSwitchPreference) OnPreferenceChangeListener(android.preference.Preference.OnPreferenceChangeListener)

Example 18 with OnPreferenceChangeListener

use of android.preference.Preference.OnPreferenceChangeListener in project AndroidChromium by JackyAndroid.

the class TranslatePreferences method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.translate_preferences);
    getActivity().setTitle(R.string.google_translate);
    setHasOptionsMenu(true);
    final Context context = getActivity();
    if (context == null)
        return;
    ChromeSwitchPreference translateSwitch = (ChromeSwitchPreference) findPreference(PREF_TRANSLATE_SWITCH);
    boolean isTranslateEnabled = PrefServiceBridge.getInstance().isTranslateEnabled();
    translateSwitch.setChecked(isTranslateEnabled);
    translateSwitch.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            PrefServiceBridge.getInstance().setTranslateEnabled((boolean) newValue);
            return true;
        }
    });
    translateSwitch.setManagedPreferenceDelegate(new ManagedPreferenceDelegate() {

        @Override
        public boolean isPreferenceControlledByPolicy(Preference preference) {
            return PrefServiceBridge.getInstance().isTranslateManaged();
        }
    });
    ButtonPreference resetTranslateButton = (ButtonPreference) findPreference(PREF_RESET_TRANSLATE_BUTTON);
    resetTranslateButton.setOnPreferenceClickListener(new OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            PrefServiceBridge.getInstance().resetTranslateDefaults();
            Toast.makeText(getActivity(), getString(R.string.translate_prefs_toast_description), Toast.LENGTH_SHORT).show();
            return true;
        }
    });
}
Also used : Context(android.content.Context) OnPreferenceClickListener(android.preference.Preference.OnPreferenceClickListener) ManagedPreferenceDelegate(org.chromium.chrome.browser.preferences.ManagedPreferenceDelegate) ButtonPreference(org.chromium.chrome.browser.preferences.ButtonPreference) ChromeSwitchPreference(org.chromium.chrome.browser.preferences.ChromeSwitchPreference) Preference(android.preference.Preference) ButtonPreference(org.chromium.chrome.browser.preferences.ButtonPreference) ChromeSwitchPreference(org.chromium.chrome.browser.preferences.ChromeSwitchPreference) OnPreferenceChangeListener(android.preference.Preference.OnPreferenceChangeListener)

Example 19 with OnPreferenceChangeListener

use of android.preference.Preference.OnPreferenceChangeListener in project AndroidChromium by JackyAndroid.

the class PhysicalWebPreferenceFragment method initPhysicalWebSwitch.

private void initPhysicalWebSwitch() {
    ChromeSwitchPreference physicalWebSwitch = (ChromeSwitchPreference) findPreference(PREF_PHYSICAL_WEB_SWITCH);
    physicalWebSwitch.setChecked(PrivacyPreferencesManager.getInstance().isPhysicalWebEnabled());
    physicalWebSwitch.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            boolean enabled = (boolean) newValue;
            if (enabled) {
                PhysicalWebUma.onPrefsFeatureEnabled(getActivity());
                ensureLocationPermission();
            } else {
                PhysicalWebUma.onPrefsFeatureDisabled(getActivity());
            }
            PrivacyPreferencesManager.getInstance().setPhysicalWebEnabled(enabled);
            return true;
        }
    });
}
Also used : ButtonPreference(org.chromium.chrome.browser.preferences.ButtonPreference) ChromeSwitchPreference(org.chromium.chrome.browser.preferences.ChromeSwitchPreference) Preference(android.preference.Preference) ChromeSwitchPreference(org.chromium.chrome.browser.preferences.ChromeSwitchPreference) OnPreferenceChangeListener(android.preference.Preference.OnPreferenceChangeListener)

Example 20 with OnPreferenceChangeListener

use of android.preference.Preference.OnPreferenceChangeListener in project AndroidChromium by JackyAndroid.

the class UsageAndCrashReportsPreferenceFragment method initUsageAndCrashReportsSwitch.

private void initUsageAndCrashReportsSwitch() {
    ChromeSwitchPreference usageAndCrashReportsSwitch = (ChromeSwitchPreference) findPreference(PREF_USAGE_AND_CRASH_REPORTS_SWITCH);
    boolean enabled = PrivacyPreferencesManager.getInstance().isUsageAndCrashReportingEnabled();
    usageAndCrashReportsSwitch.setChecked(enabled);
    usageAndCrashReportsSwitch.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            UmaSessionStats.changeMetricsReportingConsent((boolean) newValue);
            return true;
        }
    });
    usageAndCrashReportsSwitch.setManagedPreferenceDelegate(new ManagedPreferenceDelegate() {

        @Override
        public boolean isPreferenceControlledByPolicy(Preference preference) {
            return PrefServiceBridge.getInstance().isMetricsReportingManaged();
        }
    });
}
Also used : ManagedPreferenceDelegate(org.chromium.chrome.browser.preferences.ManagedPreferenceDelegate) ChromeSwitchPreference(org.chromium.chrome.browser.preferences.ChromeSwitchPreference) Preference(android.preference.Preference) ChromeSwitchPreference(org.chromium.chrome.browser.preferences.ChromeSwitchPreference) OnPreferenceChangeListener(android.preference.Preference.OnPreferenceChangeListener)

Aggregations

Preference (android.preference.Preference)23 OnPreferenceChangeListener (android.preference.Preference.OnPreferenceChangeListener)23 ChromeSwitchPreference (org.chromium.chrome.browser.preferences.ChromeSwitchPreference)10 CheckBoxPreference (android.preference.CheckBoxPreference)7 EditTextPreference (android.preference.EditTextPreference)7 SharedPreferences (android.content.SharedPreferences)6 ListPreference (android.preference.ListPreference)6 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)6 ManagedPreferenceDelegate (org.chromium.chrome.browser.preferences.ManagedPreferenceDelegate)6 DialogInterface (android.content.DialogInterface)3 View (android.view.View)3 AlertDialog (android.app.AlertDialog)2 Intent (android.content.Intent)2 Editor (android.content.SharedPreferences.Editor)2 Resources (android.content.res.Resources)2 Uri (android.net.Uri)2 Map (java.util.Map)2 ButtonPreference (org.chromium.chrome.browser.preferences.ButtonPreference)2 ChromeBaseCheckBoxPreference (org.chromium.chrome.browser.preferences.ChromeBaseCheckBoxPreference)2 ChromeBasePreference (org.chromium.chrome.browser.preferences.ChromeBasePreference)2