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

Commit 74c42ead authored by Marvin Bernal's avatar Marvin Bernal Committed by Automerger Merge Worker
Browse files

Merge "Decreased fling duration and fixed width interpolation for large...

Merge "Decreased fling duration and fixed width interpolation for large screens" into udc-dev am: aa8c33a1

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



Change-Id: I4bdf53a6bb67efd552d58ff64dbddf4742fa9f9c
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 177708b4 aa8c33a1
Loading
Loading
Loading
Loading
+30 −31
Original line number Diff line number Diff line
@@ -58,12 +58,14 @@ private const val MIN_DURATION_ACTIVE_AFTER_INACTIVE_ANIMATION = 130L
private const val MIN_DURATION_CANCELLED_ANIMATION = 200L
private const val MIN_DURATION_COMMITTED_ANIMATION = 120L
private const val MIN_DURATION_INACTIVE_BEFORE_FLUNG_ANIMATION = 50L
private const val MIN_DURATION_FLING_ANIMATION = 160L

private const val MIN_DURATION_ENTRY_TO_ACTIVE_CONSIDERED_AS_FLING = 100L
private const val MIN_DURATION_INACTIVE_TO_ACTIVE_CONSIDERED_AS_FLING = 400L

private const val FAILSAFE_DELAY_MS = 350L
private const val POP_ON_FLING_DELAY = 140L
private const val POP_ON_FLING_DELAY = 50L
private const val POP_ON_FLING_SCALE = 3f

internal val VIBRATE_ACTIVATED_EFFECT =
        VibrationEffect.createPredefined(VibrationEffect.EFFECT_CLICK)
@@ -230,7 +232,12 @@ class BackPanelController internal constructor(
                updateArrowState(GestureState.GONE)
            }

    private val playAnimationThenSetGoneOnAlphaEnd = Runnable { playAnimationThenSetGoneEnd() }
    private val onAlphaEndSetGoneStateListener = DelayedOnAnimationEndListener(mainHandler, 0L) {
        updateRestingArrowDimens()
        if (!mView.addAnimationEndListener(mView.backgroundAlpha, onEndSetGoneStateListener)) {
            scheduleFailsafe()
        }
    }

    // Minimum of the screen's width or the predefined threshold
    private var fullyStretchedThreshold = 0f
