Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 07b1d670 authored by Tony Wickham's avatar Tony Wickham Committed by Tony
Browse files

Animate to the workspace card when transitioning from overview to home

Change-Id: Ib2c2288fd935f678a5c7a354be09c6d852d86b41
parent da1e4b31
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -24,12 +24,14 @@ import com.android.launcher3.Launcher;
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 @@ public class RecentsViewStateController implements StateHandler {
    @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);
+2 −2
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
    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 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
        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);
    }

+6 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import java.util.ArrayList;
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 @@ public class AnimatorSetBuilder {
        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;
    }
}