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:
@@ -8184,10 +8184,10 @@
|
||||
other {{effect_1}, {effect_2}, and # more}
|
||||
}
|
||||
</string>
|
||||
<!-- Modes: setting for whether the mode should filter (silence/hide) notifications/volume streams -->
|
||||
<string name="mode_notification_filter_title">Limit what can notify you</string>
|
||||
<!-- Modes: subtext when a mode is not filtering (silence/hide) notifications/volume streams -->
|
||||
<string name="mode_no_notification_filter">No interruptions are filtered</string>
|
||||
<!-- Modes: setting for a mode to allow all notifications and sounds through -->
|
||||
<string name="zen_mode_allow_all_notifications">Allow all notifications</string>
|
||||
<!-- Modes: subtext when a mode is allowing all notifications and sounds (i.e. no filtering) -->
|
||||
<string name="zen_mode_all_notifications_allowed">People, apps, and sounds can interrupt</string>
|
||||
|
||||
<!-- Do not disturb: restrict notifications settings title [CHAR LIMIT=80] -->
|
||||
<string name="zen_mode_restrict_notifications_title">Display options for filtered
|
||||
|
@@ -59,8 +59,8 @@
|
||||
android:key="modes_filters">
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:key="allow_filtering"
|
||||
android:title="@string/mode_notification_filter_title"/>
|
||||
android:key="allow_all"
|
||||
android:title="@string/zen_mode_allow_all_notifications"/>
|
||||
|
||||
<com.android.settings.notification.modes.CircularIconsPreference
|
||||
android:key="zen_mode_people"
|
||||
|
@@ -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;
|
||||
});
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -87,7 +87,7 @@ public final class InterruptionFilterPreferenceControllerTest {
|
||||
.build();
|
||||
mController.updateZenMode(preference, zenMode);
|
||||
|
||||
verify(preference).setChecked(false);
|
||||
verify(preference).setChecked(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -99,7 +99,7 @@ public final class InterruptionFilterPreferenceControllerTest {
|
||||
|
||||
mController.updateZenMode(preference, zenMode);
|
||||
|
||||
mController.onPreferenceChange(preference, true);
|
||||
mController.onPreferenceChange(preference, false);
|
||||
|
||||
ArgumentCaptor<ZenMode> captor = ArgumentCaptor.forClass(ZenMode.class);
|
||||
verify(mBackend).updateMode(captor.capture());
|
||||
@@ -118,7 +118,7 @@ public final class InterruptionFilterPreferenceControllerTest {
|
||||
.build();
|
||||
mController.updateZenMode(preference, zenMode);
|
||||
|
||||
verify(preference).setChecked(true);
|
||||
verify(preference).setChecked(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -131,7 +131,7 @@ public final class InterruptionFilterPreferenceControllerTest {
|
||||
|
||||
mController.updateZenMode(preference, zenMode);
|
||||
|
||||
mController.onPreferenceChange(preference, false);
|
||||
mController.onPreferenceChange(preference, true);
|
||||
|
||||
ArgumentCaptor<ZenMode> captor = ArgumentCaptor.forClass(ZenMode.class);
|
||||
verify(mBackend).updateMode(captor.capture());
|
||||
|
Reference in New Issue
Block a user