From 9c855961110f6531ee7ef6b73aececbfbf69cf58 Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Mon, 6 Jan 2025 21:15:12 +0000 Subject: [PATCH] Support both grid and large tile with gridOnlyOverivew - With the introduction of Desktop windowing, we'll need to supprot grid task and large tile (desktop tile) coexisting - The previous gridOnlyOverview aimed to have taskSize matches actual grid task size, and introduced another carouselTaskSize for scaling in swipe up carousel - Now I'm reverting to pre-gridOnlyOverview implementation of having taskSize as both large tile size and carousel task size, and gridTaskSize as only task size in grid TaskViewSimualtor - Removed no longer needed carousel translation and related calculations - mIsGridTask is now determined with DeviceProfile, so when swipeing to Desktop task it won't use grid task size TaskView - Removed no longer used nonGridPivotTranslationX RecentsView - Make getSelectedTaskBounds / getTaskBounds picks the correct taskSize Fix: 359573248 Fix: 321697299 Fix: 325606690 Bug: 322816508 Test: Swipe up, quick switch, task launching with grid task and desktop tasks; repeat with RTL, three button, phone Flag: com.android.launcher3.enable_grid_only_overview Change-Id: I14648c6682c53a4d06f9c9585d53f28dddef4f8f --- quickstep/res/values-sw600dp-land/dimens.xml | 6 -- quickstep/res/values-sw600dp/dimens.xml | 4 - quickstep/res/values/dimens.xml | 3 - .../android/quickstep/AbsSwipeUpHandler.java | 9 +- .../quickstep/BaseContainerInterface.java | 37 +------ .../quickstep/SwipeUpAnimationLogic.java | 2 +- .../com/android/quickstep/TaskViewUtils.java | 5 +- .../AnimatorControllerWithResistance.java | 6 +- .../quickstep/util/TaskViewSimulator.java | 97 ++++--------------- .../quickstep/views/ClearAllButton.java | 9 +- .../quickstep/views/DesktopTaskView.kt | 12 +-- .../android/quickstep/views/RecentsView.java | 81 +++++----------- .../com/android/quickstep/views/TaskView.kt | 25 +---- res/values/dimens.xml | 2 - 14 files changed, 62 insertions(+), 236 deletions(-) diff --git a/quickstep/res/values-sw600dp-land/dimens.xml b/quickstep/res/values-sw600dp-land/dimens.xml index 49239aa035..0052a73df7 100644 --- a/quickstep/res/values-sw600dp-land/dimens.xml +++ b/quickstep/res/values-sw600dp-land/dimens.xml @@ -27,12 +27,6 @@ 40dp 49dp - - - 24dp - - 40dp - 24dp diff --git a/quickstep/res/values-sw600dp/dimens.xml b/quickstep/res/values-sw600dp/dimens.xml index e24d8fea79..bb4264861b 100644 --- a/quickstep/res/values-sw600dp/dimens.xml +++ b/quickstep/res/values-sw600dp/dimens.xml @@ -33,10 +33,6 @@ 36dp 64dp - - 80dp - - 80dp 24dp diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml index b404bb519c..fc671a6b20 100644 --- a/quickstep/res/values/dimens.xml +++ b/quickstep/res/values/dimens.xml @@ -34,9 +34,6 @@ 0.7 - - 0.46 48dp diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index 124be41ca8..1029c67532 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -31,7 +31,6 @@ import static com.android.launcher3.BaseActivity.EVENT_STARTED; import static com.android.launcher3.BaseActivity.INVISIBLE_BY_STATE_HANDLER; import static com.android.launcher3.BaseActivity.STATE_HANDLER_INVISIBILITY_FLAGS; import static com.android.launcher3.Flags.enableAdditionalHomeAnimations; -import static com.android.launcher3.Flags.enableGridOnlyOverview; import static com.android.launcher3.Flags.enableScalingRevealHomeAnimation; import static com.android.launcher3.Flags.msdlFeedback; import static com.android.launcher3.PagedView.INVALID_PAGE; @@ -173,6 +172,8 @@ import com.android.wm.shell.shared.startingsurface.SplashScreenExitAnimationUtil import com.google.android.msdl.data.model.MSDLToken; +import kotlin.Unit; + import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -182,8 +183,6 @@ import java.util.Optional; import java.util.OptionalInt; import java.util.function.Consumer; -import kotlin.Unit; - /** * Handles the navigation gestures when Launcher is the default home activity. */ @@ -2688,9 +2687,7 @@ public abstract class AbsSwipeUpHandler< } float scrollOffset = Math.abs(mRecentsView.getScrollOffset(mRecentsView.getCurrentPage())); - Rect carouselTaskSize = enableGridOnlyOverview() - ? mRecentsView.getLastComputedCarouselTaskSize() - : mRecentsView.getLastComputedTaskSize(); + Rect carouselTaskSize = mRecentsView.getLastComputedTaskSize(); int maxScrollOffset = mRecentsView.getPagedOrientationHandler().getPrimaryValue( carouselTaskSize.width(), carouselTaskSize.height()); maxScrollOffset += mRecentsView.getPageSpacing(); diff --git a/quickstep/src/com/android/quickstep/BaseContainerInterface.java b/quickstep/src/com/android/quickstep/BaseContainerInterface.java index b20518cf48..6d588d964e 100644 --- a/quickstep/src/com/android/quickstep/BaseContainerInterface.java +++ b/quickstep/src/com/android/quickstep/BaseContainerInterface.java @@ -251,11 +251,7 @@ public abstract class BaseContainerInterface { - // recentsViewScale is calculated rather than using recentsViewScale.value, so that - // this interpolator works independently even if recentsViewScale don't animate. - float recentsViewScale = - Utilities.mapToRange(t, 0, 1, fullScreenScale, 1, Interpolators.LINEAR); - // Without the translation, the app window will animate from fullscreen into top - // right corner. - float expectedTaskCenterX = mIsRecentsRtl - ? mDp.widthPx - mCarouselTaskSize.width() * recentsViewScale / 2f - : mCarouselTaskSize.width() * recentsViewScale / 2f; - // Calculate the expected translation, then work back the animatedFraction that - // results in this value. - float carouselPrimaryTranslation = - (exceptedCarouselCenterX - expectedTaskCenterX) / recentsViewScale; - return carouselPrimaryTranslation / carouselPrimaryTranslationTarget; - }; - - // Use addAnimatedFloat so this animation can later be canceled and animate to a - // different value in RecentsView.onPrepareGestureEndAnimation. - pa.addAnimatedFloat(carouselPrimaryTranslation, 0, carouselPrimaryTranslationTarget, - carouselTranslationInterpolator); - pa.addAnimatedFloat(carouselSecondaryTranslation, 0, carouselSecondaryTranslationTarget, - carouselTranslationInterpolator); - } else { - fullScreenScale = getFullScreenScale(); } - pa.addFloat(recentsViewScale, AnimatedFloat.VALUE, fullScreenScale, 1, interpolator); + pa.addFloat(recentsViewScale, AnimatedFloat.VALUE, getFullScreenScale(), 1, + interpolator); } /** @@ -484,11 +431,9 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy { mOrientationState.getOrientationHandler().setSecondary(mMatrix, MATRIX_POST_TRANSLATE, taskSecondaryTranslation.value); - mMatrix.postScale(carouselScale.value, carouselScale.value, mPivot.x, mPivot.y); - mOrientationState.getOrientationHandler().setPrimary(mMatrix, MATRIX_POST_TRANSLATE, - carouselPrimaryTranslation.value); - mOrientationState.getOrientationHandler().setSecondary(mMatrix, MATRIX_POST_TRANSLATE, - carouselSecondaryTranslation.value); + mMatrix.postScale(carouselScale.value, carouselScale.value, + mIsRecentsRtl ? mCarouselTaskSize.right : mCarouselTaskSize.left, + mCarouselTaskSize.top); mOrientationState.getOrientationHandler().setPrimary( mMatrix, MATRIX_POST_TRANSLATE, recentsViewScroll.value); @@ -524,8 +469,6 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy { + " taskRect: " + mTaskRect + " taskPrimaryT: " + taskPrimaryTranslation.value + " taskSecondaryT: " + taskSecondaryTranslation.value - + " carouselPrimaryT: " + carouselPrimaryTranslation.value - + " carouselSecondaryT: " + carouselSecondaryTranslation.value + " recentsPrimaryT: " + recentsViewPrimaryTranslation.value + " recentsSecondaryT: " + recentsViewSecondaryTranslation.value + " recentsScroll: " + recentsViewScroll.value diff --git a/quickstep/src/com/android/quickstep/views/ClearAllButton.java b/quickstep/src/com/android/quickstep/views/ClearAllButton.java index c3efc3cbcf..72f97dfe79 100644 --- a/quickstep/src/com/android/quickstep/views/ClearAllButton.java +++ b/quickstep/src/com/android/quickstep/views/ClearAllButton.java @@ -16,7 +16,6 @@ package com.android.quickstep.views; -import static com.android.launcher3.Flags.enableGridOnlyOverview; import static com.android.quickstep.util.BorderAnimator.DEFAULT_BORDER_COLOR; import android.content.Context; @@ -331,13 +330,7 @@ public class ClearAllButton extends Button { private float getOriginalTranslationY() { DeviceProfile deviceProfile = mContainer.getDeviceProfile(); if (deviceProfile.isTablet) { - if (enableGridOnlyOverview()) { - return (getRecentsView().getLastComputedTaskSize().height() - + deviceProfile.overviewTaskThumbnailTopMarginPx) / 2.0f - + deviceProfile.overviewRowSpacing; - } else { - return deviceProfile.overviewRowSpacing; - } + return deviceProfile.overviewRowSpacing; } return deviceProfile.overviewTaskThumbnailTopMarginPx / 2.0f; } diff --git a/quickstep/src/com/android/quickstep/views/DesktopTaskView.kt b/quickstep/src/com/android/quickstep/views/DesktopTaskView.kt index 7d044516d4..471313aff2 100644 --- a/quickstep/src/com/android/quickstep/views/DesktopTaskView.kt +++ b/quickstep/src/com/android/quickstep/views/DesktopTaskView.kt @@ -174,16 +174,8 @@ class DesktopTaskView @JvmOverloads constructor(context: Context, attrs: Attribu } @SuppressLint("RtlHardcoded") - override fun updateTaskSize( - lastComputedTaskSize: Rect, - lastComputedGridTaskSize: Rect, - lastComputedCarouselTaskSize: Rect, - ) { - super.updateTaskSize( - lastComputedTaskSize, - lastComputedGridTaskSize, - lastComputedCarouselTaskSize, - ) + override fun updateTaskSize(lastComputedTaskSize: Rect, lastComputedGridTaskSize: Rect) { + super.updateTaskSize(lastComputedTaskSize, lastComputedGridTaskSize) if (taskContainers.isEmpty()) { return } diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 770a6597f0..9b91027e2d 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -521,7 +521,6 @@ public abstract class RecentsView< @Nullable protected RemoteTargetHandle[] mRemoteTargetHandles; - protected final Rect mLastComputedCarouselTaskSize = new Rect(); protected final Rect mLastComputedTaskSize = new Rect(); protected final Rect mLastComputedGridSize = new Rect(); protected final Rect mLastComputedGridTaskSize = new Rect(); @@ -2279,11 +2278,6 @@ public abstract class RecentsView< mSizeStrategy.calculateGridTaskSize(mContainer, dp, mLastComputedGridTaskSize, getPagedOrientationHandler()); - if (enableGridOnlyOverview()) { - mSizeStrategy.calculateCarouselTaskSize(mContainer, dp, mLastComputedCarouselTaskSize, - getPagedOrientationHandler()); - } - mTaskGridVerticalDiff = mLastComputedGridTaskSize.top - mLastComputedTaskSize.top; mTopBottomRowHeightDiff = mLastComputedGridTaskSize.height() + dp.overviewTaskThumbnailTopMarginPx @@ -2303,17 +2297,9 @@ public abstract class RecentsView< } float accumulatedTranslationX = 0; - float translateXToMiddle = 0; - if (enableGridOnlyOverview() && mContainer.getDeviceProfile().isTablet) { - translateXToMiddle = mIsRtl - ? mLastComputedCarouselTaskSize.right - mLastComputedTaskSize.right - : mLastComputedCarouselTaskSize.left - mLastComputedTaskSize.left; - } for (TaskView taskView : getTaskViews()) { - taskView.updateTaskSize(mLastComputedTaskSize, mLastComputedGridTaskSize, - mLastComputedCarouselTaskSize); + taskView.updateTaskSize(mLastComputedTaskSize, mLastComputedGridTaskSize); taskView.setNonGridTranslationX(accumulatedTranslationX); - taskView.setNonGridPivotTranslationX(translateXToMiddle); // Compensate space caused by TaskView scaling. float widthDiff = taskView.getLayoutParams().width * (1 - taskView.getNonGridScale()); @@ -2342,7 +2328,8 @@ public abstract class RecentsView< */ public Rect getSelectedTaskBounds() { if (mSelectedTask == null) { - return mLastComputedTaskSize; + return enableGridOnlyOverview() && mContainer.getDeviceProfile().isTablet + ? mLastComputedGridTaskSize : mLastComputedTaskSize; } return getTaskBounds(mSelectedTask); } @@ -2351,8 +2338,9 @@ public abstract class RecentsView< int selectedPage = indexOfChild(taskView); int primaryScroll = getPagedOrientationHandler().getPrimaryScroll(this); int selectedPageScroll = getScrollForPage(selectedPage); - boolean isTopRow = taskView != null && mTopRowIdSet.contains(taskView.getTaskViewId()); - Rect outRect = new Rect(mLastComputedTaskSize); + boolean isTopRow = mTopRowIdSet.contains(taskView.getTaskViewId()); + Rect outRect = new Rect( + taskView.isGridTask() ? mLastComputedGridTaskSize : mLastComputedTaskSize); outRect.offset( -(primaryScroll - (selectedPageScroll + getOffsetFromScrollPosition(selectedPage))), (int) (showAsGrid() && enableGridOnlyOverview() && !isTopRow @@ -2369,10 +2357,6 @@ public abstract class RecentsView< return mLastComputedGridTaskSize; } - public Rect getLastComputedCarouselTaskSize() { - return mLastComputedCarouselTaskSize; - } - /** Gets the task size for modal state. */ public void getModalTaskSize(Rect outRect) { mSizeStrategy.calculateModalTaskSize(mContainer, mContainer.getDeviceProfile(), outRect, @@ -2899,8 +2883,6 @@ public abstract class RecentsView< } else { animatorSet.play(ObjectAnimator.ofFloat(this, RECENTS_GRID_PROGRESS, 1)); animatorSet.play(tvs.carouselScale.animateToValue(1)); - animatorSet.play(tvs.carouselPrimaryTranslation.animateToValue(0)); - animatorSet.play(tvs.carouselSecondaryTranslation.animateToValue(0)); animatorSet.play(tvs.taskPrimaryTranslation.animateToValue( runningTaskPrimaryGridTranslation)); animatorSet.play(tvs.taskSecondaryTranslation.animateToValue( @@ -4798,14 +4780,7 @@ public abstract class RecentsView< mTempPointF.set(mLastComputedTaskSize.centerX(), mLastComputedTaskSize.bottom); } } else { - // Only update pivot when it is tablet and not in grid yet, so the pivot is correct - // for non-current tasks when swiping up to overview - if (enableGridOnlyOverview() && mContainer.getDeviceProfile().isTablet - && !mOverviewGridEnabled) { - mTempRect.set(mLastComputedCarouselTaskSize); - } else { - mTempRect.set(mLastComputedTaskSize); - } + mTempRect.set(mLastComputedTaskSize); getPagedViewOrientedState().getFullScreenScaleAndPivot(mTempRect, mContainer.getDeviceProfile(), mTempPointF); } @@ -4916,10 +4891,12 @@ public abstract class RecentsView< && child instanceof DesktopTaskView; float totalTranslationX = (skipTranslationOffset ? 0f : translation) + modalTranslation + carouselHiddenOffsetSize; - FloatProperty translationPropertyX = child instanceof TaskView - ? ((TaskView) child).getPrimaryTaskOffsetTranslationProperty() - : getPagedOrientationHandler().getPrimaryViewTranslate(); - translationPropertyX.set(child, totalTranslationX); + if (child instanceof TaskView taskView) { + taskView.getPrimaryTaskOffsetTranslationProperty().set(taskView, totalTranslationX); + } else { + getPagedOrientationHandler().getPrimaryViewTranslate().set(child, + totalTranslationX); + } if (mEnableDrawingLiveTile && i == getRunningTaskIndex()) { runActionOnRemoteHandles( remoteTargetHandle -> remoteTargetHandle.getTaskViewSimulator() @@ -4927,11 +4904,11 @@ public abstract class RecentsView< redrawLiveTile(); } - if (showAsGrid && enableGridOnlyOverview() && child instanceof TaskView) { - float totalTranslationY = getVerticalOffsetSize(i, modalOffset); - FloatProperty translationPropertyY = - ((TaskView) child).getSecondaryTaskOffsetTranslationProperty(); - translationPropertyY.set(child, totalTranslationY); + if (showAsGrid && enableGridOnlyOverview() && child instanceof TaskView taskView) { + float totalTranslationY = getVerticalOffsetSize(taskView, modalOffset); + FloatProperty translationPropertyY = + taskView.getSecondaryTaskOffsetTranslationProperty(); + translationPropertyY.set(taskView, totalTranslationY); } } updateCurveProperties(); @@ -5047,7 +5024,7 @@ public abstract class RecentsView< * * @param offsetProgress From 0 to 1 where 0 means no offset and 1 means offset offscreen. */ - private float getVerticalOffsetSize(int childIndex, float offsetProgress) { + private float getVerticalOffsetSize(TaskView taskView, float offsetProgress) { if (offsetProgress == 0 || !(showAsGrid() && enableGridOnlyOverview()) || mSelectedTask == null) { // Don't bother calculating everything below if we won't offset vertically. @@ -5055,11 +5032,10 @@ public abstract class RecentsView< } // First, get the position of the task relative to the top row. - TaskView child = getTaskViewAt(childIndex); - Rect taskPosition = getTaskBounds(child); + Rect taskPosition = getTaskBounds(taskView); boolean isSelectedTaskTopRow = mTopRowIdSet.contains(mSelectedTask.getTaskViewId()); - boolean isChildTopRow = mTopRowIdSet.contains(child.getTaskViewId()); + boolean isChildTopRow = mTopRowIdSet.contains(taskView.getTaskViewId()); // Whether the task should be shifted to the top. boolean isTopShift = !isSelectedTaskTopRow && isChildTopRow; boolean isBottomShift = isSelectedTaskTopRow && !isChildTopRow; @@ -5656,19 +5632,10 @@ public abstract class RecentsView< * Returns the scale up required on the view, so that it coves the screen completely */ public float getMaxScaleForFullScreen() { - if (enableGridOnlyOverview() && mContainer.getDeviceProfile().isTablet - && !mOverviewGridEnabled) { - if (mLastComputedCarouselTaskSize.isEmpty()) { - mSizeStrategy.calculateCarouselTaskSize(mContainer, mContainer.getDeviceProfile(), - mLastComputedCarouselTaskSize, getPagedOrientationHandler()); - } - mTempRect.set(mLastComputedCarouselTaskSize); - } else { - if (mLastComputedTaskSize.isEmpty()) { - getTaskSize(mLastComputedTaskSize); - } - mTempRect.set(mLastComputedTaskSize); + if (mLastComputedTaskSize.isEmpty()) { + getTaskSize(mLastComputedTaskSize); } + mTempRect.set(mLastComputedTaskSize); return getPagedViewOrientedState().getFullScreenScaleAndPivot( mTempRect, mContainer.getDeviceProfile(), mTempPointF); } diff --git a/quickstep/src/com/android/quickstep/views/TaskView.kt b/quickstep/src/com/android/quickstep/views/TaskView.kt index 0dbad70874..f94eb14aae 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.kt +++ b/quickstep/src/com/android/quickstep/views/TaskView.kt @@ -165,10 +165,7 @@ constructor( * Returns addition of translationX that is persistent (e.g. fullscreen and grid), and does * not change according to a temporary state (e.g. task offset). */ - get() = - (getNonGridTrans(nonGridTranslationX) + - getGridTrans(this.gridTranslationX) + - getNonGridTrans(nonGridPivotTranslationX)) + get() = (getNonGridTrans(nonGridTranslationX) + getGridTrans(this.gridTranslationX)) protected val persistentTranslationY: Float /** @@ -352,12 +349,6 @@ constructor( applyTranslationX() } - protected var nonGridPivotTranslationX = 0f - set(value) { - field = value - applyTranslationX() - } - // Used when in SplitScreenSelectState private var splitSelectTranslationY = 0f set(value) { @@ -797,11 +788,7 @@ constructor( * Updates TaskView scaling and translation required to support variable width if enabled, while * ensuring TaskView fits into screen in fullscreen. */ - open fun updateTaskSize( - lastComputedTaskSize: Rect, - lastComputedGridTaskSize: Rect, - lastComputedCarouselTaskSize: Rect, - ) { + open fun updateTaskSize(lastComputedTaskSize: Rect, lastComputedGridTaskSize: Rect) { val thumbnailPadding = container.deviceProfile.overviewTaskThumbnailTopMarginPx val taskWidth = lastComputedTaskSize.width() val taskHeight = lastComputedTaskSize.height() @@ -829,12 +816,7 @@ constructor( expectedHeight = boxHeight + thumbnailPadding // Scale to to fit task Rect. - nonGridScale = - if (enableGridOnlyOverview()) { - lastComputedCarouselTaskSize.width() / taskWidth.toFloat() - } else { - taskWidth / boxWidth.toFloat() - } + nonGridScale = taskWidth / boxWidth.toFloat() // Align to top of task Rect. boxTranslationY = (expectedHeight - thumbnailPadding - taskHeight) / 2.0f @@ -1587,7 +1569,6 @@ constructor( gridTranslationX = 0f gridTranslationY = 0f boxTranslationY = 0f - nonGridPivotTranslationX = 0f taskContainers.forEach { it.snapshotView.translationX = 0f it.snapshotView.translationY = 0f diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 21aabfa850..212534b347 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -488,8 +488,6 @@ 0dp 0dp 0dp - 0dp - 0dp 72dp 16dp