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

Commit eb3e99bd authored by Jon's avatar Jon Committed by android-build-merger
Browse files

Merge branch 'ub-launcher3-edmonton-polish' into pi-dev

am: 0fd1472b

Change-Id: Ib3e4a8a65875a76ba0f772619f44130f94dc4dad
parents 58ae9cbc 0fd1472b
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -21,6 +21,7 @@
    <dimen name="task_thumbnail_icon_size">48dp</dimen>
    <dimen name="task_thumbnail_icon_size">48dp</dimen>
    <dimen name="task_corner_radius">2dp</dimen>
    <dimen name="task_corner_radius">2dp</dimen>
    <dimen name="recents_page_spacing">10dp</dimen>
    <dimen name="recents_page_spacing">10dp</dimen>
    <dimen name="recents_clear_all_deadzone_vertical_margin">70dp</dimen>
    <dimen name="quickscrub_adjacent_visible_width">20dp</dimen>
    <dimen name="quickscrub_adjacent_visible_width">20dp</dimen>


    <!-- The speed in dp/s at which the user needs to be scrolling in recents such that we start
    <!-- The speed in dp/s at which the user needs to be scrolling in recents such that we start
@@ -32,7 +33,7 @@


    <!-- Launcher app transition -->
    <!-- Launcher app transition -->
    <dimen name="content_trans_y">50dp</dimen>
    <dimen name="content_trans_y">50dp</dimen>
    <dimen name="springs_trans_y">-70dp</dimen>
    <dimen name="workspace_trans_y">50dp</dimen>
    <dimen name="closing_window_trans_y">115dp</dimen>
    <dimen name="closing_window_trans_y">115dp</dimen>


    <dimen name="recents_empty_message_text_size">16sp</dimen>
    <dimen name="recents_empty_message_text_size">16sp</dimen>
+15 −97
Original line number Original line Diff line number Diff line
@@ -16,7 +16,6 @@


package com.android.launcher3;
package com.android.launcher3;


import static android.view.View.TRANSLATION_Y;
import static com.android.launcher3.BaseActivity.INVISIBLE_ALL;
import static com.android.launcher3.BaseActivity.INVISIBLE_ALL;
import static com.android.launcher3.BaseActivity.INVISIBLE_BY_APP_TRANSITIONS;
import static com.android.launcher3.BaseActivity.INVISIBLE_BY_APP_TRANSITIONS;
import static com.android.launcher3.BaseActivity.INVISIBLE_BY_PENDING_FLAGS;
import static com.android.launcher3.BaseActivity.INVISIBLE_BY_PENDING_FLAGS;
@@ -28,10 +27,8 @@ import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.Utilities.postAsyncCallback;
import static com.android.launcher3.Utilities.postAsyncCallback;
import static com.android.launcher3.allapps.AllAppsTransitionController.ALL_APPS_PROGRESS;
import static com.android.launcher3.allapps.AllAppsTransitionController.ALL_APPS_PROGRESS;
import static com.android.launcher3.anim.Interpolators.AGGRESSIVE_EASE;
import static com.android.launcher3.anim.Interpolators.AGGRESSIVE_EASE;
import static com.android.launcher3.anim.Interpolators.DEACCEL;
import static com.android.launcher3.anim.Interpolators.DEACCEL_1_7;
import static com.android.launcher3.anim.Interpolators.DEACCEL_1_7;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.anim.Interpolators.OSCILLATE;
import static com.android.launcher3.dragndrop.DragLayer.ALPHA_INDEX_TRANSITIONS;
import static com.android.launcher3.dragndrop.DragLayer.ALPHA_INDEX_TRANSITIONS;
import static com.android.quickstep.TaskUtils.findTaskViewToLaunch;
import static com.android.quickstep.TaskUtils.findTaskViewToLaunch;
import static com.android.quickstep.TaskUtils.getRecentsWindowAnimator;
import static com.android.quickstep.TaskUtils.getRecentsWindowAnimator;
@@ -57,7 +54,6 @@ import android.os.CancellationSignal;
import android.os.Handler;
import android.os.Handler;
import android.os.Looper;
import android.os.Looper;
import android.util.Pair;
import android.util.Pair;
import android.util.Property;
import android.view.View;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup;


