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

Commit 2e8828bd authored by Jon Miranda's avatar Jon Miranda
Browse files

Enable All Apps spring.

Bug: 147302669

Change-Id: I944ce7d181c554d840329a3affe0dee76eed9143
parent 4e7a48f2
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ import static com.android.launcher3.anim.Interpolators.DEACCEL;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.anim.Interpolators.OVERSHOOT_1_2;
import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE;
import static com.android.launcher3.config.FeatureFlags.UNSTABLE_SPRINGS;
import static com.android.launcher3.config.FeatureFlags.QUICKSTEP_SPRINGS;
import static com.android.launcher3.util.DefaultDisplay.getSingleFrameMs;
import static com.android.launcher3.util.SystemUiController.UI_STATE_OVERVIEW;
import static com.android.quickstep.GestureState.GestureEndTarget.HOME;
@@ -973,7 +973,7 @@ public class LauncherSwipeHandler<T extends BaseDraggingActivity>
        }
        mLauncherTransitionController.getAnimationPlayer().setDuration(Math.max(0, duration));

        if (UNSTABLE_SPRINGS.get()) {
        if (QUICKSTEP_SPRINGS.get()) {
            mLauncherTransitionController.dispatchOnStartWithVelocity(end, velocityPxPerMs.y);
        }
        mLauncherTransitionController.getAnimationPlayer().start();
+2 −2
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_VERTICAL_PROGRE
import static com.android.launcher3.anim.Interpolators.ACCEL;
import static com.android.launcher3.anim.Interpolators.DEACCEL;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.config.FeatureFlags.UNSTABLE_SPRINGS;
import static com.android.launcher3.config.FeatureFlags.QUICKSTEP_SPRINGS;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_OVERVIEW_DISABLED;

import android.animation.TimeInterpolator;
@@ -277,7 +277,7 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr
    private void handleFirstSwipeToOverview(final ValueAnimator animator,
            final long expectedDuration, final LauncherState targetState, final float velocity,
            final boolean isFling) {
        if (UNSTABLE_SPRINGS.get() && mFromState == OVERVIEW && mToState == ALL_APPS
        if (QUICKSTEP_SPRINGS.get() && mFromState == OVERVIEW && mToState == ALL_APPS
                && targetState == OVERVIEW) {
            mFinishFastOnSecondTouch = true;
        } else  if (mFromState == NORMAL && mToState == OVERVIEW && targetState == OVERVIEW) {
+3 −3
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@ import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_VERTICAL_PROGRE
import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.anim.PropertySetter.NO_ANIM_PROPERTY_SETTER;
import static com.android.launcher3.config.FeatureFlags.UNSTABLE_SPRINGS;
import static com.android.launcher3.config.FeatureFlags.QUICKSTEP_SPRINGS;
import static com.android.launcher3.util.SystemUiController.UI_STATE_ALL_APPS;

import android.animation.Animator;
@@ -46,7 +46,7 @@ import com.android.launcher3.views.ScrimView;
 */
public class AllAppsTransitionController implements StateHandler, OnDeviceProfileChangeListener {

    private static final float SPRING_DAMPING_RATIO = 0.9f;
    private static final float SPRING_DAMPING_RATIO = 0.75f;
    private static final float SPRING_STIFFNESS = 600f;

    public static final FloatProperty<AllAppsTransitionController> ALL_APPS_PROGRESS =
@@ -185,7 +185,7 @@ public class AllAppsTransitionController implements StateHandler, OnDeviceProfil
    }

    public Animator createSpringAnimation(float... progressValues) {
        if (UNSTABLE_SPRINGS.get()) {
        if (QUICKSTEP_SPRINGS.get()) {
            return new SpringObjectAnimator<>(this, ALL_APPS_PROGRESS, 1f / mShiftRange,
                    SPRING_DAMPING_RATIO, SPRING_STIFFNESS, progressValues);
        }
+8 −5
Original line number Diff line number Diff line
@@ -29,12 +29,13 @@ import android.os.Looper;
import android.util.FloatProperty;
import android.util.Log;

import java.util.ArrayList;

import androidx.dynamicanimation.animation.DynamicAnimation.OnAnimationEndListener;
import androidx.dynamicanimation.animation.SpringAnimation;
import androidx.dynamicanimation.animation.SpringForce;

import java.util.ArrayList;


/**
 * This animator allows for an object's property to be be controlled by an {@link ObjectAnimator} or
 * a {@link SpringAnimation}. It extends ValueAnimator so it can be used in an AnimatorSet.
@@ -137,11 +138,13 @@ public class SpringObjectAnimator<T> extends ValueAnimator {

        mProperty.switchToSpring();

        mSpring.setStartVelocity(velocity);

        float startValue = end == 0 ? mValues[1] : mValues[0];
        float endValue = end == 0 ? mValues[0] : mValues[1];
        mSpring.setStartValue(startValue);

        // Ensures that the velocity matches the direction of the values.
        velocity = Math.signum(endValue - startValue) * Math.abs(velocity);
        mSpring.setStartVelocity(velocity);

        new Handler(Looper.getMainLooper()).postDelayed(() -> {
            mSpring.animateToFinalPosition(endValue);
        }, getStartDelay());
+6 −5
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ import static com.android.launcher3.LauncherStateManager.ANIM_ALL;
import static com.android.launcher3.LauncherStateManager.ATOMIC_OVERVIEW_SCALE_COMPONENT;
import static com.android.launcher3.LauncherStateManager.NON_ATOMIC_COMPONENT;
import static com.android.launcher3.anim.Interpolators.scrollInterpolatorForVelocity;
import static com.android.launcher3.config.FeatureFlags.UNSTABLE_SPRINGS;
import static com.android.launcher3.config.FeatureFlags.QUICKSTEP_SPRINGS;
import static com.android.launcher3.util.DefaultDisplay.getSingleFrameMs;

import android.animation.Animator;
@@ -380,6 +380,7 @@ public abstract class AbstractStateChangeTouchController

        final LauncherState targetState;
        final float progress = mCurrentAnimation.getProgressFraction();
        final float progressVelocity = velocity * mProgressMultiplier;
        final float interpolatedProgress = mCurrentAnimation.getInterpolatedProgress();
        if (fling) {
            targetState =
@@ -406,7 +407,7 @@ public abstract class AbstractStateChangeTouchController
                startProgress = 1;
            } else {
                startProgress = Utilities.boundToRange(progress
                        + velocity * getSingleFrameMs(mLauncher) * mProgressMultiplier, 0f, 1f);
                        + progressVelocity * getSingleFrameMs(mLauncher), 0f, 1f);
                duration = BaseSwipeDetector.calculateDuration(velocity,
                        endProgress - Math.max(progress, 0)) * durationMultiplier;
            }
@@ -421,7 +422,7 @@ public abstract class AbstractStateChangeTouchController
                startProgress = 0;
            } else {
                startProgress = Utilities.boundToRange(progress
                        + velocity * getSingleFrameMs(mLauncher) * mProgressMultiplier, 0f, 1f);
                        + progressVelocity * getSingleFrameMs(mLauncher), 0f, 1f);
                duration = BaseSwipeDetector.calculateDuration(velocity,
                        Math.min(progress, 1) - endProgress) * durationMultiplier;
            }
@@ -433,8 +434,8 @@ public abstract class AbstractStateChangeTouchController
        maybeUpdateAtomicAnim(mFromState, targetState, targetState == mToState ? 1f : 0f);
        updateSwipeCompleteAnimation(anim, Math.max(duration, getRemainingAtomicDuration()),
                targetState, velocity, fling);
        mCurrentAnimation.dispatchOnStartWithVelocity(endProgress, velocity);
        if (fling && targetState == LauncherState.ALL_APPS && !UNSTABLE_SPRINGS.get()) {
        mCurrentAnimation.dispatchOnStartWithVelocity(endProgress, progressVelocity);
        if (fling && targetState == LauncherState.ALL_APPS && !QUICKSTEP_SPRINGS.get()) {
            mLauncher.getAppsView().addSpringFromFlingUpdateListener(anim, velocity);
        }
        anim.start();