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

Commit e798aa5c authored by Matt Pietal's avatar Matt Pietal
Browse files

NSSL Migration - Animate top padding on shade pulldown

This to match existing behavior, with NSSL smoothly transitioning as
the user pulls down the shade and lets go. Do not animate when QS is
expanding, as that container controls the padding directly.

Flag: LEGACY MIGRATE_NSSL DISABLED
Fixes: 301238487
Test: atest SharedNotificationContainerViewModelTest
Change-Id: Ifecc7efbf7850ac9d4083070604fa6d292bfe2ba
parent 515233f5
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -20,4 +20,7 @@ package com.android.systemui.common.shared.model
data class SharedNotificationContainerPosition(
    val top: Float = 0f,
    val bottom: Float = 0f,

    /** Whether any modifications to top/bottom are smoothly animated */
    val animate: Boolean = false,
)
+2 −4
Original line number Diff line number Diff line
@@ -59,10 +59,8 @@ object SharedNotificationContainerBinder {

                launch {
                    viewModel.position.collect {
                        controller.updateTopPadding(
                            it.top,
                            controller.isAddOrRemoveAnimationPending()
                        )
                        val animate = it.animate || controller.isAddOrRemoveAnimationPending()
                        controller.updateTopPadding(it.top, animate)
                    }
                }

+10 −2
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import com.android.systemui.shade.domain.interactor.ShadeInteractor
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController
import com.android.systemui.statusbar.notification.stack.NotificationStackSizeCalculator
import com.android.systemui.statusbar.notification.stack.domain.interactor.SharedNotificationContainerInteractor
import com.android.systemui.util.kotlin.sample
import javax.inject.Inject
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.combine
@@ -118,8 +119,15 @@ constructor(
                    }
                }
            } else {
                interactor.topPosition.map { top ->
                    keyguardInteractor.sharedNotificationContainerPosition.value.copy(top = top)
                interactor.topPosition.sample(shadeInteractor.qsExpansion, ::Pair).map {
                    (top, qsExpansion) ->
                    // When QS expansion > 0, it should directly set the top padding so do not
                    // animate it
                    val animate = qsExpansion == 0f
                    keyguardInteractor.sharedNotificationContainerPosition.value.copy(
                        top = top,
                        animate = animate
                    )
                }
            }
        }
+32 −1
Original line number Diff line number Diff line
@@ -318,7 +318,26 @@ class SharedNotificationContainerViewModelTest : SysuiTestCase() {
            sharedNotificationContainerInteractor.setTopPosition(10f)

            assertThat(position)
                .isEqualTo(SharedNotificationContainerPosition(top = 10f, bottom = 0f))
                .isEqualTo(
                    SharedNotificationContainerPosition(top = 10f, bottom = 0f, animate = true)
                )
        }

    @Test
    fun positionOnQS() =
        testScope.runTest {
            val position by collectLastValue(underTest.position)

            // Start on lockscreen with shade expanded
            showLockscreenWithQSExpanded()

            // When not in split shade
            sharedNotificationContainerInteractor.setTopPosition(10f)

            assertThat(position)
                .isEqualTo(
                    SharedNotificationContainerPosition(top = 10f, bottom = 0f, animate = false)
                )
        }

    @Test
@@ -396,6 +415,18 @@ class SharedNotificationContainerViewModelTest : SysuiTestCase() {
        )
    }

    private suspend fun showLockscreenWithQSExpanded() {
        shadeRepository.setLockscreenShadeExpansion(0f)
        shadeRepository.setQsExpansion(1f)
        keyguardRepository.setStatusBarState(StatusBarState.SHADE_LOCKED)
        keyguardTransitionRepository.sendTransitionStep(
            TransitionStep(
                to = KeyguardState.LOCKSCREEN,
                transitionState = TransitionState.FINISHED
            )
        )
    }

    @SysUISingleton
    @Component(
        modules =