Merge "Fix One Handed Feedback gesture's animations are quite jarring" into sc-dev
This commit is contained in:
@@ -40,7 +40,7 @@
|
|||||||
<integer name="long_press_dock_anim_duration">250</integer>
|
<integer name="long_press_dock_anim_duration">250</integer>
|
||||||
|
|
||||||
<!-- Animation duration for translating of one handed when trigger / dismiss. -->
|
<!-- 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 -->
|
<!-- One handed mode default offset % of display size -->
|
||||||
<fraction name="config_one_handed_offset">40%</fraction>
|
<fraction name="config_one_handed_offset">40%</fraction>
|
||||||
|
|||||||
@@ -22,8 +22,7 @@ import android.annotation.IntDef;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.view.SurfaceControl;
|
import android.view.SurfaceControl;
|
||||||
import android.view.animation.Interpolator;
|
import android.view.animation.BaseInterpolator;
|
||||||
import android.view.animation.OvershootInterpolator;
|
|
||||||
import android.window.WindowContainerToken;
|
import android.window.WindowContainerToken;
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
@@ -54,7 +53,7 @@ public class OneHandedAnimationController {
|
|||||||
public @interface TransitionDirection {
|
public @interface TransitionDirection {
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Interpolator mOvershootInterpolator;
|
private final OneHandedInterpolator mInterpolator;
|
||||||
private final OneHandedSurfaceTransactionHelper mSurfaceTransactionHelper;
|
private final OneHandedSurfaceTransactionHelper mSurfaceTransactionHelper;
|
||||||
private final HashMap<WindowContainerToken, OneHandedTransitionAnimator> mAnimatorMap =
|
private final HashMap<WindowContainerToken, OneHandedTransitionAnimator> mAnimatorMap =
|
||||||
new HashMap<>();
|
new HashMap<>();
|
||||||
@@ -64,7 +63,7 @@ public class OneHandedAnimationController {
|
|||||||
*/
|
*/
|
||||||
public OneHandedAnimationController(Context context) {
|
public OneHandedAnimationController(Context context) {
|
||||||
mSurfaceTransactionHelper = new OneHandedSurfaceTransactionHelper(context);
|
mSurfaceTransactionHelper = new OneHandedSurfaceTransactionHelper(context);
|
||||||
mOvershootInterpolator = new OvershootInterpolator();
|
mInterpolator = new OneHandedInterpolator();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@@ -102,7 +101,7 @@ public class OneHandedAnimationController {
|
|||||||
OneHandedTransitionAnimator setupOneHandedTransitionAnimator(
|
OneHandedTransitionAnimator setupOneHandedTransitionAnimator(
|
||||||
OneHandedTransitionAnimator animator) {
|
OneHandedTransitionAnimator animator) {
|
||||||
animator.setSurfaceTransactionHelper(mSurfaceTransactionHelper);
|
animator.setSurfaceTransactionHelper(mSurfaceTransactionHelper);
|
||||||
animator.setInterpolator(mOvershootInterpolator);
|
animator.setInterpolator(mInterpolator);
|
||||||
animator.setFloatValues(FRACTION_START, FRACTION_END);
|
animator.setFloatValues(FRACTION_START, FRACTION_END);
|
||||||
return animator;
|
return animator;
|
||||||
}
|
}
|
||||||
@@ -112,6 +111,8 @@ public class OneHandedAnimationController {
|
|||||||
*
|
*
|
||||||
* @param <T> Type of property to animate, either offset (float)
|
* @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
|
public abstract static class OneHandedTransitionAnimator<T> extends ValueAnimator implements
|
||||||
ValueAnimator.AnimatorUpdateListener,
|
ValueAnimator.AnimatorUpdateListener,
|
||||||
ValueAnimator.AnimatorListener {
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user