Java Code Examples for org.chromium.chrome.browser.preferences.ChromeSwitchPreference#setChecked()

The following examples show how to use org.chromium.chrome.browser.preferences.ChromeSwitchPreference#setChecked() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DoNotTrackPreference.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.do_not_track_preferences);
    getActivity().setTitle(R.string.do_not_track_title);

    ChromeSwitchPreference doNotTrackSwitch =
            (ChromeSwitchPreference) findPreference(PREF_DO_NOT_TRACK_SWITCH);

    boolean isDoNotTrackEnabled = PrefServiceBridge.getInstance().isDoNotTrackEnabled();
    doNotTrackSwitch.setChecked(isDoNotTrackEnabled);

    doNotTrackSwitch.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            PrefServiceBridge.getInstance().setDoNotTrackEnabled((boolean) newValue);
            return true;
        }
    });
}
 
Example 2
Source File: PhysicalWebPreferenceFragment.java    From delion with Apache License 2.0 6 votes vote down vote up
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;
        }
    });
}
 
Example 3
Source File: DoNotTrackPreference.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.do_not_track_preferences);
    getActivity().setTitle(R.string.do_not_track_title);

    ChromeSwitchPreference doNotTrackSwitch =
            (ChromeSwitchPreference) findPreference(PREF_DO_NOT_TRACK_SWITCH);

    boolean isDoNotTrackEnabled = PrefServiceBridge.getInstance().isDoNotTrackEnabled();
    doNotTrackSwitch.setChecked(isDoNotTrackEnabled);

    doNotTrackSwitch.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            PrefServiceBridge.getInstance().setDoNotTrackEnabled((boolean) newValue);
            return true;
        }
    });
}
 
Example 4
Source File: PhysicalWebPreferenceFragment.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
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;
        }
    });
}
 
Example 5
Source File: DoNotTrackPreference.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.do_not_track_preferences);
    getActivity().setTitle(R.string.do_not_track_title);

    ChromeSwitchPreference doNotTrackSwitch =
            (ChromeSwitchPreference) findPreference(PREF_DO_NOT_TRACK_SWITCH);

    boolean isDoNotTrackEnabled = PrefServiceBridge.getInstance().isDoNotTrackEnabled();
    doNotTrackSwitch.setChecked(isDoNotTrackEnabled);

    doNotTrackSwitch.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            PrefServiceBridge.getInstance().setDoNotTrackEnabled((boolean) newValue);
            return true;
        }
    });
}
 
Example 6
Source File: PhysicalWebPreferenceFragment.java    From 365browser with Apache License 2.0 6 votes vote down vote up
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();
                ensureLocationPermission();
            } else {
                PhysicalWebUma.onPrefsFeatureDisabled();
            }
            PrivacyPreferencesManager.getInstance().setPhysicalWebEnabled(enabled);
            return true;
        }
    });
}
 
Example 7
Source File: AutofillPreferences.java    From delion with Apache License 2.0 4 votes vote down vote up
private void updateSummaries() {
    ChromeSwitchPreference autofillSwitch =
            (ChromeSwitchPreference) findPreference(PREF_AUTOFILL_SWITCH);
    autofillSwitch.setChecked(PersonalDataManager.isAutofillEnabled());
}
 
Example 8
Source File: AutofillPreferences.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
private void updateSummaries() {
    ChromeSwitchPreference autofillSwitch =
            (ChromeSwitchPreference) findPreference(PREF_AUTOFILL_SWITCH);
    autofillSwitch.setChecked(PersonalDataManager.isAutofillEnabled());
}