From de3cfb0c1fa839e69a24d2a9e02e3b97ec8baaa7 Mon Sep 17 00:00:00 2001 From: Manu Cornet Date: Wed, 25 Jan 2017 18:31:01 +0900 Subject: [PATCH] 2D Recents: use correct layout logic for drawing transition headers Bug: 33752154 Test: Checked/screencasted app -> recents -> app transitions on sw60dp device Change-Id: Ib29e5feaadb4bdacae6c60d25526d0c7af95361f --- .../android/systemui/recents/RecentsImpl.java | 18 +++++++++++++++--- .../systemui/recents/views/TaskStackView.java | 6 ++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java index 0e42a54c98da1..7ef82ff20ef5f 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java +++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java @@ -71,6 +71,7 @@ import com.android.systemui.recents.views.TaskStackView; import com.android.systemui.recents.views.TaskStackViewScroller; import com.android.systemui.recents.views.TaskViewHeader; import com.android.systemui.recents.views.TaskViewTransform; +import com.android.systemui.recents.views.grid.TaskGridLayoutAlgorithm; import com.android.systemui.stackdivider.DividerView; import com.android.systemui.statusbar.BaseStatusBar; import com.android.systemui.statusbar.phone.NavigationBarGestureHelper; @@ -618,10 +619,21 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener stackLayout.initialize(displayRect, windowRect, mTaskStackBounds, TaskStackLayoutAlgorithm.StackState.getStackStateForStack(stack)); mDummyStackView.setTasks(stack, false /* allowNotifyStackChanges */); + // Get the width of a task view so that we know how wide to draw the header bar. + int taskViewWidth = 0; + if (mDummyStackView.useGridLayout()) { + TaskGridLayoutAlgorithm gridLayout = mDummyStackView.getGridAlgorithm(); + gridLayout.initialize(windowRect); + taskViewWidth = (int) gridLayout.getTransform(0 /* taskIndex */, + stack.getTaskCount(), new TaskViewTransform(), stackLayout).rect.width(); + } else { + Rect taskViewBounds = stackLayout.getUntransformedTaskViewBounds(); + if (!taskViewBounds.isEmpty()) { + taskViewWidth = taskViewBounds.width(); + } + } - Rect taskViewBounds = stackLayout.getUntransformedTaskViewBounds(); - if (!taskViewBounds.isEmpty()) { - int taskViewWidth = taskViewBounds.width(); + if (taskViewWidth > 0) { synchronized (mHeaderBarLock) { if (mHeaderBar.getMeasuredWidth() != taskViewWidth || mHeaderBar.getMeasuredHeight() != mTaskBarHeight) { 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 c621918929bc5..0fa725ba9693b 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java @@ -95,6 +95,7 @@ import com.android.systemui.recents.model.Task; import com.android.systemui.recents.model.TaskStack; import com.android.systemui.recents.views.grid.GridTaskView; +import com.android.systemui.recents.views.grid.TaskGridLayoutAlgorithm; import com.android.systemui.recents.views.grid.TaskViewFocusFrame; import java.io.PrintWriter; import java.lang.annotation.Retention; @@ -446,6 +447,11 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal return mLayoutAlgorithm; } + /** Returns the grid algorithm for this task stack. */ + public TaskGridLayoutAlgorithm getGridAlgorithm() { + return mLayoutAlgorithm.mTaskGridLayoutAlgorithm; + } + /** * Returns the touch handler for this task stack. */