Merge "Add onPreferenceClickListener to dnd schedule"

This commit is contained in:
TreeHugger Robot
2019-02-22 16:30:34 +00:00
committed by Android (Google) Code Review

View File

@@ -63,6 +63,11 @@ public class ZenAutomaticRuleSwitchPreferenceController extends
mSwitchBar.setSwitchBarText(R.string.zen_mode_use_automatic_rule,
R.string.zen_mode_use_automatic_rule);
try {
pref.setOnPreferenceClickListener(preference -> {
mRule.setEnabled(!mRule.isEnabled());
mBackend.updateZenRule(mId, mRule);
return true;
});
mSwitchBar.addOnSwitchChangeListener(this);
} catch (IllegalStateException e) {
// an exception is thrown if you try to add the listener twice
@@ -71,7 +76,6 @@ public class ZenAutomaticRuleSwitchPreferenceController extends
}
}
public void onResume(AutomaticZenRule rule, String id) {
mRule = rule;
mId = id;