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

Commit 78cc96af authored by Winson Chung's avatar Winson Chung
Browse files

Anchoring the front most task to make the dismiss animation more stable. (Bug 16939699)

Change-Id: I49aa14bbc7fdb2fb0884a8255af385dbbbe656f8
parent eb0cefa9
Loading
Loading
Loading
Loading
+21 −1
Original line number Diff line number Diff line
@@ -395,7 +395,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal

            // Scroll the view into position (just center it in the curve)
            if (scrollToNewPosition) {
                float newScroll = mLayoutAlgorithm.getStackScrollForTaskIndex(t) - 0.5f;
                float newScroll = mLayoutAlgorithm.getStackScrollForTask(t) - 0.5f;
                newScroll = mStackScroller.getBoundedStackScroll(newScroll);
                mStackScroller.animateScroll(mStackScroller.getStackScroll(), newScroll, postScrollRunnable);
            } else {
@@ -681,8 +681,28 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
        // Notify the callback that we've removed the task and it can clean up after it
        mCb.onTaskViewDismissed(removedTask);

        // Get the stack scroll of the task to anchor to (since we are removing something, the front
        // most task will be our anchor task)
        Task anchorTask = null;
        float prevAnchorTaskScroll = 0;
        boolean pullStackForward = stack.getTaskCount() > 0;
        if (pullStackForward) {
            anchorTask = mStack.getFrontMostTask();
            prevAnchorTaskScroll = mLayoutAlgorithm.getStackScrollForTask(anchorTask);
        }

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

        // Offset the stack by as much as the anchor task would otherwise move back
        if (pullStackForward) {
            float anchorTaskScroll = mLayoutAlgorithm.getStackScrollForTask(anchorTask);
            mStackScroller.setStackScroll(mStackScroller.getStackScroll() + (anchorTaskScroll
                    - prevAnchorTaskScroll));
            mStackScroller.boundScroll();
        }

        // Animate all the tasks into place
        requestSynchronizeStackViewsWithModel(200);

        // Update the new front most task
+1 −1
Original line number Diff line number Diff line
@@ -202,7 +202,7 @@ public class TaskStackViewLayoutAlgorithm {
    /**
     * Returns the scroll to such task top = 1f;
     */
    float getStackScrollForTaskIndex(Task t) {
    float getStackScrollForTask(Task t) {
        return mTaskProgressMap.get(t.key);
    }