diff options
4 files changed, 37 insertions, 14 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java index 3c7012a16dfc..d8fdd7a281e8 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java @@ -337,7 +337,8 @@ public class RecentsView extends FrameLayout { if (RecentsDebugFlags.Static.EnableStackActionButton) { // Measure the stack action button within the constraints of the space above the stack - Rect buttonBounds = mTaskStackView.mLayoutAlgorithm.mStackActionButtonRect; + Rect buttonBounds = mTaskStackView.mLayoutAlgorithm.getStackActionButtonRect( + mTaskStackView.useGridLayout()); measureChild(mStackActionButton, MeasureSpec.makeMeasureSpec(buttonBounds.width(), MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(buttonBounds.height(), MeasureSpec.AT_MOST)); @@ -772,7 +773,8 @@ public class RecentsView extends FrameLayout { * @return the bounds of the stack action button. */ private Rect getStackActionButtonBoundsFromStackLayout() { - Rect actionButtonRect = new Rect(mTaskStackView.mLayoutAlgorithm.mStackActionButtonRect); + Rect actionButtonRect = new Rect(mTaskStackView.mLayoutAlgorithm.getStackActionButtonRect( + mTaskStackView.useGridLayout())); int left = isLayoutRtl() ? actionButtonRect.left - mStackActionButton.getPaddingLeft() : actionButtonRect.right + mStackActionButton.getPaddingRight() 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 fddf1659d616..052985647453 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java @@ -240,14 +240,14 @@ public class TaskStackLayoutAlgorithm { // This is the current system insets @ViewDebug.ExportedProperty(category="recents") public Rect mSystemInsets = new Rect(); - // This is the bounds of the stack action above the stack rect - @ViewDebug.ExportedProperty(category="recents") - public Rect mStackActionButtonRect = new Rect(); // The visible ranges when the stack is focused and unfocused private Range mUnfocusedRange; private Range mFocusedRange; + // This is the bounds of the stack action above the stack rect + @ViewDebug.ExportedProperty(category="recents") + private Rect mStackActionButtonRect = new Rect(); // The base top margin for the stack from the system insets @ViewDebug.ExportedProperty(category="recents") private int mBaseTopMargin; @@ -732,6 +732,11 @@ public class TaskStackLayoutAlgorithm { } } + public Rect getStackActionButtonRect(boolean useGridLayout) { + return useGridLayout + ? mTaskGridLayoutAlgorithm.getStackActionButtonRect() : mStackActionButtonRect; + } + /** * Returns the TaskViewTransform that would put the task just off the back of the stack. */ 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 57fde6741085..4625ca76c5cc 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java @@ -1345,14 +1345,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal setFocusedTask(focusedTaskIndex, false /* scrollToTask */, false /* requestViewFocus */); } - - // Update the stack action button visibility - if (mStackScroller.getStackScroll() < SHOW_STACK_ACTION_BUTTON_SCROLL_THRESHOLD && - mStack.getTaskCount() > 0) { - EventBus.getDefault().send(new ShowStackActionButtonEvent(false /* translate */)); - } else { - EventBus.getDefault().send(new HideStackActionButtonEvent()); - } + updateStackActionButtonVisibility(); } public boolean isTouchPointInView(float x, float y, TaskView tv) { @@ -1647,7 +1640,8 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal relayoutTaskViewsOnNextFrame(animation); } - if (mEnterAnimationComplete) { + // In grid layout, the stack action button always remains visible. + if (mEnterAnimationComplete && !useGridLayout()) { if (prevScroll > SHOW_STACK_ACTION_BUTTON_SCROLL_THRESHOLD && curScroll <= SHOW_STACK_ACTION_BUTTON_SCROLL_THRESHOLD && mStack.getTaskCount() > 0) { @@ -2063,6 +2057,9 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal } } + // Update the Clear All button in case we're switching in or out of grid layout. + updateStackActionButtonVisibility(); + // Trigger a new layout and update to the initial state if necessary if (event.fromMultiWindow) { mInitialState = INITIAL_STATE_UPDATE_LAYOUT_ONLY; @@ -2156,6 +2153,17 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal Settings.System.LOCK_TO_APP_ENABLED) != 0; } + private void updateStackActionButtonVisibility() { + // Always show the button in grid layout. + if (useGridLayout() || + (mStackScroller.getStackScroll() < SHOW_STACK_ACTION_BUTTON_SCROLL_THRESHOLD && + mStack.getTaskCount() > 0)) { + EventBus.getDefault().send(new ShowStackActionButtonEvent(false /* translate */)); + } else { + EventBus.getDefault().send(new HideStackActionButtonEvent()); + } + } + public void dump(String prefix, PrintWriter writer) { String innerPrefix = prefix + " "; String id = Integer.toHexString(System.identityHashCode(this)); diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/grid/TaskGridLayoutAlgorithm.java b/packages/SystemUI/src/com/android/systemui/recents/views/grid/TaskGridLayoutAlgorithm.java index 82ccae60c71a..0d39f5b269a2 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/grid/TaskGridLayoutAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/grid/TaskGridLayoutAlgorithm.java @@ -146,4 +146,12 @@ public class TaskGridLayoutAlgorithm { int usableHeight = mScreenSize.y - mSystemInsets.top - mSystemInsets.bottom; mAppAspectRatio = (float) usableWidth / (float) usableHeight; } + + public Rect getStackActionButtonRect() { + Rect buttonRect = new Rect(mDisplayRect); + buttonRect.right -= mPaddingLeftRight; + buttonRect.left += mPaddingLeftRight; + buttonRect.bottom = buttonRect.top + mPaddingTopBottom; + return buttonRect; + } } |