use of androidx.preference.ListPreference in project android_packages_apps_Settings by omnirom.
the class EnabledNetworkModePreferenceControllerTest method setUp.
@UiThreadTest
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
mLifecycleOwner = () -> mLifecycle;
mLifecycle = new Lifecycle(mLifecycleOwner);
mContext = spy(ApplicationProvider.getApplicationContext());
when(mContext.getSystemService(CarrierConfigManager.class)).thenReturn(mCarrierConfigManager);
when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SUB_ID);
doReturn(mInvalidTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SubscriptionManager.INVALID_SUBSCRIPTION_ID);
doReturn(mServiceState).when(mTelephonyManager).getServiceState();
mPersistableBundle = new PersistableBundle();
doReturn(mPersistableBundle).when(mCarrierConfigManager).getConfig();
doReturn(mPersistableBundle).when(mCarrierConfigManager).getConfigForSubId(SUB_ID);
mPreference = new ListPreference(mContext);
mController = new EnabledNetworkModePreferenceController(mContext, KEY);
mockAllowedNetworkTypes(ALLOWED_ALL_NETWORK_TYPE);
mockAccessFamily(TelephonyManager.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA);
mController.init(mLifecycle, SUB_ID);
mPreference.setKey(mController.getPreferenceKey());
}
use of androidx.preference.ListPreference in project android_packages_apps_Settings by omnirom.
the class ApnEditorTest method setMockPreference.
private void setMockPreference(Context context) {
mApnEditorUT.mName = new EditTextPreference(context);
mApnEditorUT.mApn = new EditTextPreference(context);
mApnEditorUT.mProxy = new EditTextPreference(context);
mApnEditorUT.mPort = new EditTextPreference(context);
mApnEditorUT.mUser = new EditTextPreference(context);
mApnEditorUT.mServer = new EditTextPreference(context);
mApnEditorUT.mPassword = new EditTextPreference(context);
mApnEditorUT.mMmsc = new EditTextPreference(context);
mApnEditorUT.mMcc = new EditTextPreference(context);
mApnEditorUT.mMnc = new EditTextPreference(context);
mApnEditorUT.mMmsProxy = new EditTextPreference(context);
mApnEditorUT.mMmsPort = new EditTextPreference(context);
mApnEditorUT.mAuthType = new ListPreference(context);
mApnEditorUT.mApnType = new EditTextPreference(context);
mApnEditorUT.mProtocol = new ListPreference(context);
mApnEditorUT.mRoamingProtocol = new ListPreference(context);
mApnEditorUT.mCarrierEnabled = new SwitchPreference(context);
mApnEditorUT.mBearerMulti = new MultiSelectListPreference(context);
mApnEditorUT.mMvnoType = new ListPreference(context);
mApnEditorUT.mMvnoMatchData = new EditTextPreference(context);
}
use of androidx.preference.ListPreference in project android_packages_apps_Settings by omnirom.
the class GraphicsDriverAppPreferenceController method createListPreference.
@VisibleForTesting
protected ListPreference createListPreference(Context context, String packageName, String appName) {
final ListPreference listPreference = new ListPreference(context);
listPreference.setKey(packageName);
listPreference.setTitle(appName);
listPreference.setDialogTitle(mPreferenceTitle);
listPreference.setEntries(mEntryList);
listPreference.setEntryValues(mEntryList);
// from Settings.Global.UPDATABLE_DRIVER_[PRODUCTION|PRERELEASE]_OPT_[IN|OUT]_APPS
if (mDevOptOutApps.contains(packageName)) {
listPreference.setValue(mPreferenceSystem);
listPreference.setSummary(mPreferenceSystem);
} else if (mDevPrereleaseOptInApps.contains(packageName)) {
listPreference.setValue(mPreferencePrereleaseDriver);
listPreference.setSummary(mPreferencePrereleaseDriver);
} else if (mDevOptInApps.contains(packageName)) {
listPreference.setValue(mPreferenceProductionDriver);
listPreference.setSummary(mPreferenceProductionDriver);
} else {
listPreference.setValue(mPreferenceDefault);
listPreference.setSummary(mPreferenceDefault);
}
listPreference.setOnPreferenceChangeListener(this);
return listPreference;
}
use of androidx.preference.ListPreference in project android_packages_apps_Settings by omnirom.
the class GraphicsDriverAppPreferenceController method onPreferenceChange.
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final ListPreference listPref = (ListPreference) preference;
final String value = newValue.toString();
final String packageName = preference.getKey();
// opt-in and opt-out apps. Then set the new summary text.
if (value.equals(mPreferenceSystem)) {
mDevOptInApps.remove(packageName);
mDevPrereleaseOptInApps.remove(packageName);
mDevOptOutApps.add(packageName);
} else if (value.equals(mPreferenceProductionDriver)) {
mDevOptInApps.add(packageName);
mDevPrereleaseOptInApps.remove(packageName);
mDevOptOutApps.remove(packageName);
} else if (value.equals(mPreferencePrereleaseDriver)) {
mDevOptInApps.remove(packageName);
mDevPrereleaseOptInApps.add(packageName);
mDevOptOutApps.remove(packageName);
} else {
mDevOptInApps.remove(packageName);
mDevPrereleaseOptInApps.remove(packageName);
mDevOptOutApps.remove(packageName);
}
listPref.setValue(value);
listPref.setSummary(value);
// Push the updated Sets for stable/prerelease opt-in and opt-out apps to
// corresponding Settings.Global.UPDATABLE_DRIVER_[PRODUCTION|PRERELEASE]_OPT_(IN|OUT)_APPS
Settings.Global.putString(mContentResolver, Settings.Global.UPDATABLE_DRIVER_PRODUCTION_OPT_IN_APPS, String.join(",", mDevOptInApps));
Settings.Global.putString(mContentResolver, Settings.Global.UPDATABLE_DRIVER_PRERELEASE_OPT_IN_APPS, String.join(",", mDevPrereleaseOptInApps));
Settings.Global.putString(mContentResolver, Settings.Global.UPDATABLE_DRIVER_PRODUCTION_OPT_OUT_APPS, String.join(",", mDevOptOutApps));
return true;
}
use of androidx.preference.ListPreference in project android_packages_apps_Settings by omnirom.
the class WindowAnimationScalePreferenceController method updateAnimationScaleValue.
private void updateAnimationScaleValue() {
try {
final float scale = mWindowManager.getAnimationScale(WINDOW_ANIMATION_SCALE_SELECTOR);
// default
int index = 0;
for (int i = 0; i < mListValues.length; i++) {
float val = Float.parseFloat(mListValues[i]);
if (scale <= val) {
index = i;
break;
}
}
final ListPreference listPreference = (ListPreference) mPreference;
listPreference.setValue(mListValues[index]);
listPreference.setSummary(mListSummaries[index]);
} catch (RemoteException e) {
// intentional no-op
}
}
Aggregations