Changes to notification silencing controls.
Bug: 123900504
Test: Manual testing.
Change-Id: Ib0075ac02fdd6f94171dc4470176b06ebcf4be2f
diff --git a/packages/SystemUI/res/drawable/circle_blue_40dp.xml b/packages/SystemUI/res/drawable/circle_blue_40dp.xml
new file mode 100644
index 0000000..00d2c52
--- /dev/null
+++ b/packages/SystemUI/res/drawable/circle_blue_40dp.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2019 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="oval">
+ <size android:height="40dp"
+ android:width="40dp" />
+ <solid android:color="#4285f4" />
+ <stroke android:color="#f1f3f4" android:width="1dp" />
+</shape>
\ No newline at end of file
diff --git a/packages/SystemUI/res/drawable/circle_white_40dp.xml b/packages/SystemUI/res/drawable/circle_white_40dp.xml
new file mode 100644
index 0000000..bcb1640
--- /dev/null
+++ b/packages/SystemUI/res/drawable/circle_white_40dp.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2019 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="oval">
+ <size android:height="40dp"
+ android:width="40dp" />
+ <solid android:color="#ffffff" />
+ <stroke android:color="#f1f3f4" android:width="1dp" />
+</shape>
\ No newline at end of file
diff --git a/packages/SystemUI/res/layout/notification_info.xml b/packages/SystemUI/res/layout/notification_info.xml
index 7e0f3ae..725ace4 100644
--- a/packages/SystemUI/res/layout/notification_info.xml
+++ b/packages/SystemUI/res/layout/notification_info.xml
@@ -220,48 +220,142 @@
android:layout_marginStart="@dimen/notification_guts_button_horizontal_spacing"
style="@style/TextAppearance.NotificationInfo.Button"/>
</LinearLayout>
-
-
</RelativeLayout>
<LinearLayout
android:id="@+id/interruptiveness_settings"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/notification_guts_button_spacing"
- android:layout_marginStart="@dimen/notification_guts_button_side_margin"
- android:layout_marginEnd="@dimen/notification_guts_button_side_margin"
- android:gravity="center"
- android:orientation="horizontal"
+ android:orientation="vertical"
android:visibility="gone">
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="2dp"
+ android:layout_marginStart="@dimen/notification_guts_button_side_margin"
+ android:layout_marginEnd="@dimen/notification_guts_button_side_margin"
+ android:gravity="center"
+ android:orientation="horizontal">
+ <LinearLayout
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:gravity="center_horizontal"
+ android:orientation="vertical">
+ <FrameLayout
+ android:id="@+id/int_block_wrapper"
+ android:padding="4dp"
+ android:layout_width="48dp"
+ android:layout_height="48dp"
+ android:gravity="center">
+ <ImageButton
+ android:id="@+id/int_block"
+ android:background="@drawable/circle_white_40dp"
+ android:src="@drawable/ic_notification_block"
+ android:layout_gravity="center"
+ android:layout_width="40dp"
+ android:layout_height="40dp"
+ android:clickable="false"
+ android:tint="@color/GM2_grey_400"
+ style="@style/TextAppearance.NotificationInfo.Button"/>
+ </FrameLayout>
+ <TextView
+ android:id="@+id/int_block_label"
+ android:text="@string/inline_block_button"
+ android:layout_gravity="center_horizontal"
+ android:gravity="center"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ellipsize="end"
+ android:maxLines="1"
+ style="@style/TextAppearance.NotificationInfo.ButtonLabel"/>
+ </LinearLayout>
+ <LinearLayout
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:gravity="center_horizontal"
+ android:orientation="vertical">
+ <FrameLayout
+ android:id="@+id/int_silent_wrapper"
+ android:padding="4dp"
+ android:layout_width="48dp"
+ android:layout_height="48dp"
+ android:gravity="center">
+ <ImageButton
+ android:id="@+id/int_silent"
+ android:background="@drawable/circle_white_40dp"
+ android:src="@drawable/ic_notifications_silence"
+ android:layout_gravity="center"
+ android:layout_width="40dp"
+ android:layout_height="40dp"
+ android:clickable="false"
+ android:tint="@color/GM2_grey_400"
+ style="@style/TextAppearance.NotificationInfo.Button"/>
+ </FrameLayout>
+ <TextView
+ android:id="@+id/int_silent_label"
+ android:text="@string/inline_silent_button_silent"
+ android:layout_gravity="center_horizontal"
+ android:gravity="center"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ellipsize="end"
+ android:maxLines="1"
+ style="@style/TextAppearance.NotificationInfo.ButtonLabel"/>
+ </LinearLayout>
+ <LinearLayout
+ android:layout_width="0dp"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:gravity="center_horizontal"
+ android:orientation="vertical">
+ <FrameLayout
+ android:id="@+id/int_alert_wrapper"
+ android:padding="4dp"
+ android:layout_width="48dp"
+ android:layout_height="48dp"
+ android:gravity="center">
+ <ImageButton
+ android:id="@+id/int_alert"
+ android:background="@drawable/circle_white_40dp"
+ android:src="@drawable/ic_notifications_alert"
+ android:layout_gravity="center"
+ android:layout_width="40dp"
+ android:layout_height="40dp"
+ android:clickable="false"
+ android:tint="@color/GM2_grey_400"
+ style="@style/TextAppearance.NotificationInfo.Button"/>
+ </FrameLayout>
+ <TextView
+ android:id="@+id/int_alert_label"
+ android:text="@string/inline_silent_button_alert"
+ android:layout_gravity="center_horizontal"
+ android:gravity="center"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ellipsize="end"
+ android:maxLines="1"
+ style="@style/TextAppearance.NotificationInfo.ButtonLabel"/>
+ </LinearLayout>
+ </LinearLayout>
<TextView
- android:id="@+id/int_block"
- android:text="@string/inline_block_button"
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:drawableTop="@drawable/ic_notification_block"
- android:drawableTint="?android:attr/colorAccent"
- android:layout_weight="1"
- style="@style/TextAppearance.NotificationInfo.Button"/>
+ android:id="@+id/hint_text"
+ android:layout_marginStart="@*android:dimen/notification_content_margin_start"
+ android:layout_marginEnd="@*android:dimen/notification_content_margin_start"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ style="@style/TextAppearance.NotificationInfo.HintText" />
<TextView
- android:id="@+id/int_silent"
- android:text="@string/inline_minimize_button"
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:drawableTop="@drawable/ic_notifications_silence"
- android:drawableTint="?android:attr/colorAccent"
- android:layout_weight="1"
- style="@style/TextAppearance.NotificationInfo.Button"/>
- <TextView
- android:id="@+id/int_alert"
- android:text="@string/inline_keep_button"
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:drawableTop="@drawable/ic_notifications_alert"
- android:drawableTint="?android:attr/colorAccent"
- android:layout_weight="1"
- style="@style/TextAppearance.NotificationInfo.Button"/>
+ android:id="@+id/done_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="right"
+ android:paddingRight="24dp"
+ android:text="@string/inline_done_button"
+ style="@style/TextAppearance.NotificationInfo.Button" />
</LinearLayout>
</LinearLayout>
+
<com.android.systemui.statusbar.notification.row.NotificationUndoLayout
android:id="@+id/confirmation"
android:layout_width="match_parent"
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index 9e9aada..75b7ec3 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -1608,7 +1608,7 @@
<string name="inline_silent_button_stay_silent">Stay silent</string>
<!-- Notification inline controls: button to make notifications alert the user [CHAR_LIMIT=35] -->
- <string name="inline_silent_button_alert">Alert me</string>
+ <string name="inline_silent_button_alert">Alert</string>
<!-- Notification inline controls: button to continue alerting the user when notifications arrive [CHAR_LIMIT=35] -->
<string name="inline_silent_button_keep_alerting">Keep alerting</string>
@@ -1616,6 +1616,15 @@
<!-- Notification Inline controls: continue receiving notifications prompt, app level -->
<string name="inline_keep_showing_app">Keep showing notifications from this app?</string>
+ <!-- Hint text for block button in the interruptiveness settings [CHAR_LIMIT=NONE]-->
+ <string name="hint_text_block">Blocked notifications do not appear anywhere or play a sound. You can unblock notifications in settings.</string>
+
+ <!-- Hint text for silent button in the interruptiveness settings [CHAR_LIMIT=NONE]-->
+ <string name="hint_text_silent">Silent notifications appear in the shade, but do not appear on the lock screen, present a banner, or play a sound.</string>
+
+ <!-- Hint text for alert button in the interruptiveness settings [CHAR_LIMIT=NONE]-->
+ <string name="hint_text_alert">Alerted notifications appear in the shade, on the lock screen, present a banner, and play a sound.</string>
+
<!-- Notification: Control panel: Label that displays when the app's notifications cannot be blocked. -->
<string name="notification_unblockable_desc">These notifications can\'t be turned off</string>
diff --git a/packages/SystemUI/res/values/styles.xml b/packages/SystemUI/res/values/styles.xml
index b985b6b..707863b 100644
--- a/packages/SystemUI/res/values/styles.xml
+++ b/packages/SystemUI/res/values/styles.xml
@@ -445,6 +445,19 @@
<item name="android:alpha">0.54</item>
</style>
+ <style name="TextAppearance.NotificationInfo.ButtonLabel">
+ <item name="android:fontFamily">@*android:string/config_bodyFontFamilyMedium</item>
+ <item name="android:textSize">14sp</item>
+ <item name="android:alpha">0.54</item>
+ <item name="android:paddingTop">4dp</item>
+ <item name="android:paddingBottom">16dp</item>
+ </style>
+
+ <style name="TextAppearance.NotificationInfo.HintText">
+ <item name="android:textSize">12sp</item>
+ <item name="android:alpha">0.54</item>
+ </style>
+
<style name="TextAppearance.NotificationInfo.Secondary.Warning">
<item name="android:textColor">?android:attr/colorError</item>
</style>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationInfo.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationInfo.java
index 3723731..2e4325b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationInfo.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationInfo.java
@@ -17,7 +17,6 @@
package com.android.systemui.statusbar.notification.row;
import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
-import static android.app.NotificationManager.IMPORTANCE_HIGH;
import static android.app.NotificationManager.IMPORTANCE_LOW;
import static android.app.NotificationManager.IMPORTANCE_MIN;
import static android.app.NotificationManager.IMPORTANCE_NONE;
@@ -38,6 +37,7 @@
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
+import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.metrics.LogMaker;
import android.os.Handler;
@@ -81,10 +81,11 @@
}
public static final int ACTION_NONE = 0;
- public static final int ACTION_UNDO = 1;
- public static final int ACTION_TOGGLE_SILENT = 2;
- public static final int ACTION_BLOCK = 3;
- public static final int ACTION_DELIVER_SILENTLY = 4;
+ static final int ACTION_UNDO = 1;
+ static final int ACTION_TOGGLE_SILENT = 2;
+ static final int ACTION_BLOCK = 3;
+ static final int ACTION_DELIVER_SILENTLY = 4;
+ private static final int ACTION_ALERT = 5;
private INotificationManager mINotificationManager;
private PackageManager mPm;
@@ -98,6 +99,7 @@
private NotificationChannel mSingleNotificationChannel;
private int mStartingChannelImportance;
private boolean mWasShownHighPriority;
+ private int mNotificationBlockState = ACTION_NONE;
/**
* The last importance level chosen by the user. Null if the user has not chosen an importance
* level; non-null once the user takes an action which indicates an explicit preference.
@@ -117,7 +119,6 @@
/** Whether this view is being shown as part of the blocking helper. */
private boolean mIsForBlockingHelper;
- private boolean mNegativeUserSentiment;
/**
* String that describes how the user exit or quit out of this view, also used as a counter tag.
@@ -126,8 +127,8 @@
private OnClickListener mOnKeepShowing = v -> {
mExitReason = NotificationCounters.BLOCKING_HELPER_KEEP_SHOWING;
- closeControls(v);
if (mIsForBlockingHelper) {
+ closeControls(v);
mMetricsLogger.write(getLogMaker().setCategory(
MetricsEvent.NOTIFICATION_BLOCKING_HELPER)
.setType(MetricsEvent.TYPE_ACTION)
@@ -135,23 +136,36 @@
}
};
- private OnClickListener mOnToggleSilent = v -> {
- handleSaveImportance(ACTION_TOGGLE_SILENT, MetricsEvent.BLOCKING_HELPER_CLICK_ALERT_ME);
+ private OnClickListener mOnAlert = v -> {
+ mExitReason = NotificationCounters.BLOCKING_HELPER_KEEP_SHOWING;
+ mChosenImportance = IMPORTANCE_DEFAULT;
+ updateButtonsAndHelpText(ACTION_ALERT);
+ };
+
+ private OnClickListener mOnDismissSettings = v -> {
+ closeControls(v);
};
private OnClickListener mOnDeliverSilently = v -> {
handleSaveImportance(
ACTION_DELIVER_SILENTLY, MetricsEvent.BLOCKING_HELPER_CLICK_STAY_SILENT);
+ if (!mIsForBlockingHelper) {
+ updateButtonsAndHelpText(ACTION_DELIVER_SILENTLY);
+ }
};
private OnClickListener mOnStopOrMinimizeNotifications = v -> {
handleSaveImportance(ACTION_BLOCK, MetricsEvent.BLOCKING_HELPER_CLICK_BLOCKED);
+ if (!mIsForBlockingHelper) {
+ updateButtonsAndHelpText(ACTION_BLOCK);
+ }
};
private void handleSaveImportance(int action, int metricsSubtype) {
Runnable saveImportance = () -> {
- swapContent(action, true /* animate */);
+ saveImportanceAndExitReason(action);
if (mIsForBlockingHelper) {
+ swapContent(action, true /* animate */);
mMetricsLogger.write(getLogMaker()
.setCategory(MetricsEvent.NOTIFICATION_BLOCKING_HELPER)
.setType(MetricsEvent.TYPE_ACTION)
@@ -177,6 +191,7 @@
} else {
mMetricsLogger.write(importanceChangeLogMaker().setType(MetricsEvent.TYPE_DISMISS));
}
+ saveImportanceAndExitReason(ACTION_UNDO);
swapContent(ACTION_UNDO, true /* animate */);
};
@@ -252,7 +267,6 @@
mSingleNotificationChannel = notificationChannel;
mStartingChannelImportance = mSingleNotificationChannel.getImportance();
mWasShownHighPriority = wasShownHighPriority;
- mNegativeUserSentiment = isUserSentimentNegative;
mIsNonblockable = isNonblockable;
mIsForeground =
(mSbn.getNotification().flags & Notification.FLAG_FOREGROUND_SERVICE) != 0;
@@ -329,14 +343,6 @@
bindGroup();
if (mIsNonblockable) {
blockPrompt.setText(R.string.notification_unblockable_desc);
- } else {
- if (mNegativeUserSentiment) {
- blockPrompt.setText(R.string.inline_blocking_helper);
- } else if (mIsSingleDefaultChannel || mNumUniqueChannelsInRow > 1) {
- blockPrompt.setText(R.string.inline_keep_showing_app);
- } else {
- blockPrompt.setText(R.string.inline_keep_showing);
- }
}
}
@@ -403,6 +409,7 @@
}
}
+
@VisibleForTesting
void logBlockingHelperCounter(String counterTag) {
if (mIsForBlockingHelper) {
@@ -454,21 +461,20 @@
if (showInterruptivenessSettings) {
findViewById(R.id.block_or_minimize).setVisibility(GONE);
findViewById(R.id.interruptiveness_settings).setVisibility(VISIBLE);
- View block = findViewById(R.id.int_block);
- TextView silent = findViewById(R.id.int_silent);
- TextView alert = findViewById(R.id.int_alert);
-
+ View done = findViewById(R.id.done_button);
+ done.setOnClickListener(mOnDismissSettings);
+ View block = findViewById(R.id.int_block_wrapper);
+ View silent = findViewById(R.id.int_silent_wrapper);
+ View alert = findViewById(R.id.int_alert_wrapper);
block.setOnClickListener(mOnStopOrMinimizeNotifications);
- if (mWasShownHighPriority) {
- silent.setOnClickListener(mOnToggleSilent);
- silent.setText(R.string.inline_silent_button_silent);
- alert.setOnClickListener(mOnKeepShowing);
- alert.setText(R.string.inline_silent_button_keep_alerting);
+ silent.setOnClickListener(mOnDeliverSilently);
+ alert.setOnClickListener(mOnAlert);
+ if (mNotificationBlockState != ACTION_NONE) {
+ updateButtonsAndHelpText(mNotificationBlockState);
+ } else if (mWasShownHighPriority) {
+ updateButtonsAndHelpText(ACTION_ALERT);
} else {
- silent.setOnClickListener(mOnKeepShowing);
- silent.setText(R.string.inline_silent_button_stay_silent);
- alert.setOnClickListener(mOnToggleSilent);
- alert.setText(R.string.inline_silent_button_alert);
+ updateButtonsAndHelpText(ACTION_DELIVER_SILENTLY);
}
} else {
findViewById(R.id.block_or_minimize).setVisibility(VISIBLE);
@@ -515,6 +521,73 @@
}
}
+ private void updateButtonsAndHelpText(int blockState) {
+ mNotificationBlockState = blockState;
+ ImageView block = findViewById(R.id.int_block);
+ ImageView silent = findViewById(R.id.int_silent);
+ ImageView alert = findViewById(R.id.int_alert);
+ TextView hintText = findViewById(R.id.hint_text);
+ switch (blockState) {
+ case ACTION_BLOCK:
+ block.setBackgroundResource(R.drawable.circle_blue_40dp);
+ block.setColorFilter(Color.WHITE);
+ silent.setBackgroundResource(R.drawable.circle_white_40dp);
+ silent.setColorFilter(getResources().getColor(R.color.GM2_grey_400));
+ alert.setBackgroundResource(R.drawable.circle_white_40dp);
+ alert.setColorFilter(getResources().getColor(R.color.GM2_grey_400));
+ hintText.setText(R.string.hint_text_block);
+ break;
+ case ACTION_DELIVER_SILENTLY:
+ silent.setBackgroundResource(R.drawable.circle_blue_40dp);
+ silent.setColorFilter(Color.WHITE);
+ block.setBackgroundResource(R.drawable.circle_white_40dp);
+ block.setColorFilter(getResources().getColor(R.color.GM2_grey_400));
+ alert.setBackgroundResource(R.drawable.circle_white_40dp);
+ alert.setColorFilter(getResources().getColor(R.color.GM2_grey_400));
+ hintText.setText(R.string.hint_text_silent);
+ break;
+ case ACTION_ALERT:
+ alert.setBackgroundResource(R.drawable.circle_blue_40dp);
+ alert.setColorFilter(Color.WHITE);
+ block.setBackgroundResource(R.drawable.circle_white_40dp);
+ block.setColorFilter(getResources().getColor(R.color.GM2_grey_400));
+ silent.setBackgroundResource(R.drawable.circle_white_40dp);
+ silent.setColorFilter(getResources().getColor(R.color.GM2_grey_400));
+ hintText.setText(R.string.hint_text_alert);
+ break;
+ }
+ }
+
+ private void saveImportanceAndExitReason(@NotificationInfoAction int action) {
+ switch (action) {
+ case ACTION_UNDO:
+ mChosenImportance = mStartingChannelImportance;
+ break;
+ case ACTION_DELIVER_SILENTLY:
+ mExitReason = NotificationCounters.BLOCKING_HELPER_DELIVER_SILENTLY;
+ mChosenImportance = IMPORTANCE_LOW;
+ break;
+ case ACTION_TOGGLE_SILENT:
+ mExitReason = NotificationCounters.BLOCKING_HELPER_TOGGLE_SILENT;
+ if (mWasShownHighPriority) {
+ mChosenImportance = IMPORTANCE_LOW;
+ } else {
+ mChosenImportance = IMPORTANCE_DEFAULT;
+ }
+ break;
+ case ACTION_BLOCK:
+ mExitReason = NotificationCounters.BLOCKING_HELPER_STOP_NOTIFICATIONS;
+ if (mIsForeground) {
+ mChosenImportance = IMPORTANCE_MIN;
+ } else {
+ mChosenImportance = IMPORTANCE_NONE;
+ }
+ break;
+ default:
+ throw new IllegalArgumentException();
+ }
+ }
+
private void swapContent(@NotificationInfoAction int action, boolean animate) {
if (mExpandAnimation != null) {
mExpandAnimation.cancel();
@@ -525,32 +598,25 @@
TextView confirmationText = findViewById(R.id.confirmation_text);
View header = findViewById(R.id.header);
+ saveImportanceAndExitReason(action);
+
switch (action) {
case ACTION_UNDO:
- mChosenImportance = mStartingChannelImportance;
break;
case ACTION_DELIVER_SILENTLY:
- mExitReason = NotificationCounters.BLOCKING_HELPER_DELIVER_SILENTLY;
- mChosenImportance = IMPORTANCE_LOW;
confirmationText.setText(R.string.notification_channel_silenced);
break;
case ACTION_TOGGLE_SILENT:
- mExitReason = NotificationCounters.BLOCKING_HELPER_TOGGLE_SILENT;
if (mWasShownHighPriority) {
- mChosenImportance = IMPORTANCE_LOW;
confirmationText.setText(R.string.notification_channel_silenced);
} else {
- mChosenImportance = IMPORTANCE_DEFAULT;
confirmationText.setText(R.string.notification_channel_unsilenced);
}
break;
case ACTION_BLOCK:
- mExitReason = NotificationCounters.BLOCKING_HELPER_STOP_NOTIFICATIONS;
if (mIsForeground) {
- mChosenImportance = IMPORTANCE_MIN;
confirmationText.setText(R.string.notification_channel_minimized);
} else {
- mChosenImportance = IMPORTANCE_NONE;
confirmationText.setText(R.string.notification_channel_disabled);
}
break;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationInfoTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationInfoTest.java
index 19a73f6..fb4fd31 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationInfoTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationInfoTest.java
@@ -341,79 +341,62 @@
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
IMPORTANCE_DEFAULT, true);
- final TextView silent = mNotificationInfo.findViewById(R.id.int_silent);
+ final TextView silent = mNotificationInfo.findViewById(R.id.int_silent_label);
assertEquals(VISIBLE, silent.getVisibility());
assertEquals(
mContext.getString(R.string.inline_silent_button_silent), silent.getText());
}
@Test
- public void testBindNotification_SilenceButton_CurrentlySilent() throws Exception {
+ public void testBindNotification_verifyButtonTexts() throws Exception {
mNotificationChannel.setImportance(IMPORTANCE_LOW);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
IMPORTANCE_LOW, false);
- final TextView silent = mNotificationInfo.findViewById(R.id.int_silent);
+ final TextView block = mNotificationInfo.findViewById(R.id.int_block_label);
+ final TextView alert = mNotificationInfo.findViewById(R.id.int_alert_label);
+ final TextView silent = mNotificationInfo.findViewById(R.id.int_silent_label);
assertEquals(VISIBLE, silent.getVisibility());
+ assertEquals(VISIBLE, block.getVisibility());
+ assertEquals(VISIBLE, alert.getVisibility());
assertEquals(
- mContext.getString(R.string.inline_silent_button_stay_silent),
+ mContext.getString(R.string.inline_silent_button_silent),
silent.getText());
+ assertEquals(
+ mContext.getString(R.string.inline_silent_button_alert), alert.getText());
+ assertEquals(
+ mContext.getString(R.string.inline_block_button), block.getText());
}
@Test
- public void testBindNotification_AlertButton_CurrentlySilent() throws Exception {
+ public void testBindNotification_verifyHintTextForSilent() throws Exception {
mNotificationChannel.setImportance(IMPORTANCE_LOW);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
IMPORTANCE_LOW, false);
- final TextView alert = mNotificationInfo.findViewById(R.id.int_alert);
- assertEquals(VISIBLE, alert.getVisibility());
- assertEquals(
- mContext.getString(R.string.inline_silent_button_alert), alert.getText());
+ TextView hintText = mNotificationInfo.findViewById(R.id.hint_text);
+ assertEquals(mContext.getString(R.string.hint_text_silent), hintText.getText());
}
@Test
- public void testBindNotification_UnSilenceButton_currentlyAlerting() throws Exception {
- mNotificationChannel.setImportance(IMPORTANCE_DEFAULT);
- mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
- TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
- IMPORTANCE_DEFAULT, true);
- final TextView alert = mNotificationInfo.findViewById(R.id.int_alert);
- assertEquals(VISIBLE, alert.getVisibility());
- assertEquals(
- mContext.getString(R.string.inline_silent_button_keep_alerting), alert.getText());
- }
-
- @Test
- public void testBindNotification_ChannelImportanceUnspecified_NotifAlerting() throws Exception {
- mNotificationChannel.setImportance(IMPORTANCE_UNSPECIFIED);
- mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
- TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
- IMPORTANCE_DEFAULT, true);
- final TextView silent = mNotificationInfo.findViewById(R.id.int_silent);
- final TextView alert = mNotificationInfo.findViewById(R.id.int_alert);
- assertEquals(VISIBLE, silent.getVisibility());
- assertEquals(VISIBLE, alert.getVisibility());
- assertEquals(
- mContext.getString(R.string.inline_silent_button_silent), silent.getText());
- assertEquals(
- mContext.getString(R.string.inline_silent_button_keep_alerting), alert.getText());
- }
-
- @Test
- public void testBindNotification_ChannelImportanceUnspecified_NotifSilent() throws Exception {
- mNotificationChannel.setImportance(IMPORTANCE_UNSPECIFIED);
+ public void testBindNotification_verifyHintTextForBlock() throws Exception {
+ mNotificationChannel.setImportance(IMPORTANCE_LOW);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
IMPORTANCE_LOW, false);
- final TextView silent = mNotificationInfo.findViewById(R.id.int_silent);
- final TextView alert = mNotificationInfo.findViewById(R.id.int_alert);
- assertEquals(VISIBLE, silent.getVisibility());
- assertEquals(VISIBLE, alert.getVisibility());
- assertEquals(
- mContext.getString(R.string.inline_silent_button_stay_silent), silent.getText());
- assertEquals(
- mContext.getString(R.string.inline_silent_button_alert), alert.getText());
+ View blockWrapper = mNotificationInfo.findViewById(R.id.int_block_wrapper);
+ blockWrapper.performClick();
+ TextView hintText = mNotificationInfo.findViewById(R.id.hint_text);
+ assertEquals(mContext.getString(R.string.hint_text_block), hintText.getText());
+ }
+
+ @Test
+ public void testBindNotification_verifyHintTextForAlert() throws Exception {
+ mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
+ TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
+ IMPORTANCE_DEFAULT, true);
+ TextView hintText = mNotificationInfo.findViewById(R.id.hint_text);
+ assertEquals(mContext.getString(R.string.hint_text_alert), hintText.getText());
}
@Test
@@ -560,16 +543,6 @@
}
@Test
- public void testbindNotification_BlockingHelper() throws Exception {
- mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
- TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, false, false,
- true, true, IMPORTANCE_DEFAULT, true);
- final TextView view = mNotificationInfo.findViewById(R.id.block_prompt);
- assertEquals(View.VISIBLE, view.getVisibility());
- assertEquals(mContext.getString(R.string.inline_blocking_helper), view.getText());
- }
-
- @Test
public void testbindNotification_UnblockableTextVisibleWhenAppUnblockable() throws Exception {
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, true,
@@ -687,8 +660,8 @@
true, false /* isNonblockable */, IMPORTANCE_DEFAULT, false
);
- mNotificationInfo.findViewById(R.id.int_block).performClick();
- waitForUndoButton();
+ mNotificationInfo.findViewById(R.id.int_block_wrapper).performClick();
+ mNotificationInfo.findViewById(R.id.done_button).performClick();
mNotificationInfo.handleCloseControls(true, false);
mTestableLooper.processAllMessages();
@@ -709,8 +682,8 @@
true, false /* isNonblockable */, IMPORTANCE_DEFAULT, false
);
- mNotificationInfo.findViewById(R.id.int_block).performClick();
- waitForUndoButton();
+ mNotificationInfo.findViewById(R.id.int_block_wrapper).performClick();
+ mNotificationInfo.findViewById(R.id.done_button).performClick();
mNotificationInfo.handleCloseControls(true, false);
mTestableLooper.processAllMessages();
@@ -842,7 +815,7 @@
mNotificationChannel.setImportance(IMPORTANCE_LOW);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, true,
- IMPORTANCE_DEFAULT, false);
+ true, false, IMPORTANCE_DEFAULT, false);
mNotificationInfo.findViewById(R.id.block).performClick();
waitForUndoButton();
@@ -861,8 +834,8 @@
true, false,
IMPORTANCE_DEFAULT, false);
- mNotificationInfo.findViewById(R.id.int_block).performClick();
- waitForUndoButton();
+ mNotificationInfo.findViewById(R.id.int_block_wrapper).performClick();
+ mNotificationInfo.findViewById(R.id.done_button).performClick();
mNotificationInfo.handleCloseControls(true, false);
ArgumentCaptor<LogMaker> logMakerCaptor = ArgumentCaptor.forClass(LogMaker.class);
@@ -929,7 +902,7 @@
mNotificationChannel.setImportance(IMPORTANCE_LOW);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, true,
- IMPORTANCE_DEFAULT, false);
+ true, false, IMPORTANCE_DEFAULT, false);
mNotificationInfo.findViewById(R.id.minimize).performClick();
waitForUndoButton();
@@ -944,7 +917,7 @@
mSbn.getNotification().flags = Notification.FLAG_FOREGROUND_SERVICE;
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
- IMPORTANCE_DEFAULT, false);
+ true, false, IMPORTANCE_DEFAULT, false);
mNotificationInfo.findViewById(R.id.minimize).performClick();
waitForUndoButton();
@@ -1014,63 +987,14 @@
}
@Test
- public void testBlockUndoDoesNotBlockNotificationChannel_notBlockingHelper() throws Exception {
- mNotificationChannel.setImportance(IMPORTANCE_LOW);
- mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
- TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn,
- null, null, null,
- true, false,
- IMPORTANCE_DEFAULT, false);
-
- mNotificationInfo.findViewById(R.id.int_block).performClick();
- waitForUndoButton();
- mNotificationInfo.findViewById(R.id.undo).performClick();
- waitForStopButton();
- // mNotificationInfo.handleCloseControls doesn't get called by this interaction.
-
- ArgumentCaptor<LogMaker> logMakerCaptor = ArgumentCaptor.forClass(LogMaker.class);
- verify(mMetricsLogger, times(2)).write(logMakerCaptor.capture());
- assertEquals(MetricsEvent.ACTION_SAVE_IMPORTANCE,
- logMakerCaptor.getValue().getCategory());
- assertEquals(MetricsEvent.TYPE_DISMISS,
- logMakerCaptor.getValue().getType());
- assertEquals(IMPORTANCE_NONE - IMPORTANCE_LOW,
- logMakerCaptor.getValue().getSubtype());
-
-
- mTestableLooper.processAllMessages();
- verify(mMockINotificationManager, never()).updateNotificationChannelForPackage(
- anyString(), eq(TEST_UID), any());
- }
-
- @Test
- public void testMinUndoDoesNotMinNotificationChannel_notBlockingHelper() throws Exception {
- mNotificationChannel.setImportance(IMPORTANCE_LOW);
- mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
- TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn,
- null, null, null, true,
- true, IMPORTANCE_DEFAULT, false);
-
- mNotificationInfo.findViewById(R.id.minimize).performClick();
- waitForUndoButton();
- mNotificationInfo.findViewById(R.id.undo).performClick();
- waitForStopButton();
- // mNotificationInfo.handleCloseControls doesn't get called by this code path
-
- mTestableLooper.processAllMessages();
- verify(mMockINotificationManager, times(0)).updateNotificationChannelForPackage(
- anyString(), eq(TEST_UID), any());
- }
-
- @Test
public void testSilenceCallsUpdateNotificationChannel() throws Exception {
mNotificationChannel.setImportance(IMPORTANCE_DEFAULT);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
IMPORTANCE_DEFAULT, true);
- mNotificationInfo.findViewById(R.id.int_silent).performClick();
- waitForUndoButton();
+ mNotificationInfo.findViewById(R.id.int_silent_wrapper).performClick();
+ mNotificationInfo.findViewById(R.id.done_button).performClick();
mNotificationInfo.handleCloseControls(true, false);
mTestableLooper.processAllMessages();
@@ -1090,8 +1014,8 @@
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
IMPORTANCE_DEFAULT, false);
- mNotificationInfo.findViewById(R.id.int_alert).performClick();
- waitForUndoButton();
+ mNotificationInfo.findViewById(R.id.int_alert_wrapper).performClick();
+ mNotificationInfo.findViewById(R.id.done_button).performClick();
mNotificationInfo.handleCloseControls(true, false);
mTestableLooper.processAllMessages();
@@ -1112,8 +1036,8 @@
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
IMPORTANCE_DEFAULT, true);
- mNotificationInfo.findViewById(R.id.int_silent).performClick();
- waitForUndoButton();
+ mNotificationInfo.findViewById(R.id.int_silent_wrapper).performClick();
+ mNotificationInfo.findViewById(R.id.done_button).performClick();
mNotificationInfo.handleCloseControls(true, false);
mTestableLooper.processAllMessages();
@@ -1134,8 +1058,8 @@
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
IMPORTANCE_LOW, false);
- mNotificationInfo.findViewById(R.id.int_alert).performClick();
- waitForUndoButton();
+ mNotificationInfo.findViewById(R.id.int_alert_wrapper).performClick();
+ mNotificationInfo.findViewById(R.id.done_button).performClick();
mNotificationInfo.handleCloseControls(true, false);
mTestableLooper.processAllMessages();
@@ -1153,7 +1077,7 @@
mNotificationChannel.setImportance(IMPORTANCE_LOW);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, true,
- IMPORTANCE_DEFAULT, false);
+ true, false, IMPORTANCE_DEFAULT, false);
mNotificationInfo.findViewById(R.id.minimize).performClick();
waitForUndoButton();
@@ -1171,8 +1095,8 @@
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
IMPORTANCE_DEFAULT, false);
- mNotificationInfo.findViewById(R.id.int_block).performClick();
- waitForUndoButton();
+ mNotificationInfo.findViewById(R.id.int_block_wrapper).performClick();
+ mNotificationInfo.findViewById(R.id.done_button).performClick();
mNotificationInfo.handleCloseControls(false, false);
mTestableLooper.processAllMessages();
@@ -1188,9 +1112,8 @@
(Runnable saveImportance, StatusBarNotification sbn) -> {
}, null, null, true, true, IMPORTANCE_DEFAULT, false);
- mNotificationInfo.findViewById(R.id.int_block).performClick();
+ mNotificationInfo.findViewById(R.id.int_block_wrapper).performClick();
mTestableLooper.processAllMessages();
- ensureNoUndoButton();
mNotificationInfo.handleCloseControls(true, false);
verify(mMockINotificationManager, never()).updateNotificationChannelForPackage(
@@ -1207,12 +1130,12 @@
}, null, null, true, false, IMPORTANCE_DEFAULT, false
);
- mNotificationInfo.findViewById(R.id.int_block).performClick();
+ mNotificationInfo.findViewById(R.id.int_block_wrapper).performClick();
+ mNotificationInfo.findViewById(R.id.done_button).performClick();
mTestableLooper.processAllMessages();
verify(mMockINotificationManager, never()).updateNotificationChannelForPackage(
eq(TEST_PACKAGE_NAME), eq(TEST_UID), eq(mNotificationChannel));
- waitForUndoButton();
mNotificationInfo.handleCloseControls(true, false);
mTestableLooper.processAllMessages();
@@ -1231,78 +1154,11 @@
mNotificationChannel.setImportance(IMPORTANCE_LOW);
mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, true,
- IMPORTANCE_DEFAULT, false);
+ true, false, IMPORTANCE_DEFAULT, false);
mNotificationInfo.findViewById(R.id.minimize).performClick();
waitForUndoButton();
TextView confirmationText = mNotificationInfo.findViewById(R.id.confirmation_text);
assertTrue(confirmationText.getText().toString().contains("minimized"));
}
-
- @Test
- public void testUndoText_block() throws Exception {
- mNotificationChannel.setImportance(IMPORTANCE_LOW);
- mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
- TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
- IMPORTANCE_DEFAULT, false);
-
- mNotificationInfo.findViewById(R.id.int_block).performClick();
- waitForUndoButton();
- TextView confirmationText = mNotificationInfo.findViewById(R.id.confirmation_text);
- assertTrue(confirmationText.getText().toString().contains("won't see"));
- }
-
- @Test
- public void testUndoText_silence() throws Exception {
- mNotificationChannel.setImportance(IMPORTANCE_DEFAULT);
- mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
- TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
- IMPORTANCE_DEFAULT, true);
-
- mNotificationInfo.findViewById(R.id.int_silent).performClick();
- waitForUndoButton();
- TextView confirmationText = mNotificationInfo.findViewById(R.id.confirmation_text);
- assertEquals(mContext.getString(R.string.notification_channel_silenced),
- confirmationText.getText());
- }
-
- @Test
- public void testUndoText_unsilence() throws Exception {
- mNotificationChannel.setImportance(IMPORTANCE_LOW);
- mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
- TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
- IMPORTANCE_DEFAULT, false);
-
- mNotificationInfo.findViewById(R.id.int_alert).performClick();
- waitForUndoButton();
- TextView confirmationText = mNotificationInfo.findViewById(R.id.confirmation_text);
- assertEquals(mContext.getString(R.string.notification_channel_unsilenced),
- confirmationText.getText());
- }
-
- @Test
- public void testNoHeaderOnConfirmation() throws Exception {
- mNotificationChannel.setImportance(IMPORTANCE_LOW);
- mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
- TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
- IMPORTANCE_DEFAULT, false);
-
- mNotificationInfo.findViewById(R.id.int_block).performClick();
- waitForUndoButton();
- assertEquals(GONE, mNotificationInfo.findViewById(R.id.header).getVisibility());
- }
-
- @Test
- public void testHeaderOnUndo() throws Exception {
- mNotificationChannel.setImportance(IMPORTANCE_LOW);
- mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager,
- TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, null, true, false,
- IMPORTANCE_DEFAULT, false);
-
- mNotificationInfo.findViewById(R.id.int_block).performClick();
- waitForUndoButton();
- mNotificationInfo.findViewById(R.id.undo).performClick();
- waitForStopButton();
- assertEquals(VISIBLE, mNotificationInfo.findViewById(R.id.header).getVisibility());
- }
}