From 86054beef06e359d224f20cbdc1a1943e92e2113 Mon Sep 17 00:00:00 2001 From: Nick Chameyev Date: Thu, 21 Apr 2022 11:52:43 +0100 Subject: [PATCH] Initialize StatusBar unfold animation with 1f progress Initializes move from center animator for the statusbar views with 1f progress, so when the device is booted in unfolded state and rotated it the translation wil be applied with 1f progress. When booted in folded mode the progress will start from 0f so it doesn't affect the animation. Bug: 229738545 Test: kill sysui in unfolded state, rotate the device, rotate during fold/unfold animation Test: atest com.android.systemui.statusbar.phone.StatusBarMoveFromCenterAnimationControllerTest Change-Id: Ia0d4a44ddc444420d3695cab328558bf2fbe589d --- .../shared/animation/UnfoldMoveFromCenterAnimator.kt | 2 +- .../StatusBarMoveFromCenterAnimationControllerTest.kt | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/animation/UnfoldMoveFromCenterAnimator.kt b/packages/SystemUI/shared/src/com/android/systemui/shared/animation/UnfoldMoveFromCenterAnimator.kt index fc6bb500562e7..d7a0b473ead68 100644 --- a/packages/SystemUI/shared/src/com/android/systemui/shared/animation/UnfoldMoveFromCenterAnimator.kt +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/animation/UnfoldMoveFromCenterAnimator.kt @@ -52,7 +52,7 @@ class UnfoldMoveFromCenterAnimator @JvmOverloads constructor( private val animatedViews: MutableList = arrayListOf() - private var lastAnimationProgress: Float = 0f + private var lastAnimationProgress: Float = 1f /** * Updates display properties in order to calculate the initial position for the views diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarMoveFromCenterAnimationControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarMoveFromCenterAnimationControllerTest.kt index 1ce7ff424df1e..1779de729e5b0 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarMoveFromCenterAnimationControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarMoveFromCenterAnimationControllerTest.kt @@ -60,6 +60,15 @@ class StatusBarMoveFromCenterAnimationControllerTest : SysuiTestCase() { assertThat(view.translationX).isZero() } + @Test + fun onStatusBarWidthChangedWithNoTransitionBefore_noTranslation() { + controller.onViewsReady(arrayOf(view)) + + controller.onStatusBarWidthChanged() + + assertThat(view.translationX).isZero() + } + @Test fun onTransitionProgress_updatesTranslations() { controller.onViewsReady(arrayOf(view))