Search in sources :

Example 56 with Preference

use of android.preference.Preference in project AntennaPod by AntennaPod.

the class PreferenceController method checkItemVisibility.

@SuppressWarnings("deprecation")
private void checkItemVisibility() {
    boolean hasFlattrToken = FlattrUtils.hasToken();
    ui.findPreference(PreferenceController.PREF_FLATTR_SETTINGS).setEnabled(FlattrUtils.hasAPICredentials());
    ui.findPreference(PreferenceController.PREF_FLATTR_AUTH).setEnabled(!hasFlattrToken);
    ui.findPreference(PreferenceController.PREF_FLATTR_REVOKE).setEnabled(hasFlattrToken);
    ui.findPreference(PreferenceController.PREF_AUTO_FLATTR_PREFS).setEnabled(hasFlattrToken);
    boolean autoDownload = UserPreferences.isEnableAutodownload();
    ui.findPreference(UserPreferences.PREF_EPISODE_CACHE_SIZE).setEnabled(autoDownload);
    ui.findPreference(UserPreferences.PREF_ENABLE_AUTODL_ON_BATTERY).setEnabled(autoDownload);
    ui.findPreference(UserPreferences.PREF_ENABLE_AUTODL_WIFI_FILTER).setEnabled(autoDownload);
    setSelectedNetworksEnabled(autoDownload && UserPreferences.isEnableAutodownloadWifiFilter());
    ui.findPreference(PREF_SEND_CRASH_REPORT).setEnabled(CrashReportWriter.getFile().exists());
    if (Build.VERSION.SDK_INT >= 16) {
        ui.findPreference(UserPreferences.PREF_SONIC).setEnabled(true);
    } else {
        Preference prefSonic = ui.findPreference(UserPreferences.PREF_SONIC);
        prefSonic.setSummary("[Android 4.1+]\n" + prefSonic.getSummary());
    }
}
Also used : EditTextPreference(android.preference.EditTextPreference) ListPreference(android.preference.ListPreference) CheckBoxPreference(android.preference.CheckBoxPreference) Preference(android.preference.Preference)

Example 57 with Preference

use of android.preference.Preference in project AndroidChromium by JackyAndroid.

the class SingleCategoryPreferences method onPreferenceChange.

// OnPreferenceChangeListener:
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
    if (READ_WRITE_TOGGLE_KEY.equals(preference.getKey())) {
        if (mCategory.isManaged())
            return false;
        if (mCategory.showAutoplaySites()) {
            PrefServiceBridge.getInstance().setAutoplayEnabled((boolean) newValue);
        } else if (mCategory.showBackgroundSyncSites()) {
            PrefServiceBridge.getInstance().setBackgroundSyncEnabled((boolean) newValue);
        } else if (mCategory.showCameraSites()) {
            PrefServiceBridge.getInstance().setCameraEnabled((boolean) newValue);
        } else if (mCategory.showCookiesSites()) {
            PrefServiceBridge.getInstance().setAllowCookiesEnabled((boolean) newValue);
            updateThirdPartyCookiesCheckBox();
        } else if (mCategory.showFullscreenSites()) {
            PrefServiceBridge.getInstance().setFullscreenAllowed((boolean) newValue);
        } else if (mCategory.showGeolocationSites()) {
            PrefServiceBridge.getInstance().setAllowLocationEnabled((boolean) newValue);
        } else if (mCategory.showJavaScriptSites()) {
            PrefServiceBridge.getInstance().setJavaScriptEnabled((boolean) newValue);
        } else if (mCategory.showMicrophoneSites()) {
            PrefServiceBridge.getInstance().setMicEnabled((boolean) newValue);
        } else if (mCategory.showNotificationsSites()) {
            PrefServiceBridge.getInstance().setNotificationsEnabled((boolean) newValue);
            updateNotificationsVibrateCheckBox();
        } else if (mCategory.showPopupSites()) {
            PrefServiceBridge.getInstance().setAllowPopupsEnabled((boolean) newValue);
        } else if (mCategory.showProtectedMediaSites()) {
            PrefServiceBridge.getInstance().setProtectedMediaIdentifierEnabled((boolean) newValue);
        }
        // Categories that support adding exceptions also manage the 'Add site' preference.
        if (mCategory.showAutoplaySites() || mCategory.showBackgroundSyncSites() || mCategory.showJavaScriptSites()) {
            if ((boolean) newValue) {
                Preference addException = getPreferenceScreen().findPreference(ADD_EXCEPTION_KEY);
                if (addException != null) {
                    // Can be null in testing.
                    getPreferenceScreen().removePreference(addException);
                }
            } else {
                getPreferenceScreen().addPreference(new AddExceptionPreference(getActivity(), ADD_EXCEPTION_KEY, getAddExceptionDialogMessage(), this));
            }
        }
        ChromeSwitchPreference globalToggle = (ChromeSwitchPreference) getPreferenceScreen().findPreference(READ_WRITE_TOGGLE_KEY);
        updateAllowedHeader(mAllowedSiteCount, !globalToggle.isChecked());
        getInfoForOrigins();
    } else if (THIRD_PARTY_COOKIES_TOGGLE_KEY.equals(preference.getKey())) {
        PrefServiceBridge.getInstance().setBlockThirdPartyCookiesEnabled(!((boolean) newValue));
    } else if (NOTIFICATIONS_VIBRATE_TOGGLE_KEY.equals(preference.getKey())) {
        PrefServiceBridge.getInstance().setNotificationsVibrateEnabled((boolean) newValue);
    }
    return true;
}
Also used : 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)

