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

Commit e41ab847 authored by Winson Chung's avatar Winson Chung
Browse files

Fixing regression with scrolling and launching an out-of-view task. (Bug 16875419)

Change-Id: Ib64e18f9a0f1de02de28a29251dd1d159d5d89ee
parent 0a4ea30c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -328,7 +328,7 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
        TaskStackViewLayoutAlgorithm algo = tsv.getStackAlgorithm();
        Rect taskStackBounds = new Rect(mTaskStackBounds);
        taskStackBounds.bottom -= mSystemInsets.bottom;
        tsv.computeRects(mWindowRect.width(), mWindowRect.height(), taskStackBounds);
        tsv.computeRects(mWindowRect.width(), mWindowRect.height(), taskStackBounds, mTriggeredFromAltTab);
        tsv.getScroller().setStackScrollToInitialState();

        // Find the running task in the TaskStack
+1 −1
Original line number Diff line number Diff line
@@ -386,7 +386,7 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
            sourceView = stackView;
            transform = stackView.getStackAlgorithm().getStackTransform(task, stackScroll, transform, null);
            offsetX = transform.rect.left;
            offsetY = Math.min(transform.rect.top, mConfig.displayRect.height());
            offsetY = mConfig.displayRect.height();
        } else {
            transform = stackView.getStackAlgorithm().getStackTransform(task, stackScroll, transform, null);
        }
+12 −12
Original line number Diff line number Diff line
@@ -349,9 +349,9 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
    }

    /** Updates the min and max virtual scroll bounds */
    void updateMinMaxScroll(boolean boundScrollToNewMinMax) {
    void updateMinMaxScroll(boolean boundScrollToNewMinMax, boolean launchedWithAltTab) {
        // Compute the min and max scroll values
        mLayoutAlgorithm.computeMinMaxScroll(mStack.getTasks());
        mLayoutAlgorithm.computeMinMaxScroll(mStack.getTasks(), launchedWithAltTab);

        // Debug logging
        if (boundScrollToNewMinMax) {
@@ -388,17 +388,17 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
                };
            }

            // Scroll the view into position (just center it in the curve)
            if (scrollToNewPosition) {
                // Scroll the view into position
                // XXX: We probably want this to be centered in view instead of p = 0f
                float newScroll = mStackScroller.getBoundedStackScroll(
                        mLayoutAlgorithm.getStackScrollForTaskIndex(t));
                float newScroll = mLayoutAlgorithm.getStackScrollForTaskIndex(t) - 0.5f;
                newScroll = mStackScroller.getBoundedStackScroll(newScroll);
                mStackScroller.animateScroll(mStackScroller.getStackScroll(), newScroll, postScrollRunnable);
            } else {
                if (postScrollRunnable != null) {
                    postScrollRunnable.run();
                }
            }

        }
    }

@@ -435,12 +435,13 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
    }

    /** Computes the stack and task rects */
    public void computeRects(int windowWidth, int windowHeight, Rect taskStackBounds) {
    public void computeRects(int windowWidth, int windowHeight, Rect taskStackBounds,
                             boolean launchedWithAltTab) {
        // Compute the rects in the stack algorithm
        mLayoutAlgorithm.computeRects(windowWidth, windowHeight, taskStackBounds);

        // Update the scroll bounds
        updateMinMaxScroll(false);
        updateMinMaxScroll(false, launchedWithAltTab);
    }

    /**
@@ -455,7 +456,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
        // Compute our stack/task rects
        Rect taskStackBounds = new Rect(mTaskStackBounds);
        taskStackBounds.bottom -= mConfig.systemInsets.bottom;
        computeRects(width, height, taskStackBounds);
        computeRects(width, height, taskStackBounds, mConfig.launchedWithAltTab);

        // If this is the first layout, then scroll to the front of the stack and synchronize the
        // stack views immediately to load all the views
@@ -543,9 +544,8 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
            mStartEnterAnimationContext = null;
        }

        // Update the focused task index to be the next item to the top task
        // When Alt-Tabbing, we scroll to and focus the previous task
        if (mConfig.launchedWithAltTab) {
            // When alt-tabbing, we focus the next previous task
            focusTask(Math.max(0, mStack.getTaskCount() - 2), false);
        }
    }
@@ -661,7 +661,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
        mCb.onTaskViewDismissed(removedTask);

        // Update the min/max scroll and animate other task views into their new positions
        updateMinMaxScroll(true);
        updateMinMaxScroll(true, mConfig.launchedWithAltTab);
        requestSynchronizeStackViewsWithModel(200);

        // Update the new front most task
+11 −4
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ package com.android.systemui.recents.views;

import android.graphics.Rect;
import com.android.systemui.recents.RecentsConfiguration;
import com.android.systemui.recents.misc.Console;
import com.android.systemui.recents.misc.Utilities;
import com.android.systemui.recents.model.Task;

@@ -87,8 +86,9 @@ public class TaskStackViewLayoutAlgorithm {
                left + size, mStackRect.top + size);
    }

    /** Computes the minimum and maximum scroll progress values */
    void computeMinMaxScroll(ArrayList<Task> tasks) {
    /** Computes the minimum and maximum scroll progress values.  This method may be called before
     * the RecentsConfiguration is set, so we need to pass in the alt-tab state. */
    void computeMinMaxScroll(ArrayList<Task> tasks, boolean launchedWithAltTab) {
        // Clear the progress map
        mTaskProgressMap.clear();

@@ -130,8 +130,13 @@ public class TaskStackViewLayoutAlgorithm {

        mMinScrollP = 0f;
        mMaxScrollP = pAtFrontMostCardTop - ((1f - pTaskHeightOffset - pNavBarOffset));
        if (launchedWithAltTab) {
            // Center the second most task, since that will be focused first
            mInitialScrollP = pAtSecondFrontMostCardTop - 0.5f;
        } else {
            mInitialScrollP = pAtSecondFrontMostCardTop - ((1f - pTaskHeightOffset - pNavBarOffset));
        }
    }

    /** Update/get the transform */
    public TaskViewTransform getStackTransform(Task task, float stackScroll, TaskViewTransform transformOut,
@@ -151,6 +156,7 @@ public class TaskStackViewLayoutAlgorithm {
        // If the task top is outside of the bounds below the screen, then immediately reset it
        if (pTaskRelative > 1f) {
            transformOut.reset();
            transformOut.rect.set(mTaskRect);
            return transformOut;
        }
        // The check for the top is trickier, since we want to show the next task if it is at all
@@ -158,6 +164,7 @@ public class TaskStackViewLayoutAlgorithm {
        if (pTaskRelative < 0f) {
            if (prevTransform != null && Float.compare(prevTransform.p, 0f) <= 0) {
                transformOut.reset();
                transformOut.rect.set(mTaskRect);
                return transformOut;
            }
        }