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;
}
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);
}
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);
}
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;
}
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);
}
Aggregations