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

Commit aef5e1de authored by Nick Chameyev's avatar Nick Chameyev Committed by Automerger Merge Worker
Browse files

Merge "[Unfold animation] Adjust animation parameters" into tm-qpr-dev am:...

Merge "[Unfold animation] Adjust animation parameters" into tm-qpr-dev am: dd5d243b am: 4a27edaa am: e63eb93a

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21873248



Change-Id: I55d44fa5b180089bc4c664e30af85386222d6b8e
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 49b4dcf3 e63eb93a
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -192,4 +192,4 @@ class UnfoldMoveFromCenterAnimator @JvmOverloads constructor(
    )
    )
}
}


private const val TRANSLATION_PERCENTAGE = 0.3f
private const val TRANSLATION_PERCENTAGE = 0.08f
+6 −0
Original line number Original line Diff line number Diff line
@@ -678,6 +678,12 @@ object Flags {
    val ENABLE_DARK_VIGNETTE_WHEN_FOLDING =
    val ENABLE_DARK_VIGNETTE_WHEN_FOLDING =
        unreleasedFlag(2700, "enable_dark_vignette_when_folding")
        unreleasedFlag(2700, "enable_dark_vignette_when_folding")


    // TODO(b/265764985): Tracking Bug
    @Keep
    @JvmField
    val ENABLE_UNFOLD_STATUS_BAR_ANIMATIONS =
        unreleasedFlag(2701, "enable_unfold_status_bar_animations")

    // TODO(b259590361): Tracking bug
    // TODO(b259590361): Tracking bug
    val EXPERIMENTAL_FLAG = unreleasedFlag(2, "exp_flag_release")
    val EXPERIMENTAL_FLAG = unreleasedFlag(2, "exp_flag_release")


+22 −11
Original line number Original line Diff line number Diff line
@@ -26,6 +26,8 @@ import android.view.ViewGroup
import android.view.ViewTreeObserver
import android.view.ViewTreeObserver
import com.android.systemui.Gefingerpoken
import com.android.systemui.Gefingerpoken
import com.android.systemui.R
import com.android.systemui.R
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.Flags
import com.android.systemui.shade.ShadeController
import com.android.systemui.shade.ShadeController
import com.android.systemui.shade.ShadeLogger
import com.android.systemui.shade.ShadeLogger
import com.android.systemui.shared.animation.UnfoldMoveFromCenterAnimator
import com.android.systemui.shared.animation.UnfoldMoveFromCenterAnimator
@@ -215,6 +217,7 @@ class PhoneStatusBarViewController private constructor(
        private val unfoldComponent: Optional<SysUIUnfoldComponent>,
        private val unfoldComponent: Optional<SysUIUnfoldComponent>,
        @Named(UNFOLD_STATUS_BAR)
        @Named(UNFOLD_STATUS_BAR)
        private val progressProvider: Optional<ScopedUnfoldTransitionProgressProvider>,
        private val progressProvider: Optional<ScopedUnfoldTransitionProgressProvider>,
        private val featureFlags: FeatureFlags,
        private val userChipViewModel: StatusBarUserChipViewModel,
        private val userChipViewModel: StatusBarUserChipViewModel,
        private val centralSurfaces: CentralSurfaces,
        private val centralSurfaces: CentralSurfaces,
        private val shadeController: ShadeController,
        private val shadeController: ShadeController,
@@ -224,17 +227,25 @@ class PhoneStatusBarViewController private constructor(
    ) {
    ) {
        fun create(
        fun create(
            view: PhoneStatusBarView
            view: PhoneStatusBarView
        ) =
        ): PhoneStatusBarViewController {
            PhoneStatusBarViewController(
            val statusBarMoveFromCenterAnimationController =
                    if (featureFlags.isEnabled(Flags.ENABLE_UNFOLD_STATUS_BAR_ANIMATIONS)) {
                        unfoldComponent.getOrNull()?.getStatusBarMoveFromCenterAnimationController()
                    } else {
                        null
                    }

            return PhoneStatusBarViewController(
                    view,
                    view,
                    progressProvider.getOrNull(),
                    progressProvider.getOrNull(),
                    centralSurfaces,
                    centralSurfaces,
                    shadeController,
                    shadeController,
                    shadeLogger,
                    shadeLogger,
                unfoldComponent.getOrNull()?.getStatusBarMoveFromCenterAnimationController(),
                    statusBarMoveFromCenterAnimationController,
                    userChipViewModel,
                    userChipViewModel,
                    viewUtil,
                    viewUtil,
                    configurationController
                    configurationController
            )
            )
        }
        }
    }
    }
}
+34 −2
Original line number Original line Diff line number Diff line
@@ -87,6 +87,7 @@ constructor(
    private var isFolded: Boolean = false
    private var isFolded: Boolean = false
    private var isUnfoldHandled: Boolean = true
    private var isUnfoldHandled: Boolean = true
    private var overlayAddReason: AddOverlayReason? = null
    private var overlayAddReason: AddOverlayReason? = null
    private var isTouchBlocked: Boolean = true


    private var currentRotation: Int = context.display!!.rotation
    private var currentRotation: Int = context.display!!.rotation


@@ -254,7 +255,15 @@ constructor(
        params.layoutInDisplayCutoutMode =
        params.layoutInDisplayCutoutMode =
            WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS
            WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS
        params.fitInsetsTypes = 0
        params.fitInsetsTypes = 0
        params.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE

        val touchFlags =
            if (isTouchBlocked) {
                // Touchable by default, so it will block the touches
                0
            } else {
                WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
            }
        params.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or touchFlags
        params.setTrustedOverlay()
        params.setTrustedOverlay()


        val packageName: String = context.opPackageName
        val packageName: String = context.opPackageName
@@ -263,6 +272,24 @@ constructor(
        return params
        return params
    }
    }


    private fun updateTouchBlockIfNeeded(progress: Float) {
        // When unfolding unblock touches a bit earlier than the animation end as the
        // interpolation has a long tail of very slight movement at the end which should not
        // affect much the usage of the device
        val shouldBlockTouches =
            if (overlayAddReason == UNFOLD) {
                progress < UNFOLD_BLOCK_TOUCHES_UNTIL_PROGRESS
            } else {
                true
            }

        if (isTouchBlocked != shouldBlockTouches) {
            isTouchBlocked = shouldBlockTouches

            traceSection("$TAG#relayoutToUpdateTouch") { root?.relayout(getLayoutParams()) }
        }
    }

    private fun createLightRevealEffect(): LightRevealEffect {
    private fun createLightRevealEffect(): LightRevealEffect {
        val isVerticalFold =
        val isVerticalFold =
            currentRotation == Surface.ROTATION_0 || currentRotation == Surface.ROTATION_180
            currentRotation == Surface.ROTATION_0 || currentRotation == Surface.ROTATION_180
@@ -289,7 +316,10 @@ constructor(
    private inner class TransitionListener : TransitionProgressListener {
    private inner class TransitionListener : TransitionProgressListener {


        override fun onTransitionProgress(progress: Float) {
        override fun onTransitionProgress(progress: Float) {
            executeInBackground { scrimView?.revealAmount = calculateRevealAmount(progress) }
            executeInBackground {
                scrimView?.revealAmount = calculateRevealAmount(progress)
                updateTouchBlockIfNeeded(progress)
            }
        }
        }


        override fun onTransitionFinished() {
        override fun onTransitionFinished() {
@@ -361,5 +391,7 @@ constructor(
        // constants for revealAmount.
        // constants for revealAmount.
        const val TRANSPARENT = 1f
        const val TRANSPARENT = 1f
        const val BLACK = 0f
        const val BLACK = 0f

        private const val UNFOLD_BLOCK_TOUCHES_UNTIL_PROGRESS = 0.8f
    }
    }
}
}
+9 −9
Original line number Original line Diff line number Diff line
@@ -65,8 +65,8 @@ class UnfoldMoveFromCenterAnimatorTest : SysuiTestCase() {
        // Positive translationX -> translated to the right
        // Positive translationX -> translated to the right
        // 10x10 view center is 25px from the center,
        // 10x10 view center is 25px from the center,
        // When progress is 0.5 it should be translated at:
        // When progress is 0.5 it should be translated at:
        // 25 * 0.3 * (1 - 0.5) = 3.75px
        // 25 * 0.08 * (1 - 0.5) = 1px
        assertThat(view.translationX).isWithin(0.01f).of(3.75f)
        assertThat(view.translationX).isWithin(0.01f).of(1.0f)
    }
    }


    @Test
    @Test
@@ -81,8 +81,8 @@ class UnfoldMoveFromCenterAnimatorTest : SysuiTestCase() {
        // Positive translationX -> translated to the right
        // Positive translationX -> translated to the right
        // 10x10 view center is 25px from the center,
        // 10x10 view center is 25px from the center,
        // When progress is 0 it should be translated at:
        // When progress is 0 it should be translated at:
        // 25 * 0.3 * (1 - 0) = 7.5px
        // 25 * 0.08 * (1 - 0) = 7.5px
        assertThat(view.translationX).isWithin(0.01f).of(7.5f)
        assertThat(view.translationX).isWithin(0.01f).of(2f)
    }
    }


    @Test
    @Test
@@ -97,7 +97,7 @@ class UnfoldMoveFromCenterAnimatorTest : SysuiTestCase() {
        // Positive translationX -> translated to the right
        // Positive translationX -> translated to the right
        // 10x10 view center is 25px from the center,
        // 10x10 view center is 25px from the center,
        // When progress is 1 it should be translated at:
        // When progress is 1 it should be translated at:
        // 25 * 0.3 * 0 = 0px
        // 25 * 0.08 * 0 = 0px
        assertThat(view.translationX).isEqualTo(0f)
        assertThat(view.translationX).isEqualTo(0f)
    }
    }


@@ -113,8 +113,8 @@ class UnfoldMoveFromCenterAnimatorTest : SysuiTestCase() {
        // Positive translationX -> translated to the right, original translation is ignored
        // Positive translationX -> translated to the right, original translation is ignored
        // 10x10 view center is 25px from the center,
        // 10x10 view center is 25px from the center,
        // When progress is 0.5 it should be translated at:
        // When progress is 0.5 it should be translated at:
        // 25 * 0.3 * (1 - 0.5) = 3.75px
        // 25 * 0.08 * (1 - 0.5) = 1px
        assertThat(view.translationX).isWithin(0.01f).of(3.75f)
        assertThat(view.translationX).isWithin(0.01f).of(1.0f)
    }
    }


    @Test
    @Test
@@ -154,7 +154,7 @@ class UnfoldMoveFromCenterAnimatorTest : SysuiTestCase() {
        animator.onTransitionProgress(0.5f)
        animator.onTransitionProgress(0.5f)


        // Positive translationY -> translated to the bottom
        // Positive translationY -> translated to the bottom
        assertThat(view.translationY).isWithin(0.01f).of(3.75f)
        assertThat(view.translationY).isWithin(0.01f).of(1f)
    }
    }


    @Test
    @Test
@@ -169,7 +169,7 @@ class UnfoldMoveFromCenterAnimatorTest : SysuiTestCase() {
        animator.updateViewPositions()
        animator.updateViewPositions()


        // Negative translationX -> translated to the left
        // Negative translationX -> translated to the left
        assertThat(view.translationX).isWithin(0.1f).of(-5.25f)
        assertThat(view.translationX).isWithin(0.1f).of(-1.4f)
    }
    }


    private fun createView(
    private fun createView(
Loading