From 0711be5cefb798eebd1e9b1622f7ab6ec292c36b Mon Sep 17 00:00:00 2001 From: Winson Date: Fri, 30 Oct 2015 16:03:08 -0700 Subject: [PATCH] Ensuring that tasks in the back are always visible. Change-Id: Ic64a1eac4b312c1efdb8c3ab005903a53b4a61d2 --- .../views/TaskStackLayoutAlgorithm.java | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java index ff02e03cd3358..45d626e153275 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java @@ -44,6 +44,8 @@ public class TaskStackLayoutAlgorithm { private static final float STACK_PEEK_MIN_SCALE = 0.85f; // The scale of the last task private static final float SINGLE_TASK_SCALE = 0.95f; + // The percentage of the height of the stack that we want to show the last task at + private static final float VISIBLE_LAST_TASK_HEIGHT_PCT = 0.45f; // The percentage of height of task to show between tasks private static final float VISIBLE_TASK_HEIGHT_BETWEEN_TASKS = 0.5f; // The percentage between the maxStackScroll and the maxScroll where a given scroll will still @@ -316,15 +318,20 @@ public class TaskStackLayoutAlgorithm { mFrontMostTaskP = pAtFrontMostTaskTop; // Set the stack end scroll progress to the point at which the bottom of the front-most // task is aligned to the bottom of the stack - mStackEndScrollP = alignToStackBottom(pAtFrontMostTaskTop, - mTaskHeightPOffset); - // Set the preferred stack end scroll progress to the point where the bottom of the - // front-most task is offset by the navbar and padding from the bottom of the stack - mPreferredStackEndScrollP = mStackEndScrollP + mStackBottomPOffset; - // Basically align the back-most task such that its progress is the same as the top of - // the front most task at the max stack scroll - mMinScrollP = alignToStackBottom(pAtBackMostTaskTop, - mStackBottomPOffset + mTaskHeightPOffset); + mStackEndScrollP = alignToStackBottom(pAtFrontMostTaskTop, mTaskHeightPOffset); + if (mNumStackTasks > 1) { + // Set the preferred stack end scroll progress to the point where the bottom of the + // front-most task is offset by the navbar and padding from the bottom of the stack + mPreferredStackEndScrollP = mStackEndScrollP + mStackBottomPOffset; + + // Basically align the back-most task such that the last two tasks would be visible + mMinScrollP = alignToStackBottom(pAtBackMostTaskTop, 2 * + mBetweenAffiliationPOffset); + } else { + // When there is a single item, then just make all the stack progresses the same + mPreferredStackEndScrollP = mStackEndScrollP; + mMinScrollP = mStackEndScrollP; + } } else { // TODO: In the case where there is only freeform tasks, then the scrolls should be // set to zero @@ -455,7 +462,7 @@ public class TaskStackLayoutAlgorithm { // Center the task in the stack, changing the scale will not follow the curve, but just // modulate some values directly float pTaskRelative = mMinScrollP - stackScroll; - float scale = SINGLE_TASK_SCALE; + float scale = (mNumFreeformTasks > 0) ? 1f : SINGLE_TASK_SCALE; int topOffset = (mStackRect.height() - mTaskRect.height()) / 2; transformOut.scale = scale; transformOut.translationX = 0;