Loading packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/SceneTransitionLayoutDataSource.kt +16 −7 Original line number Diff line number Diff line Loading @@ -59,10 +59,7 @@ class SceneTransitionLayoutDataSource( initialValue = emptySet(), ) override fun changeScene( toScene: SceneKey, transitionKey: TransitionKey?, ) { override fun changeScene(toScene: SceneKey, transitionKey: TransitionKey?) { state.setTargetScene( targetScene = toScene, transitionKey = transitionKey, Loading @@ -71,9 +68,7 @@ class SceneTransitionLayoutDataSource( } override fun snapToScene(toScene: SceneKey) { state.snapToScene( scene = toScene, ) state.snapToScene(scene = toScene) } override fun showOverlay(overlay: OverlayKey, transitionKey: TransitionKey?) { Loading @@ -100,4 +95,18 @@ class SceneTransitionLayoutDataSource( transitionKey = transitionKey, ) } override fun instantlyShowOverlay(overlay: OverlayKey) { state.snapToScene( scene = state.transitionState.currentScene, currentOverlays = state.currentOverlays + overlay, ) } override fun instantlyHideOverlay(overlay: OverlayKey) { state.snapToScene( scene = state.transitionState.currentScene, currentOverlays = state.currentOverlays - overlay, ) } } packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/interactor/SceneInteractorTest.kt +38 −0 Original line number Diff line number Diff line Loading @@ -675,4 +675,42 @@ class SceneInteractorTest : SysuiTestCase() { runCurrent() underTest.showOverlay(Overlays.QuickSettingsShade, "reason") } @Test fun instantlyShowOverlay() = kosmos.runTest { enableDualShade() runCurrent() val currentScene by collectLastValue(underTest.currentScene) val currentOverlays by collectLastValue(underTest.currentOverlays) val originalScene = currentScene assertThat(currentOverlays).isEmpty() val overlay = Overlays.NotificationsShade underTest.instantlyShowOverlay(overlay, "reason") runCurrent() assertThat(currentScene).isEqualTo(originalScene) assertThat(currentOverlays).contains(overlay) } @Test fun instantlyHideOverlay() = kosmos.runTest { enableDualShade() runCurrent() val currentScene by collectLastValue(underTest.currentScene) val currentOverlays by collectLastValue(underTest.currentOverlays) val overlay = Overlays.QuickSettingsShade underTest.showOverlay(overlay, "reason") runCurrent() val originalScene = currentScene assertThat(currentOverlays).contains(overlay) underTest.instantlyHideOverlay(overlay, "reason") runCurrent() assertThat(currentScene).isEqualTo(originalScene) assertThat(currentOverlays).isEmpty() } } packages/SystemUI/src/com/android/systemui/communal/data/repository/CommunalSceneRepository.kt +4 −0 Original line number Diff line number Diff line Loading @@ -147,5 +147,9 @@ constructor( to: OverlayKey, transitionKey: TransitionKey?, ) = Unit override fun instantlyShowOverlay(overlay: OverlayKey) = Unit override fun instantlyHideOverlay(overlay: OverlayKey) = Unit } } packages/SystemUI/src/com/android/systemui/scene/data/repository/SceneContainerRepository.kt +20 −0 Original line number Diff line number Diff line Loading @@ -130,6 +130,26 @@ constructor( dataSource.replaceOverlay(from = from, to = to, transitionKey = transitionKey) } /** * Instantly shows [overlay]. * * The change is instantaneous and not animated; it will be observable in the next frame and * there will be no transition animation. */ fun instantlyShowOverlay(overlay: OverlayKey) { dataSource.instantlyShowOverlay(overlay) } /** * Instantly hides [overlay]. * * The change is instantaneous and not animated; it will be observable in the next frame and * there will be no transition animation. */ fun instantlyHideOverlay(overlay: OverlayKey) { dataSource.instantlyHideOverlay(overlay) } /** Sets whether the container is visible. */ fun setVisible(isVisible: Boolean) { _isVisible.value = isVisible Loading packages/SystemUI/src/com/android/systemui/scene/domain/interactor/SceneInteractor.kt +32 −0 Original line number Diff line number Diff line Loading @@ -338,6 +338,38 @@ constructor( repository.hideOverlay(overlay = overlay, transitionKey = transitionKey) } /** * Instantly shows [overlay]. * * The change is instantaneous and not animated; it will be observable in the next frame and * there will be no transition animation. */ fun instantlyShowOverlay(overlay: OverlayKey, loggingReason: String) { if (!validateOverlayChange(to = overlay, loggingReason = loggingReason)) { return } logger.logOverlayChangeRequested(to = overlay, reason = loggingReason) repository.instantlyShowOverlay(overlay) } /** * Instantly hides [overlay]. * * The change is instantaneous and not animated; it will be observable in the next frame and * there will be no transition animation. */ fun instantlyHideOverlay(overlay: OverlayKey, loggingReason: String) { if (!validateOverlayChange(from = overlay, loggingReason = loggingReason)) { return } logger.logOverlayChangeRequested(from = overlay, reason = loggingReason) repository.instantlyHideOverlay(overlay) } /** * Replace [from] by [to] so that [from] ends up not being visible on screen and [to] ends up * being visible. Loading Loading
packages/SystemUI/compose/features/src/com/android/systemui/scene/ui/composable/SceneTransitionLayoutDataSource.kt +16 −7 Original line number Diff line number Diff line Loading @@ -59,10 +59,7 @@ class SceneTransitionLayoutDataSource( initialValue = emptySet(), ) override fun changeScene( toScene: SceneKey, transitionKey: TransitionKey?, ) { override fun changeScene(toScene: SceneKey, transitionKey: TransitionKey?) { state.setTargetScene( targetScene = toScene, transitionKey = transitionKey, Loading @@ -71,9 +68,7 @@ class SceneTransitionLayoutDataSource( } override fun snapToScene(toScene: SceneKey) { state.snapToScene( scene = toScene, ) state.snapToScene(scene = toScene) } override fun showOverlay(overlay: OverlayKey, transitionKey: TransitionKey?) { Loading @@ -100,4 +95,18 @@ class SceneTransitionLayoutDataSource( transitionKey = transitionKey, ) } override fun instantlyShowOverlay(overlay: OverlayKey) { state.snapToScene( scene = state.transitionState.currentScene, currentOverlays = state.currentOverlays + overlay, ) } override fun instantlyHideOverlay(overlay: OverlayKey) { state.snapToScene( scene = state.transitionState.currentScene, currentOverlays = state.currentOverlays - overlay, ) } }
packages/SystemUI/multivalentTests/src/com/android/systemui/scene/domain/interactor/SceneInteractorTest.kt +38 −0 Original line number Diff line number Diff line Loading @@ -675,4 +675,42 @@ class SceneInteractorTest : SysuiTestCase() { runCurrent() underTest.showOverlay(Overlays.QuickSettingsShade, "reason") } @Test fun instantlyShowOverlay() = kosmos.runTest { enableDualShade() runCurrent() val currentScene by collectLastValue(underTest.currentScene) val currentOverlays by collectLastValue(underTest.currentOverlays) val originalScene = currentScene assertThat(currentOverlays).isEmpty() val overlay = Overlays.NotificationsShade underTest.instantlyShowOverlay(overlay, "reason") runCurrent() assertThat(currentScene).isEqualTo(originalScene) assertThat(currentOverlays).contains(overlay) } @Test fun instantlyHideOverlay() = kosmos.runTest { enableDualShade() runCurrent() val currentScene by collectLastValue(underTest.currentScene) val currentOverlays by collectLastValue(underTest.currentOverlays) val overlay = Overlays.QuickSettingsShade underTest.showOverlay(overlay, "reason") runCurrent() val originalScene = currentScene assertThat(currentOverlays).contains(overlay) underTest.instantlyHideOverlay(overlay, "reason") runCurrent() assertThat(currentScene).isEqualTo(originalScene) assertThat(currentOverlays).isEmpty() } }
packages/SystemUI/src/com/android/systemui/communal/data/repository/CommunalSceneRepository.kt +4 −0 Original line number Diff line number Diff line Loading @@ -147,5 +147,9 @@ constructor( to: OverlayKey, transitionKey: TransitionKey?, ) = Unit override fun instantlyShowOverlay(overlay: OverlayKey) = Unit override fun instantlyHideOverlay(overlay: OverlayKey) = Unit } }
packages/SystemUI/src/com/android/systemui/scene/data/repository/SceneContainerRepository.kt +20 −0 Original line number Diff line number Diff line Loading @@ -130,6 +130,26 @@ constructor( dataSource.replaceOverlay(from = from, to = to, transitionKey = transitionKey) } /** * Instantly shows [overlay]. * * The change is instantaneous and not animated; it will be observable in the next frame and * there will be no transition animation. */ fun instantlyShowOverlay(overlay: OverlayKey) { dataSource.instantlyShowOverlay(overlay) } /** * Instantly hides [overlay]. * * The change is instantaneous and not animated; it will be observable in the next frame and * there will be no transition animation. */ fun instantlyHideOverlay(overlay: OverlayKey) { dataSource.instantlyHideOverlay(overlay) } /** Sets whether the container is visible. */ fun setVisible(isVisible: Boolean) { _isVisible.value = isVisible Loading
packages/SystemUI/src/com/android/systemui/scene/domain/interactor/SceneInteractor.kt +32 −0 Original line number Diff line number Diff line Loading @@ -338,6 +338,38 @@ constructor( repository.hideOverlay(overlay = overlay, transitionKey = transitionKey) } /** * Instantly shows [overlay]. * * The change is instantaneous and not animated; it will be observable in the next frame and * there will be no transition animation. */ fun instantlyShowOverlay(overlay: OverlayKey, loggingReason: String) { if (!validateOverlayChange(to = overlay, loggingReason = loggingReason)) { return } logger.logOverlayChangeRequested(to = overlay, reason = loggingReason) repository.instantlyShowOverlay(overlay) } /** * Instantly hides [overlay]. * * The change is instantaneous and not animated; it will be observable in the next frame and * there will be no transition animation. */ fun instantlyHideOverlay(overlay: OverlayKey, loggingReason: String) { if (!validateOverlayChange(from = overlay, loggingReason = loggingReason)) { return } logger.logOverlayChangeRequested(from = overlay, reason = loggingReason) repository.instantlyHideOverlay(overlay) } /** * Replace [from] by [to] so that [from] ends up not being visible on screen and [to] ends up * being visible. Loading