@@ -357,7 +364,7 @@ class BackPanelController internal constructor(
        mView.cancelAnimations()
        mainHandler.removeCallbacks(onEndSetCommittedStateListener.runnable)
        mainHandler.removeCallbacks(onEndSetGoneStateListener.runnable)
        mainHandler.removeCallbacks(playAnimationThenSetGoneOnAlphaEnd)
        mainHandler.removeCallbacks(onAlphaEndSetGoneStateListener.runnable)
    }

    /**
@@ -509,7 +516,7 @@ class BackPanelController internal constructor(
        val maxYOffset = (mView.height - params.entryIndicator.backgroundDimens.height) / 2f
        val rubberbandAmount = 15f
        val yProgress = MathUtils.saturate(yTranslation / (maxYOffset * rubberbandAmount))
        val yPosition = params.translationInterpolator.getInterpolation(yProgress) *
        val yPosition = params.verticalTranslationInterpolator.getInterpolation(yProgress) *
                maxYOffset *
                sign(yOffset)
        mView.animateVertically(yPosition)
@@ -520,10 +527,9 @@ class BackPanelController internal constructor(
     * the arrow is fully stretched (between 0.0 - 1.0f)
     */
    private fun fullScreenProgress(xTranslation: Float): Float {
        return MathUtils.saturate(
                (xTranslation - previousXTranslationOnActiveOffset) /
                        (fullyStretchedThreshold - previousXTranslationOnActiveOffset)
        )
        val progress = abs((xTranslation - previousXTranslationOnActiveOffset) /
                (fullyStretchedThreshold - previousXTranslationOnActiveOffset))
        return MathUtils.saturate(progress)
    }

    /**
@@ -540,7 +546,7 @@ class BackPanelController internal constructor(

    private fun stretchActiveBackIndicator(progress: Float) {
        mView.setStretch(
                horizontalTranslationStretchAmount = params.translationInterpolator
                horizontalTranslationStretchAmount = params.horizontalTranslationInterpolator
                        .getInterpolation(progress),
                arrowStretchAmount = params.arrowAngleInterpolator.getInterpolation(progress),
                backgroundWidthStretchAmount = params.activeWidthInterpolator
@@ -639,20 +645,6 @@ class BackPanelController internal constructor(
        return flingDistance > minFlingDistance && isPastFlingVelocityThreshold
    }

    private fun playHorizontalAnimationThen(onEnd: DelayedOnAnimationEndListener) {
        updateRestingArrowDimens()
        if (!mView.addAnimationEndListener(mView.horizontalTranslation, onEnd)) {
            scheduleFailsafe()
        }
    }

    private fun playAnimationThenSetGoneEnd() {
        updateRestingArrowDimens()
        if (!mView.addAnimationEndListener(mView.backgroundAlpha, onEndSetGoneStateListener)) {
            scheduleFailsafe()
        }
    }

    private fun playWithBackgroundWidthAnimation(
            onEnd: DelayedOnAnimationEndListener,
            delay: Long = 0L
@@ -912,18 +904,25 @@ class BackPanelController internal constructor(
                updateRestingArrowDimens()
            }
            GestureState.FLUNG -> {
                mainHandler.postDelayed(POP_ON_FLING_DELAY) { mView.popScale(1.9f) }
                playHorizontalAnimationThen(onEndSetCommittedStateListener)
                mainHandler.postDelayed(POP_ON_FLING_DELAY) { mView.popScale(POP_ON_FLING_SCALE) }
                updateRestingArrowDimens()
                mainHandler.postDelayed(onEndSetCommittedStateListener.runnable,
                        MIN_DURATION_FLING_ANIMATION)
            }
            GestureState.COMMITTED -> {
                // In most cases, animating between states is handled via `updateRestingArrowDimens`
                // which plays an animation immediately upon state change. Some animations however
                // occur after a delay upon state change and these animations may be independent
                // or non-sequential from the state change animation. `postDelayed` is used to
                // manually play these kinds of animations in parallel.
                if (previousState == GestureState.FLUNG) {
                    playAnimationThenSetGoneEnd()
                    updateRestingArrowDimens()
                    mainHandler.postDelayed(onEndSetGoneStateListener.runnable,
                            MIN_DURATION_COMMITTED_ANIMATION)
                } else {
                    mView.popScale(3f)
                    mainHandler.postDelayed(
                            playAnimationThenSetGoneOnAlphaEnd,
                            MIN_DURATION_COMMITTED_ANIMATION
                    )
                    mView.popScale(POP_ON_FLING_SCALE)
                    mainHandler.postDelayed(onAlphaEndSetGoneStateListener.runnable,
                            MIN_DURATION_COMMITTED_ANIMATION)
                }
            }
            GestureState.CANCELLED -> {
+17 −14
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@ package com.android.systemui.navigationbar.gestural

import android.content.res.Resources
import android.util.TypedValue
import androidx.core.animation.Interpolator
import androidx.core.animation.PathInterpolator
import androidx.dynamicanimation.animation.SpringForce
import com.android.systemui.R
@@ -77,21 +78,23 @@ data class EdgePanelParams(private var resources: Resources) {
    var swipeProgressThreshold: Float = 0f
        private set

    lateinit var entryWidthInterpolator: PathInterpolator
    lateinit var entryWidthInterpolator: Interpolator
        private set
    lateinit var entryWidthTowardsEdgeInterpolator: PathInterpolator
    lateinit var entryWidthTowardsEdgeInterpolator: Interpolator
        private set
    lateinit var activeWidthInterpolator: PathInterpolator
    lateinit var activeWidthInterpolator: Interpolator
        private set
    lateinit var arrowAngleInterpolator: PathInterpolator
    lateinit var arrowAngleInterpolator: Interpolator
        private set
    lateinit var translationInterpolator: PathInterpolator
    lateinit var horizontalTranslationInterpolator: Interpolator
        private set
    lateinit var farCornerInterpolator: PathInterpolator
    lateinit var verticalTranslationInterpolator: Interpolator
        private set
    lateinit var edgeCornerInterpolator: PathInterpolator
    lateinit var farCornerInterpolator: Interpolator
        private set
    lateinit var heightInterpolator: PathInterpolator
    lateinit var edgeCornerInterpolator: Interpolator
        private set
    lateinit var heightInterpolator: Interpolator
        private set

    init {
@@ -125,9 +128,10 @@ data class EdgePanelParams(private var resources: Resources) {

        entryWidthInterpolator = PathInterpolator(.19f, 1.27f, .71f, .86f)
        entryWidthTowardsEdgeInterpolator = PathInterpolator(1f, -3f, 1f, 1.2f)
        activeWidthInterpolator = PathInterpolator(.7f, .06f, .34f, .97f)
        activeWidthInterpolator = PathInterpolator(.56f, -0.39f, .18f, 1.46f)
        arrowAngleInterpolator = entryWidthInterpolator
        translationInterpolator = PathInterpolator(0.2f, 1.0f, 1.0f, 1.0f)
        horizontalTranslationInterpolator = PathInterpolator(0.2f, 1.0f, 1.0f, 1.0f)
        verticalTranslationInterpolator = PathInterpolator(.5f, 1.15f, .41f, .94f)
        farCornerInterpolator = PathInterpolator(.03f, .19f, .14f, 1.09f)
        edgeCornerInterpolator = PathInterpolator(0f, 1.11f, .85f, .84f)
        heightInterpolator = PathInterpolator(1f, .05f, .9f, -0.29f)
@@ -147,7 +151,7 @@ data class EdgePanelParams(private var resources: Resources) {
                scale = getDimenFloat(R.dimen.navigation_edge_entry_scale),
                scalePivotX = getDimen(R.dimen.navigation_edge_pre_threshold_background_width),
                horizontalTranslationSpring = entryActiveHorizontalTranslationSpring,
                verticalTranslationSpring = createSpring(10000f, 0.9f),
                verticalTranslationSpring = createSpring(30000f, 1f),
                scaleSpring = createSpring(120f, 0.8f),
                arrowDimens = ArrowDimens(
                        length = getDimen(R.dimen.navigation_edge_entry_arrow_length),
@@ -174,7 +178,6 @@ data class EdgePanelParams(private var resources: Resources) {
                        height = getDimen(R.dimen.navigation_edge_entry_background_height),
                        edgeCornerRadius = getDimen(R.dimen.navigation_edge_entry_edge_corners),
                        farCornerRadius = getDimen(R.dimen.navigation_edge_entry_far_corners),
                        alphaSpring = createSpring(1100f, 1f),
                        widthSpring = createSpring(450f, 0.65f),
                        heightSpring = createSpring(1500f, 0.45f),
                        farCornerRadiusSpring = createSpring(300f, 0.5f),
@@ -269,10 +272,10 @@ data class EdgePanelParams(private var resources: Resources) {
                        heightSpring = flungCommittedHeightSpring,
                        edgeCornerRadiusSpring = flungCommittedEdgeCornerSpring,
                        farCornerRadiusSpring = flungCommittedFarCornerSpring,
                        alphaSpring = createSpring(1100f, 1f),
                        alphaSpring = createSpring(1400f, 1f),
                ),
                scale = 0.85f,
                scaleSpring = createSpring(1150f, 1f),
                scaleSpring = createSpring(6000f, 1f),
        )

        flungIndicator = committedIndicator.copy(