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

Commit dcecfcf7 authored by Jason Chang's avatar Jason Chang
Browse files

Fix One Handed Feedback gesture's animations are quite jarring

To provide a new Interpolator formula for One-Handed transition
animation.

Bug: 178355565
Test: manual
Test: atest WMShellUnitTests
Change-Id: I78d998569618dc52c8b6fce6cb4a71f13ad01ba8
parent c22aff4e
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);
        }
    }
}