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

Commit 1cbeadaa authored by Julia Tuttle's avatar Julia Tuttle
Browse files

Support 'base' notifications with null style

Bug: 392058444
Test: manual: use Maps, disable PIP, start nav, check AOD
Flag: com.android.systemui.aod_ui_rich_ongoing
Change-Id: Ie8198c9d2d363c69b035c71309d941058ce46e2a
parent b7c83a6e
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -171,6 +171,17 @@ class PromotedNotificationContentExtractorImplTest : SysuiTestCase() {
        assertThat(content?.shortCriticalText).isNull()
    }

    @Test
    @EnableFlags(PromotedNotificationUi.FLAG_NAME, StatusBarNotifChips.FLAG_NAME)
    fun extractsContent_fromBaseStyle() {
        val entry = createEntry { setStyle(null) }

        val content = extractContent(entry)

        assertThat(content).isNotNull()
        assertThat(content?.style).isEqualTo(Style.Base)
    }

    @Test
    @EnableFlags(PromotedNotificationUi.FLAG_NAME, StatusBarNotifChips.FLAG_NAME)
    fun extractsContent_fromBigPictureStyle() {
+14 −10
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@ private val PromotedNotificationContentModel.layoutResource: Int?
    get() {
        return if (Flags.notificationsRedesignTemplates()) {
            when (style) {
                Style.Base -> R.layout.notification_2025_template_expanded_base
                Style.BigPicture -> R.layout.notification_2025_template_expanded_big_picture
                Style.BigText -> R.layout.notification_2025_template_expanded_big_text
                Style.Call -> R.layout.notification_2025_template_expanded_call
@@ -86,6 +87,7 @@ private val PromotedNotificationContentModel.layoutResource: Int?
            }
        } else {
            when (style) {
                Style.Base -> R.layout.notification_template_material_big_base
                Style.BigPicture -> R.layout.notification_template_material_big_picture
                Style.BigText -> R.layout.notification_template_material_big_text
                Style.Call -> R.layout.notification_template_material_big_call
@@ -133,6 +135,7 @@ private class AODPromotedNotificationViewUpdater(root: View) {

    fun update(content: PromotedNotificationContentModel) {
        when (content.style) {
            Style.Base -> updateBase(content)
            Style.BigPicture -> updateBigPicture(content)
            Style.BigText -> updateBigText(content)
            Style.Call -> updateCall(content)
@@ -141,20 +144,24 @@ private class AODPromotedNotificationViewUpdater(root: View) {
        }
    }

    private fun updateBigPicture(content: PromotedNotificationContentModel) {
    private fun updateBase(
        content: PromotedNotificationContentModel,
        textView: ImageFloatingTextView? = null,
    ) {
        updateHeader(content)

        updateTitle(title, content)
        updateText(text, content)
        updateText(textView ?: text, content)
    }

    private fun updateBigPicture(content: PromotedNotificationContentModel) {
        updateBase(content)

        bigPicture?.visibility = GONE
    }

    private fun updateBigText(content: PromotedNotificationContentModel) {
        updateHeader(content)

        updateTitle(title, content)
        updateText(bigText, content)
        updateBase(content, textView = bigText)
    }

    private fun updateCall(content: PromotedNotificationContentModel) {
@@ -164,10 +171,7 @@ private class AODPromotedNotificationViewUpdater(root: View) {
    }

    private fun updateProgress(content: PromotedNotificationContentModel) {
        updateHeader(content)

        updateTitle(title, content)
        updateText(text, content)
        updateBase(content)

        updateNewProgressBar(content)
    }
+11 −8
Original line number Diff line number Diff line
@@ -96,8 +96,7 @@ constructor(
                primaryTextColor = colorsFromNotif.primaryTextColor,
            )

        recoveredBuilder.style?.extractContent(contentBuilder)
            ?: run { contentBuilder.style = Style.Ineligible }
        recoveredBuilder.extractStyleContent(contentBuilder)

        return contentBuilder.build().also { logger.logExtractionSucceeded(entry, it) }
    }
@@ -132,28 +131,32 @@ private fun Notification.extractWhen(): When? {
    }
}

private fun Notification.Style.extractContent(
private fun Notification.Builder.extractStyleContent(
    contentBuilder: PromotedNotificationContentModel.Builder
) {
    val style = this.style

    contentBuilder.style =
        when (this) {
        when (style) {
            null -> Style.Base

            is BigPictureStyle -> {
                extractContent(contentBuilder)
                style.extractContent(contentBuilder)
                Style.BigPicture
            }

            is BigTextStyle -> {
                extractContent(contentBuilder)
                style.extractContent(contentBuilder)
                Style.BigText
            }

            is CallStyle -> {
                extractContent(contentBuilder)
                style.extractContent(contentBuilder)
                Style.Call
            }

            is ProgressStyle -> {
                extractContent(contentBuilder)
                style.extractContent(contentBuilder)
                Style.Progress
            }

+1 −0
Original line number Diff line number Diff line
@@ -131,6 +131,7 @@ data class PromotedNotificationContentModel(

    /** The promotion-eligible style of a notification, or [Style.Ineligible] if not. */
    enum class Style {
        Base, // style == null
        BigPicture,
        BigText,
        Call,