Search in sources :

Example 66 with ListPreference

use of android.support.v7.preference.ListPreference in project platform_packages_apps_Settings by BlissRoms.

the class DevelopmentSettings method addListPreference.

private ListPreference addListPreference(String prefKey) {
    ListPreference pref = (ListPreference) findPreference(prefKey);
    mAllPrefs.add(pref);
    pref.setOnPreferenceChangeListener(this);
    return pref;
}
Also used : ListPreference(android.support.v7.preference.ListPreference)

Example 67 with ListPreference

use of android.support.v7.preference.ListPreference in project platform_packages_apps_Settings by BlissRoms.

the class AccessibilitySettings method initializeAllPreferences.

private void initializeAllPreferences() {
    for (int i = 0; i < CATEGORIES.length; i++) {
        PreferenceCategory prefCategory = (PreferenceCategory) findPreference(CATEGORIES[i]);
        mCategoryToPrefCategoryMap.put(CATEGORIES[i], prefCategory);
    }
    // Text contrast.
    mToggleHighTextContrastPreference = (SwitchPreference) findPreference(TOGGLE_HIGH_TEXT_CONTRAST_PREFERENCE);
    // Display inversion.
    mToggleInversionPreference = (SwitchPreference) findPreference(TOGGLE_INVERSION_PREFERENCE);
    mToggleInversionPreference.setOnPreferenceChangeListener(this);
    // Power button ends calls.
    mTogglePowerButtonEndsCallPreference = (SwitchPreference) findPreference(TOGGLE_POWER_BUTTON_ENDS_CALL_PREFERENCE);
    if (!KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_POWER) || !Utils.isVoiceCapable(getActivity())) {
        mCategoryToPrefCategoryMap.get(CATEGORY_INTERACTION_CONTROL).removePreference(mTogglePowerButtonEndsCallPreference);
    }
    // Lock screen rotation.
    mToggleLockScreenRotationPreference = (SwitchPreference) findPreference(TOGGLE_LOCK_SCREEN_ROTATION_PREFERENCE);
    if (!RotationPolicy.isRotationSupported(getActivity())) {
        mCategoryToPrefCategoryMap.get(CATEGORY_INTERACTION_CONTROL).removePreference(mToggleLockScreenRotationPreference);
    }
    // Large pointer icon.
    mToggleLargePointerIconPreference = (SwitchPreference) findPreference(TOGGLE_LARGE_POINTER_ICON);
    // Master Mono
    mToggleMasterMonoPreference = (SwitchPreference) findPreference(TOGGLE_MASTER_MONO);
    // Long press timeout.
    mSelectLongPressTimeoutPreference = (ListPreference) findPreference(SELECT_LONG_PRESS_TIMEOUT_PREFERENCE);
    mSelectLongPressTimeoutPreference.setOnPreferenceChangeListener(this);
    if (mLongPressTimeoutValueToTitleMap.size() == 0) {
        String[] timeoutValues = getResources().getStringArray(R.array.long_press_timeout_selector_values);
        mLongPressTimeoutDefault = Integer.parseInt(timeoutValues[0]);
        String[] timeoutTitles = getResources().getStringArray(R.array.long_press_timeout_selector_titles);
        final int timeoutValueCount = timeoutValues.length;
        for (int i = 0; i < timeoutValueCount; i++) {
            mLongPressTimeoutValueToTitleMap.put(timeoutValues[i], timeoutTitles[i]);
        }
    }
    // Captioning.
    mCaptioningPreferenceScreen = findPreference(CAPTIONING_PREFERENCE_SCREEN);
    // Display magnification.
    mDisplayMagnificationPreferenceScreen = findPreference(DISPLAY_MAGNIFICATION_PREFERENCE_SCREEN);
    configureMagnificationPreferenceIfNeeded(mDisplayMagnificationPreferenceScreen);
    // Font size.
    mFontSizePreferenceScreen = findPreference(FONT_SIZE_PREFERENCE_SCREEN);
    // Autoclick after pointer stops.
    mAutoclickPreferenceScreen = findPreference(AUTOCLICK_PREFERENCE_SCREEN);
    // Display color adjustments.
    mDisplayDaltonizerPreferenceScreen = findPreference(DISPLAY_DALTONIZER_PREFERENCE_SCREEN);
    // Accessibility shortcut
    mAccessibilityShortcutPreferenceScreen = findPreference(ACCESSIBILITY_SHORTCUT_PREFERENCE);
}
Also used : PreferenceCategory(android.support.v7.preference.PreferenceCategory)

Example 68 with ListPreference

use of android.support.v7.preference.ListPreference in project platform_packages_apps_Settings by BlissRoms.

the class ThemePreferenceController method updateState.

