Merge "Add name to conversation channels"

This commit is contained in:
TreeHugger Robot
2020-01-21 22:34:35 +00:00
committed by Android (Google) Code Review
3 changed files with 16 additions and 25 deletions

View File

@@ -67,11 +67,13 @@
android:layout_height="wrap_content"
android:layout_centerVertical="true"
style="@style/TextAppearance.NotificationImportanceHeader"
android:visibility="gone"
android:layout_marginStart="2dp"
android:layout_marginEnd="2dp"
android:text="@*android:string/notification_header_divider_symbol" />
<TextView
android:id="@+id/name"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"

View File

@@ -240,6 +240,10 @@ public class NotificationConversationInfo extends LinearLayout implements
// a custom channel
if (TextUtils.isEmpty(mNotificationChannel.getConversationId())) {
try {
// TODO: remove
mNotificationChannel.setName(mContext.getString(
R.string.notification_summary_message_format,
getName(), mNotificationChannel.getName()));
mINotificationManager.createConversationNotificationChannelForPackage(
mPackageName, mAppUid, mSbn.getKey(), mNotificationChannel,
mConversationId);
@@ -347,7 +351,8 @@ public class NotificationConversationInfo extends LinearLayout implements
channelName.setText(mNotificationChannel.getName());
bindGroup();
bindName();
// TODO: bring back when channel name does not include name
// bindName();
bindPackage();
bindIcon();
@@ -383,15 +388,19 @@ public class NotificationConversationInfo extends LinearLayout implements
private void bindName() {
TextView name = findViewById(R.id.name);
name.setText(getName());
}
private String getName() {
if (mShortcutInfo != null) {
name.setText(mShortcutInfo.getShortLabel());
return mShortcutInfo.getShortLabel().toString();
} else {
Bundle extras = mSbn.getNotification().extras;
String nameString = extras.getString(Notification.EXTRA_CONVERSATION_TITLE);
if (TextUtils.isEmpty(nameString)) {
nameString = extras.getString(Notification.EXTRA_TITLE);
}
name.setText(nameString);
return nameString;
}
}

View File

@@ -208,26 +208,6 @@ public class NotificationConversationInfoTest extends SysuiTestCase {
.thenReturn(mConversationChannel);
}
@Test
public void testBindNotification_SetsTextShortcutName() {
mNotificationInfo.bindNotification(
mShortcutManager,
mLauncherApps,
mMockPackageManager,
mMockINotificationManager,
mVisualStabilityManager,
TEST_PACKAGE_NAME,
mNotificationChannel,
mEntry,
null,
null,
null,
true);
final TextView textView = mNotificationInfo.findViewById(R.id.name);
assertEquals(mShortcutInfo.getShortLabel(), textView.getText().toString());
assertEquals(VISIBLE, mNotificationInfo.findViewById(R.id.header).getVisibility());
}
@Test
public void testBindNotification_SetsShortcutIcon() {
mNotificationInfo.bindNotification(
@@ -267,7 +247,7 @@ public class NotificationConversationInfoTest extends SysuiTestCase {
assertTrue(textView.getText().toString().contains("App Name"));
assertEquals(VISIBLE, mNotificationInfo.findViewById(R.id.header).getVisibility());
}
/**
@Test
public void testBindNotification_SetsTextChannelName() {
mNotificationInfo.bindNotification(
@@ -287,7 +267,7 @@ public class NotificationConversationInfoTest extends SysuiTestCase {
assertTrue(textView.getText().toString().contains(mNotificationChannel.getName()));
assertEquals(VISIBLE, mNotificationInfo.findViewById(R.id.header).getVisibility());
}
*/
@Test
public void testBindNotification_SetsTextGroupName() throws Exception {
NotificationChannelGroup group = new NotificationChannelGroup("id", "name");