Search in sources :

Example 71 with ListPreference

use of androidx.preference.ListPreference in project android_packages_apps_Settings by omnirom.

the class PreferredNetworkModePreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(ApplicationProvider.getApplicationContext());
    when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
    when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
    when(mContext.getSystemService(CarrierConfigManager.class)).thenReturn(mCarrierConfigManager);
    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).getConfigForSubId(SUB_ID);
    mPreference = new ListPreference(mContext);
    mController = new PreferredNetworkModePreferenceController(mContext, "mobile_data");
    mController.init(SUB_ID);
    mPreference.setKey(mController.getPreferenceKey());
}
Also used : PersistableBundle(android.os.PersistableBundle) ListPreference(androidx.preference.ListPreference) Before(org.junit.Before)

Example 72 with ListPreference

use of androidx.preference.ListPreference in project android_packages_apps_Settings by omnirom.

the class NightModePreferenceController method displayPreference.

@Override
public void displayPreference(PreferenceScreen screen) {
    if (!isAvailable()) {
        setVisible(screen, KEY_NIGHT_MODE, false);
        return;
    }
    final ListPreference mNightModePreference = screen.findPreference(KEY_NIGHT_MODE);
    if (mNightModePreference != null) {
        final UiModeManager uiManager = (UiModeManager) mContext.getSystemService(UI_MODE_SERVICE);
        final int currentNightMode = uiManager.getNightMode();
        mNightModePreference.setValue(String.valueOf(currentNightMode));
        mNightModePreference.setOnPreferenceChangeListener(this);
    }
}
Also used : UiModeManager(android.app.UiModeManager) ListPreference(androidx.preference.ListPreference)

Example 73 with ListPreference

use of androidx.preference.ListPreference in project android_packages_apps_Settings by omnirom.

the class PreferredNetworkModePreferenceController method onPreferenceChange.

@Override
public boolean onPreferenceChange(Preference preference, Object object) {
    final int newPreferredNetworkMode = Integer.parseInt((String) object);
    mTelephonyManager.setAllowedNetworkTypesForReason(TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_USER, MobileNetworkUtils.getRafFromNetworkType(newPreferredNetworkMode));
    final ListPreference listPreference = (ListPreference) preference;
    listPreference.setSummary(getPreferredNetworkModeSummaryResId(newPreferredNetworkMode));
    return true;
}
Also used : ListPreference(androidx.preference.ListPreference)

Example 74 with ListPreference

use of androidx.preference.ListPreference in project android_packages_apps_Settings by omnirom.

the class CdmaSystemSelectPreferenceController method resetCdmaRoamingModeToDefault.

private void resetCdmaRoamingModeToDefault() {
    final ListPreference listPreference = (ListPreference) mPreference;
    // set the mButtonCdmaRoam
    listPreference.setValue(Integer.toString(TelephonyManager.CDMA_ROAMING_MODE_ANY));
    // set the Settings.System
    Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.CDMA_ROAMING_MODE, TelephonyManager.CDMA_ROAMING_MODE_ANY);
    // Set the Status
    mTelephonyManager.setCdmaRoamingMode(TelephonyManager.CDMA_ROAMING_MODE_ANY);
}
Also used : ListPreference(androidx.preference.ListPreference)

Example 75 with ListPreference

use of androidx.preference.ListPreference in project android_packages_apps_Settings by omnirom.

the class CdmaSubscriptionPreferenceController method updateState.

@Override
public void updateState(Preference preference) {
    super.updateState(preference);
    final ListPreference listPreference = (ListPreference) preference;
    listPreference.setVisible(getAvailabilityStatus() == AVAILABLE);
    final int mode = Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.CDMA_SUBSCRIPTION_MODE, TelephonyManager.CDMA_SUBSCRIPTION_RUIM_SIM);
    if (mode != TelephonyManager.CDMA_SUBSCRIPTION_UNKNOWN) {
        listPreference.setValue(Integer.toString(mode));
    }
}
Also used : ListPreference(androidx.preference.ListPreference)

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