Example 58 with Preference

use of android.preference.Preference in project AndroidChromium by JackyAndroid.

the class SingleCategoryPreferences method updateThirdPartyCookiesCheckBox.

private void updateThirdPartyCookiesCheckBox() {
    ChromeBaseCheckBoxPreference thirdPartyCookiesPref = (ChromeBaseCheckBoxPreference) getPreferenceScreen().findPreference(THIRD_PARTY_COOKIES_TOGGLE_KEY);
    thirdPartyCookiesPref.setEnabled(PrefServiceBridge.getInstance().isAcceptCookiesEnabled());
    thirdPartyCookiesPref.setManagedPreferenceDelegate(new ManagedPreferenceDelegate() {

        @Override
        public boolean isPreferenceControlledByPolicy(Preference preference) {
            return PrefServiceBridge.getInstance().isBlockThirdPartyCookiesManaged();
        }
    });
}
Also used : ManagedPreferenceDelegate(org.chromium.chrome.browser.preferences.ManagedPreferenceDelegate) ChromeBaseCheckBoxPreference(org.chromium.chrome.browser.preferences.ChromeBaseCheckBoxPreference) 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)

Example 59 with Preference

use of android.preference.Preference in project AndroidChromium by JackyAndroid.

the class AccountManagementFragment method configureGoogleActivityControls.

private void configureGoogleActivityControls() {
    Preference pref = findPreference(PREF_GOOGLE_ACTIVITY_CONTROLS);
    pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            Activity activity = getActivity();
            ((ChromeApplication) (activity.getApplicationContext())).createGoogleActivityController().openWebAndAppActivitySettings(activity, ChromeSigninController.get(activity).getSignedInAccountName());
            RecordUserAction.record("Signin_AccountSettings_GoogleActivityControlsClicked");
            return true;
        }
    });
}
Also used : OnPreferenceClickListener(android.preference.Preference.OnPreferenceClickListener) ChromeApplication(org.chromium.chrome.browser.ChromeApplication) ChromeBasePreference(org.chromium.chrome.browser.preferences.ChromeBasePreference) SyncPreference(org.chromium.chrome.browser.preferences.SyncPreference) Preference(android.preference.Preference) Activity(android.app.Activity)

Example 60 with Preference

use of android.preference.Preference in project AndroidChromium by JackyAndroid.

the class AccountManagementFragment method configureSyncSettings.

private void configureSyncSettings() {
    final Preferences preferences = (Preferences) getActivity();
    final Account account = ChromeSigninController.get(getActivity()).getSignedInUser();
    findPreference(PREF_SYNC_SETTINGS).setOnPreferenceClickListener(new OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            if (!isVisible() || !isResumed())
                return false;
            if (ProfileSyncService.get() == null)
                return true;
            Bundle args = new Bundle();
            args.putString(SyncCustomizationFragment.ARGUMENT_ACCOUNT, account.name);
            preferences.startFragment(SyncCustomizationFragment.class.getName(), args);
            return true;
        }
    });
}
Also used : OnPreferenceClickListener(android.preference.Preference.OnPreferenceClickListener) Account(android.accounts.Account) ChromeBasePreference(org.chromium.chrome.browser.preferences.ChromeBasePreference) SyncPreference(org.chromium.chrome.browser.preferences.SyncPreference) Preference(android.preference.Preference) Bundle(android.os.Bundle) Preferences(org.chromium.chrome.browser.preferences.Preferences)

Aggregations

Preference (android.preference.Preference)173 CheckBoxPreference (android.preference.CheckBoxPreference)50 ListPreference (android.preference.ListPreference)49 PreferenceScreen (android.preference.PreferenceScreen)36 Intent (android.content.Intent)32 EditTextPreference (android.preference.EditTextPreference)26 OnPreferenceChangeListener (android.preference.Preference.OnPreferenceChangeListener)23 PreferenceCategory (android.preference.PreferenceCategory)23 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)21 SharedPreferences (android.content.SharedPreferences)19 ChromeSwitchPreference (org.chromium.chrome.browser.preferences.ChromeSwitchPreference)16 Test (org.junit.Test)15 PreferenceGroup (android.preference.PreferenceGroup)13 Uri (android.net.Uri)12 Bundle (android.os.Bundle)12 ArrayList (java.util.ArrayList)11 Resources (android.content.res.Resources)10 SwitchPreference (android.preference.SwitchPreference)10 View (android.view.View)10 ChromeBasePreference (org.chromium.chrome.browser.preferences.ChromeBasePreference)10