use of androidx.preference.ListPreference in project android_packages_apps_Settings by omnirom.
the class ZenRuleMessagesPreferenceController method updateFromContactsValue.
private void updateFromContactsValue(Preference preference) {
if (mRule == null || mRule.getZenPolicy() == null) {
return;
}
ListPreference listPreference = (ListPreference) preference;
listPreference.setSummary(mBackend.getContactsMessagesSummary(mRule.getZenPolicy()));
final String currentVal = ZenModeBackend.getKeyFromZenPolicySetting(mRule.getZenPolicy().getPriorityMessageSenders());
listPreference.setValue(mListValues[getIndexOfSendersValue(currentVal)]);
}
use of androidx.preference.ListPreference in project android_packages_apps_Settings by omnirom.
the class ThemePreferenceControllerTest method testUpdateState.
@Test
public void testUpdateState() throws Exception {
OverlayInfo info1 = new OverlayInfo("com.android.Theme1", "android", "", OverlayInfo.CATEGORY_THEME, "", OverlayInfo.STATE_ENABLED, 0, 0, true);
OverlayInfo info2 = new OverlayInfo("com.android.Theme2", "android", "", OverlayInfo.CATEGORY_THEME, "", 0, 0, 0, true);
when(mMockPackageManager.getApplicationInfo(any(), anyInt())).thenAnswer(inv -> {
ApplicationInfo info = mock(ApplicationInfo.class);
if ("com.android.Theme1".equals(inv.getArguments()[0])) {
when(info.loadLabel(any())).thenReturn("Theme1");
} else {
when(info.loadLabel(any())).thenReturn("Theme2");
}
return info;
});
when(mMockPackageManager.getPackageInfo(anyString(), anyInt())).thenReturn(new PackageInfo());
when(mMockOverlayManager.getOverlayInfosForTarget(any(), anyInt())).thenReturn(list(info1, info2));
ListPreference pref = mock(ListPreference.class);
mPreferenceController.updateState(pref);
ArgumentCaptor<String[]> arg = ArgumentCaptor.forClass(String[].class);
verify(pref).setEntries(arg.capture());
CharSequence[] entries = arg.getValue();
assertThat(entries).asList().containsExactly("Theme1", "Theme2");
verify(pref).setEntryValues(arg.capture());
CharSequence[] entryValues = arg.getValue();
assertThat(entryValues).asList().containsExactly("com.android.Theme1", "com.android.Theme2");
verify(pref).setValue(eq("com.android.Theme1"));
}
use of androidx.preference.ListPreference in project android_packages_apps_Settings by omnirom.
the class WifiTetherSecurityPreferenceController method updateDisplay.
@Override
public void updateDisplay() {
// keyword searching only.
if (mPreference == null) {
return;
}
final ListPreference preference = (ListPreference) mPreference;
// If the device is not support WPA3 then remove the WPA3 options.
if (!mIsWpa3Supported && mSecurityMap.keySet().removeIf(key -> key > SoftApConfiguration.SECURITY_TYPE_WPA2_PSK)) {
preference.setEntries(mSecurityMap.values().stream().toArray(CharSequence[]::new));
preference.setEntryValues(mSecurityMap.keySet().stream().map(Integer::toBinaryString).toArray(CharSequence[]::new));
}
final int securityType = mWifiManager.getSoftApConfiguration().getSecurityType();
mSecurityValue = mSecurityMap.get(securityType) != null ? securityType : SoftApConfiguration.SECURITY_TYPE_WPA2_PSK;
preference.setSummary(mSecurityMap.get(mSecurityValue));
preference.setValue(String.valueOf(mSecurityValue));
}
use of androidx.preference.ListPreference in project android_packages_apps_Settings by omnirom.
the class GraphicsDriverAppPreferenceControllerTest method createPreference_configSystem_shouldSetSystemAttributes.
@Test
public void createPreference_configSystem_shouldSetSystemAttributes() {
loadConfig("", "", TEST_PKG_NAME);
final ListPreference preference = mController.createListPreference(mContext, TEST_PKG_NAME, TEST_APP_NAME);
assertThat(preference.getKey()).isEqualTo(TEST_PKG_NAME);
assertThat(preference.getTitle()).isEqualTo(TEST_APP_NAME);
assertThat(preference.getDialogTitle()).isEqualTo(mDialogTitle);
assertThat(preference.getEntries()).isEqualTo(mValueList);
assertThat(preference.getEntryValues()).isEqualTo(mValueList);
assertThat(preference.getEntry()).isEqualTo(mValueList[SYSTEM]);
assertThat(preference.getValue()).isEqualTo(mValueList[SYSTEM]);
assertThat(preference.getSummary()).isEqualTo(mValueList[SYSTEM]);
}
use of androidx.preference.ListPreference in project android_packages_apps_Settings by omnirom.
the class GraphicsDriverAppPreferenceControllerTest method createPreference_configDefault_shouldSetDefaultAttributes.
@Test
public void createPreference_configDefault_shouldSetDefaultAttributes() {
loadDefaultConfig();
final ListPreference preference = mController.createListPreference(mContext, TEST_PKG_NAME, TEST_APP_NAME);
assertThat(preference.getKey()).isEqualTo(TEST_PKG_NAME);
assertThat(preference.getTitle()).isEqualTo(TEST_APP_NAME);
assertThat(preference.getDialogTitle()).isEqualTo(mDialogTitle);
assertThat(preference.getEntries()).isEqualTo(mValueList);
assertThat(preference.getEntryValues()).isEqualTo(mValueList);
assertThat(preference.getEntry()).isEqualTo(mValueList[DEFAULT]);
assertThat(preference.getValue()).isEqualTo(mValueList[DEFAULT]);
assertThat(preference.getSummary()).isEqualTo(mValueList[DEFAULT]);
}
Aggregations