Merge "Add snooze options setting" into qt-dev am: f6f26e0447

am: 340b03b1cc

Change-Id: I9a49906bf8fab691cd94a9a057dabb2fbb4b8e36
This commit is contained in:
Julia Reynolds
2019-05-29 10:24:04 -07:00
committed by android-build-merger
3 changed files with 47 additions and 5 deletions

View File

@@ -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
@@ -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);

View File

@@ -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);

View File

@@ -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);