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

Commit 4724576e authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Don't animate empty shade visibility change when qs expanded" into main

parents 2b00535a a6c999e6
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -210,6 +210,24 @@ class NotificationListViewModelTest(flags: FlagsParameterization) : SysuiTestCas
            assertThat(shouldIncludeFooterView?.value).isFalse()
        }

    @Test
    fun shouldShowEmptyShadeView_notAnimatingWhenQsExpandedOnKeyguard() =
        testScope.runTest {
            val shouldShow by collectLastValue(underTest.shouldShowEmptyShadeView)

            // WHEN has no notifs
            activeNotificationListRepository.setActiveNotifs(count = 0)
            // AND quick settings are expanded
            shadeTestUtil.setQsFullscreen(true)
            // AND we are on the keyguard
            fakeKeyguardRepository.setStatusBarState(StatusBarState.KEYGUARD)
            shadeTestUtil.setShadeExpansion(1f)
            runCurrent()

            // THEN empty shade visibility does not animate
            assertThat(shouldShow?.isAnimating).isFalse()
        }

    @Test
    fun shouldShowEmptyShadeView_trueWhenLockedShade() =
        testScope.runTest {
+16 −9
Original line number Diff line number Diff line
@@ -98,20 +98,26 @@ constructor(
                    .distinctUntilChanged(),
                shadeModeInteractor.shadeMode.map { it == ShadeMode.Split },
                notificationStackInteractor.isShowingOnLockscreen,
            ) { hasNotifications, qsExpandedEnough, isSplitShade, isShowingOnLockscreen ->
            ) { hasNotifications, qsExpandedEnough, splitShade, isShowingOnLockscreen ->
                when {
                    hasNotifications -> false
                    hasNotifications -> VisibilityChange.DISAPPEAR_WITH_ANIMATION
                    // Hide the empty shade when QS is close to being full screen. We use this
                    // instead of isQsFullscreen to avoid some flickering.
                    qsExpandedEnough && !isSplitShade -> false
                    qsExpandedEnough && !splitShade -> VisibilityChange.DISAPPEAR_WITHOUT_ANIMATION
                    // Do not show the empty shade if the lockscreen is visible (including AOD
                    // b/228790482 and bouncer b/267060171), except if the shade is opened on
                    // top.
                    isShowingOnLockscreen -> false
                    else -> true
                    isShowingOnLockscreen -> VisibilityChange.DISAPPEAR_WITHOUT_ANIMATION
                    else -> VisibilityChange.APPEAR_WITH_ANIMATION
                }
            }
            .distinctUntilChanged()
            .distinctUntilChanged(
                // Equivalent unless visibility changes
                areEquivalent = { a: VisibilityChange, b: VisibilityChange ->
                    a.visible == b.visible
                }
            )
            // Should we animate the visibility change?
            .sample(
                // TODO(b/322167853): This check is currently duplicated in FooterViewModel
                //  but instead it should be a field in ShadeAnimationInteractor.
@@ -121,9 +127,10 @@ constructor(
                        ::Pair,
                    )
                    .onStart { emit(Pair(false, false)) }
            ) { visible, (isShadeFullyExpanded, animationsEnabled) ->
                val shouldAnimate = isShadeFullyExpanded && animationsEnabled
                AnimatableEvent(visible, shouldAnimate)
            ) { visibilityChange, (isShadeFullyExpanded, animationsEnabled) ->
                val shouldAnimate =
                    isShadeFullyExpanded && animationsEnabled && visibilityChange.canAnimate
                AnimatableEvent(visibilityChange.visible, shouldAnimate)
            }
            .toAnimatedValueFlow()
            .dumpWhileCollecting("shouldShowEmptyShadeViewAnimated")