Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f2acd603 authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Add name to conversation channels

When shortcut doesn't exist

Test: atest
Bug: 137397357
Change-Id: I27fd260a23e7546a4d437f1a8fd57edc2d990b06
parent 3ab2065d
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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"
+12 −3
Original line number Diff line number Diff line
@@ -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;
        }
    }

+2 −22
Original line number Diff line number Diff line
@@ -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");