Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0f1b721c authored by Shawn Lee's avatar Shawn Lee
Browse files

[flexiglass] Add isScrollable to NotificationStackAppearanceViewModel

Moving the source of truth for this value in Flexiglass to be scene-based rather than StatusBarState-based

Bug: 25590122
Test: updated unit tests
Flag: ACONFIG com.android.systemui.scene_container DEVELOPMENT
Change-Id: I0c6b4b39e4b27d3f0eb85f7d537f895d49642368
parent 2f1213a1
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -97,6 +97,8 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() {
            sceneInteractor.setTransitionState(transitionState)
            val expandFraction by collectLastValue(appearanceViewModel.expandFraction)
            assertThat(expandFraction).isEqualTo(0f)
            val isScrollable by collectLastValue(appearanceViewModel.isScrollable)
            assertThat(isScrollable).isFalse()

            fakeSceneDataSource.pause()
            sceneInteractor.changeScene(Scenes.Shade, "reason")
@@ -119,6 +121,7 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() {

            fakeSceneDataSource.unpause(expectedScene = Scenes.Shade)
            assertThat(expandFraction).isWithin(0.01f).of(1f)
            assertThat(isScrollable).isTrue()
        }

    @Test
@@ -131,6 +134,8 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() {
            sceneInteractor.setTransitionState(transitionState)
            val expandFraction by collectLastValue(appearanceViewModel.expandFraction)
            assertThat(expandFraction).isEqualTo(1f)
            val isScrollable by collectLastValue(appearanceViewModel.isScrollable)
            assertThat(isScrollable).isFalse()
        }

    @Test
@@ -144,7 +149,12 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() {
            val expandFraction by collectLastValue(appearanceViewModel.expandFraction)
            assertThat(expandFraction).isEqualTo(1f)

            fakeSceneDataSource.changeScene(toScene = Scenes.Shade)
            val isScrollable by collectLastValue(appearanceViewModel.isScrollable)
            assertThat(isScrollable).isTrue()

            fakeSceneDataSource.pause()

            sceneInteractor.changeScene(Scenes.QuickSettings, "reason")
            val transitionProgress = MutableStateFlow(0f)
            transitionState.value =
@@ -165,5 +175,6 @@ class NotificationStackAppearanceIntegrationTest : SysuiTestCase() {

            fakeSceneDataSource.unpause(expectedScene = Scenes.QuickSettings)
            assertThat(expandFraction).isEqualTo(1f)
            assertThat(isScrollable).isFalse()
        }
}
+4 −2
Original line number Diff line number Diff line
@@ -982,8 +982,10 @@ public class QuickSettingsControllerImpl implements QuickSettingsController, Dum
        if (!FooterViewRefactor.isEnabled()) {
            mNotificationStackScrollLayoutController.setQsFullScreen(qsFullScreen);
        }
        if (!SceneContainerFlag.isEnabled()) {
            mNotificationStackScrollLayoutController.setScrollingEnabled(
                    mBarState != KEYGUARD && (!qsFullScreen || mExpansionFromOverscroll));
        }

        if (mQsStateUpdateListener != null) {
            mQsStateUpdateListener.onQsStateUpdated(getExpanded(), mStackScrollerOverscrolling);
+2 −0
Original line number Diff line number Diff line
@@ -80,6 +80,8 @@ object NotificationStackAppearanceViewBinder {
                        wasExpanding = nowExpanding
                    }
                }

                launch { viewModel.isScrollable.collect { controller.setScrollingEnabled(it) } }
            }
        }
    }
+9 −0
Original line number Diff line number Diff line
@@ -20,23 +20,28 @@ package com.android.systemui.statusbar.notification.stack.ui.viewmodel
import com.android.compose.animation.scene.ObservableTransitionState
import com.android.systemui.common.shared.model.NotificationContainerBounds
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dump.DumpManager
import com.android.systemui.scene.domain.interactor.SceneInteractor
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.scene.shared.model.Scenes.Shade
import com.android.systemui.shade.domain.interactor.ShadeInteractor
import com.android.systemui.statusbar.notification.stack.domain.interactor.NotificationStackAppearanceInteractor
import com.android.systemui.util.kotlin.FlowDumperImpl
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.map

/** ViewModel which represents the state of the NSSL/Controller in the world of flexiglass */
@SysUISingleton
class NotificationStackAppearanceViewModel
@Inject
constructor(
    @Application applicationScope: CoroutineScope,
    dumpManager: DumpManager,
    stackAppearanceInteractor: NotificationStackAppearanceInteractor,
    shadeInteractor: ShadeInteractor,
@@ -83,4 +88,8 @@ constructor(

    /** The y-coordinate in px of top of the contents of the notification stack. */
    val contentTop: StateFlow<Float> = stackAppearanceInteractor.contentTop.dumpValue("contentTop")

    /** Whether the notification stack is scrollable or not. */
    val isScrollable: Flow<Boolean> =
        sceneInteractor.currentScene.map { it == Shade }.dumpWhileCollecting("isScrollable")
}
+2 −0
Original line number Diff line number Diff line
@@ -19,12 +19,14 @@ package com.android.systemui.statusbar.notification.stack.ui.viewmodel
import com.android.systemui.dump.dumpManager
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.Kosmos.Fixture
import com.android.systemui.kosmos.applicationCoroutineScope
import com.android.systemui.scene.domain.interactor.sceneInteractor
import com.android.systemui.shade.domain.interactor.shadeInteractor
import com.android.systemui.statusbar.notification.stack.domain.interactor.notificationStackAppearanceInteractor

val Kosmos.notificationStackAppearanceViewModel by Fixture {
    NotificationStackAppearanceViewModel(
        applicationScope = applicationCoroutineScope,
        dumpManager = dumpManager,
        stackAppearanceInteractor = notificationStackAppearanceInteractor,
        shadeInteractor = shadeInteractor,