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

Commit a6c999e6 authored by Ioana Alexandru's avatar Ioana Alexandru
Browse files

Don't animate empty shade visibility change when qs expanded

When QS is (close to being fully) expanded, we hide the "No
notifications" text. When we try to animate it out in this scenario,
there's a flicker, so instead let's just update the visibility without
animating since it still looks okay.

We're using the same approach as we do for shouldIncludeFooterView.

Fix: 414321975
Test: manual + NotificationListViewModelTest
Flag: EXEMPT bugfix
Change-Id: I04086f429437242ae1dcd36b91de27d5a1e10836
parent b3eb540d
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")