summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/app/Notification.java6
-rw-r--r--core/res/res/drawable/ic_feedback_alerted.xml30
-rw-r--r--core/res/res/drawable/ic_feedback_downrank.xml24
-rw-r--r--core/res/res/drawable/ic_feedback_silenced.xml34
-rw-r--r--core/res/res/drawable/ic_feedback_uprank.xml24
-rw-r--r--core/res/res/layout/notification_top_line_views.xml5
-rw-r--r--core/res/res/values/dimens.xml2
-rw-r--r--core/res/res/values/symbols.xml4
-rw-r--r--packages/SystemUI/res/layout/feedback_info.xml19
-rw-r--r--packages/SystemUI/res/values/strings.xml20
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/AssistantFeedbackController.java94
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java8
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/row/FeedbackInfo.java27
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java8
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationInfo.java10
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationHeaderViewWrapper.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapper.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java6
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/AssistantFeedbackControllerTest.java52
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java11
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/FeedbackInfoTest.java81
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentViewTest.java2
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java6
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationInfoTest.java100
26 files changed, 415 insertions, 172 deletions
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 82f61a4c615a..c528588b72b0 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -5163,16 +5163,10 @@ public class Notification implements Parcelable
bindHeaderChronometerAndTime(contentView, p, hasTextToLeft);
bindProfileBadge(contentView, p);
bindAlertedIcon(contentView, p);
- bindFeedbackIcon(contentView, p);
bindExpandButton(contentView, p);
mN.mUsesStandardHeader = true;
}
- private void bindFeedbackIcon(RemoteViews contentView, StandardTemplateParams p) {
- int color = getNeutralColor(p);
- contentView.setDrawableTint(R.id.feedback, false, color, PorterDuff.Mode.SRC_ATOP);
- }
-
private void bindExpandButton(RemoteViews contentView, StandardTemplateParams p) {
int color = isColorized(p) ? getPrimaryTextColor(p) : getSecondaryTextColor(p);
contentView.setDrawableTint(R.id.expand_button, false, color,
diff --git a/core/res/res/drawable/ic_feedback_alerted.xml b/core/res/res/drawable/ic_feedback_alerted.xml
new file mode 100644
index 000000000000..550500a889aa
--- /dev/null
+++ b/core/res/res/drawable/ic_feedback_alerted.xml
@@ -0,0 +1,30 @@
+<!--
+ ~ Copyright (C) 2020 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.
+-->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="16dp"
+ android:height="16dp"
+ android:viewportWidth="16"
+ android:viewportHeight="16">
+ <path
+ android:pathData="M3.3333,5.6667H6V9.6667H10V5.6667H12.6667L8,1L3.3333,5.6667Z"
+ android:fillColor="#EA4335"/>
+ <path
+ android:strokeWidth="1"
+ android:pathData="M2.9798,8.9798L2.1262,9.8333H3.3333H5.5V13.3333V13.8333H6H10H10.5V13.3333V9.8333H12.6667H13.8738L13.0202,8.9798L8.3536,4.3131L8,3.9596L7.6465,4.3131L2.9798,8.9798Z"
+ android:fillColor="#EA4335"
+ android:strokeColor="#ffffff"/>
+</vector>
diff --git a/core/res/res/drawable/ic_feedback_downrank.xml b/core/res/res/drawable/ic_feedback_downrank.xml
new file mode 100644
index 000000000000..c48505e2e4bd
--- /dev/null
+++ b/core/res/res/drawable/ic_feedback_downrank.xml
@@ -0,0 +1,24 @@
+<!--
+ ~ Copyright (C) 2020 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="16dp"
+ android:height="16dp"
+ android:viewportWidth="16"
+ android:viewportHeight="16">
+ <path
+ android:pathData="M12.6667,8H10V4H6V8H3.3333L8,12.6667L12.6667,8Z"
+ android:fillColor="#4285F4"/>
+</vector>
diff --git a/core/res/res/drawable/ic_feedback_silenced.xml b/core/res/res/drawable/ic_feedback_silenced.xml
new file mode 100644
index 000000000000..aa221b205e34
--- /dev/null
+++ b/core/res/res/drawable/ic_feedback_silenced.xml
@@ -0,0 +1,34 @@
+<!--
+ ~ Copyright (C) 2020 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.
+-->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="16dp"
+ android:height="16dp"
+ android:viewportWidth="16"
+ android:viewportHeight="16">
+ <group>
+ <clip-path
+ android:pathData="M16,16l-16,-0l-0,-16l16,-0z"/>
+ <path
+ android:pathData="M12.6667,10.3333H10V6.3333H6V10.3333H3.3333L8,15L12.6667,10.3333Z"
+ android:fillColor="#4285F4"/>
+ <path
+ android:strokeWidth="1"
+ android:pathData="M13.0202,7.0202L13.8738,6.1667H12.6667H10.5V2.6667L10.5,2.1667H10H6H5.5V2.6667V6.1667H3.3333H2.1262L2.9798,7.0202L7.6464,11.6869L8,12.0405L8.3535,11.6869L13.0202,7.0202Z"
+ android:fillColor="#4285F4"
+ android:strokeColor="#ffffff"/>
+ </group>
+</vector> \ No newline at end of file
diff --git a/core/res/res/drawable/ic_feedback_uprank.xml b/core/res/res/drawable/ic_feedback_uprank.xml
new file mode 100644
index 000000000000..340780ce0030
--- /dev/null
+++ b/core/res/res/drawable/ic_feedback_uprank.xml
@@ -0,0 +1,24 @@
+<!--
+ ~ Copyright (C) 2020 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="16dp"
+ android:height="16dp"
+ android:viewportWidth="16"
+ android:viewportHeight="16">
+ <path
+ android:pathData="M3.3333,8H6V12H10V8H12.6667L8,3.3333L3.3333,8Z"
+ android:fillColor="#EA4335"/>
+</vector>
diff --git a/core/res/res/layout/notification_top_line_views.xml b/core/res/res/layout/notification_top_line_views.xml
index 60507eddba22..361b7a393448 100644
--- a/core/res/res/layout/notification_top_line_views.xml
+++ b/core/res/res/layout/notification_top_line_views.xml
@@ -112,9 +112,8 @@
android:id="@+id/feedback"
android:layout_width="@dimen/notification_feedback_size"
android:layout_height="@dimen/notification_feedback_size"
- android:layout_marginStart="6dp"
- android:layout_marginEnd="6dp"
- android:baseline="10dp"
+ android:layout_marginStart="4dp"
+ android:layout_marginEnd="4dp"
android:scaleType="fitCenter"
android:src="@drawable/ic_feedback_indicator"
android:background="?android:selectableItemBackgroundBorderless"
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index 05db741643e8..4fd8ef6bfa24 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -480,7 +480,7 @@
<dimen name="notification_inbox_item_top_padding">5dp</dimen>
<!-- Size of the feedback indicator for notifications -->
- <dimen name="notification_feedback_size">14dp</dimen>
+ <dimen name="notification_feedback_size">16dp</dimen>
<!-- Size of the profile badge for notifications -->
<dimen name="notification_badge_size">12dp</dimen>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 611808d6c5e7..88a78a8e6ac3 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -1436,6 +1436,10 @@
<java-symbol type="drawable" name="ic_mic" />
<java-symbol type="drawable" name="ic_alert_window_layer" />
<java-symbol type="drawable" name="ic_feedback_indicator" />
+ <java-symbol type="drawable" name="ic_feedback_alerted" />
+ <java-symbol type="drawable" name="ic_feedback_silenced" />
+ <java-symbol type="drawable" name="ic_feedback_uprank" />
+ <java-symbol type="drawable" name="ic_feedback_downrank" />
<java-symbol type="drawable" name="ic_account_circle" />
<java-symbol type="color" name="user_icon_1" />
diff --git a/packages/SystemUI/res/layout/feedback_info.xml b/packages/SystemUI/res/layout/feedback_info.xml
index 753f56a18348..e013a4ebd26f 100644
--- a/packages/SystemUI/res/layout/feedback_info.xml
+++ b/packages/SystemUI/res/layout/feedback_info.xml
@@ -24,18 +24,18 @@
android:clipChildren="false"
android:clipToPadding="false"
android:orientation="vertical"
- android:paddingStart="@*android:dimen/notification_content_margin_start"
- android:paddingEnd="@*android:dimen/notification_content_margin_end"
- android:background="?android:attr/colorBackground"
- android:theme="@*android:style/Theme.DeviceDefault.Light">
+ android:paddingStart="@dimen/notification_shade_content_margin_horizontal"
+ android:paddingEnd="@dimen/notification_shade_content_margin_horizontal"
+ android:background="?android:attr/colorBackground">
<!-- Package Info -->
<LinearLayout
android:id="@+id/header"
android:layout_width="match_parent"
- android:layout_height="@dimen/notification_guts_conversation_header_height"
+ android:layout_height="wrap_content"
android:gravity="center_vertical"
android:clipChildren="false"
+ android:paddingTop="@dimen/notification_guts_header_top_padding"
android:clipToPadding="false">
<ImageView
android:id="@+id/pkg_icon"
@@ -49,7 +49,6 @@
android:layout_weight="1"
android:layout_width="0dp"
android:orientation="vertical"
-
android:layout_height="wrap_content"
android:minHeight="@dimen/notification_guts_conversation_icon_size"
android:layout_centerVertical="true"
@@ -63,10 +62,11 @@
android:orientation="horizontal">
<TextView
android:id="@+id/pkg_name"
- android:layout_width="wrap_content"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- style="@style/TextAppearance.NotificationImportanceChannelGroup"
+ style="@style/TextAppearance.NotificationImportanceApp"
android:ellipsize="end"
+ android:textDirection="locale"
android:maxLines="1"/>
</LinearLayout>
</LinearLayout>
@@ -76,8 +76,7 @@
android:id="@+id/prompt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginTop="@*android:dimen/notification_header_padding_top"
- style="@style/TextAppearance.NotificationInfo.Secondary" />
+ android:layout_marginTop="@*android:dimen/notification_header_padding_top" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index ce481baff89b..6fa4aa116aa4 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -1802,6 +1802,18 @@
<!-- [CHAR LIMIT=150] Notification Importance title: automatic importance level summary -->
<string name="notification_channel_summary_automatic">Have the system determine if this notification should make sound or vibration</string>
+ <!-- [CHAR LIMIT=150] Notification Importance title: automatic importance level summary (alerted) -->
+ <string name="notification_channel_summary_automatic_alerted">&lt;b>Status:&lt;/b> Promoted to Default</string>
+
+ <!-- [CHAR LIMIT=150] Notification Importance title: automatic importance level summary (silenced) -->
+ <string name="notification_channel_summary_automatic_silenced">&lt;b>Status:&lt;/b> Demoted to Silent</string>
+
+ <!-- [CHAR LIMIT=150] Notification Importance title: automatic importance level summary (promoted) -->
+ <string name="notification_channel_summary_automatic_promoted">&lt;b>Status:&lt;/b> Ranked Higher</string>
+
+ <!-- [CHAR LIMIT=150] Notification Importance title: automatic importance level summary (demoted) -->
+ <string name="notification_channel_summary_automatic_demoted">&lt;b>Status:&lt;/b> Ranked Lower</string>
+
<!-- [CHAR LIMIT=150] Notification Importance title: important conversation level summary -->
<string name="notification_channel_summary_priority">Shows at top of conversation section, appears as floating bubble, displays profile picture on lock screen</string>
@@ -1848,11 +1860,13 @@
<string name="notification_appops_ok">OK</string>
<!-- Notification Inline controls: describes how the notification was adjusted [CHAR_LIMIT=NONE] -->
- <string name="feedback_silenced">This notification was silenced by the system.</string>
+ <string name="feedback_alerted">This notification was automatically &lt;b>promoted to Default&lt;/b> by the system.</string>
+ <!-- Notification Inline controls: describes how the notification was adjusted [CHAR_LIMIT=NONE] -->
+ <string name="feedback_silenced">This notification was automatically &lt;b>demoted to Silent&lt;/b> by the system.</string>
<!-- Notification Inline controls: describes how the notification was adjusted [CHAR_LIMIT=NONE] -->
- <string name="feedback_promoted">This notification was promoted by the system.</string>
+ <string name="feedback_promoted">This notification was automatically &lt;b>ranked higher&lt;/b> in your shade.</string>
<!-- Notification Inline controls: describes how the notification was adjusted [CHAR_LIMIT=NONE] -->
- <string name="feedback_demoted">This notification was demoted by the system.</string>
+ <string name="feedback_demoted">This notification was automatically &lt;b>ranked lower&lt;/b> in your shade.</string>
<!-- Notification Inline controls: prompts the user for feedback [CHAR_LIMIT=NONE] -->
<string name="feedback_prompt">Was this correct?</string>
<!-- Notification Inline controls: responds to user provided feedback [CHAR_LIMIT=NONE] -->
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java
index 9bd34ad1937f..4b6d66eef56d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java
@@ -484,8 +484,8 @@ public class NotificationViewHierarchyManager implements DynamicPrivacyControlle
stack.push(notificationChildren.get(i));
}
}
-
- row.showFeedbackIcon(mAssistantFeedbackController.showFeedbackIndicator(entry));
+ row.showFeedbackIcon(mAssistantFeedbackController.showFeedbackIndicator(entry),
+ mAssistantFeedbackController.getFeedbackImageResource(entry));
row.setLastAudiblyAlertedMs(entry.getLastAudiblyAlertedMs());
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/AssistantFeedbackController.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/AssistantFeedbackController.java
index 87a3f0755ec5..a350c5d8cd77 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/AssistantFeedbackController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/AssistantFeedbackController.java
@@ -18,6 +18,7 @@ package com.android.systemui.statusbar.notification;
import static android.service.notification.NotificationListenerService.Ranking;
+import android.app.NotificationManager;
import android.content.ContentResolver;
import android.content.Context;
import android.database.ContentObserver;
@@ -29,6 +30,7 @@ import android.provider.Settings;
import androidx.annotation.Nullable;
+import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
@@ -47,6 +49,12 @@ public class AssistantFeedbackController extends ContentObserver {
= Settings.Global.getUriFor(Settings.Global.NOTIFICATION_FEEDBACK_ENABLED);
private ContentResolver mResolver;
+ public static final int STATUS_UNCHANGED = 0;
+ public static final int STATUS_ALERTED = 1;
+ public static final int STATUS_SILENCED = 2;
+ public static final int STATUS_PROMOTED = 3;
+ public static final int STATUS_DEMOTED = 4;
+
private boolean mFeedbackEnabled;
/** Injected constructor */
@@ -81,16 +89,88 @@ public class AssistantFeedbackController extends ContentObserver {
}
/**
- * Determines whether to show feedback indicator. The feedback indicator will be shown if
- * {@link #isFeedbackEnabled()} is enabled and assistant has changed this notification's rank or
- * importance.
+ * Get the feedback status according to assistant's adjustments
*
* @param entry Notification Entry to show feedback for
*/
- public boolean showFeedbackIndicator(NotificationEntry entry) {
+ public int getFeedbackStatus(NotificationEntry entry) {
+ if (!isFeedbackEnabled()) {
+ return STATUS_UNCHANGED;
+ }
Ranking ranking = entry.getRanking();
- return isFeedbackEnabled()
- && (ranking.getImportance() != ranking.getChannel().getImportance()
- || ranking.getRankingAdjustment() != Ranking.RANKING_UNCHANGED);
+ int oldImportance = ranking.getChannel().getImportance();
+ int newImportance = ranking.getImportance();
+ if (oldImportance < NotificationManager.IMPORTANCE_DEFAULT
+ && newImportance >= NotificationManager.IMPORTANCE_DEFAULT) {
+ return STATUS_ALERTED;
+ } else if (oldImportance >= NotificationManager.IMPORTANCE_DEFAULT
+ && newImportance < NotificationManager.IMPORTANCE_DEFAULT) {
+ return STATUS_SILENCED;
+ } else if (oldImportance < newImportance
+ || ranking.getRankingAdjustment() == ranking.RANKING_PROMOTED) {
+ return STATUS_PROMOTED;
+ } else if (oldImportance > newImportance
+ || ranking.getRankingAdjustment() == ranking.RANKING_DEMOTED) {
+ return STATUS_DEMOTED;
+ } else {
+ return STATUS_UNCHANGED;
+ }
+ }
+
+ /**
+ * Determines whether to show feedback indicator. The feedback indicator will be shown
+ * if {@link #isFeedbackEnabled()} is enabled and assistant has changed this notification's rank
+ * or importance.
+ *
+ * @param entry Notification Entry to show feedback for
+ */
+ public boolean showFeedbackIndicator(NotificationEntry entry) {
+ return getFeedbackStatus(entry) != STATUS_UNCHANGED;
+ }
+
+ /**
+ * Get the feedback indicator image resource according to assistant's changes on this
+ * notification's rank or importance.
+ *
+ * @param entry Notification Entry to show feedback for
+ */
+ public int getFeedbackImageResource(NotificationEntry entry) {
+ int feedbackStatus = getFeedbackStatus(entry);
+ switch (feedbackStatus) {
+ case STATUS_ALERTED:
+ return R.drawable.ic_feedback_alerted;
+ case STATUS_SILENCED:
+ return R.drawable.ic_feedback_silenced;
+ case STATUS_PROMOTED:
+ return R.drawable.ic_feedback_uprank;
+ case STATUS_DEMOTED:
+ return R.drawable.ic_feedback_downrank;
+ default:
+ return 0;
+ }
+ }
+
+ /**
+ * Get the inline settings description resource according to assistant's changes on this
+ * notification's rank or importance.
+ *
+ * @param entry Notification Entry to show feedback for
+ */
+ public int getInlineDescriptionResource(NotificationEntry entry) {
+ int feedbackStatus = getFeedbackStatus(entry);
+ switch (feedbackStatus) {
+ case STATUS_ALERTED:
+ return com.android.systemui.R.string.notification_channel_summary_automatic_alerted;
+ case STATUS_SILENCED:
+ return com.android.systemui.R.string
+ .notification_channel_summary_automatic_silenced;
+ case STATUS_PROMOTED:
+ return com.android.systemui.R.string
+ .notification_channel_summary_automatic_promoted;
+ case STATUS_DEMOTED:
+ return com.android.systemui.R.string.notification_channel_summary_automatic_demoted;
+ default:
+ return com.android.systemui.R.string.notification_channel_summary_automatic;
+ }
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java
index 10118e4733ba..11b829c4b4e8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java
@@ -1672,12 +1672,12 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
requestLayout();
}
- public void showFeedbackIcon(boolean show) {
+ public void showFeedbackIcon(boolean show, int resId) {
if (mIsSummaryWithChildren) {
- mChildrenContainer.showFeedbackIcon(show);
+ mChildrenContainer.showFeedbackIcon(show, resId);
}
- mPrivateLayout.showFeedbackIcon(show);
- mPublicLayout.showFeedbackIcon(show);
+ mPrivateLayout.showFeedbackIcon(show, resId);
+ mPublicLayout.showFeedbackIcon(show, resId);
}
/** Sets the last time the notification being displayed audibly alerted the user. */
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/FeedbackInfo.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/FeedbackInfo.java
index 149ee8c05348..35f35615e1c1 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/FeedbackInfo.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/FeedbackInfo.java
@@ -16,10 +16,6 @@
package com.android.systemui.statusbar.notification.row;
-import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
-import static android.service.notification.NotificationListenerService.Ranking.RANKING_DEMOTED;
-import static android.service.notification.NotificationListenerService.Ranking.RANKING_PROMOTED;
-
import android.annotation.SuppressLint;
import android.app.Notification;
import android.content.Context;
@@ -30,6 +26,7 @@ import android.os.Bundle;
import android.os.RemoteException;
import android.service.notification.NotificationListenerService;
import android.service.notification.StatusBarNotification;
+import android.text.Html;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
@@ -138,30 +135,30 @@ public class FeedbackInfo extends LinearLayout implements NotificationGuts.GutsC
no.setVisibility(View.VISIBLE);
yes.setOnClickListener(this::positiveFeedback);
no.setOnClickListener(this::negativeFeedback);
- prompt.setText(getPrompt());
+ prompt.setText(Html.fromHtml(getPrompt()));
}
@SuppressLint("DefaultLocale")
private String getPrompt() {
StringBuilder sb = new StringBuilder();
- int oldImportance = mRanking.getChannel().getImportance();
- int newImportance = mRanking.getImportance();
- int ranking = mRanking.getRankingAdjustment();
+ int status = mFeedbackController.getFeedbackStatus(mEntry);
if (DEBUG) {
sb.append(String.format(
"[DEBUG]: oldImportance=%d, newImportance=%d, ranking=%d\n\n",
mRanking.getChannel().getImportance(), mRanking.getImportance(),
mRanking.getRankingAdjustment()));
}
- if (oldImportance >= IMPORTANCE_DEFAULT && newImportance < IMPORTANCE_DEFAULT) {
- sb.append(mContext.getString(R.string.feedback_silenced));
- } else if (newImportance > oldImportance || ranking == RANKING_PROMOTED) {
- sb.append(mContext.getString(R.string.feedback_promoted));
- } else if (newImportance < oldImportance || ranking == RANKING_DEMOTED) {
- sb.append(mContext.getString(R.string.feedback_demoted));
+ if (status == mFeedbackController.STATUS_ALERTED) {
+ sb.append(mContext.getText(R.string.feedback_alerted));
+ } else if (status == mFeedbackController.STATUS_SILENCED) {
+ sb.append(mContext.getText(R.string.feedback_silenced));
+ } else if (status == mFeedbackController.STATUS_PROMOTED) {
+ sb.append(mContext.getText(R.string.feedback_promoted));
+ } else if (status == mFeedbackController.STATUS_DEMOTED) {
+ sb.append(mContext.getText(R.string.feedback_demoted));
}
sb.append(" ");
- sb.append(mContext.getString(R.string.feedback_prompt));
+ sb.append(mContext.getText(R.string.feedback_prompt));
return sb.toString();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java
index 74e6c003041e..475f627d8649 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java
@@ -1586,15 +1586,15 @@ public class NotificationContentView extends FrameLayout {
return null;
}
- public void showFeedbackIcon(boolean show) {
+ public void showFeedbackIcon(boolean show, int resId) {
if (mContractedChild != null) {
- mContractedWrapper.showFeedbackIcon(show);
+ mContractedWrapper.showFeedbackIcon(show, resId);
}
if (mExpandedChild != null) {
- mExpandedWrapper.showFeedbackIcon(show);
+ mExpandedWrapper.showFeedbackIcon(show, resId);
}
if (mHeadsUpChild != null) {
- mHeadsUpWrapper.showFeedbackIcon(show);
+ mHeadsUpWrapper.showFeedbackIcon(show, resId);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java
index c4f009815ba6..2fd17a587612 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java
@@ -378,7 +378,7 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx
mDeviceProvisionedController.isDeviceProvisioned(),
row.getIsNonblockable(),
mHighPriorityProvider.isHighPriority(row.getEntry()),
- mAssistantFeedbackController.isFeedbackEnabled());
+ mAssistantFeedbackController);
}
/**
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 6ff5ed1bceae..d12d98ecc62b 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
@@ -41,6 +41,7 @@ import android.metrics.LogMaker;
import android.os.Handler;
import android.os.RemoteException;
import android.service.notification.StatusBarNotification;
+import android.text.Html;
import android.text.TextUtils;
import android.transition.ChangeBounds;
import android.transition.Fade;
@@ -60,6 +61,7 @@ import com.android.internal.logging.UiEventLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.systemui.Dependency;
import com.android.systemui.R;
+import com.android.systemui.statusbar.notification.AssistantFeedbackController;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import java.lang.annotation.Retention;
@@ -96,6 +98,7 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
private PackageManager mPm;
private MetricsLogger mMetricsLogger;
private ChannelEditorDialogController mChannelEditorDialogController;
+ private AssistantFeedbackController mAssistantFeedbackController;
private String mPackageName;
private String mAppName;
@@ -200,12 +203,13 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
boolean isDeviceProvisioned,
boolean isNonblockable,
boolean wasShownHighPriority,
- boolean showAutomaticSetting)
+ AssistantFeedbackController assistantFeedbackController)
throws RemoteException {
mINotificationManager = iNotificationManager;
mMetricsLogger = Dependency.get(MetricsLogger.class);
mOnUserInteractionCallback = onUserInteractionCallback;
mChannelEditorDialogController = channelEditorDialogController;
+ mAssistantFeedbackController = assistantFeedbackController;
mPackageName = pkg;
mUniqueChannelsInRow = uniqueChannelsInRow;
mNumUniqueChannelsInRow = uniqueChannelsInRow.size();
@@ -222,7 +226,7 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
mAppUid = mSbn.getUid();
mDelegatePkg = mSbn.getOpPkg();
mIsDeviceProvisioned = isDeviceProvisioned;
- mShowAutomaticSetting = showAutomaticSetting;
+ mShowAutomaticSetting = mAssistantFeedbackController.isFeedbackEnabled();
mUiEventLogger = uiEventLogger;
int numTotalChannels = mINotificationManager.getNumNotificationChannelsForPackage(
@@ -280,6 +284,8 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G
View automatic = findViewById(R.id.automatic);
if (mShowAutomaticSetting) {
+ mAutomaticDescriptionView.setText(Html.fromHtml(mContext.getText(
+ mAssistantFeedbackController.getInlineDescriptionResource(mEntry)).toString()));
automatic.setVisibility(VISIBLE);
automatic.setOnClickListener(mOnAutomatic);
} else {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationHeaderViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationHeaderViewWrapper.java
index 7c5d4a3efee7..152527f3d76a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationHeaderViewWrapper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationHeaderViewWrapper.java
@@ -29,6 +29,7 @@ import android.view.ViewGroup;
import android.view.ViewGroup.MarginLayoutParams;
import android.view.animation.Interpolator;
import android.view.animation.PathInterpolator;
+import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
@@ -131,8 +132,11 @@ public class NotificationHeaderViewWrapper extends NotificationViewWrapper {
/** Shows or hides feedback indicator */
@Override
- public void showFeedbackIcon(boolean show) {
+ public void showFeedbackIcon(boolean show, int resId) {
mFeedbackIcon.setVisibility(show ? View.VISIBLE : View.GONE);
+ if (show && mFeedbackIcon instanceof ImageButton) {
+ ((ImageButton) mFeedbackIcon).setImageResource(resId);
+ }
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapper.java
index 2d706a48e90d..04cbe87c1e82 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/wrapper/NotificationViewWrapper.java
@@ -103,7 +103,7 @@ public abstract class NotificationViewWrapper implements TransformableView {
/**
* Shows or hides feedback icon.
*/
- public void showFeedbackIcon(boolean show) {
+ public void showFeedbackIcon(boolean show, int resId) {
}
public void onReinflated() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java
index 601fc197cfa6..a56ae7d21952 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationChildrenContainer.java
@@ -1300,12 +1300,12 @@ public class NotificationChildrenContainer extends ViewGroup {
/**
* Shows or hides feedback icon.
*/
- public void showFeedbackIcon(boolean show) {
+ public void showFeedbackIcon(boolean show, int resId) {
if (mNotificationHeaderWrapper != null) {
- mNotificationHeaderWrapper.showFeedbackIcon(show);
+ mNotificationHeaderWrapper.showFeedbackIcon(show, resId);
}
if (mNotificationHeaderWrapperLowPriority != null) {
- mNotificationHeaderWrapperLowPriority.showFeedbackIcon(show);
+ mNotificationHeaderWrapperLowPriority.showFeedbackIcon(show, resId);
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/AssistantFeedbackControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/AssistantFeedbackControllerTest.java
index fb8c3d9af05c..3f1cf83d7b5c 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/AssistantFeedbackControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/AssistantFeedbackControllerTest.java
@@ -25,6 +25,12 @@ import static android.service.notification.NotificationListenerService.Ranking.R
import static android.service.notification.NotificationListenerService.Ranking.RANKING_PROMOTED;
import static android.service.notification.NotificationListenerService.Ranking.RANKING_UNCHANGED;
+import static com.android.systemui.statusbar.notification.AssistantFeedbackController.STATUS_DEMOTED;
+import static com.android.systemui.statusbar.notification.AssistantFeedbackController.STATUS_PROMOTED;
+import static com.android.systemui.statusbar.notification.AssistantFeedbackController.STATUS_SILENCED;
+import static com.android.systemui.statusbar.notification.AssistantFeedbackController.STATUS_UNCHANGED;
+
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -40,6 +46,8 @@ import com.android.systemui.SysuiTestCase;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder;
+import junit.framework.Assert;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -76,28 +84,46 @@ public class AssistantFeedbackControllerTest extends SysuiTestCase {
}
@Test
- public void testShowFeedbackIndicator_settingDisabled() {
+ public void testFeedback_settingDisabled() {
switchSetting(OFF);
+ assertEquals(STATUS_UNCHANGED, mAssistantFeedbackController.getFeedbackStatus(
+ getEntry(IMPORTANCE_DEFAULT, IMPORTANCE_DEFAULT, RANKING_UNCHANGED)));
assertFalse(mAssistantFeedbackController.showFeedbackIndicator(
getEntry(IMPORTANCE_DEFAULT, IMPORTANCE_DEFAULT, RANKING_UNCHANGED)));
}
@Test
- public void testShowFeedbackIndicator_changedImportance() {
- assertTrue(mAssistantFeedbackController.showFeedbackIndicator(
- getEntry(IMPORTANCE_DEFAULT, IMPORTANCE_HIGH, RANKING_UNCHANGED)));
- assertTrue(mAssistantFeedbackController.showFeedbackIndicator(
- getEntry(IMPORTANCE_DEFAULT, IMPORTANCE_LOW, RANKING_UNCHANGED)));
- assertTrue(mAssistantFeedbackController.showFeedbackIndicator(
- getEntry(IMPORTANCE_LOW, IMPORTANCE_MIN, RANKING_UNCHANGED)));
+ public void testFeedback_changedImportance() {
+ NotificationEntry entry = getEntry(IMPORTANCE_DEFAULT, IMPORTANCE_HIGH, RANKING_UNCHANGED);
+ assertEquals(STATUS_PROMOTED, mAssistantFeedbackController.getFeedbackStatus(entry));
+ assertTrue(mAssistantFeedbackController.showFeedbackIndicator(entry));
+
+ entry = getEntry(IMPORTANCE_DEFAULT, IMPORTANCE_LOW, RANKING_UNCHANGED);
+ assertEquals(STATUS_SILENCED, mAssistantFeedbackController.getFeedbackStatus(entry));
+ assertTrue(mAssistantFeedbackController.showFeedbackIndicator(entry));
+
+ entry = getEntry(IMPORTANCE_LOW, IMPORTANCE_MIN, RANKING_UNCHANGED);
+ assertEquals(STATUS_DEMOTED, mAssistantFeedbackController.getFeedbackStatus(entry));
+ assertTrue(mAssistantFeedbackController.showFeedbackIndicator(entry));
+ }
+
+ @Test
+ public void testFeedback_changedRanking() {
+ NotificationEntry entry =
+ getEntry(IMPORTANCE_DEFAULT, IMPORTANCE_DEFAULT, RANKING_PROMOTED);
+ assertEquals(STATUS_PROMOTED, mAssistantFeedbackController.getFeedbackStatus(entry));
+ assertTrue(mAssistantFeedbackController.showFeedbackIndicator(entry));
+
+ entry = getEntry(IMPORTANCE_DEFAULT, IMPORTANCE_DEFAULT, RANKING_DEMOTED);
+ assertEquals(STATUS_DEMOTED, mAssistantFeedbackController.getFeedbackStatus(entry));
+ assertTrue(mAssistantFeedbackController.showFeedbackIndicator(entry));
}
@Test
- public void testShowFeedbackIndicator_changedRanking() {
- assertTrue(mAssistantFeedbackController.showFeedbackIndicator(
- getEntry(IMPORTANCE_DEFAULT, IMPORTANCE_DEFAULT, RANKING_PROMOTED)));
- assertTrue(mAssistantFeedbackController.showFeedbackIndicator(
- getEntry(IMPORTANCE_DEFAULT, IMPORTANCE_DEFAULT, RANKING_DEMOTED)));
+ public void testGetFeedbackImageResource_settingDisabled() {
+ switchSetting(OFF);
+ Assert.assertEquals(0, mAssistantFeedbackController.getFeedbackImageResource(
+ getEntry(IMPORTANCE_DEFAULT, IMPORTANCE_DEFAULT, RANKING_UNCHANGED)));
}
private NotificationEntry getEntry(int oldImportance, int newImportance,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java
index 891179c32315..ca982a64d382 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRowTest.java
@@ -210,7 +210,7 @@ public class ExpandableNotificationRowTest extends SysuiTestCase {
// public notification is custom layout - no header
mGroupRow.setSensitive(true, true);
mGroupRow.setOnFeedbackClickListener(null);
- mGroupRow.showFeedbackIcon(false);
+ mGroupRow.showFeedbackIcon(false, 0);
}
@Test
@@ -224,11 +224,12 @@ public class ExpandableNotificationRowTest extends SysuiTestCase {
mGroupRow.setChildrenContainer(mockContainer);
final boolean show = true;
- mGroupRow.showFeedbackIcon(show);
+ final int resId = 1;
+ mGroupRow.showFeedbackIcon(show, resId);
- verify(mockContainer, times(1)).showFeedbackIcon(show);
- verify(privateLayout, times(1)).showFeedbackIcon(show);
- verify(publicLayout, times(1)).showFeedbackIcon(show);
+ verify(mockContainer, times(1)).showFeedbackIcon(show, resId);
+ verify(privateLayout, times(1)).showFeedbackIcon(show, resId);
+ verify(publicLayout, times(1)).showFeedbackIcon(show, resId);
}
@Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/FeedbackInfoTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/FeedbackInfoTest.java
index 9d87579ee154..53ff957e4016 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/FeedbackInfoTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/FeedbackInfoTest.java
@@ -17,13 +17,13 @@
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.service.notification.NotificationListenerService.Ranking.RANKING_DEMOTED;
-import static android.service.notification.NotificationListenerService.Ranking.RANKING_PROMOTED;
import static android.service.notification.NotificationListenerService.Ranking.RANKING_UNCHANGED;
+import static com.android.systemui.statusbar.notification.AssistantFeedbackController.STATUS_ALERTED;
+import static com.android.systemui.statusbar.notification.AssistantFeedbackController.STATUS_DEMOTED;
+import static com.android.systemui.statusbar.notification.AssistantFeedbackController.STATUS_PROMOTED;
+import static com.android.systemui.statusbar.notification.AssistantFeedbackController.STATUS_SILENCED;
+
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertTrue;
@@ -79,6 +79,8 @@ public class FeedbackInfoTest extends SysuiTestCase {
private final NotificationGuts mGutsParent = mock(NotificationGuts.class);
private final ExpandableNotificationRow mMockNotificationRow =
mock(ExpandableNotificationRow.class);
+ private final AssistantFeedbackController mAssistantFeedbackController =
+ mock(AssistantFeedbackController.class);
private StatusBarNotification mSbn;
@Mock
@@ -120,7 +122,7 @@ public class FeedbackInfoTest extends SysuiTestCase {
public void testBindNotification_SetsTextApplicationName() {
when(mMockPackageManager.getApplicationLabel(any())).thenReturn("App Name");
mFeedbackInfo.bindGuts(mMockPackageManager, mSbn, getEntry(),
- mMockNotificationRow, mock(AssistantFeedbackController.class));
+ mMockNotificationRow, mAssistantFeedbackController);
final TextView textView = mFeedbackInfo.findViewById(R.id.pkg_name);
assertTrue(textView.getText().toString().contains("App Name"));
}
@@ -131,65 +133,60 @@ public class FeedbackInfoTest extends SysuiTestCase {
when(mMockPackageManager.getApplicationIcon(any(ApplicationInfo.class)))
.thenReturn(iconDrawable);
mFeedbackInfo.bindGuts(mMockPackageManager, mSbn, getEntry(),
- mMockNotificationRow, mock(AssistantFeedbackController.class));
+ mMockNotificationRow, mAssistantFeedbackController);
final ImageView iconView = mFeedbackInfo.findViewById(R.id.pkg_icon);
assertEquals(iconDrawable, iconView.getDrawable());
}
@Test
public void testPrompt_silenced() {
- mFeedbackInfo.bindGuts(mMockPackageManager, mSbn, getEntry(IMPORTANCE_DEFAULT,
- IMPORTANCE_LOW, RANKING_UNCHANGED), mMockNotificationRow,
- mock(AssistantFeedbackController.class));
- TextView prompt = mFeedbackInfo.findViewById(R.id.prompt);
- assertEquals("This notification was silenced by the system. Was this correct?",
- prompt.getText());
- }
-
- @Test
- public void testPrompt_promoted_importance() {
- mFeedbackInfo.bindGuts(mMockPackageManager, mSbn, getEntry(IMPORTANCE_DEFAULT,
- IMPORTANCE_HIGH, RANKING_UNCHANGED), mMockNotificationRow,
- mock(AssistantFeedbackController.class));
+ when(mAssistantFeedbackController.getFeedbackStatus(any(NotificationEntry.class)))
+ .thenReturn(STATUS_SILENCED);
+ mFeedbackInfo.bindGuts(mMockPackageManager, mSbn, getEntry(), mMockNotificationRow,
+ mAssistantFeedbackController);
TextView prompt = mFeedbackInfo.findViewById(R.id.prompt);
- assertEquals("This notification was promoted by the system. Was this correct?",
- prompt.getText());
+ assertEquals("This notification was automatically demoted to Silent by the system. "
+ + "Was this correct?", prompt.getText().toString());
}
@Test
- public void testPrompt_promoted_ranking() {
- mFeedbackInfo.bindGuts(mMockPackageManager, mSbn, getEntry(IMPORTANCE_DEFAULT,
- IMPORTANCE_DEFAULT, RANKING_PROMOTED), mMockNotificationRow,
- mock(AssistantFeedbackController.class));
+ public void testPrompt_promoted() {
+ when(mAssistantFeedbackController.getFeedbackStatus(any(NotificationEntry.class)))
+ .thenReturn(STATUS_PROMOTED);
+ mFeedbackInfo.bindGuts(mMockPackageManager, mSbn, getEntry(), mMockNotificationRow,
+ mAssistantFeedbackController);
TextView prompt = mFeedbackInfo.findViewById(R.id.prompt);
- assertEquals("This notification was promoted by the system. Was this correct?",
- prompt.getText());
+ assertEquals("This notification was automatically ranked higher in your shade. "
+ + "Was this correct?", prompt.getText().toString());
}
@Test
- public void testPrompt_demoted_importance() {
- mFeedbackInfo.bindGuts(mMockPackageManager, mSbn, getEntry(IMPORTANCE_LOW,
- IMPORTANCE_MIN, RANKING_UNCHANGED), mMockNotificationRow,
- mock(AssistantFeedbackController.class));
+ public void testPrompt_alerted() {
+ when(mAssistantFeedbackController.getFeedbackStatus(any(NotificationEntry.class)))
+ .thenReturn(STATUS_ALERTED);
+ mFeedbackInfo.bindGuts(mMockPackageManager, mSbn, getEntry(), mMockNotificationRow,
+ mAssistantFeedbackController);
TextView prompt = mFeedbackInfo.findViewById(R.id.prompt);
- assertEquals("This notification was demoted by the system. Was this correct?",
- prompt.getText());
+ assertEquals("This notification was automatically promoted to Default by the system. "
+ + "Was this correct?",
+ prompt.getText().toString());
}
@Test
- public void testPrompt_demoted_ranking() {
- mFeedbackInfo.bindGuts(mMockPackageManager, mSbn, getEntry(IMPORTANCE_DEFAULT,
- IMPORTANCE_DEFAULT, RANKING_DEMOTED), mMockNotificationRow,
- mock(AssistantFeedbackController.class));
+ public void testPrompt_demoted() {
+ when(mAssistantFeedbackController.getFeedbackStatus(any(NotificationEntry.class)))
+ .thenReturn(STATUS_DEMOTED);
+ mFeedbackInfo.bindGuts(mMockPackageManager, mSbn, getEntry(), mMockNotificationRow,
+ mAssistantFeedbackController);
TextView prompt = mFeedbackInfo.findViewById(R.id.prompt);
- assertEquals("This notification was demoted by the system. Was this correct?",
- prompt.getText());
+ assertEquals("This notification was automatically ranked lower in your shade. "
+ + "Was this correct?", prompt.getText().toString());
}
@Test
public void testPositiveFeedback() {
mFeedbackInfo.bindGuts(mMockPackageManager, mSbn, getEntry(), mMockNotificationRow,
- mock(AssistantFeedbackController.class));
+ mAssistantFeedbackController);
final View yes = mFeedbackInfo.findViewById(R.id.yes);
yes.performClick();
@@ -206,7 +203,7 @@ public class FeedbackInfoTest extends SysuiTestCase {
.thenReturn(true);
mFeedbackInfo.bindGuts(mMockPackageManager, mSbn, getEntry(), mMockNotificationRow,
- mock(AssistantFeedbackController.class));
+ mAssistantFeedbackController);
final View no = mFeedbackInfo.findViewById(R.id.no);
no.performClick();
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentViewTest.java
index 2101ea1766a1..377a69dab91b 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentViewTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationContentViewTest.java
@@ -95,7 +95,7 @@ public class NotificationContentViewTest extends SysuiTestCase {
mView.setExpandedChild(mockExpanded);
mView.setHeadsUpChild(mockHeadsUp);
- mView.showFeedbackIcon(true);
+ mView.showFeedbackIcon(true, 1);
verify(mockContracted, times(1)).setVisibility(View.VISIBLE);
verify(mockExpanded, times(1)).setVisibility(View.VISIBLE);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java
index 3000b8b449c3..458a058cc6ec 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java
@@ -374,7 +374,7 @@ public class NotificationGutsManagerTest extends SysuiTestCase {
eq(false),
eq(false),
eq(true), /* wasShownHighPriority */
- eq(false) /* showAutomaticSetting */);
+ eq(mAssistantFeedbackController));
}
@Test
@@ -408,7 +408,7 @@ public class NotificationGutsManagerTest extends SysuiTestCase {
eq(true),
eq(false),
eq(false), /* wasShownHighPriority */
- eq(false) /* showAutomaticSetting */);
+ eq(mAssistantFeedbackController));
}
@Test
@@ -440,7 +440,7 @@ public class NotificationGutsManagerTest extends SysuiTestCase {
eq(false),
eq(false),
eq(false), /* wasShownHighPriority */
- eq(false) /* showAutomaticSetting */);
+ eq(mAssistantFeedbackController));
}
@Test
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 4a2cbccad24d..324f0ac08fad 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
@@ -64,6 +64,7 @@ import com.android.internal.logging.testing.UiEventLoggerFake;
import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.SysuiTestCase;
+import com.android.systemui.statusbar.notification.AssistantFeedbackController;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder;
@@ -113,6 +114,8 @@ public class NotificationInfoTest extends SysuiTestCase {
private OnUserInteractionCallback mOnUserInteractionCallback;
@Mock
private ChannelEditorDialogController mChannelEditorDialogController;
+ @Mock
+ private AssistantFeedbackController mAssistantFeedbackController;
@Before
public void setUp() throws Exception {
@@ -160,6 +163,9 @@ public class NotificationInfoTest extends SysuiTestCase {
mSbn = new StatusBarNotification(TEST_PACKAGE_NAME, TEST_PACKAGE_NAME, 0, null, TEST_UID, 0,
new Notification(), UserHandle.CURRENT, null, 0);
mEntry = new NotificationEntryBuilder().setSbn(mSbn).build();
+ when(mAssistantFeedbackController.isFeedbackEnabled()).thenReturn(false);
+ when(mAssistantFeedbackController.getInlineDescriptionResource(any()))
+ .thenReturn(R.string.notification_channel_summary_automatic);
}
@Test
@@ -180,7 +186,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
true,
- false);
+ mAssistantFeedbackController);
final TextView textView = mNotificationInfo.findViewById(R.id.pkg_name);
assertTrue(textView.getText().toString().contains("App Name"));
assertEquals(VISIBLE, mNotificationInfo.findViewById(R.id.header).getVisibility());
@@ -206,7 +212,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
true,
- false);
+ mAssistantFeedbackController);
final ImageView iconView = mNotificationInfo.findViewById(R.id.pkg_icon);
assertEquals(iconDrawable, iconView.getDrawable());
}
@@ -228,7 +234,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
true,
- false);
+ mAssistantFeedbackController);
final TextView nameView = mNotificationInfo.findViewById(R.id.delegate_name);
assertEquals(GONE, nameView.getVisibility());
}
@@ -259,7 +265,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
true,
- false);
+ mAssistantFeedbackController);
final TextView nameView = mNotificationInfo.findViewById(R.id.delegate_name);
assertEquals(VISIBLE, nameView.getVisibility());
assertTrue(nameView.getText().toString().contains("Proxied"));
@@ -282,7 +288,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
true,
- false);
+ mAssistantFeedbackController);
final TextView groupNameView = mNotificationInfo.findViewById(R.id.group_name);
assertEquals(GONE, groupNameView.getVisibility());
}
@@ -310,7 +316,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
true,
- false);
+ mAssistantFeedbackController);
final TextView groupNameView = mNotificationInfo.findViewById(R.id.group_name);
assertEquals(View.VISIBLE, groupNameView.getVisibility());
assertEquals("Test Group Name", groupNameView.getText());
@@ -333,7 +339,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
true,
- false);
+ mAssistantFeedbackController);
final TextView textView = mNotificationInfo.findViewById(R.id.channel_name);
assertEquals(TEST_CHANNEL_NAME, textView.getText());
}
@@ -355,7 +361,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
true,
- false);
+ mAssistantFeedbackController);
final TextView textView = mNotificationInfo.findViewById(R.id.channel_name);
assertEquals(GONE, textView.getVisibility());
}
@@ -381,7 +387,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
true,
- false);
+ mAssistantFeedbackController);
final TextView textView = mNotificationInfo.findViewById(R.id.channel_name);
assertEquals(VISIBLE, textView.getVisibility());
}
@@ -403,7 +409,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
true,
true,
- false);
+ mAssistantFeedbackController);
final TextView textView = mNotificationInfo.findViewById(R.id.channel_name);
assertEquals(VISIBLE, textView.getVisibility());
}
@@ -429,7 +435,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
true,
- false);
+ mAssistantFeedbackController);
final View settingsButton = mNotificationInfo.findViewById(R.id.info);
settingsButton.performClick();
@@ -454,7 +460,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
true,
- false);
+ mAssistantFeedbackController);
final View settingsButton = mNotificationInfo.findViewById(R.id.info);
assertTrue(settingsButton.getVisibility() != View.VISIBLE);
}
@@ -479,7 +485,7 @@ public class NotificationInfoTest extends SysuiTestCase {
false,
false,
true,
- false);
+ mAssistantFeedbackController);
final View settingsButton = mNotificationInfo.findViewById(R.id.info);
assertTrue(settingsButton.getVisibility() != View.VISIBLE);
}
@@ -501,7 +507,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
true,
- false);
+ mAssistantFeedbackController);
mNotificationInfo.bindNotification(
mMockPackageManager,
mMockINotificationManager,
@@ -517,7 +523,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
true,
- false);
+ mAssistantFeedbackController);
final View settingsButton = mNotificationInfo.findViewById(R.id.info);
assertEquals(View.VISIBLE, settingsButton.getVisibility());
}
@@ -542,7 +548,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
true,
true,
- false);
+ mAssistantFeedbackController);
mNotificationInfo.findViewById(R.id.info).performClick();
// Verify that listener was triggered.
@@ -568,7 +574,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
true,
- false);
+ mAssistantFeedbackController);
final TextView channelNameView =
mNotificationInfo.findViewById(R.id.channel_name);
assertEquals(GONE, channelNameView.getVisibility());
@@ -592,7 +598,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
true,
- false);
+ mAssistantFeedbackController);
assertEquals(GONE, mNotificationInfo.findViewById(
R.id.interruptiveness_settings).getVisibility());
assertEquals(VISIBLE, mNotificationInfo.findViewById(
@@ -616,7 +622,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
true,
true,
- false);
+ mAssistantFeedbackController);
final TextView view = mNotificationInfo.findViewById(R.id.non_configurable_text);
assertEquals(View.VISIBLE, view.getVisibility());
assertEquals(mContext.getString(R.string.notification_unblockable_desc),
@@ -627,6 +633,7 @@ public class NotificationInfoTest extends SysuiTestCase {
@Test
public void testBindNotification_automaticIsVisible() throws Exception {
+ when(mAssistantFeedbackController.isFeedbackEnabled()).thenReturn(true);
mNotificationInfo.bindNotification(
mMockPackageManager,
mMockINotificationManager,
@@ -642,7 +649,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
true,
- true);
+ mAssistantFeedbackController);
assertEquals(VISIBLE, mNotificationInfo.findViewById(R.id.automatic).getVisibility());
assertEquals(VISIBLE, mNotificationInfo.findViewById(R.id.automatic_summary).getVisibility());
}
@@ -664,13 +671,14 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
true,
- false);
+ mAssistantFeedbackController);
assertEquals(GONE, mNotificationInfo.findViewById(R.id.automatic).getVisibility());
assertEquals(GONE, mNotificationInfo.findViewById(R.id.automatic_summary).getVisibility());
}
@Test
public void testBindNotification_automaticIsSelected() throws Exception {
+ when(mAssistantFeedbackController.isFeedbackEnabled()).thenReturn(true);
mNotificationChannel.unlockFields(USER_LOCKED_IMPORTANCE);
mNotificationInfo.bindNotification(
mMockPackageManager,
@@ -687,7 +695,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
true,
- true);
+ mAssistantFeedbackController);
assertTrue(mNotificationInfo.findViewById(R.id.automatic).isSelected());
}
@@ -708,7 +716,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
true,
- false);
+ mAssistantFeedbackController);
assertTrue(mNotificationInfo.findViewById(R.id.alert).isSelected());
}
@@ -729,7 +737,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
false,
- false);
+ mAssistantFeedbackController);
assertTrue(mNotificationInfo.findViewById(R.id.silence).isSelected());
}
@@ -750,7 +758,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
true,
- false);
+ mAssistantFeedbackController);
mTestableLooper.processAllMessages();
verify(mMockINotificationManager, never()).updateNotificationChannelForPackage(
anyString(), eq(TEST_UID), any());
@@ -773,7 +781,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
true,
- false);
+ mAssistantFeedbackController);
assertEquals(1, mUiEventLogger.numLogs());
assertEquals(NotificationControlsEvent.NOTIFICATION_CONTROLS_OPEN.getId(),
mUiEventLogger.eventId(0));
@@ -797,7 +805,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
false,
- false);
+ mAssistantFeedbackController);
mNotificationInfo.findViewById(R.id.alert).performClick();
mTestableLooper.processAllMessages();
@@ -824,7 +832,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
true,
- false);
+ mAssistantFeedbackController);
mNotificationInfo.findViewById(R.id.silence).performClick();
mTestableLooper.processAllMessages();
@@ -851,7 +859,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
true,
- false);
+ mAssistantFeedbackController);
mNotificationInfo.findViewById(R.id.automatic).performClick();
mTestableLooper.processAllMessages();
@@ -862,6 +870,7 @@ public class NotificationInfoTest extends SysuiTestCase {
@Test
public void testHandleCloseControls_persistAutomatic()
throws Exception {
+ when(mAssistantFeedbackController.isFeedbackEnabled()).thenReturn(true);
mNotificationChannel.unlockFields(USER_LOCKED_IMPORTANCE);
mNotificationInfo.bindNotification(
mMockPackageManager,
@@ -878,7 +887,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
true,
- true);
+ mAssistantFeedbackController);
mNotificationInfo.handleCloseControls(true, false);
mTestableLooper.processAllMessages();
@@ -905,7 +914,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
true,
- false);
+ mAssistantFeedbackController);
mNotificationInfo.handleCloseControls(true, false);
mTestableLooper.processAllMessages();
@@ -940,7 +949,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
true,
- false);
+ mAssistantFeedbackController);
mNotificationInfo.handleCloseControls(true, false);
@@ -968,7 +977,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
true,
- false);
+ mAssistantFeedbackController);
mNotificationInfo.findViewById(R.id.silence).performClick();
mNotificationInfo.findViewById(R.id.done).performClick();
@@ -1008,7 +1017,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
false,
- false);
+ mAssistantFeedbackController);
mNotificationInfo.findViewById(R.id.alert).performClick();
mNotificationInfo.findViewById(R.id.done).performClick();
@@ -1026,6 +1035,7 @@ public class NotificationInfoTest extends SysuiTestCase {
@Test
public void testAutomaticUnlocksUserImportance() throws Exception {
+ when(mAssistantFeedbackController.isFeedbackEnabled()).thenReturn(true);
mNotificationChannel.setImportance(IMPORTANCE_DEFAULT);
mNotificationChannel.lockFields(USER_LOCKED_IMPORTANCE);
mNotificationInfo.bindNotification(
@@ -1043,7 +1053,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
true,
- true);
+ mAssistantFeedbackController);
mNotificationInfo.findViewById(R.id.automatic).performClick();
mNotificationInfo.findViewById(R.id.done).performClick();
@@ -1074,7 +1084,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
true,
- false);
+ mAssistantFeedbackController);
mNotificationInfo.findViewById(R.id.silence).performClick();
mNotificationInfo.findViewById(R.id.done).performClick();
@@ -1109,7 +1119,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
false,
- false);
+ mAssistantFeedbackController);
assertEquals(mContext.getString(R.string.inline_done_button),
((TextView) mNotificationInfo.findViewById(R.id.done)).getText());
@@ -1147,7 +1157,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
false,
- false);
+ mAssistantFeedbackController);
assertEquals(mContext.getString(R.string.inline_done_button),
((TextView) mNotificationInfo.findViewById(R.id.done)).getText());
@@ -1184,7 +1194,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
true,
- false);
+ mAssistantFeedbackController);
mNotificationInfo.findViewById(R.id.silence).performClick();
mNotificationInfo.findViewById(R.id.done).performClick();
@@ -1212,7 +1222,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
false,
- false);
+ mAssistantFeedbackController);
assertEquals(mContext.getString(R.string.inline_done_button),
((TextView) mNotificationInfo.findViewById(R.id.done)).getText());
@@ -1243,7 +1253,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
false,
- false);
+ mAssistantFeedbackController);
mNotificationInfo.findViewById(R.id.alert).performClick();
mNotificationInfo.findViewById(R.id.done).performClick();
@@ -1277,7 +1287,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
false,
- false);
+ mAssistantFeedbackController);
mNotificationInfo.findViewById(R.id.alert).performClick();
mNotificationInfo.findViewById(R.id.done).performClick();
@@ -1310,7 +1320,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
false,
- false);
+ mAssistantFeedbackController);
mNotificationInfo.findViewById(R.id.alert).performClick();
mNotificationInfo.findViewById(R.id.done).performClick();
@@ -1343,7 +1353,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
false,
- false);
+ mAssistantFeedbackController);
mNotificationInfo.findViewById(R.id.alert).performClick();
@@ -1369,7 +1379,7 @@ public class NotificationInfoTest extends SysuiTestCase {
true,
false,
false,
- false);
+ mAssistantFeedbackController);
assertFalse(mNotificationInfo.willBeRemoved());
}