Apply spring forces to animate to the final position for swipe home

Now instead of an incorrect hack that simulated accelerating to the target,
we actually apply spring forces to make it feel realistic and work no matter
where the target is.

Added two helper classes for this:
- FlingSpringAnim handles the fling, applying friction until reaching the target,
  then a spring to pull towards the final position (also applies if fling wasn't
  in the right direction or strong enough to reach the target).
- RectFSpringAnim uses 2 FlingSpringAnims (x + y) to animate from a starting rect
  to a target rect. It also has an animation to scale from the start rect to the
  target rect, sending progress update callbacks to the caller.

Bug: 123900446
Change-Id: Iafa89db1d55c42816acfa9f1bb84a7519b69ff12
This commit is contained in:
Tony
2019-03-06 11:11:54 -08:00
parent 9b4c82cbf9
commit 0d447c88b8
8 changed files with 312 additions and 72 deletions

View File

@@ -15,6 +15,8 @@
*/
package com.android.launcher3.views;
import static com.android.launcher3.config.FeatureFlags.ADAPTIVE_ICON_WINDOW_ANIM;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
@@ -55,8 +57,6 @@ import com.android.launcher3.shortcuts.DeepShortcutView;
import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;
import static com.android.launcher3.config.FeatureFlags.ADAPTIVE_ICON_WINDOW_ANIM;
/**
* A view that is created to look like another view with the purpose of creating fluid animations.
*/
@@ -143,9 +143,6 @@ public class FloatingIconView extends View implements Animator.AnimatorListener,
setBackgroundDrawableBounds(bgScale);
mRevealAnimator.setCurrentFraction(shapeRevealProgress);
if (Float.compare(shapeRevealProgress, 1f) >= 0f) {
mRevealAnimator.end();
}
}
invalidate();
invalidateOutline();
@@ -160,6 +157,9 @@ public class FloatingIconView extends View implements Animator.AnimatorListener,
@Override
public void onAnimationEnd(Animator animator) {
if (mRevealAnimator != null) {
mRevealAnimator.end();
}
if (mEndRunnable != null) {
mEndRunnable.run();
}