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