Tweaking scroll-to-launch task animation.

- Always scroll so that the launch task is focused

Change-Id: I84516d0799ad0b308cfa458f4ce79c82acc48f51
This commit is contained in:
Winson
2016-03-23 18:44:26 -07:00
parent 8f6ee48225
commit f8597b2aef
3 changed files with 11 additions and 13 deletions

View File

@@ -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);
}
/**

View File

@@ -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() {

View File

@@ -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);