diff options
| author | 2019-05-29 17:03:32 +0000 | |
|---|---|---|
| committer | 2019-05-29 17:03:32 +0000 | |
| commit | f6f26e0447bd3fc61a28d66f0806ea2e1b14d940 (patch) | |
| tree | f93a31897657f88776ccea86464fe38425e150d0 | |
| parent | 826c01e8e621d376baff719ba22de14be8d8bb61 (diff) | |
| parent | 789bf3fab3f317dc0b0382a216e72199031f0fcd (diff) | |
Merge "Add snooze options setting" into qt-dev
3 files changed, 47 insertions, 5 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 66b9d168d71d..0db5c36eb961 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -8081,6 +8081,15 @@ public final class Settings { "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 * {@link android.net.Uri#encode(String)} and separated by ':'. @@ -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, @@ -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); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationMenuRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationMenuRow.java index ecbb2161a0cf..d911e1a05029 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationMenuRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationMenuRow.java @@ -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; @@ -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; @@ -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); @@ -268,7 +275,7 @@ public class NotificationMenuRow implements NotificationMenuRowPlugin, View.OnCl } if (!mIsUsingBidirectionalSwipe) { - if (!isForeground) { + if (!isForeground && showSnooze) { mRightMenuItems.add(mSnoozeItem); } mRightMenuItems.add(mInfoItem); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationMenuRowTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationMenuRowTest.java index 43ea92f13c8d..13b9d56e5a14 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationMenuRowTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationMenuRowTest.java @@ -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; @@ -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); |