use of android.support.v7.preference.Preference.OnPreferenceChangeListener in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ZenModeEventRuleSettings method onCreateInternal.
@Override
protected void onCreateInternal() {
mCreate = true;
addPreferencesFromResource(R.xml.zen_mode_event_rule_settings);
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;
final int i = calendarKey.indexOf(':');
mEvent.userId = Integer.parseInt(calendarKey.substring(0, i));
mEvent.calendar = calendarKey.substring(i + 1);
if (mEvent.calendar.isEmpty()) {
mEvent.calendar = null;
}
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 android.support.v7.preference.Preference.OnPreferenceChangeListener in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ManagedServiceSettings method updateList.
private void updateList(List<ServiceInfo> services) {
final PreferenceScreen screen = getPreferenceScreen();
screen.removeAll();
Collections.sort(services, new PackageItemInfo.DisplayNameComparator(mPM));
for (ServiceInfo service : services) {
final ComponentName cn = new ComponentName(service.packageName, service.name);
final String title = service.loadLabel(mPM).toString();
final SwitchPreference pref = new SwitchPreference(getPrefContext());
pref.setPersistent(false);
pref.setIcon(service.loadIcon(mPM));
pref.setTitle(title);
pref.setChecked(mServiceListing.isEnabled(cn));
pref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean enable = (boolean) newValue;
return setEnabled(cn, title, enable);
}
});
screen.addPreference(pref);
}
}
Aggregations