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

Commit 2b45d38b authored by Ioana Alexandru's avatar Ioana Alexandru
Browse files

Don't show "Redacted" text for public notifs

Show only "Unlock to view" instead as the title. I also updated the
names of some resources for consistency.

Bug: 429118181
Flag: EXEMPT trivial bugfix
Test: SingleLineViewInflaterTest + manual
Change-Id: I4d0df56c2d310e726a345718df0837bd5edfe1ef
parent dccbf21b
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import com.android.systemui.statusbar.notification.row.ui.viewmodel.SingleLineVi
import kotlin.test.assertEquals
import kotlin.test.assertIs
import kotlin.test.assertIsNot
import kotlin.test.assertNotNull
import kotlin.test.assertNull
import kotlin.test.assertTrue
import org.junit.Before
@@ -311,6 +312,27 @@ class SingleLineViewInflaterTest : SysuiTestCase() {
        assertEquals("summary", singleLineViewModel.conversationData?.summarization)
    }

    @Test
    fun createViewModelForPublicConversationNotification() {
        // When: a public conversation notification is inflated
        val singleLineViewModel =
            SingleLineViewInflater.inflatePublicSingleLineViewModel(context, isConversation = true)

        // Then: the view model should be populated with the correct data
        val expectedIcon = context.getDrawable(R.drawable.ic_public_notification_single_line_icon)
        assertTrue(
            (singleLineViewModel.conversationData?.avatar as? SingleIcon)
                ?.iconDrawable
                ?.equalsTo(expectedIcon) == true
        )

        val expectedTitle = context.getString(R.string.public_notification_single_line_title)
        assertEquals(expectedTitle, singleLineViewModel.titleText)

        assertNull(singleLineViewModel.contentText)
        assertNotNull(singleLineViewModel.conversationData)
    }

    sealed class NotificationType(val largeIcon: Icon? = null)

    class NonMessaging(largeIcon: Icon? = null) : NotificationType(largeIcon)
+2 −4
Original line number Diff line number Diff line
@@ -4330,10 +4330,8 @@
    <!-- Education toast text for All Apps [CHAR_LIMIT=100] -->
    <string name="all_apps_edu_toast_content">To view all your apps, press the action key on your keyboard</string>

    <!-- Title of the one line view of a redacted notification -->
    <string name="redacted_notification_single_line_title">Redacted</string>
    <!-- Main text of the one line view of a public notification -->
    <string name="public_notification_single_line_text">Unlock to view</string>
    <!-- Placeholder title for the one line view of a public notification -->
    <string name="public_notification_single_line_title">Unlock to view</string>
    <!-- Main text of the one line view of a redacted OTP notification -->
    <string name="redacted_otp_notification_single_line_text">Unlock to view code</string>
    <!-- Placeholder title for the one line view of a notification with no title or text set -->
+4 −5
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ object SingleLineViewInflater {
            return SingleLineViewModel(null, null, null)
        }
        peopleHelper.init(systemUiContext)

        var titleText = HybridGroupManager.resolveTitle(notification)
        var contentText =
            if (redactText) {
@@ -148,7 +149,7 @@ object SingleLineViewInflater {
                    SingleIcon(
                        context.getDrawable(
                            com.android.systemui.res.R.drawable
                                .ic_redacted_notification_single_line_icon
                                .ic_public_notification_single_line_icon
                        )
                    ),
                    null,
@@ -158,11 +159,9 @@ object SingleLineViewInflater {
            }
        return SingleLineViewModel(
            context.getString(
                com.android.systemui.res.R.string.redacted_notification_single_line_title
            ),
            context.getString(
                com.android.systemui.res.R.string.public_notification_single_line_text
                com.android.systemui.res.R.string.public_notification_single_line_title
            ),
            null,
            conversationData,
        )
    }