diff options
8 files changed, 40 insertions, 29 deletions
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/section/NotificationSection.kt b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/section/NotificationSection.kt index 4e117d6ff4db..6801cf27a64d 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/section/NotificationSection.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/section/NotificationSection.kt @@ -32,6 +32,7 @@ import com.android.systemui.keyguard.MigrateClocksToBlueprint import com.android.systemui.keyguard.ui.composable.modifier.burnInAware import com.android.systemui.keyguard.ui.viewmodel.AodBurnInViewModel import com.android.systemui.keyguard.ui.viewmodel.BurnInParameters +import com.android.systemui.lifecycle.rememberViewModel import com.android.systemui.notifications.ui.composable.ConstrainedNotificationStack import com.android.systemui.shade.LargeScreenHeaderHelper import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout @@ -48,7 +49,7 @@ class NotificationSection @Inject constructor( private val stackScrollView: Lazy<NotificationScrollView>, - private val viewModel: NotificationsPlaceholderViewModel, + private val viewModelFactory: NotificationsPlaceholderViewModel.Factory, private val aodBurnInViewModel: AodBurnInViewModel, sharedNotificationContainer: SharedNotificationContainer, sharedNotificationContainerViewModel: SharedNotificationContainerViewModel, @@ -98,7 +99,7 @@ constructor( ConstrainedNotificationStack( stackScrollView = stackScrollView.get(), - viewModel = viewModel, + viewModel = rememberViewModel { viewModelFactory.create() }, modifier = modifier .fillMaxWidth() diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/NotificationsShadeScene.kt b/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/NotificationsShadeScene.kt index af3d9d351e41..0cb8bd3a7efb 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/NotificationsShadeScene.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/notifications/ui/composable/NotificationsShadeScene.kt @@ -28,6 +28,7 @@ import com.android.compose.animation.scene.UserActionResult import com.android.systemui.battery.BatteryMeterViewController import com.android.systemui.dagger.SysUISingleton import com.android.systemui.keyguard.ui.composable.LockscreenContent +import com.android.systemui.lifecycle.rememberViewModel import com.android.systemui.notifications.ui.viewmodel.NotificationsShadeSceneActionsViewModel import com.android.systemui.scene.session.ui.composable.SaveableSession import com.android.systemui.scene.shared.model.Scenes @@ -53,7 +54,7 @@ constructor( private val actionsViewModelFactory: NotificationsShadeSceneActionsViewModel.Factory, private val overlayShadeViewModelFactory: OverlayShadeViewModel.Factory, private val shadeHeaderViewModelFactory: ShadeHeaderViewModel.Factory, - private val notificationsPlaceholderViewModel: NotificationsPlaceholderViewModel, + private val notificationsPlaceholderViewModelFactory: NotificationsPlaceholderViewModel.Factory, private val tintedIconManagerFactory: TintedIconManager.Factory, private val batteryMeterViewControllerFactory: BatteryMeterViewController.Factory, private val statusBarIconController: StatusBarIconController, @@ -79,6 +80,10 @@ constructor( override fun SceneScope.Content( modifier: Modifier, ) { + val notificationsPlaceholderViewModel = rememberViewModel { + notificationsPlaceholderViewModelFactory.create() + } + OverlayShade( modifier = modifier, viewModelFactory = overlayShadeViewModelFactory, diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/qs/ui/composable/QuickSettingsScene.kt b/packages/SystemUI/compose/features/src/com/android/systemui/qs/ui/composable/QuickSettingsScene.kt index 8bba0f4f3651..12edd049c0e1 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/qs/ui/composable/QuickSettingsScene.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/qs/ui/composable/QuickSettingsScene.kt @@ -121,7 +121,7 @@ constructor( private val shadeSession: SaveableSession, private val notificationStackScrollView: Lazy<NotificationScrollView>, private val viewModel: QuickSettingsSceneViewModel, - private val notificationsPlaceholderViewModel: NotificationsPlaceholderViewModel, + private val notificationsPlaceholderViewModelFactory: NotificationsPlaceholderViewModel.Factory, private val tintedIconManagerFactory: TintedIconManager.Factory, private val batteryMeterViewControllerFactory: BatteryMeterViewController.Factory, private val statusBarIconController: StatusBarIconController, @@ -140,7 +140,8 @@ constructor( QuickSettingsScene( notificationStackScrollView = notificationStackScrollView.get(), viewModel = viewModel, - notificationsPlaceholderViewModel = notificationsPlaceholderViewModel, + notificationsPlaceholderViewModel = + rememberViewModel { notificationsPlaceholderViewModelFactory.create() }, createTintedIconManager = tintedIconManagerFactory::create, createBatteryMeterViewController = batteryMeterViewControllerFactory::create, statusBarIconController = statusBarIconController, diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/GoneScene.kt b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/GoneScene.kt index b0c3fb31256f..f15e87b4514d 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/GoneScene.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/GoneScene.kt @@ -26,6 +26,7 @@ import com.android.compose.animation.scene.UserActionResult import com.android.compose.animation.scene.animateSceneDpAsState import com.android.compose.animation.scene.animateSceneFloatAsState import com.android.systemui.dagger.SysUISingleton +import com.android.systemui.lifecycle.rememberViewModel import com.android.systemui.notifications.ui.composable.SnoozeableHeadsUpNotificationSpace import com.android.systemui.qs.ui.composable.QuickSettings import com.android.systemui.qs.ui.composable.QuickSettings.SharedValues.MediaLandscapeTopOffset @@ -47,7 +48,7 @@ class GoneScene @Inject constructor( private val notificationStackScrolLView: Lazy<NotificationScrollView>, - private val notificationsPlaceholderViewModel: NotificationsPlaceholderViewModel, + private val notificationsPlaceholderViewModelFactory: NotificationsPlaceholderViewModel.Factory, private val viewModelFactory: GoneSceneActionsViewModel.Factory, ) : ComposableScene { override val key = Scenes.Gone @@ -73,7 +74,7 @@ constructor( Spacer(modifier.fillMaxSize()) SnoozeableHeadsUpNotificationSpace( stackScrollView = notificationStackScrolLView.get(), - viewModel = notificationsPlaceholderViewModel + viewModel = rememberViewModel { notificationsPlaceholderViewModelFactory.create() }, ) } } diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/ShadeScene.kt b/packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/ShadeScene.kt index 16972bc95e57..7920e74eff01 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/ShadeScene.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/ShadeScene.kt @@ -148,7 +148,7 @@ constructor( private val notificationStackScrollView: Lazy<NotificationScrollView>, private val actionsViewModelFactory: ShadeSceneActionsViewModel.Factory, private val contentViewModelFactory: ShadeSceneContentViewModel.Factory, - private val notificationsPlaceholderViewModel: NotificationsPlaceholderViewModel, + private val notificationsPlaceholderViewModelFactory: NotificationsPlaceholderViewModel.Factory, private val tintedIconManagerFactory: TintedIconManager.Factory, private val batteryMeterViewControllerFactory: BatteryMeterViewController.Factory, private val statusBarIconController: StatusBarIconController, @@ -177,7 +177,8 @@ constructor( ShadeScene( notificationStackScrollView.get(), viewModel = rememberViewModel { contentViewModelFactory.create() }, - notificationsPlaceholderViewModel = notificationsPlaceholderViewModel, + notificationsPlaceholderViewModel = + rememberViewModel { notificationsPlaceholderViewModelFactory.create() }, createTintedIconManager = tintedIconManagerFactory::create, createBatteryMeterViewController = batteryMeterViewControllerFactory::create, statusBarIconController = statusBarIconController, diff --git a/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/PatternBouncerViewModel.kt b/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/PatternBouncerViewModel.kt index a4016005a756..8b9c0a9a0bdd 100644 --- a/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/PatternBouncerViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/PatternBouncerViewModel.kt @@ -145,8 +145,7 @@ class PatternBouncerViewModel( ) } } - } - ?: emptyList() + } ?: emptyList() _selectedDots.value = linkedSetOf<PatternDotViewModel>().apply { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationsPlaceholderViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationsPlaceholderViewModel.kt index d179888b569c..53fab621173a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationsPlaceholderViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationsPlaceholderViewModel.kt @@ -16,34 +16,32 @@ package com.android.systemui.statusbar.notification.stack.ui.viewmodel -import com.android.systemui.dagger.SysUISingleton -import com.android.systemui.dump.DumpManager import com.android.systemui.flags.FeatureFlagsClassic import com.android.systemui.flags.Flags +import com.android.systemui.lifecycle.SysUiViewModel import com.android.systemui.scene.shared.flag.SceneContainerFlag import com.android.systemui.shade.domain.interactor.ShadeInteractor import com.android.systemui.statusbar.notification.domain.interactor.HeadsUpNotificationInteractor import com.android.systemui.statusbar.notification.stack.domain.interactor.NotificationStackAppearanceInteractor import com.android.systemui.statusbar.notification.stack.shared.model.ShadeScrimBounds import com.android.systemui.statusbar.notification.stack.shared.model.ShadeScrimRounding -import com.android.systemui.util.kotlin.FlowDumperImpl -import javax.inject.Inject +import dagger.assisted.AssistedFactory +import dagger.assisted.AssistedInject import kotlinx.coroutines.flow.Flow /** * ViewModel used by the Notification placeholders inside the scene container to update the * [NotificationStackAppearanceInteractor], and by extension control the NSSL. */ -@SysUISingleton class NotificationsPlaceholderViewModel -@Inject +@AssistedInject constructor( - dumpManager: DumpManager, private val interactor: NotificationStackAppearanceInteractor, shadeInteractor: ShadeInteractor, private val headsUpNotificationInteractor: HeadsUpNotificationInteractor, featureFlags: FeatureFlagsClassic, -) : FlowDumperImpl(dumpManager) { +) : SysUiViewModel() { + /** DEBUG: whether the placeholder should be made slightly visible for positional debugging. */ val isVisualDebuggingEnabled: Boolean = featureFlags.isEnabled(Flags.NSSL_DEBUG_LINES) @@ -70,35 +68,37 @@ constructor( headsUpNotificationInteractor.isHeadsUpOrAnimatingAway /** Corner rounding of the stack */ - val shadeScrimRounding: Flow<ShadeScrimRounding> = - interactor.shadeScrimRounding.dumpWhileCollecting("shadeScrimRounding") + // TODO(b/359244921): add .dumpWhileCollecting("shadeScrimRounding") + val shadeScrimRounding: Flow<ShadeScrimRounding> = interactor.shadeScrimRounding /** * The amount [0-1] that the shade or quick settings has been opened. At 0, the shade is closed; * at 1, either the shade or quick settings is open. */ - val expandFraction: Flow<Float> = shadeInteractor.anyExpansion.dumpValue("expandFraction") + // TODO(b/359244921): add .dumpValue("expandFraction") + val expandFraction: Flow<Float> = shadeInteractor.anyExpansion /** * The amount [0-1] that quick settings has been opened. At 0, the shade may be open or closed; * at 1, the quick settings are open. */ - val shadeToQsFraction: Flow<Float> = shadeInteractor.qsExpansion.dumpValue("shadeToQsFraction") + // TODO(b/359244921): add .dumpValue("shadeToQsFraction") + val shadeToQsFraction: Flow<Float> = shadeInteractor.qsExpansion /** * The amount in px that the notification stack should scroll due to internal expansion. This * should only happen when a notification expansion hits the bottom of the screen, so it is * necessary to scroll up to keep expanding the notification. */ - val syntheticScroll: Flow<Float> = - interactor.syntheticScroll.dumpWhileCollecting("syntheticScroll") + // TODO(b/359244921): add .dumpWhileCollecting("syntheticScroll") + val syntheticScroll: Flow<Float> = interactor.syntheticScroll /** * Whether the current touch gesture is overscroll. If true, it means the NSSL has already * consumed part of the gesture. */ - val isCurrentGestureOverscroll: Flow<Boolean> = - interactor.isCurrentGestureOverscroll.dumpWhileCollecting("isCurrentGestureOverScroll") + // TODO(b/359244921): add .dumpWhileCollecting("isCurrentGestureOverScroll") + val isCurrentGestureOverscroll: Flow<Boolean> = interactor.isCurrentGestureOverscroll /** Sets whether the notification stack is scrolled to the top. */ fun setScrolledToTop(scrolledToTop: Boolean) { @@ -114,6 +114,11 @@ constructor( fun snoozeHun() { headsUpNotificationInteractor.snooze() } + + @AssistedFactory + interface Factory { + fun create(): NotificationsPlaceholderViewModel + } } // Expansion fraction thresholds (between 0-1f) at which the corresponding value should be diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationsPlaceholderViewModelKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationsPlaceholderViewModelKosmos.kt index 20dc668e4ff6..1542bb349a97 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationsPlaceholderViewModelKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationsPlaceholderViewModelKosmos.kt @@ -16,7 +16,6 @@ package com.android.systemui.statusbar.notification.stack.ui.viewmodel -import com.android.systemui.dump.dumpManager import com.android.systemui.flags.featureFlagsClassic import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.Kosmos.Fixture @@ -26,7 +25,6 @@ import com.android.systemui.statusbar.notification.stack.domain.interactor.notif val Kosmos.notificationsPlaceholderViewModel by Fixture { NotificationsPlaceholderViewModel( - dumpManager = dumpManager, interactor = notificationStackAppearanceInteractor, shadeInteractor = shadeInteractor, headsUpNotificationInteractor = headsUpNotificationInteractor, |