diff options
6 files changed, 30 insertions, 104 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/call/ui/viewmodel/CallChipViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/call/ui/viewmodel/CallChipViewModelTest.kt index dbe8f8226d43..c7b3175a636f 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/call/ui/viewmodel/CallChipViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/call/ui/viewmodel/CallChipViewModelTest.kt @@ -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 diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/notification/ui/viewmodel/NotifChipsViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/notification/ui/viewmodel/NotifChipsViewModelTest.kt index 192ad879891f..aaa9b58a45df 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/notification/ui/viewmodel/NotifChipsViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/notification/ui/viewmodel/NotifChipsViewModelTest.kt @@ -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 diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/ui/viewmodel/ChipTransitionHelperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/ui/viewmodel/ChipTransitionHelperTest.kt index 60030ad4e428..e3a84fd2c2eb 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/ui/viewmodel/ChipTransitionHelperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/ui/viewmodel/ChipTransitionHelperTest.kt @@ -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, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/chips/call/ui/viewmodel/CallChipViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/chips/call/ui/viewmodel/CallChipViewModel.kt index a2c0226addfa..f466278e15a8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/chips/call/ui/viewmodel/CallChipViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/chips/call/ui/viewmodel/CallChipViewModel.kt @@ -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) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/chips/notification/ui/viewmodel/NotifChipsViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/chips/notification/ui/viewmodel/NotifChipsViewModel.kt index 8357df42937e..2d6102e310f2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/chips/notification/ui/viewmodel/NotifChipsViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/chips/notification/ui/viewmodel/NotifChipsViewModel.kt @@ -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. diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/model/ColorsModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/model/ColorsModel.kt index 25f90f9a0065..edcae7d71856 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/model/ColorsModel.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/model/ColorsModel.kt @@ -21,7 +21,6 @@ import android.content.res.ColorStateList import androidx.annotation.ColorInt import com.android.settingslib.Utils import com.android.systemui.res.R -import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModel /** Model representing how the chip in the status bar should be colored. */ sealed interface ColorsModel { @@ -31,8 +30,10 @@ sealed interface ColorsModel { /** The color for the text (and icon) on the chip. */ @ColorInt fun text(context: Context): Int - /** The chip should match the theme's primary color. */ - data object Themed : ColorsModel { + /** The chip should match the theme's primary accent color. */ + // TODO(b/347717946): The chip's color isn't getting updated when the user switches theme, it + // only gets updated when a different configuration change happens, like a rotation. + data object AccentThemed : ColorsModel { override fun background(context: Context): ColorStateList = Utils.getColorAttr(context, com.android.internal.R.attr.colorAccent) @@ -40,6 +41,19 @@ sealed interface ColorsModel { Utils.getColorAttrDefaultColor(context, com.android.internal.R.attr.colorPrimary) } + /** The chip should match the system theme main color. */ + // TODO(b/347717946): The chip's color isn't getting updated when the user switches theme, it + // only gets updated when a different configuration change happens, like a rotation. + data object SystemThemed : ColorsModel { + override fun background(context: Context): ColorStateList = + ColorStateList.valueOf( + context.getColor(com.android.internal.R.color.materialColorSurfaceDim) + ) + + override fun text(context: Context) = + context.getColor(com.android.internal.R.color.materialColorOnSurface) + } + /** The chip should have the given background color and primary text color. */ data class Custom(val backgroundColorInt: Int, val primaryTextColorInt: Int) : ColorsModel { override fun background(context: Context): ColorStateList = @@ -56,14 +70,4 @@ sealed interface ColorsModel { override fun text(context: Context) = context.getColor(android.R.color.white) } - - companion object { - /** Converts the promoted notification colors to a [Custom] colors model. */ - fun PromotedNotificationContentModel.toCustomColorsModel(): Custom { - return Custom( - backgroundColorInt = this.colors.backgroundColor, - primaryTextColorInt = this.colors.primaryTextColor, - ) - } - } } |