Flip the INTERRUPTION_FILTER_ALL switch

Instead of "Limit what can notify you", title is now "Allow all notifications" and its behavior is reversed (switch ON hides people/apps/other).

Fixes: 360359116
Test: atest InterruptionFilterPreferenceControllerTest + manual
Flag: android.app.modes_ui
Change-Id: Ibb5334889662ec3aa778cd74c51506718ab0ebc7
This commit is contained in:
Matías Hernández
2024-08-16 18:29:29 +02:00
parent 0a5c7530ed
commit 7883588653
5 changed files with 22 additions and 21 deletions

View File

@@ -8184,10 +8184,10 @@
other {{effect_1}, {effect_2}, and # more} other {{effect_1}, {effect_2}, and # more}
} }
</string> </string>
<!-- Modes: setting for whether the mode should filter (silence/hide) notifications/volume streams --> <!-- Modes: setting for a mode to allow all notifications and sounds through -->
<string name="mode_notification_filter_title">Limit what can notify you</string> <string name="zen_mode_allow_all_notifications">Allow all notifications</string>
<!-- Modes: subtext when a mode is not filtering (silence/hide) notifications/volume streams --> <!-- Modes: subtext when a mode is allowing all notifications and sounds (i.e. no filtering) -->
<string name="mode_no_notification_filter">No interruptions are filtered</string> <string name="zen_mode_all_notifications_allowed">People, apps, and sounds can interrupt</string>
<!-- Do not disturb: restrict notifications settings title [CHAR LIMIT=80] --> <!-- Do not disturb: restrict notifications settings title [CHAR LIMIT=80] -->
<string name="zen_mode_restrict_notifications_title">Display options for filtered <string name="zen_mode_restrict_notifications_title">Display options for filtered

View File

@@ -59,8 +59,8 @@
android:key="modes_filters"> android:key="modes_filters">
<SwitchPreferenceCompat <SwitchPreferenceCompat
android:key="allow_filtering" android:key="allow_all"
android:title="@string/mode_notification_filter_title"/> android:title="@string/zen_mode_allow_all_notifications"/>
<com.android.settings.notification.modes.CircularIconsPreference <com.android.settings.notification.modes.CircularIconsPreference
android:key="zen_mode_people" android:key="zen_mode_people"

View File

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

View File

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

View File

@@ -87,7 +87,7 @@ public final class InterruptionFilterPreferenceControllerTest {
.build(); .build();
mController.updateZenMode(preference, zenMode); mController.updateZenMode(preference, zenMode);
verify(preference).setChecked(false); verify(preference).setChecked(true);
} }
@Test @Test
@@ -99,7 +99,7 @@ public final class InterruptionFilterPreferenceControllerTest {
mController.updateZenMode(preference, zenMode); mController.updateZenMode(preference, zenMode);
mController.onPreferenceChange(preference, true); mController.onPreferenceChange(preference, false);
ArgumentCaptor<ZenMode> captor = ArgumentCaptor.forClass(ZenMode.class); ArgumentCaptor<ZenMode> captor = ArgumentCaptor.forClass(ZenMode.class);
verify(mBackend).updateMode(captor.capture()); verify(mBackend).updateMode(captor.capture());
@@ -118,7 +118,7 @@ public final class InterruptionFilterPreferenceControllerTest {
.build(); .build();
mController.updateZenMode(preference, zenMode); mController.updateZenMode(preference, zenMode);
verify(preference).setChecked(true); verify(preference).setChecked(false);
} }
@Test @Test
@@ -131,7 +131,7 @@ public final class InterruptionFilterPreferenceControllerTest {
mController.updateZenMode(preference, zenMode); mController.updateZenMode(preference, zenMode);
mController.onPreferenceChange(preference, false); mController.onPreferenceChange(preference, true);
ArgumentCaptor<ZenMode> captor = ArgumentCaptor.forClass(ZenMode.class); ArgumentCaptor<ZenMode> captor = ArgumentCaptor.forClass(ZenMode.class);
verify(mBackend).updateMode(captor.capture()); verify(mBackend).updateMode(captor.capture());