Loading core/java/android/provider/Settings.java +11 −0 Original line number Diff line number Diff line Loading @@ -8080,6 +8080,15 @@ public final class Settings { public static final String LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS = "lock_screen_show_silent_notifications"; /** * Indicates whether snooze options should be shown on notifications * <p> * Type: int (0 for false, 1 for true) * * @hide */ public static final String SHOW_NOTIFICATION_SNOOZE = "show_notification_snooze"; /** * List of TV inputs that are currently hidden. This is a string * containing the IDs of all hidden TV inputs. Each ID is encoded by Loading Loading @@ -8968,6 +8977,7 @@ public final class Settings { LOCK_SCREEN_CUSTOM_CLOCK_FACE, LOCK_SCREEN_SHOW_NOTIFICATIONS, LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, SHOW_NOTIFICATION_SNOOZE, ZEN_DURATION, SHOW_ZEN_UPGRADE_NOTIFICATION, SHOW_ZEN_SETTINGS_SUGGESTION, Loading Loading @@ -9150,6 +9160,7 @@ public final class Settings { VALIDATORS.put(LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, BOOLEAN_VALIDATOR); VALIDATORS.put(LOCK_SCREEN_SHOW_NOTIFICATIONS, BOOLEAN_VALIDATOR); VALIDATORS.put(LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, BOOLEAN_VALIDATOR); VALIDATORS.put(SHOW_NOTIFICATION_SNOOZE, BOOLEAN_VALIDATOR); VALIDATORS.put(ZEN_DURATION, ZEN_DURATION_VALIDATOR); VALIDATORS.put(SHOW_ZEN_UPGRADE_NOTIFICATION, BOOLEAN_VALIDATOR); VALIDATORS.put(SHOW_ZEN_SETTINGS_SUGGESTION, BOOLEAN_VALIDATOR); Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationMenuRow.java +10 −3 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.systemui.statusbar.notification.row; import static android.provider.Settings.Secure.SHOW_NOTIFICATION_SNOOZE; import static com.android.systemui.SwipeHelper.SWIPED_FAR_ENOUGH_SIZE_FRACTION; import android.animation.Animator; Loading @@ -29,6 +31,7 @@ import android.graphics.Point; import android.graphics.drawable.Drawable; import android.os.Handler; import android.os.Looper; import android.provider.Settings; import android.service.notification.StatusBarNotification; import android.util.ArrayMap; import android.view.LayoutInflater; Loading Loading @@ -255,9 +258,13 @@ public class NotificationMenuRow implements NotificationMenuRowPlugin, View.OnCl mVertSpaceForIcons = res.getDimensionPixelSize(R.dimen.notification_min_height); mLeftMenuItems.clear(); mRightMenuItems.clear(); boolean showSnooze = Settings.Secure.getInt(mContext.getContentResolver(), SHOW_NOTIFICATION_SNOOZE, 0) == 1; // Construct the menu items based on the notification if (!isForeground) { // Only show snooze for non-foreground notifications if (!isForeground && showSnooze) { // Only show snooze for non-foreground notifications, and if the setting is on mSnoozeItem = createSnoozeItem(mContext); } mAppOpsItem = createAppOpsItem(mContext); Loading @@ -268,7 +275,7 @@ public class NotificationMenuRow implements NotificationMenuRowPlugin, View.OnCl } if (!mIsUsingBidirectionalSwipe) { if (!isForeground) { if (!isForeground && showSnooze) { mRightMenuItems.add(mSnoozeItem); } mRightMenuItems.add(mInfoItem); Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationMenuRowTest.java +26 −2 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ package com.android.systemui.statusbar.notification.row; import static android.provider.Settings.Secure.NOTIFICATION_NEW_INTERRUPTION_MODEL; import static android.provider.Settings.Secure.SHOW_NOTIFICATION_SNOOZE; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertFalse; Loading Loading @@ -100,8 +101,31 @@ public class NotificationMenuRowTest extends LeakCheckedTest { @Test public void testNoAppOpsInSlowSwipe() { Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_NEW_INTERRUPTION_MODEL, 0); Settings.Secure.putInt(mContext.getContentResolver(), SHOW_NOTIFICATION_SNOOZE, 0); NotificationMenuRow row = new NotificationMenuRow(mContext); row.createMenu(mRow, null); ViewGroup container = (ViewGroup) row.getMenuView(); // noti blocking assertEquals(1, container.getChildCount()); } @Test public void testNoSnoozeInSlowSwipe() { Settings.Secure.putInt(mContext.getContentResolver(), SHOW_NOTIFICATION_SNOOZE, 0); NotificationMenuRow row = new NotificationMenuRow(mContext); row.createMenu(mRow, null); ViewGroup container = (ViewGroup) row.getMenuView(); // just for noti blocking assertEquals(1, container.getChildCount()); } @Test public void testSnoozeInSlowSwipe() { Settings.Secure.putInt(mContext.getContentResolver(), SHOW_NOTIFICATION_SNOOZE, 1); NotificationMenuRow row = new NotificationMenuRow(mContext); row.createMenu(mRow, null); Loading Loading
core/java/android/provider/Settings.java +11 −0 Original line number Diff line number Diff line Loading @@ -8080,6 +8080,15 @@ public final class Settings { public static final String LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS = "lock_screen_show_silent_notifications"; /** * Indicates whether snooze options should be shown on notifications * <p> * Type: int (0 for false, 1 for true) * * @hide */ public static final String SHOW_NOTIFICATION_SNOOZE = "show_notification_snooze"; /** * List of TV inputs that are currently hidden. This is a string * containing the IDs of all hidden TV inputs. Each ID is encoded by Loading Loading @@ -8968,6 +8977,7 @@ public final class Settings { LOCK_SCREEN_CUSTOM_CLOCK_FACE, LOCK_SCREEN_SHOW_NOTIFICATIONS, LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, SHOW_NOTIFICATION_SNOOZE, ZEN_DURATION, SHOW_ZEN_UPGRADE_NOTIFICATION, SHOW_ZEN_SETTINGS_SUGGESTION, Loading Loading @@ -9150,6 +9160,7 @@ public final class Settings { VALIDATORS.put(LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS, BOOLEAN_VALIDATOR); VALIDATORS.put(LOCK_SCREEN_SHOW_NOTIFICATIONS, BOOLEAN_VALIDATOR); VALIDATORS.put(LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, BOOLEAN_VALIDATOR); VALIDATORS.put(SHOW_NOTIFICATION_SNOOZE, BOOLEAN_VALIDATOR); VALIDATORS.put(ZEN_DURATION, ZEN_DURATION_VALIDATOR); VALIDATORS.put(SHOW_ZEN_UPGRADE_NOTIFICATION, BOOLEAN_VALIDATOR); VALIDATORS.put(SHOW_ZEN_SETTINGS_SUGGESTION, BOOLEAN_VALIDATOR); Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationMenuRow.java +10 −3 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.systemui.statusbar.notification.row; import static android.provider.Settings.Secure.SHOW_NOTIFICATION_SNOOZE; import static com.android.systemui.SwipeHelper.SWIPED_FAR_ENOUGH_SIZE_FRACTION; import android.animation.Animator; Loading @@ -29,6 +31,7 @@ import android.graphics.Point; import android.graphics.drawable.Drawable; import android.os.Handler; import android.os.Looper; import android.provider.Settings; import android.service.notification.StatusBarNotification; import android.util.ArrayMap; import android.view.LayoutInflater; Loading Loading @@ -255,9 +258,13 @@ public class NotificationMenuRow implements NotificationMenuRowPlugin, View.OnCl mVertSpaceForIcons = res.getDimensionPixelSize(R.dimen.notification_min_height); mLeftMenuItems.clear(); mRightMenuItems.clear(); boolean showSnooze = Settings.Secure.getInt(mContext.getContentResolver(), SHOW_NOTIFICATION_SNOOZE, 0) == 1; // Construct the menu items based on the notification if (!isForeground) { // Only show snooze for non-foreground notifications if (!isForeground && showSnooze) { // Only show snooze for non-foreground notifications, and if the setting is on mSnoozeItem = createSnoozeItem(mContext); } mAppOpsItem = createAppOpsItem(mContext); Loading @@ -268,7 +275,7 @@ public class NotificationMenuRow implements NotificationMenuRowPlugin, View.OnCl } if (!mIsUsingBidirectionalSwipe) { if (!isForeground) { if (!isForeground && showSnooze) { mRightMenuItems.add(mSnoozeItem); } mRightMenuItems.add(mInfoItem); Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationMenuRowTest.java +26 −2 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ package com.android.systemui.statusbar.notification.row; import static android.provider.Settings.Secure.NOTIFICATION_NEW_INTERRUPTION_MODEL; import static android.provider.Settings.Secure.SHOW_NOTIFICATION_SNOOZE; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertFalse; Loading Loading @@ -100,8 +101,31 @@ public class NotificationMenuRowTest extends LeakCheckedTest { @Test public void testNoAppOpsInSlowSwipe() { Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_NEW_INTERRUPTION_MODEL, 0); Settings.Secure.putInt(mContext.getContentResolver(), SHOW_NOTIFICATION_SNOOZE, 0); NotificationMenuRow row = new NotificationMenuRow(mContext); row.createMenu(mRow, null); ViewGroup container = (ViewGroup) row.getMenuView(); // noti blocking assertEquals(1, container.getChildCount()); } @Test public void testNoSnoozeInSlowSwipe() { Settings.Secure.putInt(mContext.getContentResolver(), SHOW_NOTIFICATION_SNOOZE, 0); NotificationMenuRow row = new NotificationMenuRow(mContext); row.createMenu(mRow, null); ViewGroup container = (ViewGroup) row.getMenuView(); // just for noti blocking assertEquals(1, container.getChildCount()); } @Test public void testSnoozeInSlowSwipe() { Settings.Secure.putInt(mContext.getContentResolver(), SHOW_NOTIFICATION_SNOOZE, 1); NotificationMenuRow row = new NotificationMenuRow(mContext); row.createMenu(mRow, null); Loading