use of androidx.preference.DropDownPreference in project android_packages_apps_Settings by omnirom.
the class WifiMeteredPreferenceController2 method updateState.
@Override
public void updateState(Preference preference) {
final DropDownPreference dropDownPreference = (DropDownPreference) preference;
final int meteredOverride = getMeteredOverride();
preference.setSelectable(mWifiEntry.canSetMeteredChoice());
dropDownPreference.setValue(Integer.toString(meteredOverride));
updateSummary(dropDownPreference, meteredOverride);
}
use of androidx.preference.DropDownPreference in project android_packages_apps_Settings by omnirom.
the class WifiMeteredPreferenceController2Test method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mPreferenceController = spy(new WifiMeteredPreferenceController2(mContext, mWifiEntry));
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 android_packages_apps_Settings by omnirom.
the class WifiPrivacyPreferenceController2Test method setUp.
@Before
public void setUp() {
mContext = RuntimeEnvironment.application;
mMockWifiEntry = mock(WifiEntry.class);
WifiPrivacyPreferenceController2 preferenceController = new WifiPrivacyPreferenceController2(mContext);
preferenceController.setWifiEntry(mMockWifiEntry);
mPreferenceController = spy(preferenceController);
mDropDownPreference = new DropDownPreference(mContext);
mDropDownPreference.setEntries(R.array.wifi_privacy_entries);
mDropDownPreference.setEntryValues(R.array.wifi_privacy_values);
mPerferenceStrings = mContext.getResources().getStringArray(R.array.wifi_privacy_entries);
}
use of androidx.preference.DropDownPreference in project android_packages_apps_Settings by omnirom.
the class WifiPrivacyPreferenceController2 method updateState.
@Override
public void updateState(Preference preference) {
final DropDownPreference dropDownPreference = (DropDownPreference) preference;
final int randomizationLevel = getRandomizationValue();
final boolean isSelectable = mWifiEntry.canSetPrivacy();
preference.setSelectable(isSelectable);
dropDownPreference.setValue(Integer.toString(randomizationLevel));
updateSummary(dropDownPreference, randomizationLevel);
// If the preference cannot be selectable, display a temporary network in the summary.
if (!isSelectable) {
dropDownPreference.setSummary(R.string.wifi_privacy_settings_ephemeral_summary);
}
}
use of androidx.preference.DropDownPreference in project android_packages_apps_Settings by omnirom.
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;
}
Aggregations