Animate to the workspace card when transitioning from overview to home
Change-Id: Ib2c2288fd935f678a5c7a354be09c6d852d86b41
diff --git a/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java b/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java
index 1f6ffe9..d657e4e 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java
@@ -24,12 +24,14 @@
import com.android.launcher3.LauncherState;
import com.android.launcher3.LauncherStateManager.AnimationConfig;
import com.android.launcher3.LauncherStateManager.StateHandler;
+import com.android.launcher3.PagedView;
import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.anim.AnimatorSetBuilder;
import com.android.launcher3.anim.Interpolators;
import com.android.quickstep.AnimatedFloat;
import com.android.quickstep.RecentsView;
+import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.OVERVIEW;
public class RecentsViewStateController implements StateHandler {
@@ -62,6 +64,16 @@
@Override
public void setStateWithAnimation(final LauncherState toState,
AnimatorSetBuilder builder, AnimationConfig config) {
+ // Scroll to the workspace card before changing to the NORMAL state.
+ int currPage = mRecentsView.getCurrentPage();
+ if (toState == NORMAL && currPage != 0 && !config.userControlled) {
+ int maxSnapDuration = PagedView.SLOW_PAGE_SNAP_ANIMATION_DURATION;
+ int durationPerPage = maxSnapDuration / 10;
+ int snapDuration = Math.min(maxSnapDuration, durationPerPage * currPage);
+ mRecentsView.snapToPage(0, snapDuration);
+ builder.setStartDelay(snapDuration);
+ }
+
ObjectAnimator progressAnim =
mTransitionProgress.animateToValue(toState == OVERVIEW ? 1 : 0);
progressAnim.setDuration(config.duration);
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index 5ed722c..87595d9 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -68,7 +68,7 @@
private static final int MIN_LENGTH_FOR_FLING = 25;
public static final int PAGE_SNAP_ANIMATION_DURATION = 750;
- protected static final int SLOW_PAGE_SNAP_ANIMATION_DURATION = 950;
+ public static final int SLOW_PAGE_SNAP_ANIMATION_DURATION = 950;
// OverScroll constants
private final static int OVERSCROLL_PAGE_SNAP_ANIMATION_DURATION = 270;
@@ -1690,7 +1690,7 @@
snapToPage(whichPage, PAGE_SNAP_ANIMATION_DURATION, true, null);
}
- protected void snapToPage(int whichPage, int duration) {
+ public void snapToPage(int whichPage, int duration) {
snapToPage(whichPage, duration, false, null);
}
diff --git a/src/com/android/launcher3/anim/AnimatorSetBuilder.java b/src/com/android/launcher3/anim/AnimatorSetBuilder.java
index 63e67ff..7cd9651 100644
--- a/src/com/android/launcher3/anim/AnimatorSetBuilder.java
+++ b/src/com/android/launcher3/anim/AnimatorSetBuilder.java
@@ -28,6 +28,7 @@
public class AnimatorSetBuilder {
protected final ArrayList<Animator> mAnims = new ArrayList<>();
+ private long mStartDelay = 0;
/**
* Associates a tag with all the animations added after this call.
@@ -38,9 +39,14 @@
mAnims.add(anim);
}
+ public void setStartDelay(long startDelay) {
+ mStartDelay = startDelay;
+ }
+
public AnimatorSet build() {
AnimatorSet anim = LauncherAnimUtils.createAnimatorSet();
anim.playTogether(mAnims);
+ anim.setStartDelay(mStartDelay);
return anim;
}
}