Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentInflater.java +4 −1 Original line number Diff line number Diff line Loading @@ -203,13 +203,16 @@ public class NotificationContentInflater implements NotificationRowContentBinder messagingStyle = mConversationProcessor .processNotification(entry, builder, mLogger); } result.mInflatedSingleLineViewModel = SingleLineViewInflater SingleLineViewModel viewModel = SingleLineViewInflater .inflateSingleLineViewModel( entry.getSbn().getNotification(), messagingStyle, builder, row.getContext() ); // If the messagingStyle is null, we want to inflate the normal view isConversation = viewModel.isConversation(); result.mInflatedSingleLineViewModel = viewModel; result.mInflatedSingleLineView = SingleLineViewInflater.inflatePrivateSingleLineView( isConversation, Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ui/viewbinder/SingleLineViewBinder.kt +6 −6 Original line number Diff line number Diff line Loading @@ -24,14 +24,14 @@ import com.android.systemui.statusbar.notification.row.ui.viewmodel.SingleLineVi object SingleLineViewBinder { @JvmStatic fun bind(viewModel: SingleLineViewModel?, view: HybridNotificationView?) { if (viewModel?.isConversation() == true && view is HybridConversationNotificationView) { if (view is HybridConversationNotificationView) { if (AsyncHybridViewInflation.isUnexpectedlyInLegacyMode()) return viewModel.conversationData?.avatar?.let { view.setAvatar(it) } viewModel?.conversationData?.avatar?.let { view.setAvatar(it) } view.setText( viewModel.titleText, viewModel.contentText, viewModel.conversationData?.conversationSenderName viewModel?.titleText, viewModel?.contentText, viewModel?.conversationData?.conversationSenderName, ) } else { // bind the title and content text views Loading @@ -39,7 +39,7 @@ object SingleLineViewBinder { bind( /* title = */ viewModel?.titleText, /* text = */ viewModel?.contentText, /* contentView = */ null /* contentView = */ null, ) } } Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/SingleLineViewBinderTest.kt +54 −11 Original line number Diff line number Diff line Loading @@ -29,12 +29,13 @@ import com.android.systemui.statusbar.notification.row.SingleLineViewInflater.in import com.android.systemui.statusbar.notification.row.SingleLineViewInflater.inflatePublicSingleLineView import com.android.systemui.statusbar.notification.row.shared.AsyncHybridViewInflation import com.android.systemui.statusbar.notification.row.ui.viewbinder.SingleLineViewBinder import com.android.systemui.util.mockito.mock import kotlin.test.assertEquals import kotlin.test.assertNotNull import kotlin.test.assertNull import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.mockito.kotlin.mock @SmallTest @RunWith(AndroidJUnit4::class) Loading Loading @@ -69,7 +70,7 @@ class SingleLineViewBinderTest : SysuiTestCase() { reinflateFlags = FLAG_CONTENT_VIEW_SINGLE_LINE, entry = row.entry, context = context, logger = mock() logger = mock(), ) val publicView = Loading @@ -78,7 +79,7 @@ class SingleLineViewBinderTest : SysuiTestCase() { reinflateFlags = FLAG_CONTENT_VIEW_PUBLIC_SINGLE_LINE, entry = row.entry, context = context, logger = mock() logger = mock(), ) assertNotNull(publicView) Loading Loading @@ -114,7 +115,7 @@ class SingleLineViewBinderTest : SysuiTestCase() { .addMessage( "How about lunch?", System.currentTimeMillis(), Person.Builder().setName("user2").build() Person.Builder().setName("user2").build(), ) .setGroupConversation(true) notificationBuilder.setStyle(style).setShortcutId(SHORTCUT_ID) Loading @@ -127,7 +128,7 @@ class SingleLineViewBinderTest : SysuiTestCase() { reinflateFlags = FLAG_CONTENT_VIEW_SINGLE_LINE, entry = row.entry, context = context, logger = mock() logger = mock(), ) as HybridConversationNotificationView Loading @@ -137,7 +138,7 @@ class SingleLineViewBinderTest : SysuiTestCase() { reinflateFlags = FLAG_CONTENT_VIEW_PUBLIC_SINGLE_LINE, entry = row.entry, context = context, logger = mock() logger = mock(), ) as HybridConversationNotificationView assertNotNull(publicView) Loading @@ -150,10 +151,7 @@ class SingleLineViewBinderTest : SysuiTestCase() { systemUiContext = context, ) // WHEN: binds the view SingleLineViewBinder.bind( viewModel, view, ) SingleLineViewBinder.bind(viewModel, view) // THEN: the single-line conversation view should be bound with view model's corresponding // fields Loading @@ -161,8 +159,53 @@ class SingleLineViewBinderTest : SysuiTestCase() { assertEquals(viewModel.contentText, view.textView.text) assertEquals( viewModel.conversationData?.conversationSenderName, view.conversationSenderNameView.text view.conversationSenderNameView.text, ) } @Test @EnableFlags(AsyncHybridViewInflation.FLAG_NAME) fun bindConversationSingleLineView_nonConversationViewModel() { // GIVEN: a ConversationSingleLineView, and a nonConversationViewModel val style = Notification.BigTextStyle().bigText(CONTENT_TEXT) notificationBuilder.setStyle(style) val notification = notificationBuilder.build() val row: ExpandableNotificationRow = helper.createRow(notification) val view = inflatePrivateSingleLineView( isConversation = true, reinflateFlags = FLAG_CONTENT_VIEW_SINGLE_LINE, entry = row.entry, context = context, logger = mock(), ) val publicView = inflatePublicSingleLineView( isConversation = true, reinflateFlags = FLAG_CONTENT_VIEW_PUBLIC_SINGLE_LINE, entry = row.entry, context = context, logger = mock(), ) assertNotNull(publicView) val viewModel = SingleLineViewInflater.inflateSingleLineViewModel( notification = notification, messagingStyle = null, builder = notificationBuilder, systemUiContext = context, ) // WHEN: binds the view with the view model SingleLineViewBinder.bind(viewModel, view) // THEN: the single-line view should be bound with view model's corresponding // fields as a normal non-conversation single-line view assertEquals(viewModel.titleText, view?.titleView?.text) assertEquals(viewModel.contentText, view?.textView?.text) assertNull(viewModel.conversationData) } private companion object { Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentInflater.java +4 −1 Original line number Diff line number Diff line Loading @@ -203,13 +203,16 @@ public class NotificationContentInflater implements NotificationRowContentBinder messagingStyle = mConversationProcessor .processNotification(entry, builder, mLogger); } result.mInflatedSingleLineViewModel = SingleLineViewInflater SingleLineViewModel viewModel = SingleLineViewInflater .inflateSingleLineViewModel( entry.getSbn().getNotification(), messagingStyle, builder, row.getContext() ); // If the messagingStyle is null, we want to inflate the normal view isConversation = viewModel.isConversation(); result.mInflatedSingleLineViewModel = viewModel; result.mInflatedSingleLineView = SingleLineViewInflater.inflatePrivateSingleLineView( isConversation, Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ui/viewbinder/SingleLineViewBinder.kt +6 −6 Original line number Diff line number Diff line Loading @@ -24,14 +24,14 @@ import com.android.systemui.statusbar.notification.row.ui.viewmodel.SingleLineVi object SingleLineViewBinder { @JvmStatic fun bind(viewModel: SingleLineViewModel?, view: HybridNotificationView?) { if (viewModel?.isConversation() == true && view is HybridConversationNotificationView) { if (view is HybridConversationNotificationView) { if (AsyncHybridViewInflation.isUnexpectedlyInLegacyMode()) return viewModel.conversationData?.avatar?.let { view.setAvatar(it) } viewModel?.conversationData?.avatar?.let { view.setAvatar(it) } view.setText( viewModel.titleText, viewModel.contentText, viewModel.conversationData?.conversationSenderName viewModel?.titleText, viewModel?.contentText, viewModel?.conversationData?.conversationSenderName, ) } else { // bind the title and content text views Loading @@ -39,7 +39,7 @@ object SingleLineViewBinder { bind( /* title = */ viewModel?.titleText, /* text = */ viewModel?.contentText, /* contentView = */ null /* contentView = */ null, ) } } Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/SingleLineViewBinderTest.kt +54 −11 Original line number Diff line number Diff line Loading @@ -29,12 +29,13 @@ import com.android.systemui.statusbar.notification.row.SingleLineViewInflater.in import com.android.systemui.statusbar.notification.row.SingleLineViewInflater.inflatePublicSingleLineView import com.android.systemui.statusbar.notification.row.shared.AsyncHybridViewInflation import com.android.systemui.statusbar.notification.row.ui.viewbinder.SingleLineViewBinder import com.android.systemui.util.mockito.mock import kotlin.test.assertEquals import kotlin.test.assertNotNull import kotlin.test.assertNull import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.mockito.kotlin.mock @SmallTest @RunWith(AndroidJUnit4::class) Loading Loading @@ -69,7 +70,7 @@ class SingleLineViewBinderTest : SysuiTestCase() { reinflateFlags = FLAG_CONTENT_VIEW_SINGLE_LINE, entry = row.entry, context = context, logger = mock() logger = mock(), ) val publicView = Loading @@ -78,7 +79,7 @@ class SingleLineViewBinderTest : SysuiTestCase() { reinflateFlags = FLAG_CONTENT_VIEW_PUBLIC_SINGLE_LINE, entry = row.entry, context = context, logger = mock() logger = mock(), ) assertNotNull(publicView) Loading Loading @@ -114,7 +115,7 @@ class SingleLineViewBinderTest : SysuiTestCase() { .addMessage( "How about lunch?", System.currentTimeMillis(), Person.Builder().setName("user2").build() Person.Builder().setName("user2").build(), ) .setGroupConversation(true) notificationBuilder.setStyle(style).setShortcutId(SHORTCUT_ID) Loading @@ -127,7 +128,7 @@ class SingleLineViewBinderTest : SysuiTestCase() { reinflateFlags = FLAG_CONTENT_VIEW_SINGLE_LINE, entry = row.entry, context = context, logger = mock() logger = mock(), ) as HybridConversationNotificationView Loading @@ -137,7 +138,7 @@ class SingleLineViewBinderTest : SysuiTestCase() { reinflateFlags = FLAG_CONTENT_VIEW_PUBLIC_SINGLE_LINE, entry = row.entry, context = context, logger = mock() logger = mock(), ) as HybridConversationNotificationView assertNotNull(publicView) Loading @@ -150,10 +151,7 @@ class SingleLineViewBinderTest : SysuiTestCase() { systemUiContext = context, ) // WHEN: binds the view SingleLineViewBinder.bind( viewModel, view, ) SingleLineViewBinder.bind(viewModel, view) // THEN: the single-line conversation view should be bound with view model's corresponding // fields Loading @@ -161,8 +159,53 @@ class SingleLineViewBinderTest : SysuiTestCase() { assertEquals(viewModel.contentText, view.textView.text) assertEquals( viewModel.conversationData?.conversationSenderName, view.conversationSenderNameView.text view.conversationSenderNameView.text, ) } @Test @EnableFlags(AsyncHybridViewInflation.FLAG_NAME) fun bindConversationSingleLineView_nonConversationViewModel() { // GIVEN: a ConversationSingleLineView, and a nonConversationViewModel val style = Notification.BigTextStyle().bigText(CONTENT_TEXT) notificationBuilder.setStyle(style) val notification = notificationBuilder.build() val row: ExpandableNotificationRow = helper.createRow(notification) val view = inflatePrivateSingleLineView( isConversation = true, reinflateFlags = FLAG_CONTENT_VIEW_SINGLE_LINE, entry = row.entry, context = context, logger = mock(), ) val publicView = inflatePublicSingleLineView( isConversation = true, reinflateFlags = FLAG_CONTENT_VIEW_PUBLIC_SINGLE_LINE, entry = row.entry, context = context, logger = mock(), ) assertNotNull(publicView) val viewModel = SingleLineViewInflater.inflateSingleLineViewModel( notification = notification, messagingStyle = null, builder = notificationBuilder, systemUiContext = context, ) // WHEN: binds the view with the view model SingleLineViewBinder.bind(viewModel, view) // THEN: the single-line view should be bound with view model's corresponding // fields as a normal non-conversation single-line view assertEquals(viewModel.titleText, view?.titleView?.text) assertEquals(viewModel.contentText, view?.textView?.text) assertNull(viewModel.conversationData) } private companion object { Loading