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

Commit f8597b2a authored by Winson's avatar Winson
Browse files

Tweaking scroll-to-launch task animation.

- Always scroll so that the launch task is focused

Change-Id: I84516d0799ad0b308cfa458f4ce79c82acc48f51
parent 8f6ee482
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -921,8 +921,8 @@ public class TaskStackLayoutAlgorithm {
    float getStackScrollForTaskAtInitialOffset(Task t) {
        float normX = getNormalizedXFromUnfocusedY(mInitialTopOffset, FROM_TOP);
        mUnfocusedRange.offset(0f);
        return (float) mTaskIndexMap.get(t.key.id, 0) - Math.max(0,
                mUnfocusedRange.getAbsoluteX(normX));
        return Utilities.clamp((float) mTaskIndexMap.get(t.key.id, 0) - Math.max(0,
                mUnfocusedRange.getAbsoluteX(normX)), mMinScrollP, mMaxScrollP);
    }

    /**
+8 −10
Original line number Diff line number Diff line
@@ -111,7 +111,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
    private static final int DRAG_SCALE_DURATION = 175;
    private static final float DRAG_SCALE_FACTOR = 1.05f;

    private static final int LAUNCH_NEXT_SCROLL_BASE_DURATION = 200;
    private static final int LAUNCH_NEXT_SCROLL_BASE_DURATION = 216;
    private static final int LAUNCH_NEXT_SCROLL_INCR_DURATION = 32;

    private static final ArraySet<Task.TaskKey> EMPTY_TASK_SET = new ArraySet<>();
@@ -1625,15 +1625,13 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
            cancelAllTaskViewAnimations();

            final Task launchTask = mStack.getStackTasks().get(launchTaskIndex);
            if (getChildViewForTask(launchTask) == null) {
                List<TaskView> taskViews = getTaskViews();
                int lastTaskIndex = !taskViews.isEmpty()
                        ? mStack.indexOfStackTask(taskViews.get(taskViews.size() - 1).getTask())
                        : mStack.getTaskCount() - 1;
                int duration = LAUNCH_NEXT_SCROLL_BASE_DURATION +
                        Math.abs(mStack.indexOfStackTask(launchTask) - lastTaskIndex)
                                * LAUNCH_NEXT_SCROLL_INCR_DURATION;
                mStackScroller.animateScroll(mLayoutAlgorithm.getStackScrollForTask(launchTask),
            float curScroll = mStackScroller.getStackScroll();
            float targetScroll = mLayoutAlgorithm.getStackScrollForTaskAtInitialOffset(launchTask);
            float absScrollDiff = Math.abs(targetScroll - curScroll);
            if (getChildViewForTask(launchTask) == null || absScrollDiff > 0.35f) {
                int duration = (int) (LAUNCH_NEXT_SCROLL_BASE_DURATION +
                        absScrollDiff * LAUNCH_NEXT_SCROLL_INCR_DURATION);
                mStackScroller.animateScroll(targetScroll,
                        duration, new Runnable() {
                            @Override
                            public void run() {
+1 −1
Original line number Diff line number Diff line
@@ -464,7 +464,7 @@ class TaskStackViewTouchHandler implements SwipeHelper.Callback {
                if (layoutAlgorithm.getFocusState() != TaskStackLayoutAlgorithm.STATE_FOCUSED) {
                    // If we are focused, we don't want the front task to move, but otherwise, we
                    // allow the back task to move up, and the front task to move back
                    stackScrollOffset /= 2;
                    stackScrollOffset *= 0.75f;
                }
                newStackScroll = stackScroller.getBoundedStackScroll(stackScroller.getStackScroll()
                        + stackScrollOffset);