diff options
4 files changed, 50 insertions, 11 deletions
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index 209d44449dfa..6d61a0c198f9 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -1506,6 +1506,10 @@ <string name="notification_channel_disabled">You won\'t see these notifications anymore</string> <!-- Notification Inline controls: continue receiving notifications prompt, channel level --> + <string name="inline_blocking_helper">You usually dismiss these notifications. + \nKeep showing them?</string> + + <!-- Notification Inline controls: continue receiving notifications prompt, channel level --> <string name="inline_keep_showing">Keep showing these notifications?</string> <!-- Notification inline controls: block notifications button --> diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationGutsManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationGutsManager.java index b9e672515499..1aaa3b2593d2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationGutsManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationGutsManager.java @@ -15,6 +15,9 @@ */ package com.android.systemui.statusbar; +import static android.service.notification.NotificationListenerService.Ranking + .USER_SENTIMENT_NEGATIVE; + import android.app.INotificationManager; import android.app.NotificationChannel; import android.content.Context; @@ -230,7 +233,8 @@ public class NotificationGutsManager implements Dumpable { try { info.bindNotification(pmUser, iNotificationManager, pkg, row.getEntry().channel, channels.size(), sbn, mCheckSaveListener, onSettingsClick, - onAppSettingsClick, mNonBlockablePkgs); + onAppSettingsClick, mNonBlockablePkgs, + row.getEntry().userSentiment == USER_SENTIMENT_NEGATIVE); } catch (RemoteException e) { Log.e(TAG, e.toString()); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationInfo.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationInfo.java index 6279fdc46599..735f4fd82dec 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationInfo.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationInfo.java @@ -79,6 +79,7 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G private OnSettingsClickListener mOnSettingsClickListener; private OnAppSettingsClickListener mAppSettingsClickListener; private NotificationGuts mGutsContainer; + private boolean mNegativeUserSentiment; private OnClickListener mOnKeepShowing = v -> { closeControls(v); @@ -122,6 +123,22 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G final OnAppSettingsClickListener onAppSettingsClick, final Set<String> nonBlockablePkgs) throws RemoteException { + bindNotification(pm, iNotificationManager, pkg, notificationChannel, numChannels, sbn, + checkSaveListener, onSettingsClick, onAppSettingsClick, nonBlockablePkgs, + false /* negative sentiment */); + } + + public void bindNotification(final PackageManager pm, + final INotificationManager iNotificationManager, + final String pkg, + final NotificationChannel notificationChannel, + final int numChannels, + final StatusBarNotification sbn, + final CheckSaveListener checkSaveListener, + final OnSettingsClickListener onSettingsClick, + final OnAppSettingsClickListener onAppSettingsClick, + final Set<String> nonBlockablePkgs, + boolean negativeUserSentiment) throws RemoteException { mINotificationManager = iNotificationManager; mPkg = pkg; mNumNotificationChannels = numChannels; @@ -133,6 +150,7 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G mOnSettingsClickListener = onSettingsClick; mSingleNotificationChannel = notificationChannel; mStartingUserImportance = mChosenImportance = mSingleNotificationChannel.getImportance(); + mNegativeUserSentiment = negativeUserSentiment; int numTotalChannels = mINotificationManager.getNumNotificationChannelsForPackage( pkg, mAppUid, false /* includeDeleted */); @@ -227,27 +245,30 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G } private void bindPrompt() { - final TextView channelName = findViewById(R.id.channel_name); final TextView blockPrompt = findViewById(R.id.block_prompt); + bindName(); if (mNonblockable) { - if (mIsSingleDefaultChannel || mNumNotificationChannels > 1) { - channelName.setVisibility(View.GONE); - } else { - channelName.setText(mSingleNotificationChannel.getName()); - } - blockPrompt.setText(R.string.notification_unblockable_desc); } else { - if (mIsSingleDefaultChannel || mNumNotificationChannels > 1) { - channelName.setVisibility(View.GONE); + if (mNegativeUserSentiment) { + blockPrompt.setText(R.string.inline_blocking_helper); + } else if (mIsSingleDefaultChannel || mNumNotificationChannels > 1) { blockPrompt.setText(R.string.inline_keep_showing_app); } else { - channelName.setText(mSingleNotificationChannel.getName()); blockPrompt.setText(R.string.inline_keep_showing); } } } + private void bindName() { + final TextView channelName = findViewById(R.id.channel_name); + if (mIsSingleDefaultChannel || mNumNotificationChannels > 1) { + channelName.setVisibility(View.GONE); + } else { + channelName.setText(mSingleNotificationChannel.getName()); + } + } + private boolean hasImportanceChanged() { return mSingleNotificationChannel != null && mStartingUserImportance != mChosenImportance; } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationInfoTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationInfoTest.java index d77bf69ad365..8e8b3e0f131b 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationInfoTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationInfoTest.java @@ -281,6 +281,16 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test + public void testbindNotification_BlockingHelper() throws Exception { + mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, + TEST_PACKAGE_NAME, mNotificationChannel, 1, mSbn, null, null, + null, null, 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, |