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

Commit 3ae337e5 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Fixing quick switch with task stabilization

> Using the scroll of the current page instead of page 0
> Starting switch from current page instead of page 0
> Disable task flip animation accordingly

Change-Id: I29b9c6dafca1e856e634f471aa2b1b667158a790
parent 224fe117
Loading
Loading
Loading
Loading
+21 −9
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static com.android.launcher3.anim.Interpolators.ACCEL;
import static com.android.launcher3.anim.Interpolators.DEACCEL_3;
import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.config.FeatureFlags.ENABLE_TASK_STABILIZER;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -289,16 +290,20 @@ public class QuickScrubController implements OnAlarmListener {
                }
                mPrevPrevProgressDelta = mPrevProgressDelta;
                mPrevProgressDelta = progressDelta;
                float scrollDiff = nextPage.getWidth() + mRecentsView.getPageSpacing();
                int scrollDir = mRecentsView.isRtl() ? -1 : 1;
                int linearScrollDiff = (int) (progress * scrollDiff * scrollDir);
                float accelScrollDiff = ACCEL.getInterpolation(progress) * scrollDiff * scrollDir;
                int startScroll = mRecentsView.getScrollForPage(
                        mRecentsView.indexOfChild(currentPage));
                int scrollDiff = mRecentsView.getScrollForPage(mRecentsView.indexOfChild(nextPage))
                        - startScroll;

                int linearScrollDiff = (int) (progress * scrollDiff);
                currentPage.setZoomScale(1 - DEACCEL_3.getInterpolation(progress)
                        * TaskView.EDGE_SCALE_DOWN_FACTOR);
                if (!ENABLE_TASK_STABILIZER.get()) {
                    float accelScrollDiff = ACCEL.getInterpolation(progress) * scrollDiff;
                    currentPage.setTranslationX(linearScrollDiff + accelScrollDiff);
                }
                nextPage.setTranslationZ(1);
                nextPage.setTranslationY(currentPage.getTranslationY());
                int startScroll = mRecentsView.isRtl() ? mRecentsView.getMaxScrollX() : 0;
                mRecentsView.setScrollX(startScroll + linearScrollDiff);
            }
            return;
@@ -358,9 +363,16 @@ public class QuickScrubController implements OnAlarmListener {
                    : mStartedFromHome
                        ? QUICK_SCRUB_FROM_HOME_START_DURATION
                        : QUICK_SCRUB_FROM_APP_START_DURATION;
            int pageToGoTo = mStartedFromHome || mIsQuickSwitch
                    ? 0
                    : mRecentsView.getNextPage() + 1;
            final int pageToGoTo;
            if (mStartedFromHome) {
                pageToGoTo = 0;
            } else if (mIsQuickSwitch) {
                TaskView tv = mRecentsView.getRunningTaskView();
                pageToGoTo = tv != null ? mRecentsView.indexOfChild(tv)
                        : mRecentsView.getNextPage();
            } else {
                pageToGoTo = mRecentsView.getNextPage() + 1;
            }
            goToPageWithHaptic(pageToGoTo, duration, true /* forceHaptic */,
                    QUICK_SCRUB_START_INTERPOLATOR);
        }