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

Commit a411d8c8 authored by Caitlin Shkuratov's avatar Caitlin Shkuratov
Browse files

[SB][Notif] Update notif chips to use system theme colors.

Bug: 394611253
Flag: com.android.systemui.status_bar_notification_chips
Test: Trigger notification chip -> verify color matches system theme for
both light and dark mode, for both Compose & non-Compose chips
Test: atest CallChipViewModelTest NotifChipsViewModelTest

Change-Id: I04279015cf8f5501ffdd1091666d5c42b369ed75
parent 436c93d6
Loading
Loading
Loading
Loading
+4 −71
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@ import com.android.systemui.kosmos.testScope
import com.android.systemui.plugins.activityStarter
import com.android.systemui.res.R
import com.android.systemui.statusbar.StatusBarIconView
import com.android.systemui.statusbar.chips.notification.shared.StatusBarNotifChips
import com.android.systemui.statusbar.chips.ui.model.ColorsModel
import com.android.systemui.statusbar.chips.ui.model.OngoingActivityChipModel
import com.android.systemui.statusbar.chips.ui.view.ChipBackgroundContainer
@@ -265,91 +264,25 @@ class CallChipViewModelTest : SysuiTestCase() {
        }

    @Test
    fun chip_positiveStartTime_notPromoted_colorsAreThemed() =
    fun chip_positiveStartTime_colorsAreAccentThemed() =
        testScope.runTest {
            val latest by collectLastValue(underTest.chip)

            repo.setOngoingCallState(inCallModel(startTimeMs = 1000, promotedContent = null))

            assertThat((latest as OngoingActivityChipModel.Active).colors)
                .isEqualTo(ColorsModel.Themed)
                .isEqualTo(ColorsModel.AccentThemed)
        }

    @Test
    fun chip_zeroStartTime_notPromoted_colorsAreThemed() =
    fun chip_zeroStartTime_colorsAreAccentThemed() =
        testScope.runTest {
            val latest by collectLastValue(underTest.chip)

            repo.setOngoingCallState(inCallModel(startTimeMs = 0, promotedContent = null))

            assertThat((latest as OngoingActivityChipModel.Active).colors)
                .isEqualTo(ColorsModel.Themed)
        }

    @Test
    @DisableFlags(StatusBarNotifChips.FLAG_NAME)
    fun chip_positiveStartTime_promoted_notifChipsFlagOff_colorsAreThemed() =
        testScope.runTest {
            val latest by collectLastValue(underTest.chip)

            repo.setOngoingCallState(
                inCallModel(startTimeMs = 1000, promotedContent = PROMOTED_CONTENT_WITH_COLOR)
            )

            assertThat((latest as OngoingActivityChipModel.Active).colors)
                .isEqualTo(ColorsModel.Themed)
        }

    @Test
    @DisableFlags(StatusBarNotifChips.FLAG_NAME)
    fun chip_zeroStartTime_promoted_notifChipsFlagOff_colorsAreThemed() =
        testScope.runTest {
            val latest by collectLastValue(underTest.chip)

            repo.setOngoingCallState(
                inCallModel(startTimeMs = 0, promotedContent = PROMOTED_CONTENT_WITH_COLOR)
            )

            assertThat((latest as OngoingActivityChipModel.Active).colors)
                .isEqualTo(ColorsModel.Themed)
        }

    @Test
    @EnableFlags(StatusBarNotifChips.FLAG_NAME)
    fun chip_positiveStartTime_promoted_notifChipsFlagOn_colorsAreCustom() =
        testScope.runTest {
            val latest by collectLastValue(underTest.chip)

            repo.setOngoingCallState(
                inCallModel(startTimeMs = 1000, promotedContent = PROMOTED_CONTENT_WITH_COLOR)
            )

            assertThat((latest as OngoingActivityChipModel.Active).colors)
                .isEqualTo(
                    ColorsModel.Custom(
                        backgroundColorInt = PROMOTED_BACKGROUND_COLOR,
                        primaryTextColorInt = PROMOTED_PRIMARY_TEXT_COLOR,
                    )
                )
        }

    @Test
    @EnableFlags(StatusBarNotifChips.FLAG_NAME)
    fun chip_zeroStartTime_promoted_notifChipsFlagOff_colorsAreCustom() =
        testScope.runTest {
            val latest by collectLastValue(underTest.chip)

            repo.setOngoingCallState(
                inCallModel(startTimeMs = 0, promotedContent = PROMOTED_CONTENT_WITH_COLOR)
            )

            assertThat((latest as OngoingActivityChipModel.Active).colors)
                .isEqualTo(
                    ColorsModel.Custom(
                        backgroundColorInt = PROMOTED_BACKGROUND_COLOR,
                        primaryTextColorInt = PROMOTED_PRIMARY_TEXT_COLOR,
                    )
                )
                .isEqualTo(ColorsModel.AccentThemed)
        }

    @Test
