From cb12f2445ea05485fc6ff67b7cc697e541d49d8d Mon Sep 17 00:00:00 2001 From: Ats Jenk Date: Wed, 30 Aug 2023 14:07:37 -0700 Subject: [PATCH] Update scale logic for desktop tasks in recents animation When swiping up to overview, we need to calculate a target position for the desktop tasks. They need to be scaled down and positioned within the desktop tile. After recents animation finishes, the tasks will be replaced by screenshots. To make the replace less flickery, the position of the tasks should match the position of the screenshots. TODO: there is a flicker when the task is replaced with recents entry. Task is hidden and then, half a second later, the recents tile is shown. Enabling live tiles should help with this. Bug: 298252273 Test: swipe up to recents from desktop Change-Id: I0c7fba40dc2511c17d0011d0516456de07cfa004 --- .../quickstep/util/TaskViewSimulator.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java index 48dadd1f34..25b9bdc0e6 100644 --- a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java +++ b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java @@ -146,12 +146,6 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy { return 1; } - if (mIsDesktopTask) { - mTaskRect.set(mThumbnailPosition); - mPivot.set(mTaskRect.centerX(), mTaskRect.centerY()); - return 1; - } - if (mIsGridTask) { mSizeStrategy.calculateGridTaskSize(mContext, mDp, mTaskRect, mOrientationState.getOrientationHandler()); @@ -169,6 +163,20 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy { mOrientationState.getOrientationHandler() .setSplitTaskSwipeRect(mDp, mTaskRect, mSplitBounds, mStagePosition); mTaskRect.offset(mTaskRectTranslationX, mTaskRectTranslationY); + } else if (mIsDesktopTask) { + // For desktop, tasks can take up only part of the screen size. + // Full task size represents the whole screen size, but scaled down to fit in recents. + // Task rect will represent the scaled down thumbnail position and is placed inside + // full task size as it is on the home screen. + fullTaskSize = new Rect(mTaskRect); + PointF fullscreenTaskDimension = new PointF(); + BaseActivityInterface.getTaskDimension(mContext, mDp, fullscreenTaskDimension); + // Calculate the scale down factor used in recents + float scale = fullTaskSize.width() / fullscreenTaskDimension.x; + mTaskRect.set(mThumbnailPosition); + mTaskRect.scale(scale); + // Ensure the task rect is inside the full task rect + mTaskRect.offset(fullTaskSize.left, fullTaskSize.top); } else { fullTaskSize = mTaskRect; }