Loading packages/SettingsLib/src/com/android/settingslib/notification/modes/TestModeBuilder.java +11 −12 Original line number Diff line number Diff line Loading @@ -40,18 +40,17 @@ public class TestModeBuilder { private ZenModeConfig.ZenRule mConfigZenRule; public static final ZenMode EXAMPLE = new TestModeBuilder().build(); public static final ZenMode MANUAL_DND_ACTIVE = ZenMode.manualDndMode( new AutomaticZenRule.Builder("Do Not Disturb", Uri.parse("rule://dnd")) .setInterruptionFilter(NotificationManager.INTERRUPTION_FILTER_PRIORITY) .setZenPolicy(new ZenPolicy.Builder().disallowAllSounds().build()) .build(), /* isActive= */ true); public static final ZenMode MANUAL_DND_INACTIVE = ZenMode.manualDndMode( new AutomaticZenRule.Builder("Do Not Disturb", Uri.parse("rule://dnd")) public static final ZenMode MANUAL_DND_ACTIVE = manualDnd(Uri.EMPTY, true); public static final ZenMode MANUAL_DND_INACTIVE = manualDnd(Uri.EMPTY, false); public static ZenMode manualDnd(Uri conditionId, boolean isActive) { return ZenMode.manualDndMode( new AutomaticZenRule.Builder("Do Not Disturb", conditionId) .setInterruptionFilter(NotificationManager.INTERRUPTION_FILTER_PRIORITY) .setZenPolicy(new ZenPolicy.Builder().disallowAllSounds().build()) .build(), /* isActive= */ false); isActive); } public TestModeBuilder() { // Reasonable defaults Loading packages/SettingsLib/src/com/android/settingslib/notification/modes/ZenMode.java +27 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import static android.app.NotificationManager.INTERRUPTION_FILTER_ALL; import static android.app.NotificationManager.INTERRUPTION_FILTER_PRIORITY; import static android.service.notification.SystemZenRules.getTriggerDescriptionForScheduleEvent; import static android.service.notification.SystemZenRules.getTriggerDescriptionForScheduleTime; import static android.service.notification.ZenModeConfig.tryParseCountdownConditionId; import static android.service.notification.ZenModeConfig.tryParseEventConditionId; import static android.service.notification.ZenModeConfig.tryParseScheduleConditionId; Loading Loading @@ -188,11 +189,37 @@ public class ZenMode implements Parcelable { return mRule.getType(); } /** Returns the trigger description of the mode. */ @Nullable public String getTriggerDescription() { return mRule.getTriggerDescription(); } /** * Returns a "dynamic" trigger description. For some modes (such as manual Do Not Disturb) * when activated, we know when (and if) the mode is expected to end on its own; this dynamic * description reflects that. In other cases, returns {@link #getTriggerDescription}. */ @Nullable public String getDynamicDescription(Context context) { if (isManualDnd() && isActive()) { long countdownEndTime = tryParseCountdownConditionId(mRule.getConditionId()); if (countdownEndTime > 0) { CharSequence formattedTime = ZenModeConfig.getFormattedTime(context, countdownEndTime, ZenModeConfig.isToday(countdownEndTime), context.getUserId()); return context.getString(com.android.internal.R.string.zen_mode_until, formattedTime); } } // TODO: b/333527800 - For TYPE_SCHEDULE_TIME rules we could do the same; however // according to the snoozing discussions the mode may or may not end at the scheduled // time if manually activated. When we resolve that point, we could calculate end time // for these modes as well. return getTriggerDescription(); } @NonNull public ListenableFuture<Drawable> getIcon(@NonNull Context context, @NonNull ZenIconLoader iconLoader) { Loading packages/SettingsLib/src/com/android/settingslib/notification/modes/ZenModesBackend.java +1 −2 Original line number Diff line number Diff line Loading @@ -116,7 +116,6 @@ public class ZenModesBackend { private ZenMode getManualDndMode(ZenModeConfig config) { ZenModeConfig.ZenRule manualRule = config.manualRule; // TODO: b/333682392 - Replace with final strings for name & trigger description AutomaticZenRule manualDndRule = new AutomaticZenRule.Builder( mContext.getString(R.string.zen_mode_settings_title), manualRule.conditionId) .setType(manualRule.type) Loading @@ -127,7 +126,7 @@ public class ZenModesBackend { .setInterruptionFilter(NotificationManager.INTERRUPTION_FILTER_PRIORITY) .build(); return ZenMode.manualDndMode(manualDndRule, config != null && config.isManualActive()); return ZenMode.manualDndMode(manualDndRule, config.isManualActive()); } public void updateMode(ZenMode mode) { Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/ui/dialog/viewmodel/ModesDialogViewModel.kt +1 −1 Original line number Diff line number Diff line Loading @@ -131,7 +131,7 @@ constructor( val on = context.resources.getString(R.string.zen_mode_on) val off = context.resources.getString(R.string.zen_mode_off) return mode.rule.triggerDescription ?: if (mode.isActive) on else off return mode.getDynamicDescription(context) ?: if (mode.isActive) on else off } private fun makeZenModeDialog(): Dialog { Loading Loading
packages/SettingsLib/src/com/android/settingslib/notification/modes/TestModeBuilder.java +11 −12 Original line number Diff line number Diff line Loading @@ -40,18 +40,17 @@ public class TestModeBuilder { private ZenModeConfig.ZenRule mConfigZenRule; public static final ZenMode EXAMPLE = new TestModeBuilder().build(); public static final ZenMode MANUAL_DND_ACTIVE = ZenMode.manualDndMode( new AutomaticZenRule.Builder("Do Not Disturb", Uri.parse("rule://dnd")) .setInterruptionFilter(NotificationManager.INTERRUPTION_FILTER_PRIORITY) .setZenPolicy(new ZenPolicy.Builder().disallowAllSounds().build()) .build(), /* isActive= */ true); public static final ZenMode MANUAL_DND_INACTIVE = ZenMode.manualDndMode( new AutomaticZenRule.Builder("Do Not Disturb", Uri.parse("rule://dnd")) public static final ZenMode MANUAL_DND_ACTIVE = manualDnd(Uri.EMPTY, true); public static final ZenMode MANUAL_DND_INACTIVE = manualDnd(Uri.EMPTY, false); public static ZenMode manualDnd(Uri conditionId, boolean isActive) { return ZenMode.manualDndMode( new AutomaticZenRule.Builder("Do Not Disturb", conditionId) .setInterruptionFilter(NotificationManager.INTERRUPTION_FILTER_PRIORITY) .setZenPolicy(new ZenPolicy.Builder().disallowAllSounds().build()) .build(), /* isActive= */ false); isActive); } public TestModeBuilder() { // Reasonable defaults Loading
packages/SettingsLib/src/com/android/settingslib/notification/modes/ZenMode.java +27 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import static android.app.NotificationManager.INTERRUPTION_FILTER_ALL; import static android.app.NotificationManager.INTERRUPTION_FILTER_PRIORITY; import static android.service.notification.SystemZenRules.getTriggerDescriptionForScheduleEvent; import static android.service.notification.SystemZenRules.getTriggerDescriptionForScheduleTime; import static android.service.notification.ZenModeConfig.tryParseCountdownConditionId; import static android.service.notification.ZenModeConfig.tryParseEventConditionId; import static android.service.notification.ZenModeConfig.tryParseScheduleConditionId; Loading Loading @@ -188,11 +189,37 @@ public class ZenMode implements Parcelable { return mRule.getType(); } /** Returns the trigger description of the mode. */ @Nullable public String getTriggerDescription() { return mRule.getTriggerDescription(); } /** * Returns a "dynamic" trigger description. For some modes (such as manual Do Not Disturb) * when activated, we know when (and if) the mode is expected to end on its own; this dynamic * description reflects that. In other cases, returns {@link #getTriggerDescription}. */ @Nullable public String getDynamicDescription(Context context) { if (isManualDnd() && isActive()) { long countdownEndTime = tryParseCountdownConditionId(mRule.getConditionId()); if (countdownEndTime > 0) { CharSequence formattedTime = ZenModeConfig.getFormattedTime(context, countdownEndTime, ZenModeConfig.isToday(countdownEndTime), context.getUserId()); return context.getString(com.android.internal.R.string.zen_mode_until, formattedTime); } } // TODO: b/333527800 - For TYPE_SCHEDULE_TIME rules we could do the same; however // according to the snoozing discussions the mode may or may not end at the scheduled // time if manually activated. When we resolve that point, we could calculate end time // for these modes as well. return getTriggerDescription(); } @NonNull public ListenableFuture<Drawable> getIcon(@NonNull Context context, @NonNull ZenIconLoader iconLoader) { Loading
packages/SettingsLib/src/com/android/settingslib/notification/modes/ZenModesBackend.java +1 −2 Original line number Diff line number Diff line Loading @@ -116,7 +116,6 @@ public class ZenModesBackend { private ZenMode getManualDndMode(ZenModeConfig config) { ZenModeConfig.ZenRule manualRule = config.manualRule; // TODO: b/333682392 - Replace with final strings for name & trigger description AutomaticZenRule manualDndRule = new AutomaticZenRule.Builder( mContext.getString(R.string.zen_mode_settings_title), manualRule.conditionId) .setType(manualRule.type) Loading @@ -127,7 +126,7 @@ public class ZenModesBackend { .setInterruptionFilter(NotificationManager.INTERRUPTION_FILTER_PRIORITY) .build(); return ZenMode.manualDndMode(manualDndRule, config != null && config.isManualActive()); return ZenMode.manualDndMode(manualDndRule, config.isManualActive()); } public void updateMode(ZenMode mode) { Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/ui/dialog/viewmodel/ModesDialogViewModel.kt +1 −1 Original line number Diff line number Diff line Loading @@ -131,7 +131,7 @@ constructor( val on = context.resources.getString(R.string.zen_mode_on) val off = context.resources.getString(R.string.zen_mode_off) return mode.rule.triggerDescription ?: if (mode.isActive) on else off return mode.getDynamicDescription(context) ?: if (mode.isActive) on else off } private fun makeZenModeDialog(): Dialog { Loading