@Override
public void updateState(Preference preference) {
    ListPreference pref = (ListPreference) preference;
    List<String> pkgs = new ArrayList<>(Arrays.asList(getAvailableThemes()));
    List<CharSequence> labels = new ArrayList<>(pkgs.size());
    for (String pkg : pkgs) {
        CharSequence label = null;
        try {
            label = mPackageManager.getApplicationInfo(pkg, 0).loadLabel(mPackageManager);
        } catch (NameNotFoundException e) {
            label = pkg;
        }
        labels.add(label);
    }
    labels.add(mContext.getString(R.string.default_theme));
    pkgs.add(KEY_THEMES_DISABLED);
    pref.setEntries(labels.toArray(new CharSequence[labels.size()]));
    pref.setEntryValues(pkgs.toArray(new String[pkgs.size()]));
    String theme = getCurrentTheme();
    CharSequence themeLabel = null;
    if (theme != null) {
        int i = 0;
        for (String pkg : pkgs) {
            if (TextUtils.equals(pkg, theme)) {
                themeLabel = labels.get(i);
                break;
            }
            i++;
        }
    }
    if (TextUtils.isEmpty(themeLabel)) {
        themeLabel = mContext.getString(R.string.default_theme);
        theme = KEY_THEMES_DISABLED;
    }
    pref.setSummary(themeLabel);
    pref.setValue(theme);
}
Also used : NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) ArrayList(java.util.ArrayList) ListPreference(android.support.v7.preference.ListPreference)

Example 69 with ListPreference

use of android.support.v7.preference.ListPreference in project platform_packages_apps_Settings by BlissRoms.

the class AppRestrictionsFragment method onPreferenceChange.

@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
    String key = preference.getKey();
    if (key != null && key.contains(DELIMITER)) {
        StringTokenizer st = new StringTokenizer(key, DELIMITER);
        final String packageName = st.nextToken();
        final String restrictionKey = st.nextToken();
        AppRestrictionsPreference appPref = (AppRestrictionsPreference) mAppList.findPreference(PKG_PREFIX + packageName);
        ArrayList<RestrictionEntry> restrictions = appPref.getRestrictions();
        if (restrictions != null) {
            for (RestrictionEntry entry : restrictions) {
                if (entry.getKey().equals(restrictionKey)) {
                    switch(entry.getType()) {
                        case RestrictionEntry.TYPE_BOOLEAN:
                            entry.setSelectedState((Boolean) newValue);
                            break;
                        case RestrictionEntry.TYPE_CHOICE:
                        case RestrictionEntry.TYPE_CHOICE_LEVEL:
                            ListPreference listPref = (ListPreference) preference;
                            entry.setSelectedString((String) newValue);
                            String readable = findInArray(entry.getChoiceEntries(), entry.getChoiceValues(), (String) newValue);
                            listPref.setSummary(readable);
                            break;
                        case RestrictionEntry.TYPE_MULTI_SELECT:
                            Set<String> set = (Set<String>) newValue;
                            String[] selectedValues = new String[set.size()];
                            set.toArray(selectedValues);
                            entry.setAllSelectedStrings(selectedValues);
                            break;
                        default:
                            continue;
                    }
                    mUserManager.setApplicationRestrictions(packageName, RestrictionsManager.convertRestrictionsToBundle(restrictions), mUser);
                    break;
                }
            }
        }
        return true;
    }
    return false;
}
Also used : StringTokenizer(java.util.StringTokenizer) HashSet(java.util.HashSet) Set(java.util.Set) RestrictionEntry(android.content.RestrictionEntry) ListPreference(android.support.v7.preference.ListPreference) MultiSelectListPreference(android.support.v14.preference.MultiSelectListPreference)

Example 70 with ListPreference

use of android.support.v7.preference.ListPreference in project platform_packages_apps_Settings by BlissRoms.

the class WifiTetherApBandPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mListPreference = new ListPreference(RuntimeEnvironment.application);
    when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
    when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE)).thenReturn(mConnectivityManager);
    when(mConnectivityManager.getTetherableWifiRegexs()).thenReturn(new String[] { "1", "2" });
    when(mContext.getResources()).thenReturn(RuntimeEnvironment.application.getResources());
    when(mScreen.findPreference(anyString())).thenReturn(mListPreference);
    mController = new WifiTetherApBandPreferenceController(mContext, mListener);
}
Also used : ListPreference(android.support.v7.preference.ListPreference) Before(org.junit.Before)

Aggregations

ListPreference (android.support.v7.preference.ListPreference)115 Preference (android.support.v7.preference.Preference)51 PreferenceScreen (android.support.v7.preference.PreferenceScreen)34 SwitchPreference (android.support.v14.preference.SwitchPreference)31 ContentResolver (android.content.ContentResolver)24 PreferenceCategory (android.support.v7.preference.PreferenceCategory)20 OnPreferenceChangeListener (android.support.v7.preference.Preference.OnPreferenceChangeListener)17 Intent (android.content.Intent)12 Resources (android.content.res.Resources)12 MultiSelectListPreference (android.support.v14.preference.MultiSelectListPreference)12 PackageInfo (android.content.pm.PackageInfo)11 CheckBoxPreference (android.support.v7.preference.CheckBoxPreference)11 RestrictionEntry (android.content.RestrictionEntry)10 OverlayInfo (android.content.om.OverlayInfo)10 ApplicationInfo (android.content.pm.ApplicationInfo)10 SmallTest (android.support.test.filters.SmallTest)10 HashSet (java.util.HashSet)10 Test (org.junit.Test)10 Matchers.anyString (org.mockito.Matchers.anyString)10 IBinder (android.os.IBinder)7