use of org.chromium.chrome.browser.preferences.ButtonPreference in project AndroidChromium by JackyAndroid.
the class PhysicalWebPreferenceFragment method initLaunchButton.
private void initLaunchButton() {
ButtonPreference physicalWebLaunch = (ButtonPreference) findPreference(PREF_PHYSICAL_WEB_LAUNCH);
physicalWebLaunch.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
startActivity(createListUrlsIntent(getActivity()));
return true;
}
});
}
use of org.chromium.chrome.browser.preferences.ButtonPreference in project AndroidChromium by JackyAndroid.
the class ClearBrowsingDataPreferences method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
RecordUserAction.record("ClearBrowsingData_DialogCreated");
mMaxImportantSites = PrefServiceBridge.getMaxImportantSites();
PrefServiceBridge.getInstance().requestInfoAboutOtherFormsOfBrowsingHistory(this);
getActivity().setTitle(R.string.clear_browsing_data_title);
addPreferencesFromResource(R.xml.clear_browsing_data_preferences);
DialogOption[] options = getDialogOptions();
mItems = new Item[options.length];
for (int i = 0; i < options.length; i++) {
boolean enabled = true;
// It is possible to disable the deletion of browsing history.
if (options[i] == DialogOption.CLEAR_HISTORY && !PrefServiceBridge.getInstance().canDeleteBrowsingHistory()) {
enabled = false;
PrefServiceBridge.getInstance().setBrowsingDataDeletionPreference(DialogOption.CLEAR_HISTORY.getDataType(), false);
}
mItems[i] = new Item(this, options[i], (ClearBrowsingDataCheckBoxPreference) findPreference(options[i].getPreferenceKey()), isOptionSelectedByDefault(options[i]), enabled);
}
// Not all checkboxes defined in the layout are necessarily handled by this class
// or a particular subclass. Hide those that are not.
EnumSet<DialogOption> unboundOptions = EnumSet.allOf(DialogOption.class);
unboundOptions.removeAll(Arrays.asList(getDialogOptions()));
for (DialogOption option : unboundOptions) {
getPreferenceScreen().removePreference(findPreference(option.getPreferenceKey()));
}
// The time range selection spinner.
SpinnerPreference spinner = (SpinnerPreference) findPreference(PREF_TIME_RANGE);
spinner.setOnPreferenceChangeListener(this);
TimePeriodSpinnerOption[] spinnerOptions = getTimePeriodSpinnerOptions();
int selectedTimePeriod = PrefServiceBridge.getInstance().getBrowsingDataDeletionTimePeriod();
int spinnerOptionIndex = -1;
for (int i = 0; i < spinnerOptions.length; ++i) {
if (spinnerOptions[i].getTimePeriod() == selectedTimePeriod) {
spinnerOptionIndex = i;
break;
}
}
assert spinnerOptionIndex != -1;
spinner.setOptions(spinnerOptions, spinnerOptionIndex);
// The "Clear" button.
ButtonPreference clearButton = (ButtonPreference) findPreference(PREF_CLEAR_BUTTON);
clearButton.setOnPreferenceClickListener(this);
clearButton.setShouldDisableView(true);
// The general information footnote informs users about data that will not be deleted.
// If the user is signed in, it also informs users about the behavior of synced deletions.
// and we show an additional Google-specific footnote. This footnote informs users that they
// will not be signed out of their Google account, and if the web history service indicates
// that they have other forms of browsing history, then also about that.
TextMessageWithLinkAndIconPreference google_summary = (TextMessageWithLinkAndIconPreference) findPreference(PREF_GOOGLE_SUMMARY);
TextMessageWithLinkAndIconPreference general_summary = (TextMessageWithLinkAndIconPreference) findPreference(PREF_GENERAL_SUMMARY);
google_summary.setLinkClickDelegate(new Runnable() {
@Override
public void run() {
new TabDelegate(false).launchUrl(WEB_HISTORY_URL, TabLaunchType.FROM_CHROME_UI);
}
});
general_summary.setLinkClickDelegate(new Runnable() {
@Override
public void run() {
HelpAndFeedback.getInstance(getActivity()).show(getActivity(), getResources().getString(R.string.help_context_clear_browsing_data), Profile.getLastUsedProfile(), null);
}
});
if (ChromeSigninController.get(getActivity()).isSignedIn()) {
general_summary.setSummary(R.string.clear_browsing_data_footnote_sync_and_site_settings);
} else {
getPreferenceScreen().removePreference(google_summary);
general_summary.setSummary(R.string.clear_browsing_data_footnote_site_settings);
}
if (ChromeFeatureList.isEnabled(ChromeFeatureList.IMPORTANT_SITES_IN_CBD)) {
PrefServiceBridge.fetchImportantSites(this);
}
}
use of org.chromium.chrome.browser.preferences.ButtonPreference 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 org.chromium.chrome.browser.preferences.ButtonPreference in project AndroidChromium by JackyAndroid.
the class ClearBrowsingDataPreferences method updateButtonState.
/**
* Disable the "Clear" button if none of the options are selected. Otherwise, enable it.
*/
private void updateButtonState() {
ButtonPreference clearButton = (ButtonPreference) findPreference(PREF_CLEAR_BUTTON);
if (clearButton == null)
return;
boolean isEnabled = !getSelectedOptions().isEmpty();
clearButton.setEnabled(isEnabled);
}
Aggregations