Search in sources :

Example 6 with ChromeSwitchPreference

use of org.chromium.chrome.browser.preferences.ChromeSwitchPreference in project AndroidChromium by JackyAndroid.

the class AutofillPreferences method updateSummaries.

private void updateSummaries() {
    ChromeSwitchPreference autofillSwitch = (ChromeSwitchPreference) findPreference(PREF_AUTOFILL_SWITCH);
    autofillSwitch.setChecked(PersonalDataManager.isAutofillEnabled());
}
Also used : ChromeSwitchPreference(org.chromium.chrome.browser.preferences.ChromeSwitchPreference)

Example 7 with ChromeSwitchPreference

use of org.chromium.chrome.browser.preferences.ChromeSwitchPreference 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 8 with ChromeSwitchPreference

use of org.chromium.chrome.browser.preferences.ChromeSwitchPreference 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 9 with ChromeSwitchPreference

use of org.chromium.chrome.browser.preferences.ChromeSwitchPreference 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)

Example 10 with ChromeSwitchPreference

use of org.chromium.chrome.browser.preferences.ChromeSwitchPreference in project AndroidChromium by JackyAndroid.

the class SavePasswordsPreferences method createSavePasswordsSwitch.

private void createSavePasswordsSwitch() {
    mSavePasswordsSwitch = new ChromeSwitchPreference(getActivity(), null);
    mSavePasswordsSwitch.setKey(PREF_SAVE_PASSWORDS_SWITCH);
    mSavePasswordsSwitch.setTitle(R.string.prefs_saved_passwords);
    mSavePasswordsSwitch.setOrder(ORDER_SWITCH);
    mSavePasswordsSwitch.setSummaryOn(R.string.text_on);
    mSavePasswordsSwitch.setSummaryOff(R.string.text_off);
    mSavePasswordsSwitch.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

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

        @Override
        public boolean isPreferenceControlledByPolicy(Preference preference) {
            return PrefServiceBridge.getInstance().isRememberPasswordsManaged();
        }
    });
    getPreferenceScreen().addPreference(mSavePasswordsSwitch);
    // Note: setting the switch state before the preference is added to the screen results in
    // some odd behavior where the switch state doesn't always match the internal enabled state
    // (e.g. the switch will say "On" when save passwords is really turned off), so
    // .setChecked() should be called after .addPreference()
    mSavePasswordsSwitch.setChecked(PrefServiceBridge.getInstance().isRememberPasswordsEnabled());
}
Also used : ManagedPreferenceDelegate(org.chromium.chrome.browser.preferences.ManagedPreferenceDelegate) ChromeSwitchPreference(org.chromium.chrome.browser.preferences.ChromeSwitchPreference) ChromeBasePreference(org.chromium.chrome.browser.preferences.ChromeBasePreference) ChromeBaseCheckBoxPreference(org.chromium.chrome.browser.preferences.ChromeBaseCheckBoxPreference) Preference(android.preference.Preference) ChromeSwitchPreference(org.chromium.chrome.browser.preferences.ChromeSwitchPreference) OnPreferenceChangeListener(android.preference.Preference.OnPreferenceChangeListener)

Aggregations

ChromeSwitchPreference (org.chromium.chrome.browser.preferences.ChromeSwitchPreference)12 Preference (android.preference.Preference)11 OnPreferenceChangeListener (android.preference.Preference.OnPreferenceChangeListener)9 ManagedPreferenceDelegate (org.chromium.chrome.browser.preferences.ManagedPreferenceDelegate)5 ChromeBaseCheckBoxPreference (org.chromium.chrome.browser.preferences.ChromeBaseCheckBoxPreference)3 ChromeBasePreference (org.chromium.chrome.browser.preferences.ChromeBasePreference)3 ButtonPreference (org.chromium.chrome.browser.preferences.ButtonPreference)2 Context (android.content.Context)1 Handler (android.os.Handler)1 CheckBoxPreference (android.preference.CheckBoxPreference)1 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)1 PreferenceGroup (android.preference.PreferenceGroup)1 SwitchPreference (android.preference.SwitchPreference)1 View (android.view.View)1 ExpandablePreferenceGroup (org.chromium.chrome.browser.preferences.ExpandablePreferenceGroup)1 SyncedAccountPreference (org.chromium.chrome.browser.preferences.SyncedAccountPreference)1 SyncAccountSwitcher (org.chromium.chrome.browser.sync.SyncAccountSwitcher)1