Search in sources :

Example 46 with Preference

use of android.preference.Preference in project android_packages_inputmethods_LatinIME by CyanogenMod.

the class SettingsFragment method onCreate.

@Override
public void onCreate(final Bundle icicle) {
    super.onCreate(icicle);
    setHasOptionsMenu(true);
    setInputMethodSettingsCategoryTitle(R.string.language_selection_title);
    setSubtypeEnablerTitle(R.string.select_language);
    addPreferencesFromResource(R.xml.prefs);
    final PreferenceScreen preferenceScreen = getPreferenceScreen();
    preferenceScreen.setTitle(ApplicationUtils.getActivityTitleResId(getActivity(), SettingsActivity.class));
    if (!ProductionFlags.ENABLE_ACCOUNT_SIGN_IN) {
        final Preference accountsPreference = findPreference(Settings.SCREEN_ACCOUNTS);
        preferenceScreen.removePreference(accountsPreference);
    }
    if (!JniUtils.mHaveGestureLib) {
        final Preference gesturePreference = findPreference(Settings.SCREEN_GESTURE);
        preferenceScreen.removePreference(gesturePreference);
    }
}
Also used : PreferenceScreen(android.preference.PreferenceScreen) Preference(android.preference.Preference)

Example 47 with Preference

use of android.preference.Preference in project android_packages_inputmethods_LatinIME by CyanogenMod.

the class DictionarySettingsFragment method refreshInterface.

void refreshInterface() {
    final Activity activity = getActivity();
    if (null == activity)
        return;
    final PreferenceGroup prefScreen = getPreferenceScreen();
    final Collection<? extends Preference> prefList = createInstalledDictSettingsCollection(mClientId);
    activity.runOnUiThread(new Runnable() {

        @Override
        public void run() {
            // TODO: display this somewhere
            // if (0 != lastUpdate) mUpdateNowPreference.setSummary(updateNowSummary);
            refreshNetworkState();
            removeAnyDictSettings(prefScreen);
            int i = 0;
            for (Preference preference : prefList) {
                preference.setOrder(i++);
                prefScreen.addPreference(preference);
            }
        }
    });
}
Also used : Preference(android.preference.Preference) Activity(android.app.Activity) PreferenceGroup(android.preference.PreferenceGroup)

Example 48 with Preference

use of android.preference.Preference in project android_packages_inputmethods_LatinIME by CyanogenMod.

the class DictionarySettingsFragment method findWordListPreference.

private WordListPreference findWordListPreference(final String id) {
    final PreferenceGroup prefScreen = getPreferenceScreen();
    if (null == prefScreen) {
        Log.e(TAG, "Could not find the preference group");
        return null;
    }
    for (int i = prefScreen.getPreferenceCount() - 1; i >= 0; --i) {
        final Preference pref = prefScreen.getPreference(i);
        if (pref instanceof WordListPreference) {
            final WordListPreference wlPref = (WordListPreference) pref;
            if (id.equals(wlPref.mWordlistId)) {
                return wlPref;
            }
        }
    }
    Log.e(TAG, "Could not find the preference for a word list id " + id);
    return null;
}
Also used : Preference(android.preference.Preference) PreferenceGroup(android.preference.PreferenceGroup)

Example 49 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 50 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)

Aggregations

Preference (android.preference.Preference)183 CheckBoxPreference (android.preference.CheckBoxPreference)54 ListPreference (android.preference.ListPreference)54 PreferenceScreen (android.preference.PreferenceScreen)37 Intent (android.content.Intent)33 EditTextPreference (android.preference.EditTextPreference)29 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 PreferenceGroup (android.preference.PreferenceGroup)15 Test (org.junit.Test)15 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