Search in sources :

Example 1 with ButtonPreference

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;
        }
    });
}
Also used : OnPreferenceClickListener(android.preference.Preference.OnPreferenceClickListener) 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)

Example 2 with ButtonPreference

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);
    }
}
Also used : SpinnerPreference(org.chromium.chrome.browser.preferences.SpinnerPreference) TextMessageWithLinkAndIconPreference(org.chromium.chrome.browser.preferences.TextMessageWithLinkAndIconPreference) ButtonPreference(org.chromium.chrome.browser.preferences.ButtonPreference) TabDelegate(org.chromium.chrome.browser.tabmodel.document.TabDelegate) ClearBrowsingDataCheckBoxPreference(org.chromium.chrome.browser.preferences.ClearBrowsingDataCheckBoxPreference)

Example 3 with ButtonPreference

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;
        }
    });
}
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 4 with ButtonPreference

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);
}
Also used : ButtonPreference(org.chromium.chrome.browser.preferences.ButtonPreference)

Aggregations

ButtonPreference (org.chromium.chrome.browser.preferences.ButtonPreference)4 Preference (android.preference.Preference)2 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)2 ChromeSwitchPreference (org.chromium.chrome.browser.preferences.ChromeSwitchPreference)2 Context (android.content.Context)1 OnPreferenceChangeListener (android.preference.Preference.OnPreferenceChangeListener)1 ClearBrowsingDataCheckBoxPreference (org.chromium.chrome.browser.preferences.ClearBrowsingDataCheckBoxPreference)1 ManagedPreferenceDelegate (org.chromium.chrome.browser.preferences.ManagedPreferenceDelegate)1 SpinnerPreference (org.chromium.chrome.browser.preferences.SpinnerPreference)1 TextMessageWithLinkAndIconPreference (org.chromium.chrome.browser.preferences.TextMessageWithLinkAndIconPreference)1 TabDelegate (org.chromium.chrome.browser.tabmodel.document.TabDelegate)1