Search in sources :

Example 61 with ListPreference

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());
}
Also used : PersistableBundle(android.os.PersistableBundle) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) ListPreference(androidx.preference.ListPreference) Before(org.junit.Before) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 62 with ListPreference

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);
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) MultiSelectListPreference(androidx.preference.MultiSelectListPreference) EditTextPreference(androidx.preference.EditTextPreference) MultiSelectListPreference(androidx.preference.MultiSelectListPreference) ListPreference(androidx.preference.ListPreference)

Example 63 with ListPreference

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;
}
Also used : ListPreference(androidx.preference.ListPreference) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 64 with 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;
}
Also used : ListPreference(androidx.preference.ListPreference)

Example 65 with ListPreference

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
    }
}
Also used : ListPreference(androidx.preference.ListPreference) RemoteException(android.os.RemoteException)

Aggregations

ListPreference (androidx.preference.ListPreference)170 Test (org.junit.Test)24 Before (org.junit.Before)23 Preference (androidx.preference.Preference)20 EditTextPreference (androidx.preference.EditTextPreference)10 PreferenceScreen (androidx.preference.PreferenceScreen)10 SwitchPreference (androidx.preference.SwitchPreference)9 Context (android.content.Context)8 ContentResolver (android.content.ContentResolver)7 Intent (android.content.Intent)7 PersistableBundle (android.os.PersistableBundle)6 MultiSelectListPreference (androidx.preference.MultiSelectListPreference)6 Resources (android.content.res.Resources)5 Bundle (android.os.Bundle)5 RemoteException (android.os.RemoteException)5 RestrictionEntry (android.content.RestrictionEntry)4 OverlayInfo (android.content.om.OverlayInfo)4 ApplicationInfo (android.content.pm.ApplicationInfo)4 PackageInfo (android.content.pm.PackageInfo)4 WifiConfiguration (android.net.wifi.WifiConfiguration)4