@@ -119,20 +115,12 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag


    public static final int RECENTS_LAUNCH_DURATION = 336;
    public static final int RECENTS_LAUNCH_DURATION = 336;
    public static final int RECENTS_QUICKSCRUB_LAUNCH_DURATION = 300;
    public static final int RECENTS_QUICKSCRUB_LAUNCH_DURATION = 300;
    private static final int LAUNCHER_RESUME_START_DELAY = 40;
    private static final int LAUNCHER_RESUME_START_DELAY = 100;
    private static final int CLOSING_TRANSITION_DURATION_MS = 250;
    private static final int CLOSING_TRANSITION_DURATION_MS = 250;


    // Progress = 0: All apps is fully pulled up, Progress = 1: All apps is fully pulled down.
    // Progress = 0: All apps is fully pulled up, Progress = 1: All apps is fully pulled down.
    public static final float ALL_APPS_PROGRESS_OFF_SCREEN = 1.3059858f;
    public static final float ALL_APPS_PROGRESS_OFF_SCREEN = 1.3059858f;


    private static final int APP_CLOSE_ROW_START_DELAY_MS = 8;

    // The sum of [slide, oscillate, and settle] should be <= LAUNCHER_RESUME_TOTAL_DURATION.
    private static final int LAUNCHER_RESUME_TOTAL_DURATION = 346;
    private static final int SPRING_SLIDE_DURATION = 166;
    private static final int SPRING_OSCILLATE_DURATION = 130;
    private static final int SPRING_SETTLE_DURATION = 50;

    private final Launcher mLauncher;
    private final Launcher mLauncher;
    private final DragLayer mDragLayer;
    private final DragLayer mDragLayer;
    private final AlphaProperty mDragLayerAlpha;
    private final AlphaProperty mDragLayerAlpha;
@@ -141,8 +129,7 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
    private final boolean mIsRtl;
    private final boolean mIsRtl;


    private final float mContentTransY;
    private final float mContentTransY;
    private final float mStartSlideTransY;
    private final float mWorkspaceTransY;
    private final float mEndSlideTransY;
    private final float mClosingWindowTransY;
    private final float mClosingWindowTransY;


    private DeviceProfile mDeviceProfile;
    private DeviceProfile mDeviceProfile;
@@ -172,9 +159,8 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag


        Resources res = mLauncher.getResources();
        Resources res = mLauncher.getResources();
        mContentTransY = res.getDimensionPixelSize(R.dimen.content_trans_y);
        mContentTransY = res.getDimensionPixelSize(R.dimen.content_trans_y);
        mWorkspaceTransY = res.getDimensionPixelSize(R.dimen.workspace_trans_y);
        mClosingWindowTransY = res.getDimensionPixelSize(R.dimen.closing_window_trans_y);
        mClosingWindowTransY = res.getDimensionPixelSize(R.dimen.closing_window_trans_y);
        mStartSlideTransY = res.getDimensionPixelSize(R.dimen.springs_trans_y);
        mEndSlideTransY = -mStartSlideTransY * 0.1f;


        mLauncher.addOnDeviceProfileChangeListener(this);
        mLauncher.addOnDeviceProfileChangeListener(this);
        registerRemoteAnimations();
        registerRemoteAnimations();
