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

Commit 42be431c authored by Winson's avatar Winson
Browse files

Tweaking animation after dismissing task.

Change-Id: Ia85e876ec08f4103ff5c3799309cf4731922624f
parent 88f00ab1
Loading
Loading
Loading
Loading
+9 −7
Original line number Diff line number Diff line
@@ -171,7 +171,8 @@ public class TaskStack {
        /* Notifies when a task has been added to the stack */
        public void onStackTaskAdded(TaskStack stack, Task t);
        /* Notifies when a task has been removed from the stack */
        public void onStackTaskRemoved(TaskStack stack, Task removedTask, Task newFrontMostTask);
        public void onStackTaskRemoved(TaskStack stack, Task removedTask, boolean wasFrontMostTask,
                                       Task newFrontMostTask);
        /* Notifies when all task has been removed from the stack */
        public void onStackAllTasksRemoved(TaskStack stack, ArrayList<Task> removedTasks);
        /** Notifies when the stack was filtered */
@@ -183,13 +184,13 @@ public class TaskStack {

    public enum DockState {
        LEFT(DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT,
                new RectF(0, 0, 0.25f, 1), new RectF(0, 0, 0.5f, 1), new RectF(0.5f, 0, 1, 1)),
                new RectF(0, 0, 0.25f, 1), new RectF(0, 0, 0.35f, 1), new RectF(0.65f, 0, 1, 1)),
        TOP(DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT,
                new RectF(0, 0, 1, 0.25f), new RectF(0, 0, 1, 0.5f), new RectF(0, 0.5f, 1, 1)),
                new RectF(0, 0, 1, 0.25f), new RectF(0, 0, 1, 0.35f), new RectF(0, 0.65f, 1, 1)),
        RIGHT(DOCKED_STACK_CREATE_MODE_BOTTOM_OR_RIGHT,
                new RectF(0.75f, 0, 1, 1), new RectF(0.5f, 0, 1, 1), new RectF(0, 0, 0.5f, 1)),
                new RectF(0.75f, 0, 1, 1), new RectF(0.65f, 0, 1, 1), new RectF(0, 0, 0.35f, 1)),
        BOTTOM(DOCKED_STACK_CREATE_MODE_BOTTOM_OR_RIGHT,
                new RectF(0, 0.75f, 1, 1), new RectF(0, 0.5f, 1, 1), new RectF(0, 0, 1, 0.5f));
                new RectF(0, 0.75f, 1, 1), new RectF(0, 0.65f, 1, 1), new RectF(0, 0, 1, 0.35f));

        public final int createMode;
        private final RectF touchArea;
@@ -284,6 +285,7 @@ public class TaskStack {
    /** Removes a task */
    public void removeTask(Task t) {
        if (mTaskList.contains(t)) {
            boolean wasFrontMostTask = (getFrontMostTask() == t);
            removeTaskImpl(t);
            Task newFrontMostTask = getFrontMostTask();
            if (newFrontMostTask != null && newFrontMostTask.lockToTaskEnabled) {
@@ -291,7 +293,7 @@ public class TaskStack {
            }
            if (mCb != null) {
                // Notify that a task has been removed
                mCb.onStackTaskRemoved(this, t, newFrontMostTask);
                mCb.onStackTaskRemoved(this, t, wasFrontMostTask, newFrontMostTask);
            }
        }
    }
@@ -319,7 +321,7 @@ public class TaskStack {
            removeTaskImpl(t);
            if (mCb != null) {
                // Notify that a task has been removed
                mCb.onStackTaskRemoved(this, t, null);
                mCb.onStackTaskRemoved(this, t, false, null);
            }
        }
        mTaskList.set(tasks);
+11 −5
Original line number Diff line number Diff line
@@ -988,7 +988,8 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
    }

    @Override
    public void onStackTaskRemoved(TaskStack stack, Task removedTask, Task newFrontMostTask) {
    public void onStackTaskRemoved(TaskStack stack, Task removedTask, boolean wasFrontMostTask,
            Task newFrontMostTask) {
        // Remove the view associated with this task, we can't rely on updateTransforms
        // to work here because the task is no longer in the list
        TaskView tv = getChildViewForTask(removedTask);
@@ -1007,14 +1008,18 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
        }

        // Update the min/max scroll and animate other task views into their new positions
        RecentsActivityLaunchState launchState = mConfig.getLaunchState();
        updateMinMaxScroll(true);

        // Offset the stack by as much as the anchor task would otherwise move back
        if (pullStackForward) {
        if (wasFrontMostTask) {
            // Since the max scroll progress is offset from the bottom of the stack, just scroll
            // to ensure that the new front most task is now fully visible
            mStackScroller.setStackScroll(mLayoutAlgorithm.mMaxScrollP);
        } else if (pullStackForward) {
            // Otherwise, offset the scroll by half the movement of the anchor task to allow the
            // tasks behind the removed task to move forward, and the tasks in front to move back
            float anchorTaskScroll = mLayoutAlgorithm.getStackScrollForTask(anchorTask);
            mStackScroller.setStackScroll(mStackScroller.getStackScroll() + (anchorTaskScroll
                    - prevAnchorTaskScroll));
                    - prevAnchorTaskScroll) / 2);
            mStackScroller.boundScroll();
        }

@@ -1290,6 +1295,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal

        // Remove the task from the view
        mStack.removeTask(task);

        // If the dismissed task was focused, then we should focus the new task in the same index
        if (taskWasFocused) {
            ArrayList<Task> tasks = mStack.getTasks();