Merge "Removing generalization from OneHandledAnimationController" into sc-dev

This commit is contained in:
Sunny Goyal
2021-05-11 16:20:44 +00:00
committed by Android (Google) Code Review

View File

@@ -113,20 +113,18 @@ public class OneHandedAnimationController {
/** /**
* Animator for OneHanded transition animation which supports both alpha and bounds animation. * Animator for OneHanded transition animation which supports both alpha and bounds animation.
*
* @param <T> Type of property to animate, either offset (float)
*/ */
// TODO: Refactoring to use SpringAnimation and DynamicAnimation instead of using ValueAnimator // TODO: Refactoring to use SpringAnimation and DynamicAnimation instead of using ValueAnimator
// to implement One-Handed transition animation. (b/185129031) // to implement One-Handed transition animation. (b/185129031)
public abstract static class OneHandedTransitionAnimator<T> extends ValueAnimator implements public abstract static class OneHandedTransitionAnimator extends ValueAnimator implements
ValueAnimator.AnimatorUpdateListener, ValueAnimator.AnimatorUpdateListener,
ValueAnimator.AnimatorListener { ValueAnimator.AnimatorListener {
private final SurfaceControl mLeash; private final SurfaceControl mLeash;
private final WindowContainerToken mToken; private final WindowContainerToken mToken;
private T mStartValue; private float mStartValue;
private T mEndValue; private float mEndValue;
private T mCurrentValue; private float mCurrentValue;
private final List<OneHandedAnimationCallback> mOneHandedAnimationCallbacks = private final List<OneHandedAnimationCallback> mOneHandedAnimationCallbacks =
new ArrayList<>(); new ArrayList<>();
@@ -137,7 +135,7 @@ public class OneHandedAnimationController {
private @TransitionDirection int mTransitionDirection; private @TransitionDirection int mTransitionDirection;
private OneHandedTransitionAnimator(WindowContainerToken token, SurfaceControl leash, private OneHandedTransitionAnimator(WindowContainerToken token, SurfaceControl leash,
T startValue, T endValue) { float startValue, float endValue) {
mLeash = leash; mLeash = leash;
mToken = token; mToken = token;
mStartValue = startValue; mStartValue = startValue;
@@ -204,7 +202,7 @@ public class OneHandedAnimationController {
mSurfaceTransactionHelper = helper; mSurfaceTransactionHelper = helper;
} }
OneHandedTransitionAnimator<T> addOneHandedAnimationCallback( OneHandedTransitionAnimator addOneHandedAnimationCallback(
OneHandedAnimationCallback callback) { OneHandedAnimationCallback callback) {
mOneHandedAnimationCallbacks.add(callback); mOneHandedAnimationCallbacks.add(callback);
return this; return this;
@@ -223,27 +221,27 @@ public class OneHandedAnimationController {
return mTransitionDirection; return mTransitionDirection;
} }
OneHandedTransitionAnimator<T> setTransitionDirection(int direction) { OneHandedTransitionAnimator setTransitionDirection(int direction) {
mTransitionDirection = direction; mTransitionDirection = direction;
return this; return this;
} }
T getStartValue() { float getStartValue() {
return mStartValue; return mStartValue;
} }
T getEndValue() { float getEndValue() {
return mEndValue; return mEndValue;
} }
void setCurrentValue(T value) { void setCurrentValue(float value) {
mCurrentValue = value; mCurrentValue = value;
} }
/** /**
* Updates the {@link #mEndValue}. * Updates the {@link #mEndValue}.
*/ */
void updateEndValue(T endValue) { void updateEndValue(float endValue) {
mEndValue = endValue; mEndValue = endValue;
} }
@@ -252,10 +250,10 @@ public class OneHandedAnimationController {
} }
@VisibleForTesting @VisibleForTesting
static OneHandedTransitionAnimator<Float> ofYOffset(WindowContainerToken token, static OneHandedTransitionAnimator ofYOffset(WindowContainerToken token,
SurfaceControl leash, float startValue, float endValue, Rect displayBounds) { SurfaceControl leash, float startValue, float endValue, Rect displayBounds) {
return new OneHandedTransitionAnimator<Float>(token, leash, startValue, endValue) { return new OneHandedTransitionAnimator(token, leash, startValue, endValue) {
private final Rect mTmpRect = new Rect(displayBounds); private final Rect mTmpRect = new Rect(displayBounds);