+2 −5
Original line number Diff line number Diff line
@@ -186,7 +186,7 @@ class NotifChipsViewModelTest : SysuiTestCase() {

    @Test
    @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY)
    fun chips_onePromotedNotif_colorMatches() =
    fun chips_onePromotedNotif_colorIsSystemThemed() =
        kosmos.runTest {
            val latest by collectLastValue(underTest.chips)

@@ -209,10 +209,7 @@ class NotifChipsViewModelTest : SysuiTestCase() {
            )

            assertThat(latest).hasSize(1)
            val colors = latest!![0].colors
            assertThat(colors).isInstanceOf(ColorsModel.Custom::class.java)
            assertThat((colors as ColorsModel.Custom).backgroundColorInt).isEqualTo(56)
            assertThat((colors as ColorsModel.Custom).primaryTextColorInt).isEqualTo(89)
            assertThat(latest!![0].colors).isEqualTo(ColorsModel.SystemThemed)
        }

    @Test
+4 −4
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ class ChipTransitionHelperTest : SysuiTestCase() {
                OngoingActivityChipModel.Active.Timer(
                    key = KEY,
                    icon = createIcon(R.drawable.ic_cake),
                    colors = ColorsModel.Themed,
                    colors = ColorsModel.AccentThemed,
                    startTimeMs = 100L,
                    onClickListenerLegacy = null,
                    clickBehavior = OngoingActivityChipModel.ClickBehavior.None,
@@ -68,7 +68,7 @@ class ChipTransitionHelperTest : SysuiTestCase() {
                OngoingActivityChipModel.Active.IconOnly(
                    key = KEY,
                    icon = createIcon(R.drawable.ic_hotspot),
                    colors = ColorsModel.Themed,
                    colors = ColorsModel.AccentThemed,
                    onClickListenerLegacy = null,
                    clickBehavior = OngoingActivityChipModel.ClickBehavior.None,
                )
@@ -90,7 +90,7 @@ class ChipTransitionHelperTest : SysuiTestCase() {
                OngoingActivityChipModel.Active.Timer(
                    key = KEY,
                    icon = createIcon(R.drawable.ic_cake),
                    colors = ColorsModel.Themed,
                    colors = ColorsModel.AccentThemed,
                    startTimeMs = 100L,
                    onClickListenerLegacy = null,
                    clickBehavior = OngoingActivityChipModel.ClickBehavior.None,
@@ -132,7 +132,7 @@ class ChipTransitionHelperTest : SysuiTestCase() {
                OngoingActivityChipModel.Active.Timer(
                    key = KEY,
                    icon = createIcon(R.drawable.ic_cake),
                    colors = ColorsModel.Themed,
                    colors = ColorsModel.AccentThemed,
                    startTimeMs = 100L,
                    onClickListenerLegacy = null,
                    clickBehavior = OngoingActivityChipModel.ClickBehavior.None,
+1 −8
Original line number Diff line number Diff line
@@ -32,9 +32,7 @@ import com.android.systemui.res.R
import com.android.systemui.statusbar.chips.StatusBarChipLogTags.pad
import com.android.systemui.statusbar.chips.StatusBarChipsLog
import com.android.systemui.statusbar.chips.call.domain.interactor.CallChipInteractor
import com.android.systemui.statusbar.chips.notification.shared.StatusBarNotifChips
import com.android.systemui.statusbar.chips.ui.model.ColorsModel
import com.android.systemui.statusbar.chips.ui.model.ColorsModel.Companion.toCustomColorsModel
import com.android.systemui.statusbar.chips.ui.model.OngoingActivityChipModel
import com.android.systemui.statusbar.chips.ui.view.ChipBackgroundContainer
import com.android.systemui.statusbar.chips.ui.viewmodel.OngoingActivityChipViewModel
@@ -86,12 +84,7 @@ constructor(
                                OngoingActivityChipModel.ChipIcon.SingleColorIcon(phoneIcon)
                            }

                        val colors =
                            if (StatusBarNotifChips.isEnabled && state.promotedContent != null) {
                                state.promotedContent.toCustomColorsModel()
                            } else {
                                ColorsModel.Themed
                            }
                        val colors = ColorsModel.AccentThemed

                        // This block mimics OngoingCallController#updateChip.
                        if (state.startTimeMs <= 0L) {
+2 −3
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ import com.android.systemui.res.R
import com.android.systemui.statusbar.chips.notification.domain.interactor.StatusBarNotificationChipsInteractor
import com.android.systemui.statusbar.chips.notification.domain.model.NotificationChipModel
import com.android.systemui.statusbar.chips.notification.shared.StatusBarNotifChips
import com.android.systemui.statusbar.chips.ui.model.ColorsModel.Companion.toCustomColorsModel
import com.android.systemui.statusbar.chips.ui.model.ColorsModel
import com.android.systemui.statusbar.chips.ui.model.OngoingActivityChipModel
import com.android.systemui.statusbar.core.StatusBarConnectedDisplays
import com.android.systemui.statusbar.notification.domain.interactor.HeadsUpNotificationInteractor
@@ -85,8 +85,7 @@ constructor(
                    contentDescription,
                )
            }
        val colors = this.promotedContent.toCustomColorsModel()

        val colors = ColorsModel.SystemThemed
        val clickListener: () -> Unit = {
            // The notification pipeline needs everything to run on the main thread, so keep
            // this event on the main thread.
Loading