Tuning app close, and turn on flag.

- Tracks centery, slowed things down a bit

* We will be replacing StaggeredWorkspaceAnim with
  another animation, but I'm keeping it here in
  case we decide to turn the flag off later on.

Bug: 173107751
Test: manual
Change-Id: I5cd54ec374ad07c4912aff125a905b3b1dc7ebd5
This commit is contained in:
Jon Miranda committed 2021-05-12 15:04:15 -07:00
1 parent d30f4ce528
commit b3a267b58a
5 files changed
+80 -88

No files matched your search

@@ -69,12 +69,12 @@ public class RectFSpringAnim2 extends RectFSpringAnim {
new FloatPropertyCompat<RectFSpringAnim2>("rectYSpring") {
@Override
public float getValue(RectFSpringAnim2 anim) {
return anim.mCurrentY;
return anim.mCurrentCenterY;
}
@Override
public void setValue(RectFSpringAnim2 anim, float y) {
anim.mCurrentY = y;
anim.mCurrentCenterY = y;
anim.onUpdate();
}
};
@@ -100,13 +100,12 @@ public class RectFSpringAnim2 extends RectFSpringAnim {
private final List<Animator.AnimatorListener> mAnimatorListeners = new ArrayList<>();
private float mCurrentCenterX;
private float mCurrentY;
private float mCurrentCenterY;
private float mTargetX;
private float mTargetY;
// If true, tracking the bottom of the rects, else tracking the top.
private final boolean mTrackingBottomY;
private float mProgress;
private SpringAnimation mRectXAnim;
private SpringAnimation mRectYAnim;
@@ -139,11 +138,10 @@ public class RectFSpringAnim2 extends RectFSpringAnim {
mStartRect = startRect;
mTargetRect = targetRect;
mTrackingBottomY = startRect.bottom < targetRect.bottom;
mCurrentY = mTrackingBottomY ? mStartRect.bottom : mStartRect.top;
mCurrentCenterY = mStartRect.centerY();
mCurrentCenterX = mStartRect.centerX();
mTargetY = mTrackingBottomY ? mTargetRect.bottom : mTargetRect.top;
mTargetY = mTargetRect.centerY();
mTargetX = mTargetRect.centerX();
ResourceProvider rp = DynamicResource.provider(context);
@@ -157,12 +155,6 @@ public class RectFSpringAnim2 extends RectFSpringAnim {
mHomeTransYEnd = dpToPx(rp.getFloat(R.dimen.swipe_up_trans_y_dp));
mScaleStart = rp.getFloat(R.dimen.swipe_up_scale_start);
if (!mTrackingBottomY) {
mYStiffness *= rp.getFloat(R.dimen.swipe_up_rect_2_y_stiffness_low_swipe_multiplier);
mDuration *= rp.getFloat(R.dimen.swipe_up_low_swipe_duration_multiplier);
}
mCloseInterpolator = getAppCloseInterpolator(context);
// End on a "round-enough" radius so that the shape reveal doesn't have to do too much
@@ -180,11 +172,8 @@ public class RectFSpringAnim2 extends RectFSpringAnim {
}
if (mRectYAnim != null) {
if (mTrackingBottomY && mTargetY != mTargetRect.bottom) {
mTargetY = mTargetRect.bottom;
mRectYAnim.animateToFinalPosition(mTargetY);
} else if (!mTrackingBottomY && mTargetY != mTargetRect.top) {
mTargetY = mTargetRect.top;
if (mTargetY != mTargetRect.centerY()) {
mTargetY = mTargetRect.centerY();
mRectYAnim.animateToFinalPosition(mTargetY);
}
}
@@ -220,9 +209,9 @@ public class RectFSpringAnim2 extends RectFSpringAnim {
}));
mRectYAnim = new SpringAnimation(this, RECT_Y)
.setStartValue(mCurrentY)
.setMinValue(Math.min(0, mCurrentY))
.setMaxValue(Math.max(dp.heightPx, mCurrentY))
.setStartValue(mCurrentCenterY)
.setMinValue(Math.min(0, mCurrentCenterY))
.setMaxValue(Math.max(dp.heightPx, mCurrentCenterY))
.setStartVelocity(velocityPxPerMs.y * 1000)
.setSpring(new SpringForce(mTargetY)
.setStiffness(mYStiffness)
@@ -336,13 +325,11 @@ public class RectFSpringAnim2 extends RectFSpringAnim {
mTargetRect.width());
float currentHeight = Utilities.mapRange(rectProgress, mStartRect.height(),
mTargetRect.height());
if (mTrackingBottomY) {
mCurrentRect.set(mCurrentCenterX - currentWidth / 2, mCurrentY - currentHeight,
mCurrentCenterX + currentWidth / 2, mCurrentY);
} else {
mCurrentRect.set(mCurrentCenterX - currentWidth / 2, mCurrentY,
mCurrentCenterX + currentWidth / 2, mCurrentY + currentHeight);
}
mCurrentRect.set(mCurrentCenterX - currentWidth / 2,
mCurrentCenterY - currentHeight / 2,
mCurrentCenterX + currentWidth / 2,
mCurrentCenterY + currentHeight / 2);
float currentPlayTime = mRectScaleAnimEnded ? mRectScaleAnim.getDuration()
: mRectScaleAnim.getCurrentPlayTime();