From fc6ac0a78af37a072a006180203591d49857dc69 Mon Sep 17 00:00:00 2001 From: Manu Cornet Date: Wed, 18 Jan 2017 15:42:14 -0800 Subject: [PATCH] 2D Recents: polish the app -> recents transition * Do not draw the header as part of the transition thumbnail since the header is already shown. Just let the thumbnail slot into the task view already drawn on screen. * Shift the target rectangle by the header height so that the end state of the animation corresponds exactly to the task view layout. * Remove unused local variable. Bug: 32101881 Bug: 33752154 Test: Checked/screencasted recents -> app -> recents animations on local sw600dp device Change-Id: I4c8ce52b378567114735e6bd582572124a2a354c --- .../src/com/android/systemui/recents/RecentsImpl.java | 9 ++++++--- .../recents/views/TaskStackLayoutAlgorithm.java | 18 +++++++++++++++++- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java index 86f61e91012a..0e42a54c98da 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java +++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java @@ -733,8 +733,12 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener Task toTask = new Task(); TaskViewTransform toTransform = getThumbnailTransitionTransform(stackView, toTask, windowOverrideRect); - Bitmap thumbnail = drawThumbnailTransitionBitmap(toTask, toTransform, - mThumbTransitionBitmapCache); + // When using a grid layout, the header is already visible on screen at the target + // location, making it unnecessary to draw it in the transition thumbnail. + Bitmap thumbnail = stackView.useGridLayout() + ? mThumbTransitionBitmapCache.createAshmemBitmap() + : drawThumbnailTransitionBitmap(toTask, toTransform, + mThumbTransitionBitmapCache); if (thumbnail != null) { RectF toTaskRect = toTransform.rect; return ActivityOptions.makeThumbnailAspectScaleDownAnimation(mDummyStackView, @@ -765,7 +769,6 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener // Get the transform for the running task stackView.updateLayoutAlgorithm(true /* boundScroll */); stackView.updateToInitialState(); - boolean isInSplitScreen = Recents.getSystemServices().hasDockedTask(); stackView.getStackAlgorithm().getStackTransformScreenCoordinates(launchTask, stackView.getScroller().getStackScroll(), mTmpTransform, null, windowOverrideRect); return mTmpTransform; 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 3fa6d7568d6b..5ab650729d97 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java @@ -292,6 +292,9 @@ public class TaskStackLayoutAlgorithm { @ViewDebug.ExportedProperty(category="recents") private int mStackBottomOffset; + /** The height, in pixels, of each task view's title bar. */ + private int mTitleBarHeight; + // The paths defining the motion of the tasks when the stack is focused and unfocused private Path mUnfocusedCurve; private Path mFocusedCurve; @@ -404,6 +407,14 @@ public class TaskStackLayoutAlgorithm { mBaseBottomMargin = res.getDimensionPixelSize(R.dimen.recents_layout_bottom_margin); mFreeformStackGap = res.getDimensionPixelSize(R.dimen.recents_freeform_layout_bottom_margin); + mTitleBarHeight = getDimensionForDevice(mContext, + R.dimen.recents_task_view_header_height, + R.dimen.recents_task_view_header_height, + R.dimen.recents_task_view_header_height, + R.dimen.recents_task_view_header_height_tablet_land, + R.dimen.recents_task_view_header_height, + R.dimen.recents_task_view_header_height_tablet_land, + R.dimen.recents_grid_task_view_header_height); } /** @@ -904,12 +915,17 @@ public class TaskStackLayoutAlgorithm { * Transforms the given {@param transformOut} to the screen coordinates, overriding the current * window rectangle with {@param windowOverrideRect} if non-null. */ - public TaskViewTransform transformToScreenCoordinates(TaskViewTransform transformOut, + TaskViewTransform transformToScreenCoordinates(TaskViewTransform transformOut, Rect windowOverrideRect) { Rect windowRect = windowOverrideRect != null ? windowOverrideRect : Recents.getSystemServices().getWindowRect(); transformOut.rect.offset(windowRect.left, windowRect.top); + if (useGridLayout()) { + // Draw the thumbnail a little lower to perfectly coincide with the view we are + // transitioning to, where the header bar has already been drawn. + transformOut.rect.offset(0, mTitleBarHeight); + } return transformOut; } -- 2.11.0