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
@@ -21,7 +21,6 @@ import static com.android.quickstep.views.RecentsView.CONTENT_ALPHA;
import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.ComponentName;
import android.content.Context;
import android.graphics.Rect;
import android.graphics.RectF;
@@ -90,7 +89,7 @@ public final class FallbackActivityControllerHelper implements
@NonNull
@Override
public Animator createActivityAnimationToHome() {
public AnimatorPlaybackController createActivityAnimationToHome() {
Animator anim = ObjectAnimator.ofFloat(recentsView, CONTENT_ALPHA, 0);
anim.addListener(new AnimationSuccessListener() {
@Override
@@ -98,7 +97,10 @@ public final class FallbackActivityControllerHelper implements
recentsView.startHome();
}
});
return anim;
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.play(anim);
long accuracy = 2 * Math.max(recentsView.getWidth(), recentsView.getHeight());
return AnimatorPlaybackController.wrap(animatorSet, accuracy);
}
};
}