Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/notification/ui/viewmodel/NotifChipsViewModelTest.kt +47 −7 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import com.android.systemui.statusbar.chips.notification.shared.StatusBarNotifCh 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.core.StatusBarRootModernization import com.android.systemui.statusbar.notification.data.model.activeNotificationModel import com.android.systemui.statusbar.notification.data.repository.ActiveNotificationsStore import com.android.systemui.statusbar.notification.data.repository.UnconfinedFakeHeadsUpRowRepository Loading @@ -44,6 +45,7 @@ import com.android.systemui.statusbar.notification.headsup.PinnedStatus import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModel import com.android.systemui.statusbar.notification.shared.ActiveNotificationModel import com.android.systemui.statusbar.notification.stack.data.repository.headsUpNotificationRepository import com.android.systemui.statusbar.phone.ongoingcall.StatusBarChipsModernization import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlin.test.Test Loading Loading @@ -629,22 +631,26 @@ class NotifChipsViewModelTest : SysuiTestCase() { } @Test @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) fun chips_clickingChipNotifiesInteractor() = @DisableFlags( FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY, StatusBarRootModernization.FLAG_NAME, StatusBarChipsModernization.FLAG_NAME, ) fun chips_chipsModernizationDisabled_clickingChipNotifiesInteractor() = kosmos.runTest { val latest by collectLastValue(underTest.chips) val latestChipTap by val latestChipTapKey by collectLastValue( kosmos.statusBarNotificationChipsInteractor.promotedNotificationChipTapEvent ) val key = "clickTest" setNotifs( listOf( activeNotificationModel( key = "clickTest", key, statusBarChipIcon = createStatusBarIconViewOrNull(), promotedContent = PromotedNotificationContentModel.Builder("clickTest").build(), promotedContent = PromotedNotificationContentModel.Builder(key).build(), ) ) ) Loading @@ -652,7 +658,41 @@ class NotifChipsViewModelTest : SysuiTestCase() { chip.onClickListenerLegacy!!.onClick(mock<View>()) assertThat(latestChipTap).isEqualTo("clickTest") assertThat(latestChipTapKey).isEqualTo(key) } @Test @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) @EnableFlags(StatusBarRootModernization.FLAG_NAME, StatusBarChipsModernization.FLAG_NAME) fun chips_chipsModernizationEnabled_clickingChipNotifiesInteractor() = kosmos.runTest { val latest by collectLastValue(underTest.chips) val latestChipTapKey by collectLastValue( kosmos.statusBarNotificationChipsInteractor.promotedNotificationChipTapEvent ) val key = "clickTest" setNotifs( listOf( activeNotificationModel( key, statusBarChipIcon = createStatusBarIconViewOrNull(), promotedContent = PromotedNotificationContentModel.Builder(key).build(), ) ) ) val chip = latest!![0] assertThat(chip.clickBehavior) .isInstanceOf( OngoingActivityChipModel.ClickBehavior.ShowHeadsUpNotification::class.java ) (chip.clickBehavior as OngoingActivityChipModel.ClickBehavior.ShowHeadsUpNotification) .onClick() assertThat(latestChipTapKey).isEqualTo(key) } private fun setNotifs(notifs: List<ActiveNotificationModel>) { Loading packages/SystemUI/src/com/android/systemui/statusbar/chips/notification/ui/viewmodel/NotifChipsViewModel.kt +24 −16 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import com.android.systemui.statusbar.notification.domain.interactor.HeadsUpNoti import com.android.systemui.statusbar.notification.domain.model.TopPinnedState import com.android.systemui.statusbar.notification.headsup.PinnedStatus import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModel import com.android.systemui.statusbar.phone.ongoingcall.StatusBarChipsModernization import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.Flow Loading Loading @@ -73,17 +74,24 @@ constructor( OngoingActivityChipModel.ChipIcon.StatusBarNotificationIcon(this.key) } val colors = this.promotedContent.toCustomColorsModel() val onClickListener = View.OnClickListener { val clickListener: () -> Unit = { // The notification pipeline needs everything to run on the main thread, so keep // this event on the main thread. applicationScope.launch { notifChipsInteractor.onPromotedNotificationChipTapped( this@toActivityChipModel.key ) notifChipsInteractor.onPromotedNotificationChipTapped(this@toActivityChipModel.key) } } val clickBehavior = OngoingActivityChipModel.ClickBehavior.None val onClickListenerLegacy = View.OnClickListener { StatusBarChipsModernization.assertInLegacyMode() clickListener.invoke() } val clickBehavior = OngoingActivityChipModel.ClickBehavior.ShowHeadsUpNotification({ StatusBarChipsModernization.assertInNewMode() clickListener.invoke() }) val isShowingHeadsUpFromChipTap = headsUpState is TopPinnedState.Pinned && Loading @@ -95,7 +103,7 @@ constructor( return OngoingActivityChipModel.Shown.IconOnly( icon, colors, onClickListener, onClickListenerLegacy, clickBehavior, ) } Loading @@ -105,7 +113,7 @@ constructor( icon, colors, this.promotedContent.shortCriticalText, onClickListener, onClickListenerLegacy, clickBehavior, ) } Loading @@ -121,7 +129,7 @@ constructor( return OngoingActivityChipModel.Shown.IconOnly( icon, colors, onClickListener, onClickListenerLegacy, clickBehavior, ) } Loading @@ -130,7 +138,7 @@ constructor( return OngoingActivityChipModel.Shown.IconOnly( icon, colors, onClickListener, onClickListenerLegacy, clickBehavior, ) } Loading @@ -140,7 +148,7 @@ constructor( icon, colors, time = this.promotedContent.time.time, onClickListener, onClickListenerLegacy, clickBehavior, ) } Loading @@ -149,7 +157,7 @@ constructor( icon, colors, startTimeMs = this.promotedContent.time.time, onClickListener, onClickListenerLegacy, clickBehavior, ) } Loading @@ -159,7 +167,7 @@ constructor( icon, colors, startTimeMs = this.promotedContent.time.time, onClickListener, onClickListenerLegacy, clickBehavior, ) } Loading packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/compose/OngoingActivityChip.kt +3 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,9 @@ fun OngoingActivityChip(model: OngoingActivityChipModel.Shown, modifier: Modifie ChipBody(model, onClick = { clickBehavior.onClick(expandable) }) } } is OngoingActivityChipModel.ClickBehavior.ShowHeadsUpNotification -> { ChipBody(model, onClick = { clickBehavior.onClick() }) } is OngoingActivityChipModel.ClickBehavior.None -> { ChipBody(model, modifier = modifier) Loading packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/model/OngoingActivityChipModel.kt +3 −0 Original line number Diff line number Diff line Loading @@ -170,5 +170,8 @@ sealed class OngoingActivityChipModel { /** The chip expands into a dialog or activity on click. */ data class ExpandAction(val onClick: (Expandable) -> Unit) : ClickBehavior /** Clicking the chip will show the heads up notification associated with the chip. */ data class ShowHeadsUpNotification(val onClick: () -> Unit) : ClickBehavior } } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/notification/ui/viewmodel/NotifChipsViewModelTest.kt +47 −7 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import com.android.systemui.statusbar.chips.notification.shared.StatusBarNotifCh 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.core.StatusBarRootModernization import com.android.systemui.statusbar.notification.data.model.activeNotificationModel import com.android.systemui.statusbar.notification.data.repository.ActiveNotificationsStore import com.android.systemui.statusbar.notification.data.repository.UnconfinedFakeHeadsUpRowRepository Loading @@ -44,6 +45,7 @@ import com.android.systemui.statusbar.notification.headsup.PinnedStatus import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModel import com.android.systemui.statusbar.notification.shared.ActiveNotificationModel import com.android.systemui.statusbar.notification.stack.data.repository.headsUpNotificationRepository import com.android.systemui.statusbar.phone.ongoingcall.StatusBarChipsModernization import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlin.test.Test Loading Loading @@ -629,22 +631,26 @@ class NotifChipsViewModelTest : SysuiTestCase() { } @Test @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) fun chips_clickingChipNotifiesInteractor() = @DisableFlags( FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY, StatusBarRootModernization.FLAG_NAME, StatusBarChipsModernization.FLAG_NAME, ) fun chips_chipsModernizationDisabled_clickingChipNotifiesInteractor() = kosmos.runTest { val latest by collectLastValue(underTest.chips) val latestChipTap by val latestChipTapKey by collectLastValue( kosmos.statusBarNotificationChipsInteractor.promotedNotificationChipTapEvent ) val key = "clickTest" setNotifs( listOf( activeNotificationModel( key = "clickTest", key, statusBarChipIcon = createStatusBarIconViewOrNull(), promotedContent = PromotedNotificationContentModel.Builder("clickTest").build(), promotedContent = PromotedNotificationContentModel.Builder(key).build(), ) ) ) Loading @@ -652,7 +658,41 @@ class NotifChipsViewModelTest : SysuiTestCase() { chip.onClickListenerLegacy!!.onClick(mock<View>()) assertThat(latestChipTap).isEqualTo("clickTest") assertThat(latestChipTapKey).isEqualTo(key) } @Test @DisableFlags(FLAG_PROMOTE_NOTIFICATIONS_AUTOMATICALLY) @EnableFlags(StatusBarRootModernization.FLAG_NAME, StatusBarChipsModernization.FLAG_NAME) fun chips_chipsModernizationEnabled_clickingChipNotifiesInteractor() = kosmos.runTest { val latest by collectLastValue(underTest.chips) val latestChipTapKey by collectLastValue( kosmos.statusBarNotificationChipsInteractor.promotedNotificationChipTapEvent ) val key = "clickTest" setNotifs( listOf( activeNotificationModel( key, statusBarChipIcon = createStatusBarIconViewOrNull(), promotedContent = PromotedNotificationContentModel.Builder(key).build(), ) ) ) val chip = latest!![0] assertThat(chip.clickBehavior) .isInstanceOf( OngoingActivityChipModel.ClickBehavior.ShowHeadsUpNotification::class.java ) (chip.clickBehavior as OngoingActivityChipModel.ClickBehavior.ShowHeadsUpNotification) .onClick() assertThat(latestChipTapKey).isEqualTo(key) } private fun setNotifs(notifs: List<ActiveNotificationModel>) { Loading
packages/SystemUI/src/com/android/systemui/statusbar/chips/notification/ui/viewmodel/NotifChipsViewModel.kt +24 −16 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import com.android.systemui.statusbar.notification.domain.interactor.HeadsUpNoti import com.android.systemui.statusbar.notification.domain.model.TopPinnedState import com.android.systemui.statusbar.notification.headsup.PinnedStatus import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModel import com.android.systemui.statusbar.phone.ongoingcall.StatusBarChipsModernization import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.Flow Loading Loading @@ -73,17 +74,24 @@ constructor( OngoingActivityChipModel.ChipIcon.StatusBarNotificationIcon(this.key) } val colors = this.promotedContent.toCustomColorsModel() val onClickListener = View.OnClickListener { val clickListener: () -> Unit = { // The notification pipeline needs everything to run on the main thread, so keep // this event on the main thread. applicationScope.launch { notifChipsInteractor.onPromotedNotificationChipTapped( this@toActivityChipModel.key ) notifChipsInteractor.onPromotedNotificationChipTapped(this@toActivityChipModel.key) } } val clickBehavior = OngoingActivityChipModel.ClickBehavior.None val onClickListenerLegacy = View.OnClickListener { StatusBarChipsModernization.assertInLegacyMode() clickListener.invoke() } val clickBehavior = OngoingActivityChipModel.ClickBehavior.ShowHeadsUpNotification({ StatusBarChipsModernization.assertInNewMode() clickListener.invoke() }) val isShowingHeadsUpFromChipTap = headsUpState is TopPinnedState.Pinned && Loading @@ -95,7 +103,7 @@ constructor( return OngoingActivityChipModel.Shown.IconOnly( icon, colors, onClickListener, onClickListenerLegacy, clickBehavior, ) } Loading @@ -105,7 +113,7 @@ constructor( icon, colors, this.promotedContent.shortCriticalText, onClickListener, onClickListenerLegacy, clickBehavior, ) } Loading @@ -121,7 +129,7 @@ constructor( return OngoingActivityChipModel.Shown.IconOnly( icon, colors, onClickListener, onClickListenerLegacy, clickBehavior, ) } Loading @@ -130,7 +138,7 @@ constructor( return OngoingActivityChipModel.Shown.IconOnly( icon, colors, onClickListener, onClickListenerLegacy, clickBehavior, ) } Loading @@ -140,7 +148,7 @@ constructor( icon, colors, time = this.promotedContent.time.time, onClickListener, onClickListenerLegacy, clickBehavior, ) } Loading @@ -149,7 +157,7 @@ constructor( icon, colors, startTimeMs = this.promotedContent.time.time, onClickListener, onClickListenerLegacy, clickBehavior, ) } Loading @@ -159,7 +167,7 @@ constructor( icon, colors, startTimeMs = this.promotedContent.time.time, onClickListener, onClickListenerLegacy, clickBehavior, ) } Loading
packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/compose/OngoingActivityChip.kt +3 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,9 @@ fun OngoingActivityChip(model: OngoingActivityChipModel.Shown, modifier: Modifie ChipBody(model, onClick = { clickBehavior.onClick(expandable) }) } } is OngoingActivityChipModel.ClickBehavior.ShowHeadsUpNotification -> { ChipBody(model, onClick = { clickBehavior.onClick() }) } is OngoingActivityChipModel.ClickBehavior.None -> { ChipBody(model, modifier = modifier) Loading
packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/model/OngoingActivityChipModel.kt +3 −0 Original line number Diff line number Diff line Loading @@ -170,5 +170,8 @@ sealed class OngoingActivityChipModel { /** The chip expands into a dialog or activity on click. */ data class ExpandAction(val onClick: (Expandable) -> Unit) : ClickBehavior /** Clicking the chip will show the heads up notification associated with the chip. */ data class ShowHeadsUpNotification(val onClick: () -> Unit) : ClickBehavior } }