use of androidx.preference.DropDownPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class WifiPrivacyPreferenceController method updateState.
@Override
public void updateState(Preference preference) {
final DropDownPreference dropDownPreference = (DropDownPreference) preference;
final int randomizationLevel = getRandomizationValue();
dropDownPreference.setValue(Integer.toString(randomizationLevel));
updateSummary(dropDownPreference, randomizationLevel);
// Makes preference not selectable, when this is a ephemeral network.
if (mIsEphemeral || mIsPasspoint) {
preference.setSelectable(false);
dropDownPreference.setSummary(R.string.wifi_privacy_settings_ephemeral_summary);
}
}
use of androidx.preference.DropDownPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class WifiMeteredPreferenceControllerTest method setUp.
@Before
public void setUp() {
mContext = RuntimeEnvironment.application;
mPreferenceController = spy(new WifiMeteredPreferenceController(mContext, mWifiConfiguration));
mDropDownPreference = new DropDownPreference(mContext);
mDropDownPreference.setEntries(R.array.wifi_metered_entries);
mDropDownPreference.setEntryValues(R.array.wifi_metered_values);
}
use of androidx.preference.DropDownPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SettingPref method init.
public Preference init(SettingsPreferenceFragment settings) {
final Context context = settings.getActivity();
Preference p = settings.getPreferenceScreen().findPreference(mKey);
if (p != null && !isApplicable(context)) {
settings.getPreferenceScreen().removePreference(p);
p = null;
}
if (p instanceof TwoStatePreference) {
mTwoState = (TwoStatePreference) p;
} else if (p instanceof DropDownPreference) {
mDropDown = (DropDownPreference) p;
CharSequence[] entries = new CharSequence[mValues.length];
CharSequence[] values = new CharSequence[mValues.length];
for (int i = 0; i < mValues.length; i++) {
entries[i] = getCaption(context.getResources(), mValues[i]);
values[i] = Integer.toString(mValues[i]);
}
mDropDown.setEntries(entries);
mDropDown.setEntryValues(values);
}
update(context);
if (mTwoState != null) {
p.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
setSetting(context, (Boolean) newValue ? 1 : 0);
return true;
}
});
return mTwoState;
}
if (mDropDown != null) {
p.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
return setSetting(context, Integer.parseInt((String) newValue));
}
});
return mDropDown;
}
return null;
}
use of androidx.preference.DropDownPreference in project android_packages_apps_Settings by omnirom.
the class EmergencyTonePreferenceControllerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
final Context appContext = RuntimeEnvironment.application;
when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
when(mTelephonyManager.getCurrentPhoneType()).thenReturn(TelephonyManager.PHONE_TYPE_CDMA);
when(mSetting.getActivity()).thenReturn(mActivity);
when(mActivity.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
when(mActivity.getContentResolver()).thenReturn(mContentResolver);
when(mActivity.getResources()).thenReturn(appContext.getResources());
mPreference = new DropDownPreference(appContext);
mController = new EmergencyTonePreferenceController(mContext, mSetting, null);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
doReturn(mScreen).when(mSetting).getPreferenceScreen();
}
use of androidx.preference.DropDownPreference in project android_packages_apps_Settings by omnirom.
the class NfcForegroundPreferenceControllerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
when(mContext.getPackageManager()).thenReturn(mManager);
mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
mController = new NfcForegroundPreferenceController(mContext, PREF_KEY);
mPreference = new DropDownPreference(mContext);
when(mScreen.findPreference(PREF_KEY)).thenReturn(mPreference);
}
Aggregations