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

Commit 62388bec authored by Tony Wickham's avatar Tony Wickham Committed by Android (Google) Code Review
Browse files

Merge "Move window to align with first task during quick scrub" into ub-launcher3-master

parents adca2fc1 8cb30026
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -93,7 +93,7 @@ public class QuickScrubController implements OnAlarmListener {
    }

    public void snapToPageForCurrentQuickScrubSection() {
        goToPageWithHaptic(mRecentsView.getCurrentPage() + mQuickScrubSection);
        goToPageWithHaptic(mRecentsView.getFirstTaskIndex() + mQuickScrubSection);
    }

    private void goToPageWithHaptic(int pageToGoTo) {
+4 −1
Original line number Diff line number Diff line
@@ -135,6 +135,7 @@ public class RecentsView extends PagedView implements Insettable {
            final TaskView taskView = (TaskView) getChildAt(i);
            if (taskView.getTask().key.id == taskId) {
                taskView.onTaskDataLoaded(taskView.getTask(), thumbnailData);
                taskView.setAlpha(1);
                return;
            }
        }
@@ -467,7 +468,9 @@ public class RecentsView extends PagedView implements Insettable {
        mRunningTaskId = runningTaskId;
        setCurrentPage(mFirstTaskIndex);
        if (mCurrentPage >= mFirstTaskIndex) {
            ((TaskView) getPageAt(mCurrentPage)).setIconScale(0);
            TaskView currentTask = (TaskView) getPageAt(mCurrentPage);
            currentTask.setIconScale(0);
            currentTask.setAlpha(0);
        }
    }

+0 −1
Original line number Diff line number Diff line
@@ -212,7 +212,6 @@ public class TaskView extends FrameLayout implements TaskCallbacks, PageCallback

        float translation =
                scrollState.distanceFromScreenCenter * curveInterpolation * CURVE_FACTOR;
        setTranslationX(translation);

        if (scrollState.lastScrollType == SCROLL_TYPE_WORKSPACE) {
            // Make sure that the task cards do not overlap with the workspace card
+25 −3
Original line number Diff line number Diff line
@@ -124,6 +124,8 @@ public class WindowTransformSwipeHandler extends BaseSwipeInteractionHandler {
    private final Rect mHomeStackBounds = new Rect();
    // The bounds of the task view in launcher window coordinates
    private final Rect mTargetRect = new Rect();
    // Doesn't change after initialized, used as an anchor when changing mTargetRect
    private final Rect mInitialTargetRect = new Rect();
    // The interpolated rect from the source app rect to the target rect
    private final Rect mCurrentRect = new Rect();
    // The clip rect in source app window coordinates
@@ -224,6 +226,7 @@ public class WindowTransformSwipeHandler extends BaseSwipeInteractionHandler {
        RecentsView.getPageRect(dp, mContext, mTargetRect);
        mTargetRect.offset(mHomeStackBounds.left - mSourceStackBounds.left,
                mHomeStackBounds.top - mSourceStackBounds.top);
        mInitialTargetRect.set(mTargetRect);

        // Calculate the clip based on the target rect (since the content insets and the
        // launcher insets may differ, so the aspect ratio of the target rect can differ
@@ -436,7 +439,9 @@ public class WindowTransformSwipeHandler extends BaseSwipeInteractionHandler {

        synchronized (mRecentsAnimationWrapper) {
            if (mRecentsAnimationWrapper.controller != null) {
                synchronized (mTargetRect) {
                    mRectEvaluator.evaluate(shift, mSourceRect, mTargetRect);
                }
                float scale = (float) mCurrentRect.width() / mSourceRect.width();

                mClipRect.left = (int) (mSourceWindowClipInsets.left * shift);
@@ -460,11 +465,28 @@ public class WindowTransformSwipeHandler extends BaseSwipeInteractionHandler {
        }

        if (mLauncherTransitionController != null) {
            if (Looper.getMainLooper() == Looper.myLooper()) {
            Runnable runOnUi = () -> {
                mLauncherTransitionController.setPlayFraction(shift);

                // Make sure the window follows the first task if it moves, e.g. during quick scrub.
                int firstTaskIndex = mRecentsView.getFirstTaskIndex();
                View firstTask = mRecentsView.getPageAt(firstTaskIndex);
                int scrollForFirstTask = mRecentsView.getScrollForPage(firstTaskIndex);
                int offsetFromFirstTask = (scrollForFirstTask - mRecentsView.getScrollX());
                if (offsetFromFirstTask != 0) {
                    synchronized (mTargetRect) {
                        mTargetRect.set(mInitialTargetRect);
                        Utilities.scaleRectAboutCenter(mTargetRect, firstTask.getScaleX());
                        int offsetX = (int) (offsetFromFirstTask + firstTask.getTranslationX());
                        mTargetRect.offset(offsetX, 0);
                    }
                }
            };
            if (Looper.getMainLooper() == Looper.myLooper()) {
                runOnUi.run();
            } else {
                // The fling operation completed even before the launcher was drawn
                mMainExecutor.execute(() -> mLauncherTransitionController.setPlayFraction(shift));
                mMainExecutor.execute(runOnUi);
            }
        }
    }