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();
}
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();
}
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;
}
});
}
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;
}
});
}
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();
}
});
}
Aggregations