@@ -786,33 +772,25 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
            });
            });
        } else {
        } else {
            AnimatorSet workspaceAnimator = new AnimatorSet();
            AnimatorSet workspaceAnimator = new AnimatorSet();
            workspaceAnimator.setStartDelay(LAUNCHER_RESUME_START_DELAY);


            ShortcutAndWidgetContainer currentPage = ((CellLayout) mLauncher.getWorkspace()
            mDragLayer.setTranslationY(-mWorkspaceTransY);;
                    .getChildAt(mLauncher.getWorkspace().getCurrentPage()))
            workspaceAnimator.play(ObjectAnimator.ofFloat(mDragLayer, View.TRANSLATION_Y,
                    .getShortcutsAndWidgets();
                    -mWorkspaceTransY, 0));


            // Set up springs on workspace items.
            mDragLayerAlpha.setValue(0);
            for (int i = currentPage.getChildCount() - 1; i >= 0; i--) {
            workspaceAnimator.play(ObjectAnimator.ofFloat(
                View child = currentPage.getChildAt(i);
                    mDragLayerAlpha, MultiValueAlpha.VALUE, 0, 1f));
                CellLayout.LayoutParams lp = ((CellLayout.LayoutParams) child.getLayoutParams());
                addStaggeredAnimationForView(child, workspaceAnimator, lp.cellY + lp.cellVSpan);
            }


            // Set up a spring for the shelf.
            workspaceAnimator.setStartDelay(LAUNCHER_RESUME_START_DELAY);
            if (!mLauncher.getDeviceProfile().isVerticalBarLayout()) {
            workspaceAnimator.setDuration(333);
                AllAppsTransitionController allAppsController = mLauncher.getAllAppsController();
            workspaceAnimator.setInterpolator(Interpolators.DEACCEL_1_7);
                float shiftRange = allAppsController.getShiftRange();
                float slideStart = shiftRange / (shiftRange - mStartSlideTransY);
                float oscillateStart = shiftRange / (shiftRange - mEndSlideTransY);

                buildSpringAnimation(workspaceAnimator, allAppsController, ALL_APPS_PROGRESS,
                        0 /* startDelay */, slideStart, oscillateStart, 1f /* finalPosition */);
            }


            mDragLayer.getScrim().hideSysUiScrim(true);
            mDragLayer.getScrim().hideSysUiScrim(true);

            // Pause page indicator animations as they lead to layer trashing.
            // Pause page indicator animations as they lead to layer trashing.
            mLauncher.getWorkspace().getPageIndicator().pauseAnimations();
            mLauncher.getWorkspace().getPageIndicator().pauseAnimations();
            mDragLayer.setLayerType(View.LAYER_TYPE_HARDWARE, null);

            workspaceAnimator.addListener(new AnimatorListenerAdapter() {
            workspaceAnimator.addListener(new AnimatorListenerAdapter() {
                @Override
                @Override
                public void onAnimationEnd(Animator animation) {
                public void onAnimationEnd(Animator animation) {
@@ -823,66 +801,6 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
        }
        }
    }
    }


    /**
     * Adds an alpha/trans animator for {@param v}, with a start delay based on the view's row.
     *
     * @param v View in a ShortcutAndWidgetContainer.
     * @param row The bottom-most row that contains the view.
     */
    private void addStaggeredAnimationForView(View v, AnimatorSet outAnimator, int row) {
        // Invert the rows, because we stagger starting from the bottom of the screen.
        int invertedRow = LauncherAppState.getIDP(mLauncher).numRows - row + 1;
        long startDelay = (long) (invertedRow * APP_CLOSE_ROW_START_DELAY_MS);

        v.setAlpha(0);
        ObjectAnimator alpha = ObjectAnimator.ofFloat(v, View.ALPHA, 1f);
        alpha.setInterpolator(LINEAR);
        alpha.setDuration(SPRING_SLIDE_DURATION + SPRING_OSCILLATE_DURATION);
        alpha.setStartDelay(startDelay);
        outAnimator.play(alpha);

        buildSpringAnimation(outAnimator, v, TRANSLATION_Y, startDelay, mStartSlideTransY,
                mEndSlideTransY, 0f /* finalPosition */);

        outAnimator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                v.setAlpha(1f);
                v.setTranslationY(0);
            }
        });
    }

    /**
     * Spring animations consists of three sequential animators: a slide, an oscillation, and
     * a settle.
     */
    private <T> void buildSpringAnimation(AnimatorSet outAnimator, T objectToSpring,
            Property<T, Float> property, long startDelay, float slideStart, float oscillateStart,
            float finalPosition) {
        // Ensures a clean hand-off between slide and oscillate.
        float slideEnd = Utilities.mapToRange(0, 0, 1f, oscillateStart, finalPosition, OSCILLATE);

        property.set(objectToSpring, slideStart);

        ObjectAnimator slideIn = ObjectAnimator.ofFloat(objectToSpring, property, slideStart,
                slideEnd);
        slideIn.setInterpolator(DEACCEL);
        slideIn.setStartDelay(startDelay);
        slideIn.setDuration(SPRING_SLIDE_DURATION);

        ObjectAnimator oscillate = ObjectAnimator.ofFloat(objectToSpring, property, oscillateStart,
                finalPosition);
        oscillate.setInterpolator(OSCILLATE);
        oscillate.setDuration(SPRING_OSCILLATE_DURATION);

        ObjectAnimator settle = ObjectAnimator.ofFloat(objectToSpring, property, finalPosition);
        settle.setInterpolator(LINEAR);
        settle.setDuration(SPRING_SETTLE_DURATION);

        outAnimator.playSequentially(slideIn, oscillate, settle);
    }

    private void resetContentView() {
    private void resetContentView() {
        mLauncher.getWorkspace().getPageIndicator().skipAnimationsToEnd();
        mLauncher.getWorkspace().getPageIndicator().skipAnimationsToEnd();
        mDragLayerAlpha.setValue(1f);
        mDragLayerAlpha.setValue(1f);
+20 −5
Original line number Original line Diff line number Diff line
@@ -20,17 +20,22 @@ import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.anim.Interpolators.DEACCEL;
import static com.android.launcher3.anim.Interpolators.DEACCEL;
import static com.android.quickstep.WindowTransformSwipeHandler.MAX_SWIPE_DURATION;
import static com.android.quickstep.WindowTransformSwipeHandler.MAX_SWIPE_DURATION;
import static com.android.quickstep.WindowTransformSwipeHandler.MIN_OVERSHOOT_DURATION;


import android.animation.ValueAnimator;
import android.animation.ValueAnimator;
import android.view.animation.Interpolator;


import com.android.launcher3.Launcher;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAnimUtils;
import com.android.launcher3.LauncherAnimUtils;
import com.android.launcher3.LauncherStateManager;
import com.android.launcher3.LauncherStateManager;
import com.android.launcher3.R;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.allapps.AllAppsTransitionController;
import com.android.launcher3.allapps.AllAppsTransitionController;
import com.android.launcher3.allapps.DiscoveryBounce;
import com.android.launcher3.allapps.DiscoveryBounce;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.AnimatorSetBuilder;
import com.android.launcher3.anim.AnimatorSetBuilder;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.anim.Interpolators.OvershootParams;
import com.android.launcher3.uioverrides.PortraitStatesTouchController;
import com.android.launcher3.uioverrides.PortraitStatesTouchController;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
@@ -89,7 +94,9 @@ public class LongSwipeHelper {
    }
    }


    public void end(float velocity, boolean isFling, Runnable callback) {
    public void end(float velocity, boolean isFling, Runnable callback) {
        float velocityPxPerMs = velocity / 1000;
        long duration = MAX_SWIPE_DURATION;
        long duration = MAX_SWIPE_DURATION;
        Interpolator interpolator = DEACCEL;


        final float currentFraction = mAnimator.getProgressFraction();
        final float currentFraction = mAnimator.getProgressFraction();
        final boolean toAllApps;
        final boolean toAllApps;
@@ -107,6 +114,16 @@ public class LongSwipeHelper {
            long expectedDuration = Math.abs(Math.round((endProgress - currentFraction)
            long expectedDuration = Math.abs(Math.round((endProgress - currentFraction)
                    * MAX_SWIPE_DURATION * SWIPE_DURATION_MULTIPLIER));
                    * MAX_SWIPE_DURATION * SWIPE_DURATION_MULTIPLIER));
            duration = Math.min(MAX_SWIPE_DURATION, expectedDuration);
            duration = Math.min(MAX_SWIPE_DURATION, expectedDuration);

            if (blockedFling && !toAllApps) {
                Interpolators.OvershootParams overshoot = new OvershootParams(currentFraction,
                        currentFraction, endProgress, velocityPxPerMs, (int) mMaxSwipeDistance);
                duration = (overshoot.duration + duration);
                duration = Utilities.boundToRange(duration, MIN_OVERSHOOT_DURATION,
                        MAX_SWIPE_DURATION);
                interpolator = overshoot.interpolator;
                endProgress = overshoot.end;
            }
        } else {
        } else {
            toAllApps = velocity < 0;
            toAllApps = velocity < 0;
            endProgress = toAllApps ? 1 : 0;
            endProgress = toAllApps ? 1 : 0;
@@ -119,18 +136,16 @@ public class LongSwipeHelper {
                // we want the page's snap velocity to approximately match the velocity at
                // we want the page's snap velocity to approximately match the velocity at
                // which the user flings, so we scale the duration by a value near to the
                // which the user flings, so we scale the duration by a value near to the
                // derivative of the scroll interpolator at zero, ie. 2.
                // derivative of the scroll interpolator at zero, ie. 2.
                long baseDuration = Math.round(1000 * Math.abs(distanceToTravel / velocity));
                long baseDuration = Math.round(Math.abs(distanceToTravel / velocityPxPerMs));
                duration = Math.min(MAX_SWIPE_DURATION, 2 * baseDuration);
                duration = Math.min(MAX_SWIPE_DURATION, 2 * baseDuration);
            }
            }
        }
        }


        if (blockedFling && !toAllApps) {
            duration *= LauncherAnimUtils.blockedFlingDurationFactor(0);
        }
        final boolean finalIsFling = isFling;
        final boolean finalIsFling = isFling;
        mAnimator.setEndAction(() -> onSwipeAnimationComplete(toAllApps, finalIsFling, callback));
        mAnimator.setEndAction(() -> onSwipeAnimationComplete(toAllApps, finalIsFling, callback));

        ValueAnimator animator = mAnimator.getAnimationPlayer();
        ValueAnimator animator = mAnimator.getAnimationPlayer();
        animator.setDuration(duration).setInterpolator(DEACCEL);
        animator.setDuration(duration).setInterpolator(interpolator);
        animator.setFloatValues(currentFraction, endProgress);
        animator.setFloatValues(currentFraction, endProgress);
        animator.start();
        animator.start();
    }
    }
