summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Julia Reynolds <juliacr@google.com> 2020-06-09 16:58:47 -0400
committer Julia Reynolds <juliacr@google.com> 2020-06-09 17:01:38 -0400
commit0b02ee7a1996b4aae3a9a0ea39bafbd6d1158d5d (patch)
tree1d441e50c58c18ae6187411869cbc82a5db87467
parent1567a8847c132c50ac3f779a748367166694f49c (diff)
Clarify notif guts for apps that don't use shortcuts
Remove the channel specific controls and replace the conversation icon with the app icon to make it clearer what the scope of the text and linked controls is Test: atest Fixes: 158592601 Change-Id: I6056e9de37d68e4236b483bcc3ebc6d3b0557e35
-rw-r--r--packages/SystemUI/res/layout/partial_conversation_info.xml16
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/row/PartialConversationInfo.java52
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/PartialConversationInfoTest.java97
3 files changed, 12 insertions, 153 deletions
diff --git a/packages/SystemUI/res/layout/partial_conversation_info.xml b/packages/SystemUI/res/layout/partial_conversation_info.xml
index 803b0c61e6da..ecc311893497 100644
--- a/packages/SystemUI/res/layout/partial_conversation_info.xml
+++ b/packages/SystemUI/res/layout/partial_conversation_info.xml
@@ -35,7 +35,7 @@
android:clipChildren="false"
android:clipToPadding="false">
<ImageView
- android:id="@+id/conversation_icon"
+ android:id="@+id/icon"
android:layout_width="@dimen/notification_guts_conversation_icon_size"
android:layout_height="@dimen/notification_guts_conversation_icon_size"
android:layout_centerVertical="true"
@@ -60,20 +60,6 @@
android:textDirection="locale"
style="@style/TextAppearance.NotificationImportanceChannel"/>
<TextView
- android:id="@+id/parent_channel_name"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:ellipsize="end"
- android:textDirection="locale"
- style="@style/TextAppearance.NotificationImportanceChannel"/>
- <TextView
- android:id="@+id/group_name"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:ellipsize="end"
- android:textDirection="locale"
- style="@style/TextAppearance.NotificationImportanceChannelGroup"/>
- <TextView
android:id="@+id/delegate_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/PartialConversationInfo.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/PartialConversationInfo.java
index f1fe54ad4024..186ffa67f046 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/PartialConversationInfo.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/PartialConversationInfo.java
@@ -148,8 +148,7 @@ public class PartialConversationInfo extends LinearLayout implements
}
private void bindHeader() {
- bindConversationDetails();
-
+ bindPackage();
// Delegate
bindDelegate();
}
@@ -180,51 +179,6 @@ public class PartialConversationInfo extends LinearLayout implements
});
}
- private void bindConversationDetails() {
- final TextView channelName = findViewById(R.id.parent_channel_name);
- channelName.setText(mNotificationChannel.getName());
-
- bindGroup();
- bindName();
- bindPackage();
- bindIcon();
- }
-
- private void bindName() {
- TextView name = findViewById(R.id.name);
- Bundle extras = mSbn.getNotification().extras;
- CharSequence nameString = extras.getCharSequence(Notification.EXTRA_CONVERSATION_TITLE, "");
- if (TextUtils.isEmpty(nameString)) {
- nameString = extras.getCharSequence(Notification.EXTRA_TITLE, "");
- }
- name.setText(nameString);
- }
-
- private void bindIcon() {
- ImageView image = findViewById(R.id.conversation_icon);
- if (mSbn.getNotification().extras.getBoolean(EXTRA_IS_GROUP_CONVERSATION, false)) {
- // TODO: maybe use a generic group icon, or a composite of recent senders
- image.setImageDrawable(mPkgIcon);
- } else {
- final List<Notification.MessagingStyle.Message> messages =
- Notification.MessagingStyle.Message.getMessagesFromBundleArray(
- (Parcelable[]) mSbn.getNotification().extras.get(
- Notification.EXTRA_MESSAGES));
-
- final Notification.MessagingStyle.Message latestMessage =
- Notification.MessagingStyle.findLatestIncomingMessage(messages);
- Icon personIcon = null;
- if (latestMessage != null && latestMessage.getSenderPerson() != null) {
- personIcon = latestMessage.getSenderPerson().getIcon();
- }
- if (personIcon != null) {
- image.setImageIcon(latestMessage.getSenderPerson().getIcon());
- } else {
- image.setImageDrawable(mPkgIcon);
- }
- }
- }
-
private void bindPackage() {
ApplicationInfo info;
try {
@@ -241,6 +195,10 @@ public class PartialConversationInfo extends LinearLayout implements
} catch (PackageManager.NameNotFoundException e) {
mPkgIcon = mPm.getDefaultActivityIcon();
}
+ TextView name = findViewById(R.id.name);
+ name.setText(mAppName);
+ ImageView image = findViewById(R.id.icon);
+ image.setImageDrawable(mPkgIcon);
}
private void bindDelegate() {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/PartialConversationInfoTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/PartialConversationInfoTest.java
index f327967ebd73..43aa8fef76a9 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/PartialConversationInfoTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/PartialConversationInfoTest.java
@@ -25,6 +25,7 @@ import static android.view.View.VISIBLE;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.anyObject;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyBoolean;
import static org.mockito.Mockito.anyInt;
@@ -162,6 +163,7 @@ public class PartialConversationInfoTest extends SysuiTestCase {
@Test
public void testBindNotification_SetsName() {
+ when(mMockPackageManager.getApplicationLabel(any())).thenReturn("Package");
mInfo.bindNotification(
mMockPackageManager,
mMockINotificationManager,
@@ -174,42 +176,13 @@ public class PartialConversationInfoTest extends SysuiTestCase {
true,
false);
final TextView textView = mInfo.findViewById(R.id.name);
- assertTrue(textView.getText().toString().contains("title"));
+ assertTrue(textView.getText().toString().equals("Package"));
}
- @Test
- public void testBindNotification_groupSetsPackageIcon() {
- mEntry.getSbn().getNotification().extras.putBoolean(EXTRA_IS_GROUP_CONVERSATION, true);
- final Drawable iconDrawable = mock(Drawable.class);
- when(mMockPackageManager.getApplicationIcon(any(ApplicationInfo.class)))
- .thenReturn(iconDrawable);
- mInfo.bindNotification(
- mMockPackageManager,
- mMockINotificationManager,
- mChannelEditorDialogController,
- TEST_PACKAGE_NAME,
- mNotificationChannel,
- mNotificationChannelSet,
- mEntry,
- null,
- true,
- false);
- final ImageView iconView = mInfo.findViewById(R.id.conversation_icon);
- assertEquals(iconDrawable, iconView.getDrawable());
- }
@Test
- public void testBindNotification_notGroupSetsMessageIcon() {
- Notification n = new Notification.Builder(mContext, TEST_CHANNEL_NAME)
- .setStyle(new Notification.MessagingStyle(
- new Person.Builder().setName("me").build())
- .addMessage(new Notification.MessagingStyle.Message("hello", 0,
- new Person.Builder().setName("friend").setIcon(mIcon).build())))
- .build();
- mSbn = new StatusBarNotification(TEST_PACKAGE_NAME, TEST_PACKAGE_NAME, 0, null, TEST_UID, 0,
- n, UserHandle.CURRENT, null, 0);
- mEntry.setSbn(mSbn);
- mEntry.getSbn().getNotification().extras.putBoolean(EXTRA_IS_GROUP_CONVERSATION, false);
+ public void testBindNotification_setsIcon() {
+ when(mMockPackageManager.getApplicationIcon((ApplicationInfo) any())).thenReturn(mDrawable);
mInfo.bindNotification(
mMockPackageManager,
mMockINotificationManager,
@@ -221,7 +194,7 @@ public class PartialConversationInfoTest extends SysuiTestCase {
null,
true,
false);
- final ImageView iconView = mInfo.findViewById(R.id.conversation_icon);
+ final ImageView iconView = mInfo.findViewById(R.id.icon);
assertEquals(mDrawable.hashCode() + "", mDrawable, iconView.getDrawable());
}
@@ -270,64 +243,6 @@ public class PartialConversationInfoTest extends SysuiTestCase {
}
@Test
- public void testBindNotification_GroupNameHiddenIfNoGroup() throws Exception {
- mInfo.bindNotification(
- mMockPackageManager,
- mMockINotificationManager,
- mChannelEditorDialogController,
- TEST_PACKAGE_NAME,
- mNotificationChannel,
- mNotificationChannelSet,
- mEntry,
- null,
- true,
- false);
- final TextView groupNameView = mInfo.findViewById(R.id.group_name);
- assertEquals(GONE, groupNameView.getVisibility());
- }
-
- @Test
- public void testBindNotification_SetsGroupNameIfNonNull() throws Exception {
- mNotificationChannel.setGroup("test_group_id");
- final NotificationChannelGroup notificationChannelGroup =
- new NotificationChannelGroup("test_group_id", "Test Group Name");
- when(mMockINotificationManager.getNotificationChannelGroupForPackage(
- eq("test_group_id"), eq(TEST_PACKAGE_NAME), eq(TEST_UID)))
- .thenReturn(notificationChannelGroup);
- mInfo.bindNotification(
- mMockPackageManager,
- mMockINotificationManager,
- mChannelEditorDialogController,
- TEST_PACKAGE_NAME,
- mNotificationChannel,
- mNotificationChannelSet,
- mEntry,
- null,
- true,
- false);
- final TextView groupNameView = mInfo.findViewById(R.id.group_name);
- assertEquals(View.VISIBLE, groupNameView.getVisibility());
- assertEquals("Test Group Name", groupNameView.getText());
- }
-
- @Test
- public void testBindNotification_SetsTextChannelName() {
- mInfo.bindNotification(
- mMockPackageManager,
- mMockINotificationManager,
- mChannelEditorDialogController,
- TEST_PACKAGE_NAME,
- mNotificationChannel,
- mNotificationChannelSet,
- mEntry,
- null,
- true,
- false);
- final TextView textView = mInfo.findViewById(R.id.parent_channel_name);
- assertEquals(TEST_CHANNEL_NAME, textView.getText());
- }
-
- @Test
public void testBindNotification_SetsOnClickListenerForSettings() {
final CountDownLatch latch = new CountDownLatch(1);
mInfo.bindNotification(