Merge "Flip the INTERRUPTION_FILTER_ALL switch" into main

This commit is contained in:
Matías Hernández
2024-08-20 14:06:17 +00:00
committed by Android (Google) Code Review
5 changed files with 22 additions and 21 deletions

View File

@@ -45,20 +45,21 @@ class InterruptionFilterPreferenceController extends AbstractZenModePreferenceCo
@Override
public void updateState(Preference preference, @NonNull ZenMode zenMode) {
preference.setEnabled(zenMode.isEnabled());
boolean filteringNotifications = zenMode.getRule().getInterruptionFilter()
!= INTERRUPTION_FILTER_ALL;
((TwoStatePreference) preference).setChecked(filteringNotifications);
preference.setSummary(filteringNotifications ? "" :
mContext.getResources().getString(R.string.mode_no_notification_filter));
boolean allowingAll = zenMode.getRule().getInterruptionFilter() == INTERRUPTION_FILTER_ALL;
((TwoStatePreference) preference).setChecked(allowingAll);
preference.setSummary(allowingAll
? mContext.getString(R.string.zen_mode_all_notifications_allowed)
: "");
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean filterNotifications = ((Boolean) newValue);
public boolean onPreferenceChange(@NonNull Preference preference, Object newValue) {
final boolean allowAll = ((Boolean) newValue);
return saveMode(zenMode -> {
zenMode.getRule().setInterruptionFilter(filterNotifications
? INTERRUPTION_FILTER_PRIORITY
: INTERRUPTION_FILTER_ALL);
zenMode.getRule().setInterruptionFilter(allowAll
? INTERRUPTION_FILTER_ALL
: INTERRUPTION_FILTER_PRIORITY);
return zenMode;
});
}

View File

@@ -77,7 +77,7 @@ public class ZenModeFragment extends ZenModeFragmentBase {
new ZenModeTriggerAddPreferenceController(context, "zen_add_automatic_trigger",
this, mBackend));
prefControllers.add(new InterruptionFilterPreferenceController(
context, "allow_filtering", mBackend));
context, "allow_all", mBackend));
prefControllers.add(new ManualDurationPreferenceController(
context, "mode_manual_duration", this, mBackend));
return prefControllers;