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

Commit 969f924c authored by Nate Myren's avatar Nate Myren Committed by Android (Google) Code Review
Browse files

Merge "Lock Screen: Show contact name and icon for multi-message notifications" into main

parents 8fd8ec8d de173222
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -116,6 +116,7 @@ class NotificationRowContentBinderImplTest : SysuiTestCase() {
            }
        }
    private val promotedNotificationContentExtractor = FakePromotedNotificationContentExtractor()
    private val conversationNotificationProcessor: ConversationNotificationProcessor = mock()

    @Before
    fun setUp() {
@@ -132,7 +133,7 @@ class NotificationRowContentBinderImplTest : SysuiTestCase() {
            NotificationRowContentBinderImpl(
                cache,
                mock(),
                mock<ConversationNotificationProcessor>(),
                conversationNotificationProcessor,
                mock(),
                smartReplyStateInflater,
                layoutInflaterFactoryProvider,
@@ -462,12 +463,15 @@ class NotificationRowContentBinderImplTest : SysuiTestCase() {
    @Test
    fun testInflatePublicSingleLineConversationView() {
        val testPerson = Person.Builder().setName("Person").build()
        val style = Notification.MessagingStyle(testPerson)
        val messagingBuilder =
            Notification.Builder(mContext, "no-id")
                .setSmallIcon(R.drawable.ic_person)
                .setContentTitle("Title")
                .setContentText("Text")
                .setStyle(Notification.MessagingStyle(testPerson))
                .setStyle(style)
        whenever(conversationNotificationProcessor.processNotification(any(), any(), any()))
            .thenReturn(style)

        val messagingRow = spy(testHelper.createRow(messagingBuilder.build()))
        messagingRow.publicLayout.removeAllViews()
+41 −14
Original line number Diff line number Diff line
@@ -203,18 +203,20 @@ public class NotificationContentInflater implements NotificationRowContentBinder
        result = inflateSmartReplyViews(result, reInflateFlags, entry, row.getContext(),
                packageContext, row.getExistingSmartReplyState(), smartRepliesInflater, mLogger);
        boolean isConversation = entry.getRanking().isConversation();
        if (AsyncHybridViewInflation.isEnabled()) {
        Notification.MessagingStyle messagingStyle = null;
            if (isConversation) {
        if (isConversation && (AsyncHybridViewInflation.isEnabled()
                || LockscreenOtpRedaction.isSingleLineViewEnabled())) {
            messagingStyle = mConversationProcessor
                    .processNotification(entry, builder, mLogger);
        }
        if (AsyncHybridViewInflation.isEnabled()) {
            SingleLineViewModel viewModel = SingleLineViewInflater
                    .inflateSingleLineViewModel(
                            entry.getSbn().getNotification(),
                            messagingStyle,
                            builder,
                            row.getContext()
                            row.getContext(),
                            false
                    );
            // If the messagingStyle is null, we want to inflate the normal view
            isConversation = viewModel.isConversation();
@@ -228,11 +230,22 @@ public class NotificationContentInflater implements NotificationRowContentBinder
                            mLogger
                    );
        }

        if (LockscreenOtpRedaction.isSingleLineViewEnabled()) {
            if (bindParams.redactionType == REDACTION_TYPE_SENSITIVE_CONTENT) {
                result.mPublicInflatedSingleLineViewModel =
                    SingleLineViewInflater.inflateRedactedSingleLineViewModel(row.getContext(),
                            isConversation);
                        SingleLineViewInflater.inflateSingleLineViewModel(
                                entry.getSbn().getNotification(),
                                messagingStyle,
                                builder,
                                row.getContext(),
                                true);
            } else {
                result.mPublicInflatedSingleLineViewModel =
                        SingleLineViewInflater.inflateRedactedSingleLineViewModel(
                                row.getContext(),
                                isConversation
                        );
            }
            result.mPublicInflatedSingleLineView =
                    SingleLineViewInflater.inflatePublicSingleLineView(
                            isConversation,
@@ -1300,7 +1313,8 @@ public class NotificationContentInflater implements NotificationRowContentBinder
                                mEntry.getSbn().getNotification(),
                                messagingStyle,
                                recoveredBuilder,
                                mContext
                                mContext,
                                false
                        );
                result.mInflatedSingleLineView =
                        SingleLineViewInflater.inflatePrivateSingleLineView(
@@ -1313,9 +1327,22 @@ public class NotificationContentInflater implements NotificationRowContentBinder
            }

            if (LockscreenOtpRedaction.isSingleLineViewEnabled()) {
                if (mBindParams.redactionType == REDACTION_TYPE_SENSITIVE_CONTENT) {
                    result.mPublicInflatedSingleLineViewModel =
                            SingleLineViewInflater.inflateSingleLineViewModel(
                                    mEntry.getSbn().getNotification(),
                                    messagingStyle,
                                    recoveredBuilder,
                                    mContext,
                                    true
                            );
                } else {
                    result.mPublicInflatedSingleLineViewModel =
                        SingleLineViewInflater.inflateRedactedSingleLineViewModel(mContext,
                                isConversation);
                            SingleLineViewInflater.inflateRedactedSingleLineViewModel(
                                    mContext,
                                    isConversation
                            );
                }
                result.mPublicInflatedSingleLineView =
                        SingleLineViewInflater.inflatePublicSingleLineView(
                                isConversation,
+15 −4
Original line number Diff line number Diff line
@@ -718,6 +718,7 @@ constructor(
                        messagingStyle = messagingStyle,
                        builder = builder,
                        systemUiContext = systemUiContext,
                        redactText = false,
                    )
                } else null

@@ -727,10 +728,20 @@ constructor(
                        reInflateFlags and FLAG_CONTENT_VIEW_PUBLIC_SINGLE_LINE != 0
                ) {
                    logger.logAsyncTaskProgress(entry, "inflating public single line view model")
                    if (bindParams.redactionType == REDACTION_TYPE_SENSITIVE_CONTENT) {
                        SingleLineViewInflater.inflateSingleLineViewModel(
                            notification = entry.sbn.notification,
                            messagingStyle = messagingStyle,
                            builder = builder,
                            systemUiContext = systemUiContext,
                            redactText = true,
                        )
                    } else {
                        SingleLineViewInflater.inflateRedactedSingleLineViewModel(
                            systemUiContext,
                            entry.ranking.isConversation,
                        )
                    }
                } else null

            val headsUpStatusBarModel =
+11 −2
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ internal object SingleLineViewInflater {
     *   notification, not for legacy messaging notifications
     * @param builder the recovered Notification Builder
     * @param systemUiContext the context of Android System UI
     * @param redactText indicates if the text needs to be redacted
     * @return the inflated SingleLineViewModel
     */
    @JvmStatic
@@ -59,13 +60,21 @@ internal object SingleLineViewInflater {
        messagingStyle: MessagingStyle?,
        builder: Notification.Builder,
        systemUiContext: Context,
        redactText: Boolean,
    ): SingleLineViewModel {
        if (AsyncHybridViewInflation.isUnexpectedlyInLegacyMode()) {
            return SingleLineViewModel(null, null, null)
        }
        peopleHelper.init(systemUiContext)
        var titleText = HybridGroupManager.resolveTitle(notification)
        var contentText = HybridGroupManager.resolveText(notification)
        var contentText =
            if (redactText) {
                systemUiContext.getString(
                    com.android.systemui.res.R.string.redacted_notification_single_line_text
                )
            } else {
                HybridGroupManager.resolveText(notification)
            }

        if (messagingStyle == null) {
            return SingleLineViewModel(
@@ -81,7 +90,7 @@ internal object SingleLineViewInflater {
        if (conversationTextData?.conversationTitle?.isNotEmpty() == true) {
            titleText = conversationTextData.conversationTitle
        }
        if (conversationTextData?.conversationText?.isNotEmpty() == true) {
        if (!redactText && conversationTextData?.conversationText?.isNotEmpty() == true) {
            contentText = conversationTextData.conversationText
        }

+3 −0
Original line number Diff line number Diff line
@@ -89,6 +89,7 @@ class SingleLineViewBinderTest : SysuiTestCase() {
                messagingStyle = null,
                builder = notificationBuilder,
                systemUiContext = context,
                redactText = false,
            )

        // WHEN: binds the viewHolder
@@ -149,6 +150,7 @@ class SingleLineViewBinderTest : SysuiTestCase() {
                messagingStyle = style,
                builder = notificationBuilder,
                systemUiContext = context,
                redactText = false,
            )
        // WHEN: binds the view
        SingleLineViewBinder.bind(viewModel, view)
@@ -197,6 +199,7 @@ class SingleLineViewBinderTest : SysuiTestCase() {
                messagingStyle = null,
                builder = notificationBuilder,
                systemUiContext = context,
                redactText = false,
            )
        // WHEN: binds the view with the view model
        SingleLineViewBinder.bind(viewModel, view)
Loading