use of androidx.preference.DropDownPreference in project android_packages_apps_Settings by omnirom.
the class NfcForegroundPreferenceController method onPreferenceChange.
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (!(preference instanceof DropDownPreference)) {
return false;
}
final DropDownPreference pref = (DropDownPreference) preference;
final String newValueString = (String) newValue;
pref.setSummary(pref.getEntries()[pref.findIndexOfValue(newValueString)]);
final boolean foregroundMode = Integer.parseInt(newValueString) != 0;
mPaymentBackend.setForegroundMode(foregroundMode);
mMetricsFeatureProvider.action(mContext, foregroundMode ? SettingsEnums.ACTION_NFC_PAYMENT_FOREGROUND_SETTING : SettingsEnums.ACTION_NFC_PAYMENT_ALWAYS_SETTING);
return true;
}
use of androidx.preference.DropDownPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ZenModeEventRuleSettings method onCreateInternal.
@Override
protected void onCreateInternal() {
mCreate = true;
final PreferenceScreen root = getPreferenceScreen();
mCalendar = (DropDownPreference) root.findPreference(KEY_CALENDAR);
mCalendar.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final String calendarKey = (String) newValue;
if (calendarKey.equals(key(mEvent)))
return false;
String[] key = calendarKey.split(":", 3);
mEvent.userId = Integer.parseInt(key[0]);
mEvent.calendarId = key[1].equals("") ? null : Long.parseLong(key[1]);
mEvent.calName = key[2].equals("") ? null : key[2];
updateRule(ZenModeConfig.toEventConditionId(mEvent));
return true;
}
});
mReply = (DropDownPreference) root.findPreference(KEY_REPLY);
mReply.setEntries(new CharSequence[] { getString(R.string.zen_mode_event_rule_reply_any_except_no), getString(R.string.zen_mode_event_rule_reply_yes_or_maybe), getString(R.string.zen_mode_event_rule_reply_yes) });
mReply.setEntryValues(new CharSequence[] { Integer.toString(EventInfo.REPLY_ANY_EXCEPT_NO), Integer.toString(EventInfo.REPLY_YES_OR_MAYBE), Integer.toString(EventInfo.REPLY_YES) });
mReply.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final int reply = Integer.parseInt((String) newValue);
if (reply == mEvent.reply)
return false;
mEvent.reply = reply;
updateRule(ZenModeConfig.toEventConditionId(mEvent));
return true;
}
});
reloadCalendar();
updateControlsInternal();
}
use of androidx.preference.DropDownPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class WifiMeteredPreferenceController method updateState.
@Override
public void updateState(Preference preference) {
final DropDownPreference dropDownPreference = (DropDownPreference) preference;
final int meteredOverride = getMeteredOverride();
dropDownPreference.setValue(Integer.toString(meteredOverride));
updateSummary(dropDownPreference, meteredOverride);
}
use of androidx.preference.DropDownPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class NfcForegroundPreferenceController method onPreferenceChange.
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (!(preference instanceof DropDownPreference)) {
return false;
}
final DropDownPreference pref = (DropDownPreference) preference;
final String newValueString = (String) newValue;
pref.setSummary(pref.getEntries()[pref.findIndexOfValue(newValueString)]);
final boolean foregroundMode = Integer.parseInt(newValueString) != 0;
mPaymentBackend.setForegroundMode(foregroundMode);
mMetricsFeatureProvider.action(mContext, foregroundMode ? SettingsEnums.ACTION_NFC_PAYMENT_FOREGROUND_SETTING : SettingsEnums.ACTION_NFC_PAYMENT_ALWAYS_SETTING);
return true;
}
use of androidx.preference.DropDownPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class WifiPrivacyPreferenceControllerTest method setUp.
@Before
public void setUp() {
mContext = RuntimeEnvironment.application;
WifiPrivacyPreferenceController preferenceController = new WifiPrivacyPreferenceController(mContext);
preferenceController.setWifiConfiguration(mWifiConfiguration);
mPreferenceController = spy(preferenceController);
mDropDownPreference = new DropDownPreference(mContext);
mDropDownPreference.setEntries(R.array.wifi_privacy_entries);
mDropDownPreference.setEntryValues(R.array.wifi_privacy_values);
perferenceString = mContext.getResources().getStringArray(R.array.wifi_privacy_entries);
}
Aggregations