Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f6f26e04 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add snooze options setting" into qt-dev

parents 826c01e8 789bf3fa
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -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);
+10 −3
Original line number Diff line number Diff line
@@ -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);
+26 −2
Original line number Diff line number Diff line
@@ -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);