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

Commit d15ce9f5 authored by Jason Chang's avatar Jason Chang Committed by Automerger Merge Worker
Browse files

Merge "Fix One Handed Feedback gesture's animations are quite jarring" into sc-dev am: 97bf5c62

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

Change-Id: I83766b7ea23e8922727a831f3124e9c8465b668a
parents 1ad4228b 97bf5c62
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@
    <integer name="long_press_dock_anim_duration">250</integer>

    <!-- Animation duration for translating of one handed when trigger / dismiss. -->
    <integer name="config_one_handed_translate_animation_duration">300</integer>
    <integer name="config_one_handed_translate_animation_duration">800</integer>

    <!-- One handed mode default offset % of display size -->
    <fraction name="config_one_handed_offset">40%</fraction>
+17 −5
Original line number Diff line number Diff line
@@ -22,8 +22,7 @@ import android.annotation.IntDef;
import android.content.Context;
import android.graphics.Rect;
import android.view.SurfaceControl;
import android.view.animation.Interpolator;
import android.view.animation.OvershootInterpolator;
import android.view.animation.BaseInterpolator;
import android.window.WindowContainerToken;

import androidx.annotation.VisibleForTesting;
@@ -54,7 +53,7 @@ public class OneHandedAnimationController {
    public @interface TransitionDirection {
    }

    private final Interpolator mOvershootInterpolator;
    private final OneHandedInterpolator mInterpolator;
    private final OneHandedSurfaceTransactionHelper mSurfaceTransactionHelper;
    private final HashMap<WindowContainerToken, OneHandedTransitionAnimator> mAnimatorMap =
            new HashMap<>();
@@ -64,7 +63,7 @@ public class OneHandedAnimationController {
     */
    public OneHandedAnimationController(Context context) {
        mSurfaceTransactionHelper = new OneHandedSurfaceTransactionHelper(context);
        mOvershootInterpolator = new OvershootInterpolator();
        mInterpolator = new OneHandedInterpolator();
    }

    @SuppressWarnings("unchecked")
@@ -102,7 +101,7 @@ public class OneHandedAnimationController {
    OneHandedTransitionAnimator setupOneHandedTransitionAnimator(
            OneHandedTransitionAnimator animator) {
        animator.setSurfaceTransactionHelper(mSurfaceTransactionHelper);
        animator.setInterpolator(mOvershootInterpolator);
        animator.setInterpolator(mInterpolator);
        animator.setFloatValues(FRACTION_START, FRACTION_END);
        return animator;
    }
@@ -112,6 +111,8 @@ public class OneHandedAnimationController {
     *
     * @param <T> Type of property to animate, either offset (float)
     */
    // TODO: Refactoring to use SpringAnimation and DynamicAnimation instead of using ValueAnimator
    //  to implement One-Handed transition animation. (b/185129031)
    public abstract static class OneHandedTransitionAnimator<T> extends ValueAnimator implements
            ValueAnimator.AnimatorUpdateListener,
            ValueAnimator.AnimatorListener {
@@ -297,4 +298,15 @@ public class OneHandedAnimationController {
            };
        }
    }

    /**
     * An Interpolator for One-Handed transition animation.
     */
    public class OneHandedInterpolator extends BaseInterpolator {
        @Override
        public float getInterpolation(float input) {
            return (float) (Math.pow(2, -10 * input) * Math.sin(((input - 4.0f) / 4.0f)
                    * (2.0f * Math.PI) / 4.0f) + 1);
        }
    }
}