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
This commit is contained in:
@@ -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"
|
||||
@@ -59,20 +59,6 @@
|
||||
android:ellipsize="end"
|
||||
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"
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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,15 +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);
|
||||
public void testBindNotification_setsIcon() {
|
||||
when(mMockPackageManager.getApplicationIcon((ApplicationInfo) any())).thenReturn(mDrawable);
|
||||
mInfo.bindNotification(
|
||||
mMockPackageManager,
|
||||
mMockINotificationManager,
|
||||
@@ -194,34 +194,7 @@ public class PartialConversationInfoTest extends SysuiTestCase {
|
||||
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);
|
||||
mInfo.bindNotification(
|
||||
mMockPackageManager,
|
||||
mMockINotificationManager,
|
||||
mChannelEditorDialogController,
|
||||
TEST_PACKAGE_NAME,
|
||||
mNotificationChannel,
|
||||
mNotificationChannelSet,
|
||||
mEntry,
|
||||
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());
|
||||
}
|
||||
|
||||
@@ -269,64 +242,6 @@ public class PartialConversationInfoTest extends SysuiTestCase {
|
||||
assertTrue(nameView.getText().toString().contains("Proxied"));
|
||||
}
|
||||
|
||||
@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);
|
||||
|
||||
Reference in New Issue
Block a user