diff options
25 files changed, 438 insertions, 411 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 03c07510ce53..dbe8f8226d43 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 @@ -88,7 +88,7 @@ class CallChipViewModelTest : SysuiTestCase() { repo.setOngoingCallState(OngoingCallModel.NoCall) - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Inactive::class.java) } @Test @@ -98,7 +98,7 @@ class CallChipViewModelTest : SysuiTestCase() { repo.setOngoingCallState(inCallModel(startTimeMs = 0)) - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown.IconOnly::class.java) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active.IconOnly::class.java) } @Test @@ -108,7 +108,7 @@ class CallChipViewModelTest : SysuiTestCase() { repo.setOngoingCallState(inCallModel(startTimeMs = -2)) - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown.IconOnly::class.java) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active.IconOnly::class.java) } @Test @@ -118,7 +118,7 @@ class CallChipViewModelTest : SysuiTestCase() { repo.setOngoingCallState(inCallModel(startTimeMs = 345)) - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown.Timer::class.java) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active.Timer::class.java) } @Test @@ -135,7 +135,7 @@ class CallChipViewModelTest : SysuiTestCase() { // started 2000ms ago (1000 - 3000). The OngoingActivityChipModel start time needs to be // relative to elapsedRealtime, so it should be 2000ms before the elapsed realtime set // on the clock. - assertThat((latest as OngoingActivityChipModel.Shown.Timer).startTimeMs) + assertThat((latest as OngoingActivityChipModel.Active.Timer).startTimeMs) .isEqualTo(398_000) } @@ -150,12 +150,12 @@ class CallChipViewModelTest : SysuiTestCase() { inCallModel(startTimeMs = 1000, notificationIcon = null, notificationKey = notifKey) ) - assertThat((latest as OngoingActivityChipModel.Shown).icon) + assertThat((latest as OngoingActivityChipModel.Active).icon) .isInstanceOf( OngoingActivityChipModel.ChipIcon.StatusBarNotificationIcon::class.java ) val actualNotifKey = - (((latest as OngoingActivityChipModel.Shown).icon) + (((latest as OngoingActivityChipModel.Active).icon) as OngoingActivityChipModel.ChipIcon.StatusBarNotificationIcon) .notificationKey assertThat(actualNotifKey).isEqualTo(notifKey) @@ -176,10 +176,10 @@ class CallChipViewModelTest : SysuiTestCase() { ) ) - assertThat((latest as OngoingActivityChipModel.Shown).icon) + assertThat((latest as OngoingActivityChipModel.Active).icon) .isInstanceOf(OngoingActivityChipModel.ChipIcon.StatusBarView::class.java) val actualIcon = - (latest as OngoingActivityChipModel.Shown).icon + (latest as OngoingActivityChipModel.Active).icon as OngoingActivityChipModel.ChipIcon.StatusBarView assertThat(actualIcon.impl).isEqualTo(notifIcon) assertThat(actualIcon.contentDescription.loadContentDescription(context)) @@ -203,12 +203,12 @@ class CallChipViewModelTest : SysuiTestCase() { ) ) - assertThat((latest as OngoingActivityChipModel.Shown).icon) + assertThat((latest as OngoingActivityChipModel.Active).icon) .isInstanceOf( OngoingActivityChipModel.ChipIcon.StatusBarNotificationIcon::class.java ) val actualIcon = - (latest as OngoingActivityChipModel.Shown).icon + (latest as OngoingActivityChipModel.Active).icon as OngoingActivityChipModel.ChipIcon.StatusBarNotificationIcon assertThat(actualIcon.notificationKey).isEqualTo("notifKey") assertThat(actualIcon.contentDescription.loadContentDescription(context)) @@ -225,10 +225,10 @@ class CallChipViewModelTest : SysuiTestCase() { repo.setOngoingCallState(inCallModel(startTimeMs = 1000, notificationIcon = null)) - assertThat((latest as OngoingActivityChipModel.Shown).icon) + assertThat((latest as OngoingActivityChipModel.Active).icon) .isInstanceOf(OngoingActivityChipModel.ChipIcon.SingleColorIcon::class.java) val icon = - (((latest as OngoingActivityChipModel.Shown).icon) + (((latest as OngoingActivityChipModel.Active).icon) as OngoingActivityChipModel.ChipIcon.SingleColorIcon) .impl as Icon.Resource assertThat(icon.res).isEqualTo(com.android.internal.R.drawable.ic_phone) @@ -250,12 +250,12 @@ class CallChipViewModelTest : SysuiTestCase() { ) ) - assertThat((latest as OngoingActivityChipModel.Shown).icon) + assertThat((latest as OngoingActivityChipModel.Active).icon) .isInstanceOf( OngoingActivityChipModel.ChipIcon.StatusBarNotificationIcon::class.java ) val actualIcon = - (latest as OngoingActivityChipModel.Shown).icon + (latest as OngoingActivityChipModel.Active).icon as OngoingActivityChipModel.ChipIcon.StatusBarNotificationIcon assertThat(actualIcon.notificationKey).isEqualTo("notifKey") assertThat(actualIcon.contentDescription.loadContentDescription(context)) @@ -271,7 +271,7 @@ class CallChipViewModelTest : SysuiTestCase() { repo.setOngoingCallState(inCallModel(startTimeMs = 1000, promotedContent = null)) - assertThat((latest as OngoingActivityChipModel.Shown).colors) + assertThat((latest as OngoingActivityChipModel.Active).colors) .isEqualTo(ColorsModel.Themed) } @@ -282,7 +282,7 @@ class CallChipViewModelTest : SysuiTestCase() { repo.setOngoingCallState(inCallModel(startTimeMs = 0, promotedContent = null)) - assertThat((latest as OngoingActivityChipModel.Shown).colors) + assertThat((latest as OngoingActivityChipModel.Active).colors) .isEqualTo(ColorsModel.Themed) } @@ -296,7 +296,7 @@ class CallChipViewModelTest : SysuiTestCase() { inCallModel(startTimeMs = 1000, promotedContent = PROMOTED_CONTENT_WITH_COLOR) ) - assertThat((latest as OngoingActivityChipModel.Shown).colors) + assertThat((latest as OngoingActivityChipModel.Active).colors) .isEqualTo(ColorsModel.Themed) } @@ -310,7 +310,7 @@ class CallChipViewModelTest : SysuiTestCase() { inCallModel(startTimeMs = 0, promotedContent = PROMOTED_CONTENT_WITH_COLOR) ) - assertThat((latest as OngoingActivityChipModel.Shown).colors) + assertThat((latest as OngoingActivityChipModel.Active).colors) .isEqualTo(ColorsModel.Themed) } @@ -324,7 +324,7 @@ class CallChipViewModelTest : SysuiTestCase() { inCallModel(startTimeMs = 1000, promotedContent = PROMOTED_CONTENT_WITH_COLOR) ) - assertThat((latest as OngoingActivityChipModel.Shown).colors) + assertThat((latest as OngoingActivityChipModel.Active).colors) .isEqualTo( ColorsModel.Custom( backgroundColorInt = PROMOTED_BACKGROUND_COLOR, @@ -343,7 +343,7 @@ class CallChipViewModelTest : SysuiTestCase() { inCallModel(startTimeMs = 0, promotedContent = PROMOTED_CONTENT_WITH_COLOR) ) - assertThat((latest as OngoingActivityChipModel.Shown).colors) + assertThat((latest as OngoingActivityChipModel.Active).colors) .isEqualTo( ColorsModel.Custom( backgroundColorInt = PROMOTED_BACKGROUND_COLOR, @@ -361,13 +361,13 @@ class CallChipViewModelTest : SysuiTestCase() { // Start a call repo.setOngoingCallState(inCallModel(startTimeMs = 1000)) - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown::class.java) - assertThat((latest as OngoingActivityChipModel.Shown.Timer).startTimeMs) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active::class.java) + assertThat((latest as OngoingActivityChipModel.Active.Timer).startTimeMs) .isEqualTo(398_000) // End the call repo.setOngoingCallState(OngoingCallModel.NoCall) - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Inactive::class.java) // Let 100_000ms elapse kosmos.fakeSystemClock.setCurrentTimeMillis(103_000) @@ -375,8 +375,8 @@ class CallChipViewModelTest : SysuiTestCase() { // Start a new call, which started 1000ms ago repo.setOngoingCallState(inCallModel(startTimeMs = 102_000)) - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown::class.java) - assertThat((latest as OngoingActivityChipModel.Shown.Timer).startTimeMs) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active::class.java) + assertThat((latest as OngoingActivityChipModel.Active.Timer).startTimeMs) .isEqualTo(499_000) } @@ -388,7 +388,7 @@ class CallChipViewModelTest : SysuiTestCase() { repo.setOngoingCallState(inCallModel(startTimeMs = 1000, intent = null)) - assertThat((latest as OngoingActivityChipModel.Shown).onClickListenerLegacy).isNull() + assertThat((latest as OngoingActivityChipModel.Active).onClickListenerLegacy).isNull() } @Test @@ -399,7 +399,7 @@ class CallChipViewModelTest : SysuiTestCase() { val pendingIntent = mock<PendingIntent>() repo.setOngoingCallState(inCallModel(startTimeMs = 1000, intent = pendingIntent)) - val clickListener = (latest as OngoingActivityChipModel.Shown).onClickListenerLegacy + val clickListener = (latest as OngoingActivityChipModel.Active).onClickListenerLegacy assertThat(clickListener).isNotNull() clickListener!!.onClick(chipView) @@ -417,7 +417,7 @@ class CallChipViewModelTest : SysuiTestCase() { val pendingIntent = mock<PendingIntent>() repo.setOngoingCallState(inCallModel(startTimeMs = 0, intent = pendingIntent)) - val clickListener = (latest as OngoingActivityChipModel.Shown).onClickListenerLegacy + val clickListener = (latest as OngoingActivityChipModel.Active).onClickListenerLegacy assertThat(clickListener).isNotNull() @@ -440,7 +440,7 @@ class CallChipViewModelTest : SysuiTestCase() { intent = null, ) - assertThat((latest as OngoingActivityChipModel.Shown).clickBehavior) + assertThat((latest as OngoingActivityChipModel.Active).clickBehavior) .isInstanceOf(OngoingActivityChipModel.ClickBehavior.None::class.java) } @@ -457,7 +457,7 @@ class CallChipViewModelTest : SysuiTestCase() { intent = pendingIntent, ) - val clickBehavior = (latest as OngoingActivityChipModel.Shown).clickBehavior + val clickBehavior = (latest as OngoingActivityChipModel.Active).clickBehavior assertThat(clickBehavior) .isInstanceOf(OngoingActivityChipModel.ClickBehavior.ExpandAction::class.java) (clickBehavior as OngoingActivityChipModel.ClickBehavior.ExpandAction).onClick( @@ -482,7 +482,7 @@ class CallChipViewModelTest : SysuiTestCase() { intent = pendingIntent, ) - val clickBehavior = (latest as OngoingActivityChipModel.Shown).clickBehavior + val clickBehavior = (latest as OngoingActivityChipModel.Active).clickBehavior assertThat(clickBehavior) .isInstanceOf(OngoingActivityChipModel.ClickBehavior.ExpandAction::class.java) (clickBehavior as OngoingActivityChipModel.ClickBehavior.ExpandAction).onClick( diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/casttootherdevice/ui/viewmodel/CastToOtherDeviceChipViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/casttootherdevice/ui/viewmodel/CastToOtherDeviceChipViewModelTest.kt index fcf8c834dc12..cd3c8cdcd6e9 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/casttootherdevice/ui/viewmodel/CastToOtherDeviceChipViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/casttootherdevice/ui/viewmodel/CastToOtherDeviceChipViewModelTest.kt @@ -119,7 +119,7 @@ class CastToOtherDeviceChipViewModelTest : SysuiTestCase() { mediaProjectionRepo.mediaProjectionState.value = MediaProjectionState.NotProjecting - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Inactive::class.java) } @Test @@ -135,9 +135,9 @@ class CastToOtherDeviceChipViewModelTest : SysuiTestCase() { createTask(taskId = 1), ) - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown.Timer::class.java) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active.Timer::class.java) val icon = - (((latest as OngoingActivityChipModel.Shown).icon) + (((latest as OngoingActivityChipModel.Active).icon) as OngoingActivityChipModel.ChipIcon.SingleColorIcon) .impl as Icon.Resource assertThat(icon.res).isEqualTo(R.drawable.ic_cast_connected) @@ -157,9 +157,9 @@ class CastToOtherDeviceChipViewModelTest : SysuiTestCase() { hostPackage = CAST_TO_OTHER_DEVICES_PACKAGE ) - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown.IconOnly::class.java) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active.IconOnly::class.java) val icon = - (((latest as OngoingActivityChipModel.Shown).icon) + (((latest as OngoingActivityChipModel.Active).icon) as OngoingActivityChipModel.ChipIcon.SingleColorIcon) .impl as Icon.Resource assertThat(icon.res).isEqualTo(R.drawable.ic_cast_connected) @@ -177,9 +177,9 @@ class CastToOtherDeviceChipViewModelTest : SysuiTestCase() { mediaProjectionRepo.mediaProjectionState.value = MediaProjectionState.Projecting.EntireScreen(CAST_TO_OTHER_DEVICES_PACKAGE) - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown.Timer::class.java) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active.Timer::class.java) val icon = - (((latest as OngoingActivityChipModel.Shown).icon) + (((latest as OngoingActivityChipModel.Active).icon) as OngoingActivityChipModel.ChipIcon.SingleColorIcon) .impl as Icon.Resource assertThat(icon.res).isEqualTo(R.drawable.ic_cast_connected) @@ -195,7 +195,7 @@ class CastToOtherDeviceChipViewModelTest : SysuiTestCase() { mediaRouterRepo.castDevices.value = emptyList() - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Inactive::class.java) } @Test @@ -215,9 +215,9 @@ class CastToOtherDeviceChipViewModelTest : SysuiTestCase() { ) ) - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown.IconOnly::class.java) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active.IconOnly::class.java) val icon = - (((latest as OngoingActivityChipModel.Shown).icon) + (((latest as OngoingActivityChipModel.Active).icon) as OngoingActivityChipModel.ChipIcon.SingleColorIcon) .impl as Icon.Resource assertThat(icon.res).isEqualTo(R.drawable.ic_cast_connected) @@ -245,9 +245,9 @@ class CastToOtherDeviceChipViewModelTest : SysuiTestCase() { ) // Only the projection info will show a timer - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown.Timer::class.java) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active.Timer::class.java) val icon = - (((latest as OngoingActivityChipModel.Shown).icon) + (((latest as OngoingActivityChipModel.Active).icon) as OngoingActivityChipModel.ChipIcon.SingleColorIcon) .impl as Icon.Resource assertThat(icon.res).isEqualTo(R.drawable.ic_cast_connected) @@ -265,7 +265,7 @@ class CastToOtherDeviceChipViewModelTest : SysuiTestCase() { mediaProjectionRepo.mediaProjectionState.value = MediaProjectionState.Projecting.EntireScreen(CAST_TO_OTHER_DEVICES_PACKAGE) - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown::class.java) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active::class.java) // WHEN the stop action on the dialog is clicked val dialogStopAction = @@ -279,13 +279,13 @@ class CastToOtherDeviceChipViewModelTest : SysuiTestCase() { dialogStopAction.onClick(mock<DialogInterface>(), 0) // THEN the chip is immediately hidden... - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Inactive::class.java) // ...even though the repo still says it's projecting assertThat(mediaProjectionRepo.mediaProjectionState.value) .isInstanceOf(MediaProjectionState.Projecting::class.java) // AND we specify no animation - assertThat((latest as OngoingActivityChipModel.Hidden).shouldAnimate).isFalse() + assertThat((latest as OngoingActivityChipModel.Inactive).shouldAnimate).isFalse() } @Test @@ -304,7 +304,7 @@ class CastToOtherDeviceChipViewModelTest : SysuiTestCase() { ) ) - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown::class.java) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active::class.java) // WHEN the stop action on the dialog is clicked val dialogStopAction = @@ -318,12 +318,12 @@ class CastToOtherDeviceChipViewModelTest : SysuiTestCase() { dialogStopAction.onClick(mock<DialogInterface>(), 0) // THEN the chip is immediately hidden... - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Inactive::class.java) // ...even though the repo still says it's projecting assertThat(mediaRouterRepo.castDevices.value).isNotEmpty() // AND we specify no animation - assertThat((latest as OngoingActivityChipModel.Hidden).shouldAnimate).isFalse() + assertThat((latest as OngoingActivityChipModel.Inactive).shouldAnimate).isFalse() } @Test @@ -334,7 +334,8 @@ class CastToOtherDeviceChipViewModelTest : SysuiTestCase() { mediaProjectionRepo.mediaProjectionState.value = MediaProjectionState.Projecting.EntireScreen(CAST_TO_OTHER_DEVICES_PACKAGE) - assertThat((latest as OngoingActivityChipModel.Shown).colors).isEqualTo(ColorsModel.Red) + assertThat((latest as OngoingActivityChipModel.Active).colors) + .isEqualTo(ColorsModel.Red) } @Test @@ -346,7 +347,7 @@ class CastToOtherDeviceChipViewModelTest : SysuiTestCase() { mediaProjectionRepo.mediaProjectionState.value = MediaProjectionState.Projecting.NoScreen(NORMAL_PACKAGE) - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Inactive::class.java) } @Test @@ -361,7 +362,7 @@ class CastToOtherDeviceChipViewModelTest : SysuiTestCase() { createTask(taskId = 1), ) - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Inactive::class.java) } @Test @@ -372,7 +373,7 @@ class CastToOtherDeviceChipViewModelTest : SysuiTestCase() { mediaProjectionRepo.mediaProjectionState.value = MediaProjectionState.Projecting.EntireScreen(NORMAL_PACKAGE) - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Inactive::class.java) } @Test @@ -384,11 +385,12 @@ class CastToOtherDeviceChipViewModelTest : SysuiTestCase() { mediaProjectionRepo.mediaProjectionState.value = MediaProjectionState.Projecting.EntireScreen(CAST_TO_OTHER_DEVICES_PACKAGE) - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown::class.java) - assertThat((latest as OngoingActivityChipModel.Shown.Timer).startTimeMs).isEqualTo(1234) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active::class.java) + assertThat((latest as OngoingActivityChipModel.Active.Timer).startTimeMs) + .isEqualTo(1234) mediaProjectionRepo.mediaProjectionState.value = MediaProjectionState.NotProjecting - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Inactive::class.java) systemClock.setElapsedRealtime(5678) mediaProjectionRepo.mediaProjectionState.value = @@ -398,8 +400,9 @@ class CastToOtherDeviceChipViewModelTest : SysuiTestCase() { createTask(taskId = 1), ) - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown::class.java) - assertThat((latest as OngoingActivityChipModel.Shown.Timer).startTimeMs).isEqualTo(5678) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active::class.java) + assertThat((latest as OngoingActivityChipModel.Active.Timer).startTimeMs) + .isEqualTo(5678) } @Test @@ -421,7 +424,7 @@ class CastToOtherDeviceChipViewModelTest : SysuiTestCase() { ) ) - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown.IconOnly::class.java) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active.IconOnly::class.java) // Later, set MediaProjection to also have information systemClock.setElapsedRealtime(5678) @@ -429,8 +432,9 @@ class CastToOtherDeviceChipViewModelTest : SysuiTestCase() { MediaProjectionState.Projecting.EntireScreen(CAST_TO_OTHER_DEVICES_PACKAGE) // Verify the new time is used - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown::class.java) - assertThat((latest as OngoingActivityChipModel.Shown.Timer).startTimeMs).isEqualTo(5678) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active::class.java) + assertThat((latest as OngoingActivityChipModel.Active.Timer).startTimeMs) + .isEqualTo(5678) } @Test @@ -441,7 +445,7 @@ class CastToOtherDeviceChipViewModelTest : SysuiTestCase() { mediaProjectionRepo.mediaProjectionState.value = MediaProjectionState.Projecting.EntireScreen(CAST_TO_OTHER_DEVICES_PACKAGE) - val clickListener = ((latest as OngoingActivityChipModel.Shown).onClickListenerLegacy) + val clickListener = ((latest as OngoingActivityChipModel.Active).onClickListenerLegacy) assertThat(clickListener).isNotNull() clickListener!!.onClick(chipView) @@ -462,7 +466,7 @@ class CastToOtherDeviceChipViewModelTest : SysuiTestCase() { createTask(taskId = 1), ) - val clickListener = ((latest as OngoingActivityChipModel.Shown).onClickListenerLegacy) + val clickListener = ((latest as OngoingActivityChipModel.Active).onClickListenerLegacy) assertThat(clickListener).isNotNull() clickListener!!.onClick(chipView) @@ -487,7 +491,7 @@ class CastToOtherDeviceChipViewModelTest : SysuiTestCase() { ) ) - val clickListener = ((latest as OngoingActivityChipModel.Shown).onClickListenerLegacy) + val clickListener = ((latest as OngoingActivityChipModel.Active).onClickListenerLegacy) assertThat(clickListener).isNotNull() clickListener!!.onClick(chipView) @@ -508,7 +512,7 @@ class CastToOtherDeviceChipViewModelTest : SysuiTestCase() { mediaProjectionRepo.mediaProjectionState.value = MediaProjectionState.Projecting.EntireScreen(CAST_TO_OTHER_DEVICES_PACKAGE) - val clickListener = ((latest as OngoingActivityChipModel.Shown).onClickListenerLegacy) + val clickListener = ((latest as OngoingActivityChipModel.Active).onClickListenerLegacy) clickListener!!.onClick(chipView) val cujCaptor = argumentCaptor<DialogCuj>() @@ -537,7 +541,7 @@ class CastToOtherDeviceChipViewModelTest : SysuiTestCase() { ) ) - val clickListener = ((latest as OngoingActivityChipModel.Shown).onClickListenerLegacy) + val clickListener = ((latest as OngoingActivityChipModel.Active).onClickListenerLegacy) clickListener!!.onClick(chipView) val cujCaptor = argumentCaptor<DialogCuj>() @@ -566,7 +570,7 @@ class CastToOtherDeviceChipViewModelTest : SysuiTestCase() { ) ) - assertThat((latest as OngoingActivityChipModel.Shown).clickBehavior) + assertThat((latest as OngoingActivityChipModel.Active).clickBehavior) .isInstanceOf(OngoingActivityChipModel.ClickBehavior.ExpandAction::class.java) } @@ -579,7 +583,7 @@ class CastToOtherDeviceChipViewModelTest : SysuiTestCase() { mediaProjectionRepo.mediaProjectionState.value = MediaProjectionState.Projecting.EntireScreen(CAST_TO_OTHER_DEVICES_PACKAGE) - assertThat((latest as OngoingActivityChipModel.Shown).clickBehavior) + assertThat((latest as OngoingActivityChipModel.Active).clickBehavior) .isInstanceOf(OngoingActivityChipModel.ClickBehavior.ExpandAction::class.java) } @@ -592,7 +596,7 @@ class CastToOtherDeviceChipViewModelTest : SysuiTestCase() { MediaProjectionState.Projecting.EntireScreen(CAST_TO_OTHER_DEVICES_PACKAGE) val expandAction = - ((latest as OngoingActivityChipModel.Shown).clickBehavior + ((latest as OngoingActivityChipModel.Active).clickBehavior as OngoingActivityChipModel.ClickBehavior.ExpandAction) expandAction.onClick(mockExpandable) @@ -614,7 +618,7 @@ class CastToOtherDeviceChipViewModelTest : SysuiTestCase() { ) val expandAction = - ((latest as OngoingActivityChipModel.Shown).clickBehavior + ((latest as OngoingActivityChipModel.Active).clickBehavior as OngoingActivityChipModel.ClickBehavior.ExpandAction) expandAction.onClick(mockExpandable) @@ -640,7 +644,7 @@ class CastToOtherDeviceChipViewModelTest : SysuiTestCase() { ) val expandAction = - ((latest as OngoingActivityChipModel.Shown).clickBehavior + ((latest as OngoingActivityChipModel.Active).clickBehavior as OngoingActivityChipModel.ClickBehavior.ExpandAction) expandAction.onClick(mockExpandable) 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 1f77ddc73aa5..192ad879891f 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 @@ -310,8 +310,8 @@ class NotifChipsViewModelTest : SysuiTestCase() { ) assertThat(latest).hasSize(1) - assertThat(latest!![0]).isInstanceOf(OngoingActivityChipModel.Shown.Text::class.java) - assertThat((latest!![0] as OngoingActivityChipModel.Shown.Text).text) + assertThat(latest!![0]).isInstanceOf(OngoingActivityChipModel.Active.Text::class.java) + assertThat((latest!![0] as OngoingActivityChipModel.Active.Text).text) .isEqualTo("Arrived") } @@ -335,7 +335,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { assertThat(latest).hasSize(1) assertThat(latest!![0]) - .isInstanceOf(OngoingActivityChipModel.Shown.IconOnly::class.java) + .isInstanceOf(OngoingActivityChipModel.Active.IconOnly::class.java) } @Test @@ -365,7 +365,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { assertThat(latest).hasSize(1) assertThat(latest!![0]) - .isInstanceOf(OngoingActivityChipModel.Shown.IconOnly::class.java) + .isInstanceOf(OngoingActivityChipModel.Active.IconOnly::class.java) } @Test @@ -395,7 +395,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { assertThat(latest).hasSize(1) assertThat(latest!![0]) - .isInstanceOf(OngoingActivityChipModel.Shown.ShortTimeDelta::class.java) + .isInstanceOf(OngoingActivityChipModel.Active.ShortTimeDelta::class.java) } @Test @@ -424,7 +424,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { assertThat(latest).hasSize(1) assertThat(latest!![0]) - .isInstanceOf(OngoingActivityChipModel.Shown.ShortTimeDelta::class.java) + .isInstanceOf(OngoingActivityChipModel.Active.ShortTimeDelta::class.java) } @Test @@ -452,7 +452,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { ) assertThat(latest).hasSize(1) - assertThat(latest!![0]).isInstanceOf(OngoingActivityChipModel.Shown.Timer::class.java) + assertThat(latest!![0]).isInstanceOf(OngoingActivityChipModel.Active.Timer::class.java) } @Test @@ -480,7 +480,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { ) assertThat(latest).hasSize(1) - assertThat(latest!![0]).isInstanceOf(OngoingActivityChipModel.Shown.Timer::class.java) + assertThat(latest!![0]).isInstanceOf(OngoingActivityChipModel.Active.Timer::class.java) } @Test @@ -512,7 +512,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { // THEN the chip shows the time assertThat(latest!![0]) - .isInstanceOf(OngoingActivityChipModel.Shown.ShortTimeDelta::class.java) + .isInstanceOf(OngoingActivityChipModel.Active.ShortTimeDelta::class.java) } @Test @@ -551,7 +551,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { // (In real life the chip won't show at all, but that's handled in a different part of // the system. What we know here is that the chip shouldn't shrink to icon only.) assertThat(latest!![0]) - .isInstanceOf(OngoingActivityChipModel.Shown.ShortTimeDelta::class.java) + .isInstanceOf(OngoingActivityChipModel.Active.ShortTimeDelta::class.java) } @Test @@ -603,7 +603,8 @@ class NotifChipsViewModelTest : SysuiTestCase() { // THEN the "notif" chip keeps showing time val chip = latest!![0] - assertThat(chip).isInstanceOf(OngoingActivityChipModel.Shown.ShortTimeDelta::class.java) + assertThat(chip) + .isInstanceOf(OngoingActivityChipModel.Active.ShortTimeDelta::class.java) assertIsNotifChip(chip, context, icon, "notif") } @@ -641,7 +642,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { // THEN the chip shrinks to icon only assertThat(latest!![0]) - .isInstanceOf(OngoingActivityChipModel.Shown.IconOnly::class.java) + .isInstanceOf(OngoingActivityChipModel.Active.IconOnly::class.java) } @Test @@ -724,22 +725,23 @@ class NotifChipsViewModelTest : SysuiTestCase() { expectedNotificationKey: String, expectedContentDescriptionSubstrings: List<String> = emptyList(), ) { - val shown = latest as OngoingActivityChipModel.Shown + val active = latest as OngoingActivityChipModel.Active if (StatusBarConnectedDisplays.isEnabled) { - assertThat(shown.icon) + assertThat(active.icon) .isInstanceOf( OngoingActivityChipModel.ChipIcon.StatusBarNotificationIcon::class.java ) - val icon = shown.icon as OngoingActivityChipModel.ChipIcon.StatusBarNotificationIcon + val icon = + active.icon as OngoingActivityChipModel.ChipIcon.StatusBarNotificationIcon assertThat(icon.notificationKey).isEqualTo(expectedNotificationKey) expectedContentDescriptionSubstrings.forEach { assertThat(icon.contentDescription.loadContentDescription(context)).contains(it) } } else { - assertThat(shown.icon) + assertThat(active.icon) .isInstanceOf(OngoingActivityChipModel.ChipIcon.StatusBarView::class.java) - val icon = shown.icon as OngoingActivityChipModel.ChipIcon.StatusBarView + val icon = active.icon as OngoingActivityChipModel.ChipIcon.StatusBarView assertThat(icon.impl).isEqualTo(expectedIcon!!) expectedContentDescriptionSubstrings.forEach { assertThat(icon.contentDescription.loadContentDescription(context)).contains(it) @@ -749,7 +751,7 @@ class NotifChipsViewModelTest : SysuiTestCase() { fun assertIsNotifKey(latest: OngoingActivityChipModel?, expectedKey: String) { assertThat( - ((latest as OngoingActivityChipModel.Shown).icon + ((latest as OngoingActivityChipModel.Active).icon as OngoingActivityChipModel.ChipIcon.StatusBarNotificationIcon) .notificationKey ) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/screenrecord/ui/viewmodel/ScreenRecordChipViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/screenrecord/ui/viewmodel/ScreenRecordChipViewModelTest.kt index 1f82dcd9c308..6cfad8540491 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/screenrecord/ui/viewmodel/ScreenRecordChipViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/screenrecord/ui/viewmodel/ScreenRecordChipViewModelTest.kt @@ -101,7 +101,7 @@ class ScreenRecordChipViewModelTest : SysuiTestCase() { screenRecordRepo.screenRecordState.value = ScreenRecordModel.DoingNothing - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Inactive::class.java) } @Test @@ -111,9 +111,9 @@ class ScreenRecordChipViewModelTest : SysuiTestCase() { screenRecordRepo.screenRecordState.value = ScreenRecordModel.Starting(400) - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown.Countdown::class.java) - assertThat((latest as OngoingActivityChipModel.Shown).icon).isNull() - assertThat((latest as OngoingActivityChipModel.Shown).onClickListenerLegacy).isNull() + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active.Countdown::class.java) + assertThat((latest as OngoingActivityChipModel.Active).icon).isNull() + assertThat((latest as OngoingActivityChipModel.Active).onClickListenerLegacy).isNull() } // The millis we typically get from [ScreenRecordRepository] are around 2995, 1995, and 995. @@ -124,7 +124,7 @@ class ScreenRecordChipViewModelTest : SysuiTestCase() { screenRecordRepo.screenRecordState.value = ScreenRecordModel.Starting(2995) - assertThat((latest as OngoingActivityChipModel.Shown.Countdown).secondsUntilStarted) + assertThat((latest as OngoingActivityChipModel.Active.Countdown).secondsUntilStarted) .isEqualTo(3) } @@ -135,7 +135,7 @@ class ScreenRecordChipViewModelTest : SysuiTestCase() { screenRecordRepo.screenRecordState.value = ScreenRecordModel.Starting(1995) - assertThat((latest as OngoingActivityChipModel.Shown.Countdown).secondsUntilStarted) + assertThat((latest as OngoingActivityChipModel.Active.Countdown).secondsUntilStarted) .isEqualTo(2) } @@ -146,7 +146,7 @@ class ScreenRecordChipViewModelTest : SysuiTestCase() { screenRecordRepo.screenRecordState.value = ScreenRecordModel.Starting(995) - assertThat((latest as OngoingActivityChipModel.Shown.Countdown).secondsUntilStarted) + assertThat((latest as OngoingActivityChipModel.Active.Countdown).secondsUntilStarted) .isEqualTo(1) } @@ -157,9 +157,9 @@ class ScreenRecordChipViewModelTest : SysuiTestCase() { screenRecordRepo.screenRecordState.value = ScreenRecordModel.Recording - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown.Timer::class.java) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active.Timer::class.java) val icon = - (((latest as OngoingActivityChipModel.Shown).icon) + (((latest as OngoingActivityChipModel.Active).icon) as OngoingActivityChipModel.ChipIcon.SingleColorIcon) .impl as Icon.Resource assertThat(icon.res).isEqualTo(R.drawable.ic_screenrecord) @@ -179,8 +179,8 @@ class ScreenRecordChipViewModelTest : SysuiTestCase() { mediaProjectionRepo.mediaProjectionState.value = MediaProjectionState.Projecting.EntireScreen("fake.package") - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown::class.java) - assertThat(latestShareToApp).isInstanceOf(OngoingActivityChipModel.Shown::class.java) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active::class.java) + assertThat(latestShareToApp).isInstanceOf(OngoingActivityChipModel.Active::class.java) // WHEN the stop action on the dialog is clicked val dialogStopAction = @@ -194,8 +194,8 @@ class ScreenRecordChipViewModelTest : SysuiTestCase() { dialogStopAction.onClick(mock<DialogInterface>(), 0) // THEN both the screen record chip and the share-to-app chip are immediately hidden... - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) - assertThat(latestShareToApp).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Inactive::class.java) + assertThat(latestShareToApp).isInstanceOf(OngoingActivityChipModel.Inactive::class.java) // ...even though the repos still say it's recording assertThat(screenRecordRepo.screenRecordState.value) .isEqualTo(ScreenRecordModel.Recording) @@ -203,7 +203,7 @@ class ScreenRecordChipViewModelTest : SysuiTestCase() { .isInstanceOf(MediaProjectionState.Projecting::class.java) // AND we specify no animation - assertThat((latest as OngoingActivityChipModel.Hidden).shouldAnimate).isFalse() + assertThat((latest as OngoingActivityChipModel.Inactive).shouldAnimate).isFalse() } @Test @@ -213,7 +213,8 @@ class ScreenRecordChipViewModelTest : SysuiTestCase() { screenRecordRepo.screenRecordState.value = ScreenRecordModel.Starting(2000L) - assertThat((latest as OngoingActivityChipModel.Shown).colors).isEqualTo(ColorsModel.Red) + assertThat((latest as OngoingActivityChipModel.Active).colors) + .isEqualTo(ColorsModel.Red) } @Test @@ -223,7 +224,8 @@ class ScreenRecordChipViewModelTest : SysuiTestCase() { screenRecordRepo.screenRecordState.value = ScreenRecordModel.Recording - assertThat((latest as OngoingActivityChipModel.Shown).colors).isEqualTo(ColorsModel.Red) + assertThat((latest as OngoingActivityChipModel.Active).colors) + .isEqualTo(ColorsModel.Red) } @Test @@ -234,17 +236,19 @@ class ScreenRecordChipViewModelTest : SysuiTestCase() { systemClock.setElapsedRealtime(1234) screenRecordRepo.screenRecordState.value = ScreenRecordModel.Recording - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown::class.java) - assertThat((latest as OngoingActivityChipModel.Shown.Timer).startTimeMs).isEqualTo(1234) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active::class.java) + assertThat((latest as OngoingActivityChipModel.Active.Timer).startTimeMs) + .isEqualTo(1234) screenRecordRepo.screenRecordState.value = ScreenRecordModel.DoingNothing - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Inactive::class.java) systemClock.setElapsedRealtime(5678) screenRecordRepo.screenRecordState.value = ScreenRecordModel.Recording - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown::class.java) - assertThat((latest as OngoingActivityChipModel.Shown.Timer).startTimeMs).isEqualTo(5678) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active::class.java) + assertThat((latest as OngoingActivityChipModel.Active.Timer).startTimeMs) + .isEqualTo(5678) } /** Regression test for b/349620526. */ @@ -258,8 +262,9 @@ class ScreenRecordChipViewModelTest : SysuiTestCase() { screenRecordRepo.screenRecordState.value = ScreenRecordModel.Recording mediaProjectionRepo.mediaProjectionState.value = MediaProjectionState.NotProjecting - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown::class.java) - assertThat((latest as OngoingActivityChipModel.Shown.Timer).startTimeMs).isEqualTo(1234) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active::class.java) + assertThat((latest as OngoingActivityChipModel.Active.Timer).startTimeMs) + .isEqualTo(1234) // WHEN we receive the recording task info a few milliseconds later systemClock.setElapsedRealtime(1240) @@ -271,8 +276,9 @@ class ScreenRecordChipViewModelTest : SysuiTestCase() { ) // THEN the start time is still the old start time - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown::class.java) - assertThat((latest as OngoingActivityChipModel.Shown.Timer).startTimeMs).isEqualTo(1234) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active::class.java) + assertThat((latest as OngoingActivityChipModel.Active.Timer).startTimeMs) + .isEqualTo(1234) } @Test @@ -283,7 +289,7 @@ class ScreenRecordChipViewModelTest : SysuiTestCase() { screenRecordRepo.screenRecordState.value = ScreenRecordModel.Recording mediaProjectionRepo.mediaProjectionState.value = MediaProjectionState.NotProjecting - val clickListener = ((latest as OngoingActivityChipModel.Shown).onClickListenerLegacy) + val clickListener = ((latest as OngoingActivityChipModel.Active).onClickListenerLegacy) assertThat(clickListener).isNotNull() clickListener!!.onClick(chipView) @@ -301,7 +307,7 @@ class ScreenRecordChipViewModelTest : SysuiTestCase() { mediaProjectionRepo.mediaProjectionState.value = MediaProjectionState.Projecting.EntireScreen("host.package") - val clickListener = ((latest as OngoingActivityChipModel.Shown).onClickListenerLegacy) + val clickListener = ((latest as OngoingActivityChipModel.Active).onClickListenerLegacy) assertThat(clickListener).isNotNull() clickListener!!.onClick(chipView) @@ -323,7 +329,7 @@ class ScreenRecordChipViewModelTest : SysuiTestCase() { FakeActivityTaskManager.createTask(taskId = 1), ) - val clickListener = ((latest as OngoingActivityChipModel.Shown).onClickListenerLegacy) + val clickListener = ((latest as OngoingActivityChipModel.Active).onClickListenerLegacy) assertThat(clickListener).isNotNull() clickListener!!.onClick(chipView) @@ -341,7 +347,7 @@ class ScreenRecordChipViewModelTest : SysuiTestCase() { mediaProjectionRepo.mediaProjectionState.value = MediaProjectionState.Projecting.EntireScreen("host.package") - val clickListener = ((latest as OngoingActivityChipModel.Shown).onClickListenerLegacy) + val clickListener = ((latest as OngoingActivityChipModel.Active).onClickListenerLegacy) clickListener!!.onClick(chipView) val cujCaptor = argumentCaptor<DialogCuj>() @@ -358,8 +364,8 @@ class ScreenRecordChipViewModelTest : SysuiTestCase() { testScope.runTest { val latest by collectLastValue(underTest.chip) screenRecordRepo.screenRecordState.value = ScreenRecordModel.Recording - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown.Timer::class.java) - assertThat((latest as OngoingActivityChipModel.Shown).clickBehavior) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active.Timer::class.java) + assertThat((latest as OngoingActivityChipModel.Active).clickBehavior) .isInstanceOf(OngoingActivityChipModel.ClickBehavior.ExpandAction::class.java) } @@ -372,7 +378,7 @@ class ScreenRecordChipViewModelTest : SysuiTestCase() { mediaProjectionRepo.mediaProjectionState.value = MediaProjectionState.NotProjecting val expandAction = - ((latest as OngoingActivityChipModel.Shown).clickBehavior + ((latest as OngoingActivityChipModel.Active).clickBehavior as OngoingActivityChipModel.ClickBehavior.ExpandAction) expandAction.onClick(mockExpandable) @@ -387,7 +393,7 @@ class ScreenRecordChipViewModelTest : SysuiTestCase() { screenRecordRepo.screenRecordState.value = ScreenRecordModel.Recording val expandAction = - ((latest as OngoingActivityChipModel.Shown).clickBehavior + ((latest as OngoingActivityChipModel.Active).clickBehavior as OngoingActivityChipModel.ClickBehavior.ExpandAction) expandAction.onClick(mockExpandable) @@ -408,7 +414,7 @@ class ScreenRecordChipViewModelTest : SysuiTestCase() { ) val expandAction = - ((latest as OngoingActivityChipModel.Shown).clickBehavior + ((latest as OngoingActivityChipModel.Active).clickBehavior as OngoingActivityChipModel.ClickBehavior.ExpandAction) expandAction.onClick(mockExpandable) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/sharetoapp/ui/viewmodel/ShareToAppChipViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/sharetoapp/ui/viewmodel/ShareToAppChipViewModelTest.kt index 3961e177d1aa..e708382799c2 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/sharetoapp/ui/viewmodel/ShareToAppChipViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/sharetoapp/ui/viewmodel/ShareToAppChipViewModelTest.kt @@ -117,12 +117,12 @@ class ShareToAppChipViewModelTest : SysuiTestCase() { MediaProjectionState.Projecting.EntireScreen(NORMAL_PACKAGE) // Verify the chip is initially shown - assertThat(latestChip).isInstanceOf(OngoingActivityChipModel.Shown::class.java) + assertThat(latestChip).isInstanceOf(OngoingActivityChipModel.Active::class.java) fakeMediaProjectionRepository.emitProjectionStartedDuringCallAndActivePostCallEvent() // Verify the chip is hidden - assertThat(latestChip).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) + assertThat(latestChip).isInstanceOf(OngoingActivityChipModel.Inactive::class.java) } @Test @@ -136,12 +136,12 @@ class ShareToAppChipViewModelTest : SysuiTestCase() { MediaProjectionState.Projecting.EntireScreen(NORMAL_PACKAGE) // Verify the chip is initially shown - assertThat(latestChip).isInstanceOf(OngoingActivityChipModel.Shown::class.java) + assertThat(latestChip).isInstanceOf(OngoingActivityChipModel.Active::class.java) fakeMediaProjectionRepository.emitProjectionStartedDuringCallAndActivePostCallEvent() // Chip is still shown - assertThat(latestChip).isInstanceOf(OngoingActivityChipModel.Shown::class.java) + assertThat(latestChip).isInstanceOf(OngoingActivityChipModel.Active::class.java) } @Test @@ -330,7 +330,7 @@ class ShareToAppChipViewModelTest : SysuiTestCase() { mediaProjectionRepo.mediaProjectionState.value = MediaProjectionState.NotProjecting - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Inactive::class.java) } @Test @@ -345,7 +345,7 @@ class ShareToAppChipViewModelTest : SysuiTestCase() { hostDeviceName = null, ) - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Inactive::class.java) } @Test @@ -360,7 +360,7 @@ class ShareToAppChipViewModelTest : SysuiTestCase() { createTask(taskId = 1), ) - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Inactive::class.java) } @Test @@ -371,7 +371,7 @@ class ShareToAppChipViewModelTest : SysuiTestCase() { mediaProjectionRepo.mediaProjectionState.value = MediaProjectionState.Projecting.EntireScreen(CAST_TO_OTHER_DEVICES_PACKAGE) - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Inactive::class.java) } @Test @@ -383,9 +383,9 @@ class ShareToAppChipViewModelTest : SysuiTestCase() { mediaProjectionRepo.mediaProjectionState.value = MediaProjectionState.Projecting.NoScreen(NORMAL_PACKAGE, hostDeviceName = null) - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown.IconOnly::class.java) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active.IconOnly::class.java) val icon = - (((latest as OngoingActivityChipModel.Shown).icon) + (((latest as OngoingActivityChipModel.Active).icon) as OngoingActivityChipModel.ChipIcon.SingleColorIcon) .impl as Icon.Resource assertThat(icon.res).isEqualTo(R.drawable.ic_present_to_all) @@ -406,9 +406,9 @@ class ShareToAppChipViewModelTest : SysuiTestCase() { createTask(taskId = 1), ) - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown.Timer::class.java) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active.Timer::class.java) val icon = - (((latest as OngoingActivityChipModel.Shown).icon) + (((latest as OngoingActivityChipModel.Active).icon) as OngoingActivityChipModel.ChipIcon.SingleColorIcon) .impl as Icon.Resource assertThat(icon.res).isEqualTo(R.drawable.ic_present_to_all) @@ -423,9 +423,9 @@ class ShareToAppChipViewModelTest : SysuiTestCase() { mediaProjectionRepo.mediaProjectionState.value = MediaProjectionState.Projecting.EntireScreen(NORMAL_PACKAGE) - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown.Timer::class.java) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active.Timer::class.java) val icon = - (((latest as OngoingActivityChipModel.Shown).icon) + (((latest as OngoingActivityChipModel.Active).icon) as OngoingActivityChipModel.ChipIcon.SingleColorIcon) .impl as Icon.Resource assertThat(icon.res).isEqualTo(R.drawable.ic_present_to_all) @@ -440,7 +440,7 @@ class ShareToAppChipViewModelTest : SysuiTestCase() { mediaProjectionRepo.mediaProjectionState.value = MediaProjectionState.Projecting.EntireScreen(NORMAL_PACKAGE) - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown::class.java) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active::class.java) // WHEN the stop action on the dialog is clicked val dialogStopAction = @@ -454,13 +454,13 @@ class ShareToAppChipViewModelTest : SysuiTestCase() { dialogStopAction.onClick(mock<DialogInterface>(), 0) // THEN the chip is immediately hidden... - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Inactive::class.java) // ...even though the repo still says it's projecting assertThat(mediaProjectionRepo.mediaProjectionState.value) .isInstanceOf(MediaProjectionState.Projecting::class.java) // AND we specify no animation - assertThat((latest as OngoingActivityChipModel.Hidden).shouldAnimate).isFalse() + assertThat((latest as OngoingActivityChipModel.Inactive).shouldAnimate).isFalse() } @Test @@ -471,7 +471,8 @@ class ShareToAppChipViewModelTest : SysuiTestCase() { mediaProjectionRepo.mediaProjectionState.value = MediaProjectionState.Projecting.EntireScreen(NORMAL_PACKAGE) - assertThat((latest as OngoingActivityChipModel.Shown).colors).isEqualTo(ColorsModel.Red) + assertThat((latest as OngoingActivityChipModel.Active).colors) + .isEqualTo(ColorsModel.Red) } @Test @@ -483,11 +484,12 @@ class ShareToAppChipViewModelTest : SysuiTestCase() { mediaProjectionRepo.mediaProjectionState.value = MediaProjectionState.Projecting.EntireScreen(NORMAL_PACKAGE) - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown::class.java) - assertThat((latest as OngoingActivityChipModel.Shown.Timer).startTimeMs).isEqualTo(1234) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active::class.java) + assertThat((latest as OngoingActivityChipModel.Active.Timer).startTimeMs) + .isEqualTo(1234) mediaProjectionRepo.mediaProjectionState.value = MediaProjectionState.NotProjecting - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Inactive::class.java) systemClock.setElapsedRealtime(5678) mediaProjectionRepo.mediaProjectionState.value = @@ -497,8 +499,9 @@ class ShareToAppChipViewModelTest : SysuiTestCase() { createTask(taskId = 1), ) - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown::class.java) - assertThat((latest as OngoingActivityChipModel.Shown.Timer).startTimeMs).isEqualTo(5678) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active::class.java) + assertThat((latest as OngoingActivityChipModel.Active.Timer).startTimeMs) + .isEqualTo(5678) } @Test @@ -510,7 +513,7 @@ class ShareToAppChipViewModelTest : SysuiTestCase() { mediaProjectionRepo.mediaProjectionState.value = MediaProjectionState.Projecting.NoScreen(NORMAL_PACKAGE) - val clickListener = ((latest as OngoingActivityChipModel.Shown).onClickListenerLegacy) + val clickListener = ((latest as OngoingActivityChipModel.Active).onClickListenerLegacy) assertThat(clickListener).isNotNull() clickListener!!.onClick(chipView) @@ -531,7 +534,7 @@ class ShareToAppChipViewModelTest : SysuiTestCase() { mediaProjectionRepo.mediaProjectionState.value = MediaProjectionState.Projecting.EntireScreen(NORMAL_PACKAGE) - val clickListener = ((latest as OngoingActivityChipModel.Shown).onClickListenerLegacy) + val clickListener = ((latest as OngoingActivityChipModel.Active).onClickListenerLegacy) assertThat(clickListener).isNotNull() clickListener!!.onClick(chipView) @@ -556,7 +559,7 @@ class ShareToAppChipViewModelTest : SysuiTestCase() { createTask(taskId = 1), ) - val clickListener = ((latest as OngoingActivityChipModel.Shown).onClickListenerLegacy) + val clickListener = ((latest as OngoingActivityChipModel.Active).onClickListenerLegacy) assertThat(clickListener).isNotNull() clickListener!!.onClick(chipView) @@ -581,7 +584,7 @@ class ShareToAppChipViewModelTest : SysuiTestCase() { createTask(taskId = 1), ) - val clickListener = ((latest as OngoingActivityChipModel.Shown).onClickListenerLegacy) + val clickListener = ((latest as OngoingActivityChipModel.Active).onClickListenerLegacy) clickListener!!.onClick(chipView) val cujCaptor = argumentCaptor<DialogCuj>() @@ -601,7 +604,7 @@ class ShareToAppChipViewModelTest : SysuiTestCase() { mediaProjectionRepo.mediaProjectionState.value = MediaProjectionState.Projecting.NoScreen(NORMAL_PACKAGE) - assertThat((latest as OngoingActivityChipModel.Shown).clickBehavior) + assertThat((latest as OngoingActivityChipModel.Active).clickBehavior) .isInstanceOf(OngoingActivityChipModel.ClickBehavior.ExpandAction::class.java) } @@ -613,7 +616,7 @@ class ShareToAppChipViewModelTest : SysuiTestCase() { mediaProjectionRepo.mediaProjectionState.value = MediaProjectionState.Projecting.EntireScreen(NORMAL_PACKAGE) - assertThat((latest as OngoingActivityChipModel.Shown).clickBehavior) + assertThat((latest as OngoingActivityChipModel.Active).clickBehavior) .isInstanceOf(OngoingActivityChipModel.ClickBehavior.ExpandAction::class.java) } @@ -629,7 +632,7 @@ class ShareToAppChipViewModelTest : SysuiTestCase() { createTask(taskId = 1), ) - assertThat((latest as OngoingActivityChipModel.Shown).clickBehavior) + assertThat((latest as OngoingActivityChipModel.Active).clickBehavior) .isInstanceOf(OngoingActivityChipModel.ClickBehavior.ExpandAction::class.java) } @@ -646,7 +649,7 @@ class ShareToAppChipViewModelTest : SysuiTestCase() { MediaProjectionState.Projecting.NoScreen(NORMAL_PACKAGE) val expandAction = - ((latest as OngoingActivityChipModel.Shown).clickBehavior + ((latest as OngoingActivityChipModel.Active).clickBehavior as OngoingActivityChipModel.ClickBehavior.ExpandAction) expandAction.onClick(mockExpandable) verify(kosmos.mockDialogTransitionAnimator) @@ -662,7 +665,7 @@ class ShareToAppChipViewModelTest : SysuiTestCase() { MediaProjectionState.Projecting.EntireScreen(NORMAL_PACKAGE) val expandAction = - ((latest as OngoingActivityChipModel.Shown).clickBehavior + ((latest as OngoingActivityChipModel.Active).clickBehavior as OngoingActivityChipModel.ClickBehavior.ExpandAction) expandAction.onClick(mockExpandable) verify(kosmos.mockDialogTransitionAnimator) @@ -682,7 +685,7 @@ class ShareToAppChipViewModelTest : SysuiTestCase() { ) val expandAction = - ((latest as OngoingActivityChipModel.Shown).clickBehavior + ((latest as OngoingActivityChipModel.Active).clickBehavior as OngoingActivityChipModel.ClickBehavior.ExpandAction) expandAction.onClick(mockExpandable) 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 550faab2aeda..60030ad4e428 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 @@ -47,11 +47,11 @@ class ChipTransitionHelperTest : SysuiTestCase() { testScope.runTest { val underTest = ChipTransitionHelper(kosmos.applicationCoroutineScope) val inputChipFlow = - MutableStateFlow<OngoingActivityChipModel>(OngoingActivityChipModel.Hidden()) + MutableStateFlow<OngoingActivityChipModel>(OngoingActivityChipModel.Inactive()) val latest by collectLastValue(underTest.createChipFlow(inputChipFlow)) val newChip = - OngoingActivityChipModel.Shown.Timer( + OngoingActivityChipModel.Active.Timer( key = KEY, icon = createIcon(R.drawable.ic_cake), colors = ColorsModel.Themed, @@ -65,7 +65,7 @@ class ChipTransitionHelperTest : SysuiTestCase() { assertThat(latest).isEqualTo(newChip) val newerChip = - OngoingActivityChipModel.Shown.IconOnly( + OngoingActivityChipModel.Active.IconOnly( key = KEY, icon = createIcon(R.drawable.ic_hotspot), colors = ColorsModel.Themed, @@ -83,11 +83,11 @@ class ChipTransitionHelperTest : SysuiTestCase() { testScope.runTest { val underTest = ChipTransitionHelper(kosmos.applicationCoroutineScope) val inputChipFlow = - MutableStateFlow<OngoingActivityChipModel>(OngoingActivityChipModel.Hidden()) + MutableStateFlow<OngoingActivityChipModel>(OngoingActivityChipModel.Inactive()) val latest by collectLastValue(underTest.createChipFlow(inputChipFlow)) - val shownChip = - OngoingActivityChipModel.Shown.Timer( + val activeChip = + OngoingActivityChipModel.Active.Timer( key = KEY, icon = createIcon(R.drawable.ic_cake), colors = ColorsModel.Themed, @@ -96,28 +96,28 @@ class ChipTransitionHelperTest : SysuiTestCase() { clickBehavior = OngoingActivityChipModel.ClickBehavior.None, ) - inputChipFlow.value = shownChip + inputChipFlow.value = activeChip - assertThat(latest).isEqualTo(shownChip) + assertThat(latest).isEqualTo(activeChip) // WHEN #onActivityStopped is invoked underTest.onActivityStoppedFromDialog() runCurrent() // THEN the chip is hidden and has no animation - assertThat(latest).isEqualTo(OngoingActivityChipModel.Hidden(shouldAnimate = false)) + assertThat(latest).isEqualTo(OngoingActivityChipModel.Inactive(shouldAnimate = false)) // WHEN only 250ms have elapsed advanceTimeBy(250) // THEN the chip is still hidden - assertThat(latest).isEqualTo(OngoingActivityChipModel.Hidden(shouldAnimate = false)) + assertThat(latest).isEqualTo(OngoingActivityChipModel.Inactive(shouldAnimate = false)) // WHEN over 500ms have elapsed advanceTimeBy(251) // THEN the chip returns to the original input flow value - assertThat(latest).isEqualTo(shownChip) + assertThat(latest).isEqualTo(activeChip) } @Test @@ -125,11 +125,11 @@ class ChipTransitionHelperTest : SysuiTestCase() { testScope.runTest { val underTest = ChipTransitionHelper(kosmos.applicationCoroutineScope) val inputChipFlow = - MutableStateFlow<OngoingActivityChipModel>(OngoingActivityChipModel.Hidden()) + MutableStateFlow<OngoingActivityChipModel>(OngoingActivityChipModel.Inactive()) val latest by collectLastValue(underTest.createChipFlow(inputChipFlow)) - val shownChip = - OngoingActivityChipModel.Shown.Timer( + val activeChip = + OngoingActivityChipModel.Active.Timer( key = KEY, icon = createIcon(R.drawable.ic_cake), colors = ColorsModel.Themed, @@ -138,16 +138,16 @@ class ChipTransitionHelperTest : SysuiTestCase() { clickBehavior = OngoingActivityChipModel.ClickBehavior.None, ) - inputChipFlow.value = shownChip + inputChipFlow.value = activeChip - assertThat(latest).isEqualTo(shownChip) + assertThat(latest).isEqualTo(activeChip) // WHEN #onActivityStopped is invoked underTest.onActivityStoppedFromDialog() runCurrent() // THEN the chip is hidden and has no animation - assertThat(latest).isEqualTo(OngoingActivityChipModel.Hidden(shouldAnimate = false)) + assertThat(latest).isEqualTo(OngoingActivityChipModel.Inactive(shouldAnimate = false)) // WHEN 250ms have elapsed, get another stop event advanceTimeBy(250) @@ -155,11 +155,11 @@ class ChipTransitionHelperTest : SysuiTestCase() { runCurrent() // THEN the chip is still hidden for another 500ms afterwards - assertThat(latest).isEqualTo(OngoingActivityChipModel.Hidden(shouldAnimate = false)) + assertThat(latest).isEqualTo(OngoingActivityChipModel.Inactive(shouldAnimate = false)) advanceTimeBy(499) - assertThat(latest).isEqualTo(OngoingActivityChipModel.Hidden(shouldAnimate = false)) + assertThat(latest).isEqualTo(OngoingActivityChipModel.Inactive(shouldAnimate = false)) advanceTimeBy(2) - assertThat(latest).isEqualTo(shownChip) + assertThat(latest).isEqualTo(activeChip) } private fun createIcon(@DrawableRes drawable: Int) = diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipsViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipsViewModelTest.kt index ffa9d99546de..626dcd5b0864 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipsViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipsViewModelTest.kt @@ -118,7 +118,7 @@ class OngoingActivityChipsViewModelTest : SysuiTestCase() { val latest by collectLastValue(underTest.primaryChip) - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Inactive::class.java) } @Test @@ -266,7 +266,8 @@ class OngoingActivityChipsViewModelTest : SysuiTestCase() { runCurrent() - assertThat((latest as OngoingActivityChipModel.Shown.Timer).startTimeMs).isEqualTo(1234) + assertThat((latest as OngoingActivityChipModel.Active.Timer).startTimeMs) + .isEqualTo(1234) // Stop subscribing to the chip flow job1.cancel() @@ -280,7 +281,8 @@ class OngoingActivityChipsViewModelTest : SysuiTestCase() { runCurrent() // THEN the old start time is still used - assertThat((latest as OngoingActivityChipModel.Shown.Timer).startTimeMs).isEqualTo(1234) + assertThat((latest as OngoingActivityChipModel.Active.Timer).startTimeMs) + .isEqualTo(1234) job2.cancel() } @@ -312,7 +314,7 @@ class OngoingActivityChipsViewModelTest : SysuiTestCase() { dialogStopAction.onClick(mock<DialogInterface>(), 0) // THEN the chip is immediately hidden with no animation - assertThat(latest).isEqualTo(OngoingActivityChipModel.Hidden(shouldAnimate = false)) + assertThat(latest).isEqualTo(OngoingActivityChipModel.Inactive(shouldAnimate = false)) } @Test @@ -339,7 +341,7 @@ class OngoingActivityChipsViewModelTest : SysuiTestCase() { dialogStopAction.onClick(mock<DialogInterface>(), 0) // THEN the chip is immediately hidden with no animation - assertThat(latest).isEqualTo(OngoingActivityChipModel.Hidden(shouldAnimate = false)) + assertThat(latest).isEqualTo(OngoingActivityChipModel.Inactive(shouldAnimate = false)) } companion object { @@ -372,13 +374,13 @@ class OngoingActivityChipsViewModelTest : SysuiTestCase() { .thenThrow(PackageManager.NameNotFoundException()) if (StatusBarChipsModernization.isEnabled) { - val clickBehavior = (latest as OngoingActivityChipModel.Shown).clickBehavior + val clickBehavior = (latest as OngoingActivityChipModel.Active).clickBehavior (clickBehavior as OngoingActivityChipModel.ClickBehavior.ExpandAction).onClick( expandable ) } else { val clickListener = - ((latest as OngoingActivityChipModel.Shown).onClickListenerLegacy) + ((latest as OngoingActivityChipModel.Active).onClickListenerLegacy) clickListener!!.onClick(chipView) } @@ -386,8 +388,8 @@ class OngoingActivityChipsViewModelTest : SysuiTestCase() { } fun assertIsScreenRecordChip(latest: OngoingActivityChipModel?) { - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown::class.java) - assertThat((latest as OngoingActivityChipModel.Shown).key) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active::class.java) + assertThat((latest as OngoingActivityChipModel.Active).key) .isEqualTo(ScreenRecordChipViewModel.KEY) val icon = ((latest.icon) as OngoingActivityChipModel.ChipIcon.SingleColorIcon).impl @@ -396,8 +398,8 @@ class OngoingActivityChipsViewModelTest : SysuiTestCase() { } fun assertIsShareToAppChip(latest: OngoingActivityChipModel?) { - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown::class.java) - assertThat((latest as OngoingActivityChipModel.Shown).key) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active::class.java) + assertThat((latest as OngoingActivityChipModel.Active).key) .isEqualTo(ShareToAppChipViewModel.KEY) val icon = ((latest.icon) as OngoingActivityChipModel.ChipIcon.SingleColorIcon).impl @@ -406,8 +408,8 @@ class OngoingActivityChipsViewModelTest : SysuiTestCase() { } fun assertIsCallChip(latest: OngoingActivityChipModel?, notificationKey: String) { - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Shown::class.java) - assertThat((latest as OngoingActivityChipModel.Shown).key).isEqualTo(notificationKey) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active::class.java) + assertThat((latest as OngoingActivityChipModel.Active).key).isEqualTo(notificationKey) if (StatusBarConnectedDisplays.isEnabled) { assertNotificationIcon(latest, notificationKey) @@ -423,9 +425,9 @@ class OngoingActivityChipsViewModelTest : SysuiTestCase() { latest: OngoingActivityChipModel?, notificationKey: String, ) { - val shown = latest as OngoingActivityChipModel.Shown + val active = latest as OngoingActivityChipModel.Active val notificationIcon = - shown.icon as OngoingActivityChipModel.ChipIcon.StatusBarNotificationIcon + active.icon as OngoingActivityChipModel.ChipIcon.StatusBarNotificationIcon assertThat(notificationIcon.notificationKey).isEqualTo(notificationKey) } } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipsWithNotifsViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipsWithNotifsViewModelTest.kt index 29528cc48a26..0ece62e73b96 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipsWithNotifsViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipsWithNotifsViewModelTest.kt @@ -134,7 +134,7 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { val latest by collectLastValue(underTest.primaryChip) - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Inactive::class.java) } @Test @@ -146,8 +146,9 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { val latest by collectLastValue(underTest.chips) - assertThat(latest!!.primary).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) - assertThat(latest!!.secondary).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) + assertThat(latest!!.primary).isInstanceOf(OngoingActivityChipModel.Inactive::class.java) + assertThat(latest!!.secondary) + .isInstanceOf(OngoingActivityChipModel.Inactive::class.java) } @Test @@ -172,7 +173,8 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { val latest by collectLastValue(underTest.chips) assertIsScreenRecordChip(latest!!.primary) - assertThat(latest!!.secondary).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) + assertThat(latest!!.secondary) + .isInstanceOf(OngoingActivityChipModel.Inactive::class.java) } @Test @@ -210,7 +212,7 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { // The call chip isn't squished (squished chips would be icon only) assertThat(latest!!.primary) - .isInstanceOf(OngoingActivityChipModel.Shown.Timer::class.java) + .isInstanceOf(OngoingActivityChipModel.Active.Timer::class.java) } @Test @@ -224,9 +226,9 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { // Squished chips are icon only assertThat(latest!!.primary) - .isInstanceOf(OngoingActivityChipModel.Shown.IconOnly::class.java) + .isInstanceOf(OngoingActivityChipModel.Active.IconOnly::class.java) assertThat(latest!!.secondary) - .isInstanceOf(OngoingActivityChipModel.Shown.IconOnly::class.java) + .isInstanceOf(OngoingActivityChipModel.Active.IconOnly::class.java) } @Test @@ -240,10 +242,10 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { // The screen record countdown isn't squished to icon-only assertThat(latest!!.primary) - .isInstanceOf(OngoingActivityChipModel.Shown.Countdown::class.java) + .isInstanceOf(OngoingActivityChipModel.Active.Countdown::class.java) // But the call chip *is* squished assertThat(latest!!.secondary) - .isInstanceOf(OngoingActivityChipModel.Shown.IconOnly::class.java) + .isInstanceOf(OngoingActivityChipModel.Active.IconOnly::class.java) } @Test @@ -258,26 +260,28 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { // The screen record isn't squished because it's the only one assertThat(latest!!.primary) - .isInstanceOf(OngoingActivityChipModel.Shown.Timer::class.java) - assertThat(latest!!.secondary).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) + .isInstanceOf(OngoingActivityChipModel.Active.Timer::class.java) + assertThat(latest!!.secondary) + .isInstanceOf(OngoingActivityChipModel.Inactive::class.java) // WHEN there's 2 chips callRepo.setOngoingCallState(inCallModel(startTimeMs = 34, notificationKey = "call")) // THEN they both become squished assertThat(latest!!.primary) - .isInstanceOf(OngoingActivityChipModel.Shown.IconOnly::class.java) + .isInstanceOf(OngoingActivityChipModel.Active.IconOnly::class.java) // But the call chip *is* squished assertThat(latest!!.secondary) - .isInstanceOf(OngoingActivityChipModel.Shown.IconOnly::class.java) + .isInstanceOf(OngoingActivityChipModel.Active.IconOnly::class.java) // WHEN we go back down to 1 chip screenRecordState.value = ScreenRecordModel.DoingNothing // THEN the remaining chip unsquishes assertThat(latest!!.primary) - .isInstanceOf(OngoingActivityChipModel.Shown.Timer::class.java) - assertThat(latest!!.secondary).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) + .isInstanceOf(OngoingActivityChipModel.Active.Timer::class.java) + assertThat(latest!!.secondary) + .isInstanceOf(OngoingActivityChipModel.Inactive::class.java) } @Test @@ -298,9 +302,9 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { // THEN the chips aren't squished (squished chips would be icon only) assertThat(latest!!.primary) - .isInstanceOf(OngoingActivityChipModel.Shown.Timer::class.java) + .isInstanceOf(OngoingActivityChipModel.Active.Timer::class.java) assertThat(latest!!.secondary) - .isInstanceOf(OngoingActivityChipModel.Shown.Timer::class.java) + .isInstanceOf(OngoingActivityChipModel.Active.Timer::class.java) } @Test @@ -317,9 +321,9 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { // THEN the chips aren't squished (squished chips would be icon only) assertThat(latest!!.primary) - .isInstanceOf(OngoingActivityChipModel.Shown.Timer::class.java) + .isInstanceOf(OngoingActivityChipModel.Active.Timer::class.java) assertThat(latest!!.secondary) - .isInstanceOf(OngoingActivityChipModel.Shown.Timer::class.java) + .isInstanceOf(OngoingActivityChipModel.Active.Timer::class.java) } @Test @@ -342,9 +346,9 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { // Squished chips would be icon only assertThat(latest!!.primary) - .isInstanceOf(OngoingActivityChipModel.Shown.Timer::class.java) + .isInstanceOf(OngoingActivityChipModel.Active.Timer::class.java) assertThat(latest!!.secondary) - .isInstanceOf(OngoingActivityChipModel.Shown.Timer::class.java) + .isInstanceOf(OngoingActivityChipModel.Active.Timer::class.java) } @Test @@ -373,7 +377,8 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { assertIsScreenRecordChip(latest!!.primary) // Even though share-to-app is active, we suppress it because this share-to-app is // represented by screen record being active. See b/296461748. - assertThat(latest!!.secondary).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) + assertThat(latest!!.secondary) + .isInstanceOf(OngoingActivityChipModel.Inactive::class.java) } @Test @@ -438,7 +443,8 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { val latest by collectLastValue(underTest.chips) assertIsCallChip(latest!!.primary, callNotificationKey) - assertThat(latest!!.secondary).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) + assertThat(latest!!.secondary) + .isInstanceOf(OngoingActivityChipModel.Inactive::class.java) } @Test @@ -458,7 +464,8 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { ) assertIsNotifChip(latest!!.primary, context, icon, "notif") - assertThat(latest!!.secondary).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) + assertThat(latest!!.secondary) + .isInstanceOf(OngoingActivityChipModel.Inactive::class.java) } @Test @@ -699,7 +706,8 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { val latest by collectLastValue(underTest.chips) assertIsNotifChip(latest!!.primary, context, notifIcon, "notif") - assertThat(latest!!.secondary).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) + assertThat(latest!!.secondary) + .isInstanceOf(OngoingActivityChipModel.Inactive::class.java) // WHEN the higher priority call chip is added callRepo.setOngoingCallState( @@ -743,7 +751,8 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { // THEN notif is promoted to primary assertIsNotifChip(latest!!.primary, context, notifIcon, "notif") - assertThat(latest!!.secondary).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) + assertThat(latest!!.secondary) + .isInstanceOf(OngoingActivityChipModel.Inactive::class.java) } /** Regression test for b/347726238. */ @@ -760,7 +769,8 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { runCurrent() - assertThat((latest as OngoingActivityChipModel.Shown.Timer).startTimeMs).isEqualTo(1234) + assertThat((latest as OngoingActivityChipModel.Active.Timer).startTimeMs) + .isEqualTo(1234) // Stop subscribing to the chip flow job1.cancel() @@ -774,7 +784,8 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { runCurrent() // THEN the old start time is still used - assertThat((latest as OngoingActivityChipModel.Shown.Timer).startTimeMs).isEqualTo(1234) + assertThat((latest as OngoingActivityChipModel.Active.Timer).startTimeMs) + .isEqualTo(1234) job2.cancel() } @@ -793,7 +804,7 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { runCurrent() - val primaryChip = latest!!.primary as OngoingActivityChipModel.Shown.Timer + val primaryChip = latest!!.primary as OngoingActivityChipModel.Active.Timer assertThat(primaryChip.startTimeMs).isEqualTo(1234) // Stop subscribing to the chip flow @@ -808,7 +819,7 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { runCurrent() // THEN the old start time is still used - val newPrimaryChip = latest!!.primary as OngoingActivityChipModel.Shown.Timer + val newPrimaryChip = latest!!.primary as OngoingActivityChipModel.Active.Timer assertThat(newPrimaryChip.startTimeMs).isEqualTo(1234) job2.cancel() @@ -838,7 +849,7 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { dialogStopAction.onClick(mock<DialogInterface>(), 0) // THEN the chip is immediately hidden with no animation - assertThat(latest).isEqualTo(OngoingActivityChipModel.Hidden(shouldAnimate = false)) + assertThat(latest).isEqualTo(OngoingActivityChipModel.Inactive(shouldAnimate = false)) } @Test @@ -865,7 +876,7 @@ class OngoingActivityChipsWithNotifsViewModelTest : SysuiTestCase() { dialogStopAction.onClick(mock<DialogInterface>(), 0) // THEN the chip is immediately hidden with no animation - assertThat(latest).isEqualTo(OngoingActivityChipModel.Hidden(shouldAnimate = false)) + assertThat(latest).isEqualTo(OngoingActivityChipModel.Inactive(shouldAnimate = false)) } private fun setNotifs(notifs: List<ActiveNotificationModel>) { diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/FakeHomeStatusBarViewModel.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/FakeHomeStatusBarViewModel.kt index 4af97c0d33d9..e4143a07d159 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/FakeHomeStatusBarViewModel.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/FakeHomeStatusBarViewModel.kt @@ -41,7 +41,7 @@ class FakeHomeStatusBarViewModel( override val transitionFromLockscreenToDreamStartedEvent = MutableSharedFlow<Unit>() override val primaryOngoingActivityChip: MutableStateFlow<OngoingActivityChipModel> = - MutableStateFlow(OngoingActivityChipModel.Hidden()) + MutableStateFlow(OngoingActivityChipModel.Inactive()) override val ongoingActivityChips = MutableStateFlow(MultipleOngoingActivityChipsModel()) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/HomeStatusBarViewModelImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/HomeStatusBarViewModelImplTest.kt index 2719e85f5db5..eaee9d5d6db9 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/HomeStatusBarViewModelImplTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/HomeStatusBarViewModelImplTest.kt @@ -488,7 +488,7 @@ class HomeStatusBarViewModelImplTest : SysuiTestCase() { kosmos.screenRecordRepository.screenRecordState.value = ScreenRecordModel.DoingNothing - assertThat(latest).isInstanceOf(OngoingActivityChipModel.Hidden::class.java) + assertThat(latest).isInstanceOf(OngoingActivityChipModel.Inactive::class.java) kosmos.fakeMediaProjectionRepository.mediaProjectionState.value = MediaProjectionState.Projecting.EntireScreen(NORMAL_PACKAGE) 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 1aeb73caa9d9..a2c0226addfa 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 @@ -66,7 +66,7 @@ constructor( .map { state -> when (state) { is OngoingCallModel.NoCall, - is OngoingCallModel.InCallWithVisibleApp -> OngoingActivityChipModel.Hidden() + is OngoingCallModel.InCallWithVisibleApp -> OngoingActivityChipModel.Inactive() is OngoingCallModel.InCall -> { val key = state.notificationKey val contentDescription = getContentDescription(state.appName) @@ -97,7 +97,7 @@ constructor( if (state.startTimeMs <= 0L) { // If the start time is invalid, don't show a timer and show just an // icon. See b/192379214. - OngoingActivityChipModel.Shown.IconOnly( + OngoingActivityChipModel.Active.IconOnly( key = key, icon = icon, colors = colors, @@ -108,7 +108,7 @@ constructor( val startTimeInElapsedRealtime = state.startTimeMs - systemClock.currentTimeMillis() + systemClock.elapsedRealtime() - OngoingActivityChipModel.Shown.Timer( + OngoingActivityChipModel.Active.Timer( key = key, icon = icon, colors = colors, @@ -120,7 +120,7 @@ constructor( } } } - .stateIn(scope, SharingStarted.WhileSubscribed(), OngoingActivityChipModel.Hidden()) + .stateIn(scope, SharingStarted.WhileSubscribed(), OngoingActivityChipModel.Inactive()) private fun getOnClickListener(state: OngoingCallModel.InCall): View.OnClickListener? { if (state.intent == null) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/chips/casttootherdevice/ui/viewmodel/CastToOtherDeviceChipViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/chips/casttootherdevice/ui/viewmodel/CastToOtherDeviceChipViewModel.kt index 51abc695a284..6ce350cb95f5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/chips/casttootherdevice/ui/viewmodel/CastToOtherDeviceChipViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/chips/casttootherdevice/ui/viewmodel/CastToOtherDeviceChipViewModel.kt @@ -76,7 +76,7 @@ constructor( mediaProjectionChipInteractor.projection .map { projectionModel -> when (projectionModel) { - is ProjectionChipModel.NotProjecting -> OngoingActivityChipModel.Hidden() + is ProjectionChipModel.NotProjecting -> OngoingActivityChipModel.Inactive() is ProjectionChipModel.Projecting -> { when (projectionModel.receiver) { ProjectionChipModel.Receiver.CastToOtherDevice -> { @@ -88,19 +88,19 @@ constructor( } } ProjectionChipModel.Receiver.ShareToApp -> - OngoingActivityChipModel.Hidden() + OngoingActivityChipModel.Inactive() } } } } // See b/347726238 for [SharingStarted.Lazily] reasoning. - .stateIn(scope, SharingStarted.Lazily, OngoingActivityChipModel.Hidden()) + .stateIn(scope, SharingStarted.Lazily, OngoingActivityChipModel.Inactive()) /** * The cast chip to show, based only on MediaRouter API events. * - * This chip will be [OngoingActivityChipModel.Shown] when the user is casting their screen *or* - * their audio. + * This chip will be [OngoingActivityChipModel.Active] when the user is casting their screen + * *or* their audio. * * The MediaProjection APIs are typically not invoked for casting *only audio* to another device * because MediaProjection is only concerned with *screen* sharing (see b/342169876). We listen @@ -118,7 +118,7 @@ constructor( mediaRouterChipInteractor.mediaRouterCastingState .map { routerModel -> when (routerModel) { - is MediaRouterCastModel.DoingNothing -> OngoingActivityChipModel.Hidden() + is MediaRouterCastModel.DoingNothing -> OngoingActivityChipModel.Inactive() is MediaRouterCastModel.Casting -> { // A consequence of b/269975671 is that MediaRouter will mark a device as // casting before casting has actually started. To alleviate this bug a bit, @@ -132,7 +132,7 @@ constructor( } } } - .stateIn(scope, SharingStarted.WhileSubscribed(), OngoingActivityChipModel.Hidden()) + .stateIn(scope, SharingStarted.WhileSubscribed(), OngoingActivityChipModel.Inactive()) private val internalChip: StateFlow<OngoingActivityChipModel> = combine(projectionChip, routerChip) { projection, router -> @@ -151,24 +151,24 @@ constructor( // // 1. When the user chooses what device to cast to, the MediaRouter APIs mark the // device as casting (even though casting hasn't actually started yet). At this - // point, `routerChip` is [OngoingActivityChipModel.Shown] but `projectionChip` is - // [OngoingActivityChipModel.Hidden], and we'll show the router chip. + // point, `routerChip` is [OngoingActivityChipModel.Active] but `projectionChip` is + // [OngoingActivityChipModel.Inactive], and we'll show the router chip. // // 2. Once casting has actually started, the MediaProjection APIs become aware of // the device. At this point, both `routerChip` and `projectionChip` are - // [OngoingActivityChipModel.Shown]. + // [OngoingActivityChipModel.Active]. // // Because the MediaProjection APIs have activated, we know that the user is screen // casting (not audio casting). We need to switch to using `projectionChip` because // that chip will show information specific to screen casting. The `projectionChip` // will also show a timer, as opposed to `routerChip`'s icon-only display. - if (projection is OngoingActivityChipModel.Shown) { + if (projection is OngoingActivityChipModel.Active) { projection } else { router } } - .stateIn(scope, SharingStarted.WhileSubscribed(), OngoingActivityChipModel.Hidden()) + .stateIn(scope, SharingStarted.WhileSubscribed(), OngoingActivityChipModel.Inactive()) private val hideChipDuringDialogTransitionHelper = ChipTransitionHelper(scope) @@ -191,8 +191,8 @@ constructor( private fun createCastScreenToOtherDeviceChip( state: ProjectionChipModel.Projecting - ): OngoingActivityChipModel.Shown { - return OngoingActivityChipModel.Shown.Timer( + ): OngoingActivityChipModel.Active { + return OngoingActivityChipModel.Active.Timer( key = KEY, icon = OngoingActivityChipModel.ChipIcon.SingleColorIcon( @@ -229,8 +229,8 @@ constructor( ) } - private fun createIconOnlyCastChip(deviceName: String?): OngoingActivityChipModel.Shown { - return OngoingActivityChipModel.Shown.IconOnly( + private fun createIconOnlyCastChip(deviceName: String?): OngoingActivityChipModel.Active { + return OngoingActivityChipModel.Active.IconOnly( key = KEY, icon = OngoingActivityChipModel.ChipIcon.SingleColorIcon( 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 3b26d1c7c9df..8357df42937e 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 @@ -56,7 +56,7 @@ constructor( * A flow modeling the notification chips that should be shown. Emits an empty list if there are * no notifications that should show a status bar chip. */ - val chips: Flow<List<OngoingActivityChipModel.Shown>> = + val chips: Flow<List<OngoingActivityChipModel.Active>> = combine( notifChipsInteractor.notificationChips, headsUpNotificationInteractor.statusBarHeadsUpState, @@ -68,7 +68,7 @@ constructor( /** Converts the notification to the [OngoingActivityChipModel] object. */ private fun NotificationChipModel.toActivityChipModel( headsUpState: TopPinnedState - ): OngoingActivityChipModel.Shown { + ): OngoingActivityChipModel.Active { StatusBarNotifChips.assertInNewMode() val contentDescription = getContentDescription(this.appName) val icon = @@ -113,7 +113,7 @@ constructor( if (isShowingHeadsUpFromChipTap) { // If the user tapped this chip to show the HUN, we want to just show the icon because // the HUN will show the rest of the information. - return OngoingActivityChipModel.Shown.IconOnly( + return OngoingActivityChipModel.Active.IconOnly( this.key, icon, colors, @@ -123,7 +123,7 @@ constructor( } if (this.promotedContent.shortCriticalText != null) { - return OngoingActivityChipModel.Shown.Text( + return OngoingActivityChipModel.Active.Text( this.key, icon, colors, @@ -141,7 +141,7 @@ constructor( // notification will likely just be set to the current time, which would cause the chip // to always show "now". We don't want early testers to get that experience since it's // not what will happen at launch, so just don't show any time. - return OngoingActivityChipModel.Shown.IconOnly( + return OngoingActivityChipModel.Active.IconOnly( this.key, icon, colors, @@ -151,7 +151,7 @@ constructor( } if (this.promotedContent.time == null) { - return OngoingActivityChipModel.Shown.IconOnly( + return OngoingActivityChipModel.Active.IconOnly( this.key, icon, colors, @@ -161,7 +161,7 @@ constructor( } when (this.promotedContent.time.mode) { PromotedNotificationContentModel.When.Mode.BasicTime -> { - return OngoingActivityChipModel.Shown.ShortTimeDelta( + return OngoingActivityChipModel.Active.ShortTimeDelta( this.key, icon, colors, @@ -171,7 +171,7 @@ constructor( ) } PromotedNotificationContentModel.When.Mode.CountUp -> { - return OngoingActivityChipModel.Shown.Timer( + return OngoingActivityChipModel.Active.Timer( this.key, icon, colors, @@ -182,7 +182,7 @@ constructor( } PromotedNotificationContentModel.When.Mode.CountDown -> { // TODO(b/364653005): Support CountDown. - return OngoingActivityChipModel.Shown.Timer( + return OngoingActivityChipModel.Active.Timer( this.key, icon, colors, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/chips/screenrecord/ui/viewmodel/ScreenRecordChipViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/chips/screenrecord/ui/viewmodel/ScreenRecordChipViewModel.kt index e1f855373daa..55c89a96422f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/chips/screenrecord/ui/viewmodel/ScreenRecordChipViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/chips/screenrecord/ui/viewmodel/ScreenRecordChipViewModel.kt @@ -73,16 +73,16 @@ constructor( interactor.screenRecordState .map { state -> when (state) { - is ScreenRecordChipModel.DoingNothing -> OngoingActivityChipModel.Hidden() + is ScreenRecordChipModel.DoingNothing -> OngoingActivityChipModel.Inactive() is ScreenRecordChipModel.Starting -> { - OngoingActivityChipModel.Shown.Countdown( + OngoingActivityChipModel.Active.Countdown( key = KEY, colors = ColorsModel.Red, secondsUntilStarted = state.millisUntilStarted.toCountdownSeconds(), ) } is ScreenRecordChipModel.Recording -> { - OngoingActivityChipModel.Shown.Timer( + OngoingActivityChipModel.Active.Timer( key = KEY, icon = OngoingActivityChipModel.ChipIcon.SingleColorIcon( @@ -118,7 +118,7 @@ constructor( } } // See b/347726238 for [SharingStarted.Lazily] reasoning. - .stateIn(scope, SharingStarted.Lazily, OngoingActivityChipModel.Hidden()) + .stateIn(scope, SharingStarted.Lazily, OngoingActivityChipModel.Inactive()) /** * The screen record chip to show that also ensures that the start time doesn't change once we @@ -127,11 +127,11 @@ constructor( */ private val chipWithConsistentTimer: StateFlow<OngoingActivityChipModel> = simpleChip - .pairwise(initialValue = OngoingActivityChipModel.Hidden()) + .pairwise(initialValue = OngoingActivityChipModel.Inactive()) .map { (old, new) -> if ( - old is OngoingActivityChipModel.Shown.Timer && - new is OngoingActivityChipModel.Shown.Timer + old is OngoingActivityChipModel.Active.Timer && + new is OngoingActivityChipModel.Active.Timer ) { new.copy(startTimeMs = old.startTimeMs) } else { @@ -139,7 +139,7 @@ constructor( } } // See b/347726238 for [SharingStarted.Lazily] reasoning. - .stateIn(scope, SharingStarted.Lazily, OngoingActivityChipModel.Hidden()) + .stateIn(scope, SharingStarted.Lazily, OngoingActivityChipModel.Inactive()) private val chipTransitionHelper = ChipTransitionHelper(scope) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/chips/sharetoapp/ui/viewmodel/ShareToAppChipViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/chips/sharetoapp/ui/viewmodel/ShareToAppChipViewModel.kt index 12cf8b59ff4c..92e17bdd511a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/chips/sharetoapp/ui/viewmodel/ShareToAppChipViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/chips/sharetoapp/ui/viewmodel/ShareToAppChipViewModel.kt @@ -129,7 +129,7 @@ constructor( mediaProjectionChipInteractor.projection .map { projectionModel -> when (projectionModel) { - is ProjectionChipModel.NotProjecting -> OngoingActivityChipModel.Hidden() + is ProjectionChipModel.NotProjecting -> OngoingActivityChipModel.Inactive() is ProjectionChipModel.Projecting -> { when (projectionModel.receiver) { ProjectionChipModel.Receiver.ShareToApp -> { @@ -141,13 +141,13 @@ constructor( } } ProjectionChipModel.Receiver.CastToOtherDevice -> - OngoingActivityChipModel.Hidden() + OngoingActivityChipModel.Inactive() } } } } // See b/347726238 for [SharingStarted.Lazily] reasoning. - .stateIn(scope, SharingStarted.Lazily, OngoingActivityChipModel.Hidden()) + .stateIn(scope, SharingStarted.Lazily, OngoingActivityChipModel.Inactive()) private val chipTransitionHelper = ChipTransitionHelper(scope) @@ -165,12 +165,12 @@ constructor( {}, { "Hiding the chip as stop dialog is being shown" }, ) - OngoingActivityChipModel.Hidden() + OngoingActivityChipModel.Inactive() } else { currentChip } } - .stateIn(scope, SharingStarted.WhileSubscribed(), OngoingActivityChipModel.Hidden()) + .stateIn(scope, SharingStarted.WhileSubscribed(), OngoingActivityChipModel.Inactive()) /** * Notifies this class that the user just stopped a screen recording from the dialog that's @@ -219,8 +219,8 @@ constructor( private fun createShareScreenToAppChip( state: ProjectionChipModel.Projecting - ): OngoingActivityChipModel.Shown { - return OngoingActivityChipModel.Shown.Timer( + ): OngoingActivityChipModel.Active { + return OngoingActivityChipModel.Active.Timer( key = KEY, icon = OngoingActivityChipModel.ChipIcon.SingleColorIcon( @@ -254,8 +254,8 @@ constructor( ) } - private fun createIconOnlyShareToAppChip(): OngoingActivityChipModel.Shown { - return OngoingActivityChipModel.Shown.IconOnly( + private fun createIconOnlyShareToAppChip(): OngoingActivityChipModel.Active { + return OngoingActivityChipModel.Active.IconOnly( key = KEY, icon = OngoingActivityChipModel.ChipIcon.SingleColorIcon( diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/binder/OngoingActivityChipBinder.kt b/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/binder/OngoingActivityChipBinder.kt index de9d4974c0c6..456cd121a540 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/binder/OngoingActivityChipBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/binder/OngoingActivityChipBinder.kt @@ -54,7 +54,7 @@ object OngoingActivityChipBinder { val chipBackgroundView = viewBinding.backgroundView when (chipModel) { - is OngoingActivityChipModel.Shown -> { + is OngoingActivityChipModel.Active -> { // Data setChipIcon(chipModel, chipBackgroundView, chipDefaultIconView, iconViewStore) setChipMainContent(chipModel, chipTextView, chipTimeView, chipShortTimeDeltaView) @@ -79,7 +79,7 @@ object OngoingActivityChipBinder { (chipBackgroundView.background as GradientDrawable).color = chipModel.colors.background(chipContext) } - is OngoingActivityChipModel.Hidden -> { + is OngoingActivityChipModel.Inactive -> { // The Chronometer should be stopped to prevent leaks -- see b/192243808 and // [Chronometer.start]. chipTimeView.stop() @@ -110,12 +110,12 @@ object OngoingActivityChipBinder { primaryChipViewBinding: OngoingActivityChipViewBinding, currentPrimaryChipViewModel: OngoingActivityChipModel, ) { - if (currentPrimaryChipViewModel is OngoingActivityChipModel.Hidden) { + if (currentPrimaryChipViewModel is OngoingActivityChipModel.Inactive) { return } resetChipMainContentWidthRestrictions( primaryChipViewBinding, - currentPrimaryChipViewModel as OngoingActivityChipModel.Shown, + currentPrimaryChipViewModel as OngoingActivityChipModel.Active, ) } @@ -129,27 +129,27 @@ object OngoingActivityChipBinder { secondaryChipViewBinding: OngoingActivityChipViewBinding, currentSecondaryChipModel: OngoingActivityChipModel, ) { - if (currentSecondaryChipModel is OngoingActivityChipModel.Hidden) { + if (currentSecondaryChipModel is OngoingActivityChipModel.Inactive) { return } secondaryChipViewBinding.rootView.resetWidthRestriction() resetChipMainContentWidthRestrictions( secondaryChipViewBinding, - currentSecondaryChipModel as OngoingActivityChipModel.Shown, + currentSecondaryChipModel as OngoingActivityChipModel.Active, ) } private fun resetChipMainContentWidthRestrictions( viewBinding: OngoingActivityChipViewBinding, - model: OngoingActivityChipModel.Shown, + model: OngoingActivityChipModel.Active, ) { when (model) { - is OngoingActivityChipModel.Shown.Text -> viewBinding.textView.resetWidthRestriction() - is OngoingActivityChipModel.Shown.Timer -> viewBinding.timeView.resetWidthRestriction() - is OngoingActivityChipModel.Shown.ShortTimeDelta -> + is OngoingActivityChipModel.Active.Text -> viewBinding.textView.resetWidthRestriction() + is OngoingActivityChipModel.Active.Timer -> viewBinding.timeView.resetWidthRestriction() + is OngoingActivityChipModel.Active.ShortTimeDelta -> viewBinding.shortTimeDeltaView.resetWidthRestriction() - is OngoingActivityChipModel.Shown.IconOnly, - is OngoingActivityChipModel.Shown.Countdown -> {} + is OngoingActivityChipModel.Active.IconOnly, + is OngoingActivityChipModel.Active.Countdown -> {} } } @@ -167,7 +167,7 @@ object OngoingActivityChipBinder { } private fun setChipIcon( - chipModel: OngoingActivityChipModel.Shown, + chipModel: OngoingActivityChipModel.Active, backgroundView: ChipBackgroundContainer, defaultIconView: ImageView, iconViewStore: IconViewStore?, @@ -278,34 +278,34 @@ object OngoingActivityChipBinder { } private fun setChipMainContent( - chipModel: OngoingActivityChipModel.Shown, + chipModel: OngoingActivityChipModel.Active, chipTextView: TextView, chipTimeView: ChipChronometer, chipShortTimeDeltaView: DateTimeView, ) { when (chipModel) { - is OngoingActivityChipModel.Shown.Countdown -> { + is OngoingActivityChipModel.Active.Countdown -> { chipTextView.text = chipModel.secondsUntilStarted.toString() chipTextView.visibility = View.VISIBLE chipTimeView.hide() chipShortTimeDeltaView.visibility = View.GONE } - is OngoingActivityChipModel.Shown.Text -> { + is OngoingActivityChipModel.Active.Text -> { chipTextView.text = chipModel.text chipTextView.visibility = View.VISIBLE chipTimeView.hide() chipShortTimeDeltaView.visibility = View.GONE } - is OngoingActivityChipModel.Shown.Timer -> { + is OngoingActivityChipModel.Active.Timer -> { ChipChronometerBinder.bind(chipModel.startTimeMs, chipTimeView) chipTimeView.visibility = View.VISIBLE chipTextView.visibility = View.GONE chipShortTimeDeltaView.visibility = View.GONE } - is OngoingActivityChipModel.Shown.ShortTimeDelta -> { + is OngoingActivityChipModel.Active.ShortTimeDelta -> { chipShortTimeDeltaView.setTime(chipModel.time) chipShortTimeDeltaView.visibility = View.VISIBLE chipShortTimeDeltaView.isShowRelativeTime = true @@ -319,7 +319,7 @@ object OngoingActivityChipBinder { chipTextView.visibility = View.GONE chipTimeView.hide() } - is OngoingActivityChipModel.Shown.IconOnly -> { + is OngoingActivityChipModel.Active.IconOnly -> { chipTextView.visibility = View.GONE chipShortTimeDeltaView.visibility = View.GONE chipTimeView.hide() @@ -335,7 +335,7 @@ object OngoingActivityChipBinder { } private fun updateChipPadding( - chipModel: OngoingActivityChipModel.Shown, + chipModel: OngoingActivityChipModel.Active, backgroundView: View, chipTextView: TextView, chipTimeView: ChipChronometer, @@ -425,19 +425,19 @@ object OngoingActivityChipBinder { } private fun setChipAccessibility( - chipModel: OngoingActivityChipModel.Shown, + chipModel: OngoingActivityChipModel.Active, chipView: View, chipBackgroundView: View, ) { when (chipModel) { - is OngoingActivityChipModel.Shown.Countdown -> { + is OngoingActivityChipModel.Active.Countdown -> { // Set as assertive so talkback will announce the countdown chipView.accessibilityLiveRegion = View.ACCESSIBILITY_LIVE_REGION_ASSERTIVE } - is OngoingActivityChipModel.Shown.Timer, - is OngoingActivityChipModel.Shown.Text, - is OngoingActivityChipModel.Shown.ShortTimeDelta, - is OngoingActivityChipModel.Shown.IconOnly -> { + is OngoingActivityChipModel.Active.Timer, + is OngoingActivityChipModel.Active.Text, + is OngoingActivityChipModel.Active.ShortTimeDelta, + is OngoingActivityChipModel.Active.IconOnly -> { chipView.accessibilityLiveRegion = View.ACCESSIBILITY_LIVE_REGION_NONE } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/compose/ChipContent.kt b/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/compose/ChipContent.kt index cf2ec47a36d8..32de0fbfd870 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/compose/ChipContent.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/compose/ChipContent.kt @@ -48,7 +48,7 @@ import com.android.systemui.statusbar.chips.ui.viewmodel.rememberChronometerStat import kotlin.math.min @Composable -fun ChipContent(viewModel: OngoingActivityChipModel.Shown, modifier: Modifier = Modifier) { +fun ChipContent(viewModel: OngoingActivityChipModel.Active, modifier: Modifier = Modifier) { val context = LocalContext.current val isTextOnly = viewModel.icon == null val hasEmbeddedIcon = @@ -73,7 +73,7 @@ fun ChipContent(viewModel: OngoingActivityChipModel.Shown, modifier: Modifier = } val textMeasurer = rememberTextMeasurer() when (viewModel) { - is OngoingActivityChipModel.Shown.Timer -> { + is OngoingActivityChipModel.Active.Timer -> { val timerState = rememberChronometerState(startTimeMillis = viewModel.startTimeMs) val text = timerState.currentTimeText Text( @@ -96,7 +96,7 @@ fun ChipContent(viewModel: OngoingActivityChipModel.Shown, modifier: Modifier = ) } - is OngoingActivityChipModel.Shown.Countdown -> { + is OngoingActivityChipModel.Active.Countdown -> { val text = viewModel.secondsUntilStarted.toString() Text( text = text, @@ -107,7 +107,7 @@ fun ChipContent(viewModel: OngoingActivityChipModel.Shown, modifier: Modifier = ) } - is OngoingActivityChipModel.Shown.Text -> { + is OngoingActivityChipModel.Active.Text -> { var hasOverflow by remember { mutableStateOf(false) } val text = viewModel.text Text( @@ -137,11 +137,11 @@ fun ChipContent(viewModel: OngoingActivityChipModel.Shown, modifier: Modifier = ) } - is OngoingActivityChipModel.Shown.ShortTimeDelta -> { + is OngoingActivityChipModel.Active.ShortTimeDelta -> { // TODO(b/372657935): Implement ShortTimeDelta content in compose. } - is OngoingActivityChipModel.Shown.IconOnly -> { + is OngoingActivityChipModel.Active.IconOnly -> { throw IllegalStateException("ChipContent should only be used if the chip shows text") } } @@ -149,10 +149,10 @@ fun ChipContent(viewModel: OngoingActivityChipModel.Shown, modifier: Modifier = /** A modifier that ensures the width of the content only increases and never decreases. */ private fun Modifier.neverDecreaseWidth(): Modifier { - return this.then(neverDecreaseWidthElement) + return this.then(NeverDecreaseWidthElement) } -private data object neverDecreaseWidthElement : ModifierNodeElement<NeverDecreaseWidthNode>() { +private data object NeverDecreaseWidthElement : ModifierNodeElement<NeverDecreaseWidthNode>() { override fun create(): NeverDecreaseWidthNode { return NeverDecreaseWidthNode() } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/compose/OngoingActivityChip.kt b/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/compose/OngoingActivityChip.kt index dbcc88bf7743..c4506fba6ad9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/compose/OngoingActivityChip.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/compose/OngoingActivityChip.kt @@ -52,7 +52,7 @@ import com.android.systemui.statusbar.chips.ui.model.ColorsModel import com.android.systemui.statusbar.chips.ui.model.OngoingActivityChipModel @Composable -fun OngoingActivityChip(model: OngoingActivityChipModel.Shown, modifier: Modifier = Modifier) { +fun OngoingActivityChip(model: OngoingActivityChipModel.Active, modifier: Modifier = Modifier) { when (val clickBehavior = model.clickBehavior) { is OngoingActivityChipModel.ClickBehavior.ExpandAction -> { // Wrap the chip in an Expandable so we can animate the expand transition. @@ -79,7 +79,7 @@ fun OngoingActivityChip(model: OngoingActivityChipModel.Shown, modifier: Modifie @Composable private fun ChipBody( - model: OngoingActivityChipModel.Shown, + model: OngoingActivityChipModel.Active, modifier: Modifier = Modifier, onClick: (() -> Unit)? = null, ) { @@ -148,7 +148,7 @@ private fun ChipBody( ) { model.icon?.let { ChipIcon(viewModel = it, colors = model.colors) } - val isIconOnly = model is OngoingActivityChipModel.Shown.IconOnly + val isIconOnly = model is OngoingActivityChipModel.Active.IconOnly if (!isIconOnly) { ChipContent(viewModel = model) } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/compose/OngoingActivityChips.kt b/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/compose/OngoingActivityChips.kt index 06b6b71b27bf..17539fea0240 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/compose/OngoingActivityChips.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/compose/OngoingActivityChips.kt @@ -38,11 +38,11 @@ fun OngoingActivityChips(chips: MultipleOngoingActivityChipsModel, modifier: Mod ) { // TODO(b/372657935): Make sure chips are only shown when there is enough horizontal // space. - if (chips.primary is OngoingActivityChipModel.Shown) { + if (chips.primary is OngoingActivityChipModel.Active) { val chip = chips.primary key(chip.key) { OngoingActivityChip(model = chip) } } - if (chips.secondary is OngoingActivityChipModel.Shown) { + if (chips.secondary is OngoingActivityChipModel.Active) { val chip = chips.secondary key(chip.key) { OngoingActivityChip(model = chip) } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/model/MultipleOngoingActivityChipsModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/model/MultipleOngoingActivityChipsModel.kt index d2555b0fe4a9..3bdf04d0f87d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/model/MultipleOngoingActivityChipsModel.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/model/MultipleOngoingActivityChipsModel.kt @@ -19,19 +19,19 @@ package com.android.systemui.statusbar.chips.ui.model /** Models multiple active ongoing activity chips at once. */ data class MultipleOngoingActivityChipsModel( /** The primary chip to show. This will *always* be shown. */ - val primary: OngoingActivityChipModel = OngoingActivityChipModel.Hidden(), + val primary: OngoingActivityChipModel = OngoingActivityChipModel.Inactive(), /** * The secondary chip to show. If there's not enough room in the status bar, this chip will * *not* be shown. */ - val secondary: OngoingActivityChipModel = OngoingActivityChipModel.Hidden(), + val secondary: OngoingActivityChipModel = OngoingActivityChipModel.Inactive(), ) { init { if ( - primary is OngoingActivityChipModel.Hidden && - secondary is OngoingActivityChipModel.Shown + primary is OngoingActivityChipModel.Inactive && + secondary is OngoingActivityChipModel.Active ) { - throw IllegalArgumentException("`secondary` cannot be Shown if `primary` is Hidden") + throw IllegalArgumentException("`secondary` cannot be Active if `primary` is Inactive") } } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/model/OngoingActivityChipModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/model/OngoingActivityChipModel.kt index 13f4b845887a..ba42eb4f3387 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/model/OngoingActivityChipModel.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/model/OngoingActivityChipModel.kt @@ -32,16 +32,16 @@ sealed class OngoingActivityChipModel { /** * This chip shouldn't be shown. * - * @property shouldAnimate true if the transition from [Shown] to [Hidden] should be animated, - * and false if that transition should *not* be animated (i.e. the chip view should + * @property shouldAnimate true if the transition from [Active] to [Inactive] should be + * animated, and false if that transition should *not* be animated (i.e. the chip view should * immediately disappear). */ - data class Hidden(val shouldAnimate: Boolean = true) : OngoingActivityChipModel() { - override val logName = "Hidden(anim=$shouldAnimate)" + data class Inactive(val shouldAnimate: Boolean = true) : OngoingActivityChipModel() { + override val logName = "Inactive(anim=$shouldAnimate)" } /** This chip should be shown with the given information. */ - sealed class Shown( + sealed class Active( /** * A key that uniquely identifies this chip. Used for better visual effects, like animation. */ @@ -66,8 +66,8 @@ sealed class OngoingActivityChipModel { override val colors: ColorsModel, override val onClickListenerLegacy: View.OnClickListener?, override val clickBehavior: ClickBehavior, - ) : Shown(key, icon, colors, onClickListenerLegacy, clickBehavior) { - override val logName = "Shown.Icon" + ) : Active(key, icon, colors, onClickListenerLegacy, clickBehavior) { + override val logName = "Active.Icon" } /** The chip shows a timer, counting up from [startTimeMs]. */ @@ -87,8 +87,8 @@ sealed class OngoingActivityChipModel { val startTimeMs: Long, override val onClickListenerLegacy: View.OnClickListener?, override val clickBehavior: ClickBehavior, - ) : Shown(key, icon, colors, onClickListenerLegacy, clickBehavior) { - override val logName = "Shown.Timer" + ) : Active(key, icon, colors, onClickListenerLegacy, clickBehavior) { + override val logName = "Active.Timer" } /** @@ -103,12 +103,12 @@ sealed class OngoingActivityChipModel { val time: Long, override val onClickListenerLegacy: View.OnClickListener?, override val clickBehavior: ClickBehavior, - ) : Shown(key, icon, colors, onClickListenerLegacy, clickBehavior) { + ) : Active(key, icon, colors, onClickListenerLegacy, clickBehavior) { init { StatusBarNotifChips.assertInNewMode() } - override val logName = "Shown.ShortTimeDelta" + override val logName = "Active.ShortTimeDelta" } /** @@ -121,14 +121,14 @@ sealed class OngoingActivityChipModel { /** The number of seconds until an event is started. */ val secondsUntilStarted: Long, ) : - Shown( + Active( key, icon = null, colors, onClickListenerLegacy = null, clickBehavior = ClickBehavior.None, ) { - override val logName = "Shown.Countdown" + override val logName = "Active.Countdown" } /** This chip shows the specified [text] in the chip. */ @@ -140,8 +140,8 @@ sealed class OngoingActivityChipModel { val text: String, override val onClickListenerLegacy: View.OnClickListener? = null, override val clickBehavior: ClickBehavior, - ) : Shown(key, icon, colors, onClickListenerLegacy, clickBehavior) { - override val logName = "Shown.Text" + ) : Active(key, icon, colors, onClickListenerLegacy, clickBehavior) { + override val logName = "Active.Text" } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/viewmodel/ChipTransitionHelper.kt b/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/viewmodel/ChipTransitionHelper.kt index 823b910ca13b..3b47a5e0f770 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/viewmodel/ChipTransitionHelper.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/viewmodel/ChipTransitionHelper.kt @@ -17,6 +17,7 @@ package com.android.systemui.statusbar.chips.ui.viewmodel import android.annotation.SuppressLint +import com.android.app.tracing.coroutines.launchTraced as launch import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.statusbar.chips.ui.model.OngoingActivityChipModel import kotlinx.coroutines.CoroutineScope @@ -28,7 +29,6 @@ import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.flow.transformLatest -import com.android.app.tracing.coroutines.launchTraced as launch /** * A class that can help [OngoingActivityChipViewModel] instances with various transition states. @@ -76,20 +76,19 @@ class ChipTransitionHelper(@Application private val scope: CoroutineScope) { * (see [onActivityStoppedFromDialog]). In general, this flow just uses value in [chip]. */ fun createChipFlow(chip: Flow<OngoingActivityChipModel>): StateFlow<OngoingActivityChipModel> { - return combine( - chip, - wasActivityRecentlyStoppedFromDialog, - ) { chipModel, activityRecentlyStopped -> + return combine(chip, wasActivityRecentlyStoppedFromDialog) { + chipModel, + activityRecentlyStopped -> if (activityRecentlyStopped) { // There's a bit of a delay between when the user stops an activity via // SysUI and when the system services notify SysUI that the activity has // indeed stopped. Prevent the chip from showing during this delay by // immediately hiding it without any animation. - OngoingActivityChipModel.Hidden(shouldAnimate = false) + OngoingActivityChipModel.Inactive(shouldAnimate = false) } else { chipModel } } - .stateIn(scope, SharingStarted.WhileSubscribed(), OngoingActivityChipModel.Hidden()) + .stateIn(scope, SharingStarted.WhileSubscribed(), OngoingActivityChipModel.Inactive()) } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipsViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipsViewModel.kt index dd7a4b417ba1..e7dcb74a735f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipsViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/viewmodel/OngoingActivityChipsViewModel.kt @@ -100,28 +100,28 @@ constructor( * Represents that we've internally decided to show the chip with type [type] with the given * [model] information. */ - data class Shown(val type: ChipType, val model: OngoingActivityChipModel.Shown) : + data class Active(val type: ChipType, val model: OngoingActivityChipModel.Active) : InternalChipModel /** * Represents that all chip types would like to be hidden. Each value specifies *how* that * chip type should get hidden. */ - data class Hidden( - val screenRecord: OngoingActivityChipModel.Hidden, - val shareToApp: OngoingActivityChipModel.Hidden, - val castToOtherDevice: OngoingActivityChipModel.Hidden, - val call: OngoingActivityChipModel.Hidden, - val notifs: OngoingActivityChipModel.Hidden, + data class Inactive( + val screenRecord: OngoingActivityChipModel.Inactive, + val shareToApp: OngoingActivityChipModel.Inactive, + val castToOtherDevice: OngoingActivityChipModel.Inactive, + val call: OngoingActivityChipModel.Inactive, + val notifs: OngoingActivityChipModel.Inactive, ) : InternalChipModel } private data class ChipBundle( - val screenRecord: OngoingActivityChipModel = OngoingActivityChipModel.Hidden(), - val shareToApp: OngoingActivityChipModel = OngoingActivityChipModel.Hidden(), - val castToOtherDevice: OngoingActivityChipModel = OngoingActivityChipModel.Hidden(), - val call: OngoingActivityChipModel = OngoingActivityChipModel.Hidden(), - val notifs: List<OngoingActivityChipModel.Shown> = emptyList(), + val screenRecord: OngoingActivityChipModel = OngoingActivityChipModel.Inactive(), + val shareToApp: OngoingActivityChipModel = OngoingActivityChipModel.Inactive(), + val castToOtherDevice: OngoingActivityChipModel = OngoingActivityChipModel.Inactive(), + val call: OngoingActivityChipModel = OngoingActivityChipModel.Inactive(), + val notifs: List<OngoingActivityChipModel.Active> = emptyList(), ) /** Bundles all the incoming chips into one object to easily pass to various flows. */ @@ -179,9 +179,9 @@ constructor( */ val primaryChip: StateFlow<OngoingActivityChipModel> = internalChip - .pairwise(initialValue = DEFAULT_INTERNAL_HIDDEN_MODEL) + .pairwise(initialValue = DEFAULT_INTERNAL_INACTIVE_MODEL) .map { (old, new) -> createOutputModel(old, new) } - .stateIn(scope, SharingStarted.Lazily, OngoingActivityChipModel.Hidden()) + .stateIn(scope, SharingStarted.Lazily, OngoingActivityChipModel.Inactive()) /** * Equivalent to [MultipleOngoingActivityChipsModel] but using the internal models to do some @@ -197,17 +197,17 @@ constructor( // First: Find the most important chip. val primaryChipResult = pickMostImportantChip(bundle) when (val primaryChip = primaryChipResult.mostImportantChip) { - is InternalChipModel.Hidden -> { + is InternalChipModel.Inactive -> { // If the primary chip is hidden, the secondary chip will also be hidden, so // just pass the same Hidden model for both. InternalMultipleOngoingActivityChipsModel(primaryChip, primaryChip) } - is InternalChipModel.Shown -> { + is InternalChipModel.Active -> { // Otherwise: Find the next most important chip. val secondaryChip = pickMostImportantChip(primaryChipResult.remainingChips).mostImportantChip if ( - secondaryChip is InternalChipModel.Shown && + secondaryChip is InternalChipModel.Active && StatusBarNotifChips.isEnabled && !StatusBarChipsModernization.isEnabled && !isScreenReasonablyLarge @@ -231,27 +231,27 @@ constructor( } /** Squishes the chip down to the smallest content possible. */ - private fun InternalChipModel.Shown.squish(): InternalChipModel.Shown { + private fun InternalChipModel.Active.squish(): InternalChipModel.Active { return when (model) { // Icon-only is already maximum squished - is OngoingActivityChipModel.Shown.IconOnly -> this + is OngoingActivityChipModel.Active.IconOnly -> this // Countdown shows just a single digit, so already maximum squished - is OngoingActivityChipModel.Shown.Countdown -> this + is OngoingActivityChipModel.Active.Countdown -> this // The other chips have icon+text, so we should hide the text - is OngoingActivityChipModel.Shown.Timer, - is OngoingActivityChipModel.Shown.ShortTimeDelta, - is OngoingActivityChipModel.Shown.Text -> - InternalChipModel.Shown(this.type, this.model.toIconOnly()) + is OngoingActivityChipModel.Active.Timer, + is OngoingActivityChipModel.Active.ShortTimeDelta, + is OngoingActivityChipModel.Active.Text -> + InternalChipModel.Active(this.type, this.model.toIconOnly()) } } - private fun OngoingActivityChipModel.Shown.toIconOnly(): OngoingActivityChipModel.Shown { + private fun OngoingActivityChipModel.Active.toIconOnly(): OngoingActivityChipModel.Active { // If this chip doesn't have an icon, then it only has text and we should continue showing // its text. (This is theoretically impossible because - // [OngoingActivityChipModel.Shown.Countdown] is the only chip without an icon, but protect + // [OngoingActivityChipModel.Active.Countdown] is the only chip without an icon, but protect // against it just in case.) val currentIcon = icon ?: return this - return OngoingActivityChipModel.Shown.IconOnly( + return OngoingActivityChipModel.Active.IconOnly( key, currentIcon, colors, @@ -275,13 +275,13 @@ constructor( .map { MultipleOngoingActivityChipsModel( primary = it, - secondary = OngoingActivityChipModel.Hidden(), + secondary = OngoingActivityChipModel.Inactive(), ) } .stateIn(scope, SharingStarted.Lazily, MultipleOngoingActivityChipsModel()) } else { internalChips - .pairwise(initialValue = DEFAULT_MULTIPLE_INTERNAL_HIDDEN_MODEL) + .pairwise(initialValue = DEFAULT_MULTIPLE_INTERNAL_INACTIVE_MODEL) .map { (old, new) -> val correctPrimary = createOutputModel(old.primary, new.primary) val correctSecondary = createOutputModel(old.secondary, new.secondary) @@ -305,13 +305,13 @@ constructor( private fun pickMostImportantChip(bundle: ChipBundle): MostImportantChipResult { // This `when` statement shows the priority order of the chips. return when { - bundle.screenRecord is OngoingActivityChipModel.Shown -> + bundle.screenRecord is OngoingActivityChipModel.Active -> MostImportantChipResult( mostImportantChip = - InternalChipModel.Shown(ChipType.ScreenRecord, bundle.screenRecord), + InternalChipModel.Active(ChipType.ScreenRecord, bundle.screenRecord), remainingChips = bundle.copy( - screenRecord = OngoingActivityChipModel.Hidden(), + screenRecord = OngoingActivityChipModel.Inactive(), // Screen recording also activates the media projection APIs, which // means that whenever the screen recording chip is active, the // share-to-app chip would also be active. (Screen recording is a @@ -321,52 +321,52 @@ constructor( // case. If we did have screen recording as the primary chip, we need to // suppress the share-to-app chip to make sure they don't both show. // See b/296461748. - shareToApp = OngoingActivityChipModel.Hidden(), + shareToApp = OngoingActivityChipModel.Inactive(), ), ) - bundle.shareToApp is OngoingActivityChipModel.Shown -> + bundle.shareToApp is OngoingActivityChipModel.Active -> MostImportantChipResult( mostImportantChip = - InternalChipModel.Shown(ChipType.ShareToApp, bundle.shareToApp), - remainingChips = bundle.copy(shareToApp = OngoingActivityChipModel.Hidden()), + InternalChipModel.Active(ChipType.ShareToApp, bundle.shareToApp), + remainingChips = bundle.copy(shareToApp = OngoingActivityChipModel.Inactive()), ) - bundle.castToOtherDevice is OngoingActivityChipModel.Shown -> + bundle.castToOtherDevice is OngoingActivityChipModel.Active -> MostImportantChipResult( mostImportantChip = - InternalChipModel.Shown( + InternalChipModel.Active( ChipType.CastToOtherDevice, bundle.castToOtherDevice, ), remainingChips = - bundle.copy(castToOtherDevice = OngoingActivityChipModel.Hidden()), + bundle.copy(castToOtherDevice = OngoingActivityChipModel.Inactive()), ) - bundle.call is OngoingActivityChipModel.Shown -> + bundle.call is OngoingActivityChipModel.Active -> MostImportantChipResult( - mostImportantChip = InternalChipModel.Shown(ChipType.Call, bundle.call), - remainingChips = bundle.copy(call = OngoingActivityChipModel.Hidden()), + mostImportantChip = InternalChipModel.Active(ChipType.Call, bundle.call), + remainingChips = bundle.copy(call = OngoingActivityChipModel.Inactive()), ) bundle.notifs.isNotEmpty() -> MostImportantChipResult( mostImportantChip = - InternalChipModel.Shown(ChipType.Notification, bundle.notifs.first()), + InternalChipModel.Active(ChipType.Notification, bundle.notifs.first()), remainingChips = bundle.copy(notifs = bundle.notifs.subList(1, bundle.notifs.size)), ) else -> { // We should only get here if all chip types are hidden - check(bundle.screenRecord is OngoingActivityChipModel.Hidden) - check(bundle.shareToApp is OngoingActivityChipModel.Hidden) - check(bundle.castToOtherDevice is OngoingActivityChipModel.Hidden) - check(bundle.call is OngoingActivityChipModel.Hidden) + check(bundle.screenRecord is OngoingActivityChipModel.Inactive) + check(bundle.shareToApp is OngoingActivityChipModel.Inactive) + check(bundle.castToOtherDevice is OngoingActivityChipModel.Inactive) + check(bundle.call is OngoingActivityChipModel.Inactive) check(bundle.notifs.isEmpty()) MostImportantChipResult( mostImportantChip = - InternalChipModel.Hidden( + InternalChipModel.Inactive( screenRecord = bundle.screenRecord, shareToApp = bundle.shareToApp, castToOtherDevice = bundle.castToOtherDevice, call = bundle.call, - notifs = OngoingActivityChipModel.Hidden(), + notifs = OngoingActivityChipModel.Inactive(), ), // All the chips are already hidden, so no need to filter anything out of the // bundle. @@ -380,14 +380,14 @@ constructor( old: InternalChipModel, new: InternalChipModel, ): OngoingActivityChipModel { - return if (old is InternalChipModel.Shown && new is InternalChipModel.Hidden) { + return if (old is InternalChipModel.Active && new is InternalChipModel.Inactive) { // If we're transitioning from showing the chip to hiding the chip, different // chips require different animation behaviors. For example, the screen share // chips shouldn't animate if the user stopped the screen share from the dialog // (see b/353249803#comment4), but the call chip should always animate. // - // This `when` block makes sure that when we're transitioning from Shown to - // Hidden, we check what chip type was previously showing and we use that chip + // This `when` block makes sure that when we're transitioning from Active to + // Inactive, we check what chip type was previously showing and we use that chip // type's hide animation behavior. return when (old.type) { ChipType.ScreenRecord -> new.screenRecord @@ -396,13 +396,13 @@ constructor( ChipType.Call -> new.call ChipType.Notification -> new.notifs } - } else if (new is InternalChipModel.Shown) { + } else if (new is InternalChipModel.Active) { // If we have a chip to show, always show it. new.model } else { // In the Hidden -> Hidden transition, it shouldn't matter which hidden model we // choose because no animation should happen regardless. - OngoingActivityChipModel.Hidden() + OngoingActivityChipModel.Inactive() } } @@ -412,19 +412,19 @@ constructor( companion object { private val TAG = "ChipsViewModel".pad() - private val DEFAULT_INTERNAL_HIDDEN_MODEL = - InternalChipModel.Hidden( - screenRecord = OngoingActivityChipModel.Hidden(), - shareToApp = OngoingActivityChipModel.Hidden(), - castToOtherDevice = OngoingActivityChipModel.Hidden(), - call = OngoingActivityChipModel.Hidden(), - notifs = OngoingActivityChipModel.Hidden(), + private val DEFAULT_INTERNAL_INACTIVE_MODEL = + InternalChipModel.Inactive( + screenRecord = OngoingActivityChipModel.Inactive(), + shareToApp = OngoingActivityChipModel.Inactive(), + castToOtherDevice = OngoingActivityChipModel.Inactive(), + call = OngoingActivityChipModel.Inactive(), + notifs = OngoingActivityChipModel.Inactive(), ) - private val DEFAULT_MULTIPLE_INTERNAL_HIDDEN_MODEL = + private val DEFAULT_MULTIPLE_INTERNAL_INACTIVE_MODEL = InternalMultipleOngoingActivityChipsModel( - primary = DEFAULT_INTERNAL_HIDDEN_MODEL, - secondary = DEFAULT_INTERNAL_HIDDEN_MODEL, + primary = DEFAULT_INTERNAL_INACTIVE_MODEL, + secondary = DEFAULT_INTERNAL_INACTIVE_MODEL, ) } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/binder/HomeStatusBarViewBinder.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/binder/HomeStatusBarViewBinder.kt index acce6426362d..2cfe01e0c68b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/binder/HomeStatusBarViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/binder/HomeStatusBarViewBinder.kt @@ -157,12 +157,12 @@ constructor( ) if (StatusBarRootModernization.isEnabled) { when (primaryChipModel) { - is OngoingActivityChipModel.Shown -> + is OngoingActivityChipModel.Active -> primaryChipViewBinding.rootView.show( shouldAnimateChange = true ) - is OngoingActivityChipModel.Hidden -> + is OngoingActivityChipModel.Inactive -> primaryChipViewBinding.rootView.hide( state = View.GONE, shouldAnimateChange = primaryChipModel.shouldAnimate, @@ -170,14 +170,14 @@ constructor( } } else { when (primaryChipModel) { - is OngoingActivityChipModel.Shown -> + is OngoingActivityChipModel.Active -> listener?.onOngoingActivityStatusChanged( hasPrimaryOngoingActivity = true, hasSecondaryOngoingActivity = false, shouldAnimate = true, ) - is OngoingActivityChipModel.Hidden -> + is OngoingActivityChipModel.Inactive -> listener?.onOngoingActivityStatusChanged( hasPrimaryOngoingActivity = false, hasSecondaryOngoingActivity = false, @@ -221,9 +221,9 @@ constructor( } else { listener?.onOngoingActivityStatusChanged( hasPrimaryOngoingActivity = - chips.primary is OngoingActivityChipModel.Shown, + chips.primary is OngoingActivityChipModel.Active, hasSecondaryOngoingActivity = - chips.secondary is OngoingActivityChipModel.Shown, + chips.secondary is OngoingActivityChipModel.Active, // TODO(b/364653005): Figure out the animation story here. shouldAnimate = true, ) @@ -321,7 +321,7 @@ constructor( private fun OngoingActivityChipModel.toVisibilityModel(): VisibilityModel { return VisibilityModel( - visibility = if (this is OngoingActivityChipModel.Shown) View.VISIBLE else View.GONE, + visibility = if (this is OngoingActivityChipModel.Active) View.VISIBLE else View.GONE, // TODO(b/364653005): Figure out the animation story here. shouldAnimateChange = true, ) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/HomeStatusBarViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/HomeStatusBarViewModel.kt index df6a2fe3597e..f28f62f24f9b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/HomeStatusBarViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/HomeStatusBarViewModel.kt @@ -331,9 +331,9 @@ constructor( private val isAnyChipVisible = if (StatusBarNotifChips.isEnabled) { - ongoingActivityChips.map { it.primary is OngoingActivityChipModel.Shown } + ongoingActivityChips.map { it.primary is OngoingActivityChipModel.Active } } else { - primaryOngoingActivityChip.map { it is OngoingActivityChipModel.Shown } + primaryOngoingActivityChip.map { it is OngoingActivityChipModel.Active } } /** |