From a2236f11c650519f20509f62f48fbb371653bc65 Mon Sep 17 00:00:00 2001 From: Winson Date: Fri, 13 Nov 2015 16:10:01 -0800 Subject: [PATCH] Fixing some Recents landscape issues. - Tasks were drawing under the navigation in landscape since we did not account for the nav bar space - Fixing issue with tiny tasks in landscape - Fixing issue where pooled views were not being measured or laid out after resizing. - Fixing issue where the stack scroll would have out of bounds when tasks were resized (we animate them into bounds) Change-Id: Id301dc6891e7ff2692cb040a7df1a5a854ac84a3 --- .../recents/RecentsConfiguration.java | 2 +- .../views/TaskStackLayoutAlgorithm.java | 2 +- .../systemui/recents/views/TaskStackView.java | 31 ++++++++++--------- .../systemui/recents/views/ViewPool.java | 12 +++---- 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java index a73f3234ed44a..8f952beb50380 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java +++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java @@ -154,7 +154,7 @@ public class RecentsConfiguration { int swInset = getInsetToSmallestWidth(windowBounds.right - windowBounds.left); int top = searchBarBounds.isEmpty() ? topInset : 0; taskStackBounds.set(windowBounds.left + swInset, searchBarBounds.bottom + top, - windowBounds.right - swInset, windowBounds.bottom); + windowBounds.right - swInset - rightInset, windowBounds.bottom); } } 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 51091c38eec03..b3bd6edc84ddc 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java @@ -201,7 +201,7 @@ public class TaskStackLayoutAlgorithm { taskStackBounds.right - widthPadding, taskStackBounds.bottom); // Anchor the task rect to the top-center of the non-freeform stack rect - int size = Math.min(mStackRect.width(), mStackRect.height() - mStackBottomOffset); + int size = mStackRect.width(); mTaskRect.set(mStackRect.left, mStackRect.top, mStackRect.left + size, mStackRect.top + size); mCurrentStackRect = ssp.hasFreeformWorkspaceSupport() ? mFreeformStackRect : mStackRect; diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java index a57ac9dd570fd..7250d6abaede0 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java @@ -114,6 +114,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal HashMap mTmpTaskViewMap = new HashMap<>(); ArrayList mTaskViews = new ArrayList<>(); List mImmutableTaskViews = new ArrayList<>(); + List mTmpTaskViews = new ArrayList<>(); LayoutInflater mInflater; boolean mLayersDisabled; boolean mTouchExplorationEnabled; @@ -279,14 +280,9 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal } // Mark each task view for relayout - if (mViewPool != null) { - Iterator iter = mViewPool.poolViewIterator(); - if (iter != null) { - while (iter.hasNext()) { - TaskView tv = iter.next(); - tv.reset(); - } - } + List poolViews = mViewPool.getViews(); + for (TaskView tv : poolViews) { + tv.reset(); } // Reset the stack state @@ -862,10 +858,12 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal } // Measure each of the TaskViews - List taskViews = getTaskViews(); - int taskViewCount = taskViews.size(); + mTmpTaskViews.clear(); + mTmpTaskViews.addAll(getTaskViews()); + mTmpTaskViews.addAll(mViewPool.getViews()); + int taskViewCount = mTmpTaskViews.size(); for (int i = 0; i < taskViewCount; i++) { - TaskView tv = taskViews.get(i); + TaskView tv = mTmpTaskViews.get(i); if (tv.getBackground() != null) { tv.getBackground().getPadding(mTmpRect); } else { @@ -891,10 +889,12 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { // Layout each of the TaskViews - List taskViews = getTaskViews(); - int taskViewCount = taskViews.size(); + mTmpTaskViews.clear(); + mTmpTaskViews.addAll(getTaskViews()); + mTmpTaskViews.addAll(mViewPool.getViews()); + int taskViewCount = mTmpTaskViews.size(); for (int i = 0; i < taskViewCount; i++) { - TaskView tv = taskViews.get(i); + TaskView tv = mTmpTaskViews.get(i); if (tv.getBackground() != null) { tv.getBackground().getPadding(mTmpRect); } else { @@ -911,6 +911,9 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal } if (changed) { + if (mStackScroller.isScrollOutOfBounds()) { + mStackScroller.boundScroll(); + } requestSynchronizeStackViewsWithModel(); synchronizeStackViewsWithModel(); clipTaskViews(true /* forceUpdate */); diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/ViewPool.java b/packages/SystemUI/src/com/android/systemui/recents/views/ViewPool.java index 12b91affce7de..31fbd3e157056 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/ViewPool.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/ViewPool.java @@ -20,6 +20,7 @@ import android.content.Context; import java.util.Iterator; import java.util.LinkedList; +import java.util.List; /* A view pool to manage more views than we can visibly handle */ @@ -76,11 +77,10 @@ public class ViewPool { return v; } - /** Returns an iterator to the list of the views in the pool. */ - Iterator poolViewIterator() { - if (mPool != null) { - return mPool.iterator(); - } - return null; + /** + * Returns the list of views in the pool. + */ + List getViews() { + return mPool; } }