+5 −0
Original line number Original line Diff line number Diff line
@@ -189,9 +189,14 @@ public class TaskSystemShortcut<T extends SystemShortcut> extends SystemShortcut
                    final Rect taskBounds = new Rect(position[0], position[1],
                    final Rect taskBounds = new Rect(position[0], position[1],
                            position[0] + width, position[1] + height);
                            position[0] + width, position[1] + height);


                    // Take the thumbnail of the task without a scrim and apply it back after
                    float alpha = thumbnailView.getDimAlpha();
                    thumbnailView.setDimAlpha(0);
                    Bitmap thumbnail = RecentsTransition.drawViewIntoHardwareBitmap(
                    Bitmap thumbnail = RecentsTransition.drawViewIntoHardwareBitmap(
                            taskBounds.width(), taskBounds.height(), thumbnailView, 1f,
                            taskBounds.width(), taskBounds.height(), thumbnailView, 1f,
                            Color.BLACK);
                            Color.BLACK);
                    thumbnailView.setDimAlpha(alpha);

                    AppTransitionAnimationSpecsFuture future =
                    AppTransitionAnimationSpecsFuture future =
                            new AppTransitionAnimationSpecsFuture(mHandler) {
                            new AppTransitionAnimationSpecsFuture(mHandler) {
                        @Override
                        @Override
+51 −25
Original line number Original line Diff line number Diff line
@@ -21,6 +21,7 @@ import static com.android.launcher3.Utilities.SINGLE_FRAME_MS;
import static com.android.launcher3.Utilities.postAsyncCallback;
import static com.android.launcher3.Utilities.postAsyncCallback;
import static com.android.launcher3.anim.Interpolators.DEACCEL;
import static com.android.launcher3.anim.Interpolators.DEACCEL;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.anim.Interpolators.OVERSHOOT_1_2;
import static com.android.quickstep.QuickScrubController.QUICK_SCRUB_FROM_APP_START_DURATION;
import static com.android.quickstep.QuickScrubController.QUICK_SCRUB_FROM_APP_START_DURATION;
import static com.android.quickstep.TouchConsumer.INTERACTION_NORMAL;
import static com.android.quickstep.TouchConsumer.INTERACTION_NORMAL;
import static com.android.quickstep.TouchConsumer.INTERACTION_QUICK_SCRUB;
import static com.android.quickstep.TouchConsumer.INTERACTION_QUICK_SCRUB;
@@ -163,6 +164,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> {


    public static final long MAX_SWIPE_DURATION = 350;
    public static final long MAX_SWIPE_DURATION = 350;
    public static final long MIN_SWIPE_DURATION = 80;
    public static final long MIN_SWIPE_DURATION = 80;
    public static final long MIN_OVERSHOOT_DURATION = 120;


    public static final float MIN_PROGRESS_FOR_OVERVIEW = 0.5f;
    public static final float MIN_PROGRESS_FOR_OVERVIEW = 0.5f;
    private static final float SWIPE_DURATION_MULTIPLIER =
    private static final float SWIPE_DURATION_MULTIPLIER =
@@ -498,7 +500,8 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> {
        setStateOnUiThread(STATE_QUICK_SCRUB_START | STATE_GESTURE_COMPLETED);
        setStateOnUiThread(STATE_QUICK_SCRUB_START | STATE_GESTURE_COMPLETED);


        // Start the window animation without waiting for launcher.
        // Start the window animation without waiting for launcher.
        animateToProgress(mCurrentShift.value, 1f, QUICK_SCRUB_FROM_APP_START_DURATION, LINEAR);
        animateToProgress(mCurrentShift.value, 1f, QUICK_SCRUB_FROM_APP_START_DURATION, LINEAR,
                true /* goingToHome */);
    }
    }


    private void shiftAnimationDestinationForQuickscrub() {
    private void shiftAnimationDestinationForQuickscrub() {
@@ -699,25 +702,36 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> {
    private void handleNormalGestureEnd(float endVelocity, boolean isFling) {
    private void handleNormalGestureEnd(float endVelocity, boolean isFling) {
        float velocityPxPerMs = endVelocity / 1000;
        float velocityPxPerMs = endVelocity / 1000;
        long duration = MAX_SWIPE_DURATION;
        long duration = MAX_SWIPE_DURATION;
        final float endShift;
        float currentShift = mCurrentShift.value;
        final boolean goingToHome;
        float endShift;
        final float startShift;
        final float startShift;
        final Interpolator interpolator;
        Interpolator interpolator = DEACCEL;
        if (!isFling) {
        if (!isFling) {
            endShift = mCurrentShift.value >= MIN_PROGRESS_FOR_OVERVIEW && mGestureStarted ? 1 : 0;
            goingToHome = currentShift >= MIN_PROGRESS_FOR_OVERVIEW && mGestureStarted;
            long expectedDuration = Math.abs(Math.round((endShift - mCurrentShift.value)
            endShift = goingToHome ? 1 : 0;
            long expectedDuration = Math.abs(Math.round((endShift - currentShift)
                    * MAX_SWIPE_DURATION * SWIPE_DURATION_MULTIPLIER));
                    * MAX_SWIPE_DURATION * SWIPE_DURATION_MULTIPLIER));
            duration = Math.min(MAX_SWIPE_DURATION, expectedDuration);
            duration = Math.min(MAX_SWIPE_DURATION, expectedDuration);
            startShift = mCurrentShift.value;
            startShift = currentShift;
            interpolator = DEACCEL;
            interpolator = goingToHome ? OVERSHOOT_1_2 : DEACCEL;
        } else {
        } else {
            endShift = endVelocity < 0 ? 1 : 0;
            goingToHome = endVelocity < 0;
            interpolator = endVelocity < 0
            endShift = goingToHome ? 1 : 0;
                    ? Interpolators.overshootInterpolatorForVelocity(velocityPxPerMs, 2f)
            startShift = Utilities.boundToRange(currentShift - velocityPxPerMs
                    : DEACCEL;
                    * SINGLE_FRAME_MS / mTransitionDragLength, 0, 1);
            float minFlingVelocity = mContext.getResources()
            float minFlingVelocity = mContext.getResources()
                    .getDimension(R.dimen.quickstep_fling_min_velocity);
                    .getDimension(R.dimen.quickstep_fling_min_velocity);
            if (Math.abs(endVelocity) > minFlingVelocity && mTransitionDragLength > 0) {
            if (Math.abs(endVelocity) > minFlingVelocity && mTransitionDragLength > 0) {
                float distanceToTravel = (endShift - mCurrentShift.value) * mTransitionDragLength;
                if (goingToHome) {
                    Interpolators.OvershootParams overshoot = new Interpolators.OvershootParams(
                            startShift, endShift, endShift, velocityPxPerMs, mTransitionDragLength);
                    endShift = overshoot.end;
                    interpolator = overshoot.interpolator;
                    duration = Utilities.boundToRange(overshoot.duration, MIN_OVERSHOOT_DURATION,
                            MAX_SWIPE_DURATION);
                } else {
                    float distanceToTravel = (endShift - currentShift) * mTransitionDragLength;


                    // we want the page's snap velocity to approximately match the velocity at
                    // we want the page's snap velocity to approximately match the velocity at
                    // which the user flings, so we scale the duration by a value near to the
                    // which the user flings, so we scale the duration by a value near to the
@@ -725,10 +739,9 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> {
                    long baseDuration = Math.round(Math.abs(distanceToTravel / velocityPxPerMs));
                    long baseDuration = Math.round(Math.abs(distanceToTravel / velocityPxPerMs));
                    duration = Math.min(MAX_SWIPE_DURATION, 2 * baseDuration);
                    duration = Math.min(MAX_SWIPE_DURATION, 2 * baseDuration);
                }
                }
            startShift = Utilities.boundToRange(mCurrentShift.value - velocityPxPerMs
                    * SINGLE_FRAME_MS / (mTransitionDragLength), 0, 1);
            }
            }
        animateToProgress(startShift, endShift, duration, interpolator);
        }
        animateToProgress(startShift, endShift, duration, interpolator, goingToHome);
    }
    }


    private void doLogGesture(boolean toLauncher) {
    private void doLogGesture(boolean toLauncher) {
@@ -754,14 +767,14 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> {


    /** Animates to the given progress, where 0 is the current app and 1 is overview. */
    /** Animates to the given progress, where 0 is the current app and 1 is overview. */
    private void animateToProgress(float start, float end, long duration,
    private void animateToProgress(float start, float end, long duration,
            Interpolator interpolator) {
            Interpolator interpolator, boolean goingToHome) {
        mRecentsAnimationWrapper.runOnInit(() -> animateToProgressInternal(start, end, duration,
        mRecentsAnimationWrapper.runOnInit(() -> animateToProgressInternal(start, end, duration,
                interpolator));
                interpolator, goingToHome));
    }
    }


    private void animateToProgressInternal(float start, float end, long duration,
    private void animateToProgressInternal(float start, float end, long duration,
            Interpolator interpolator) {
            Interpolator interpolator, boolean goingToHome) {
        mIsGoingToHome = Float.compare(end, 1) == 0;
        mIsGoingToHome = goingToHome;
        ObjectAnimator anim = mCurrentShift.animateToValue(start, end).setDuration(duration);
        ObjectAnimator anim = mCurrentShift.animateToValue(start, end).setDuration(duration);
        anim.setInterpolator(interpolator);
        anim.setInterpolator(interpolator);
        anim.addListener(new AnimationSuccessListener() {
        anim.addListener(new AnimationSuccessListener() {
@@ -869,8 +882,21 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> {
                // new thumbnail
                // new thumbnail
                finishTransitionPosted = new WindowCallbacksCompat(taskView) {
                finishTransitionPosted = new WindowCallbacksCompat(taskView) {


                    // The number of frames to defer until we actually finish the animation
                    private int mDeferFrameCount = 2;

                    @Override
                    @Override
                    public void onPostDraw(Canvas canvas) {
                    public void onPostDraw(Canvas canvas) {
                        if (mDeferFrameCount > 0) {
                            mDeferFrameCount--;
                            // Workaround, detach and reattach to invalidate the root node for
                            // another draw
                            detach();
                            attach();
                            taskView.invalidate();
                            return;
                        }

                        setStateOnUiThread(STATE_SCREENSHOT_CAPTURED);
                        setStateOnUiThread(STATE_SCREENSHOT_CAPTURED);
                        detach();
                        detach();
                    }
                    }
Loading