From 9fde4781eaae76e8f251f833c6af21ce1bc1fb80 Mon Sep 17 00:00:00 2001 From: Thales Lima Date: Thu, 23 Feb 2023 16:33:18 +0000 Subject: [PATCH] Fix TaskView cropping for transient taskbar TaskView clipping is not necessary anymore because task in Overview will always be the same aspect ratio as the app when in fullscreen. Fix: 268211636 Test: manual trigger of Overview (landscape, portrait, split screen) Change-Id: Ib4faeda6f0cccef3b23fcbacb89c6d2832c0df59 Merged-In: Ib4faeda6f0cccef3b23fcbacb89c6d2832c0df59 --- .../quickstep/BaseActivityInterface.java | 22 +-- .../quickstep/util/RecentsOrientedState.java | 2 +- .../quickstep/util/TaskViewSimulator.java | 12 +- .../views/DigitalWellBeingToast.java | 16 +- .../quickstep/views/GroupedTaskView.java | 4 +- .../quickstep/views/TaskThumbnailView.java | 13 +- .../com/android/quickstep/views/TaskView.java | 42 +---- .../quickstep/FullscreenDrawParamsTest.kt | 165 +++++------------- .../touch/PortraitPagedViewHandler.java | 6 +- 9 files changed, 73 insertions(+), 209 deletions(-) diff --git a/quickstep/src/com/android/quickstep/BaseActivityInterface.java b/quickstep/src/com/android/quickstep/BaseActivityInterface.java index d7ff8ab3fc..58ec2188b9 100644 --- a/quickstep/src/com/android/quickstep/BaseActivityInterface.java +++ b/quickstep/src/com/android/quickstep/BaseActivityInterface.java @@ -244,6 +244,7 @@ public abstract class BaseActivityInterface 0) { - mScale = previewWidth / (previewWidth + currentInsetsLeft + currentInsetsRight); - } - } - - /** - * Insets to used for clipping the thumbnail (in case it is drawing outside its own space) - */ - private static RectF getInsetsToDrawInFullscreen(PreviewPositionHelper pph, - DeviceProfile dp, boolean isTaskbarTransient) { - if (dp.isTaskbarPresent && isTaskbarTransient) { - return pph.getClippedInsets(); - } - return dp.isTaskbarPresent && !dp.isTaskbarPresentInApps - ? pph.getClippedInsets() : EMPTY_RECT_F; } } diff --git a/quickstep/tests/src/com/android/quickstep/FullscreenDrawParamsTest.kt b/quickstep/tests/src/com/android/quickstep/FullscreenDrawParamsTest.kt index bc1b87deb0..6c0e7dc8fd 100644 --- a/quickstep/tests/src/com/android/quickstep/FullscreenDrawParamsTest.kt +++ b/quickstep/tests/src/com/android/quickstep/FullscreenDrawParamsTest.kt @@ -16,16 +16,14 @@ package com.android.quickstep import android.graphics.Rect -import android.graphics.RectF import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.launcher3.FakeInvariantDeviceProfileTest -import com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_BOTTOM_OR_RIGHT -import com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT +import com.android.quickstep.util.TaskCornerRadius import com.android.quickstep.views.TaskView.FullscreenDrawParams import com.android.systemui.shared.recents.model.ThumbnailData import com.android.systemui.shared.recents.utilities.PreviewPositionHelper -import com.android.wm.shell.util.SplitBounds +import com.android.systemui.shared.system.QuickStepContract import com.google.common.truth.Truth.assertThat import kotlin.math.roundToInt import org.junit.Before @@ -50,7 +48,42 @@ class FullscreenDrawParamsTest : FakeInvariantDeviceProfileTest() { } @Test - fun setFullProgress_currentDrawnInsets_clipTaskbarSizeFromBottomForTablets() { + fun setStartProgress_correctCornerRadiusForTablet() { + initializeVarsForTablet() + val dp = newDP() + val previewRect = Rect(0, 0, 100, 100) + val canvasWidth = (dp.widthPx * TASK_SCALE).roundToInt() + val canvasHeight = (dp.heightPx * TASK_SCALE).roundToInt() + val currentRotation = 0 + val isRtl = false + + mPreviewPositionHelper.updateThumbnailMatrix( + previewRect, + mThumbnailData, + canvasWidth, + canvasHeight, + dp.widthPx, + dp.heightPx, + dp.taskbarSize, + dp.isTablet, + currentRotation, + isRtl + ) + params.setProgress( + /* fullscreenProgress= */ 0f, + /* parentScale= */ 1.0f, + /* taskViewScale= */ 1.0f, + /* previewWidth= */ 0, + dp, + mPreviewPositionHelper + ) + + val expectedRadius = TaskCornerRadius.get(context) + assertThat(params.mCurrentDrawnCornerRadius).isEqualTo(expectedRadius) + } + + @Test + fun setFullProgress_correctCornerRadiusForTablet() { initializeVarsForTablet() val dp = newDP() val previewRect = Rect(0, 0, 100, 100) @@ -80,122 +113,19 @@ class FullscreenDrawParamsTest : FakeInvariantDeviceProfileTest() { mPreviewPositionHelper ) - val expectedClippedInsets = RectF(0f, 0f, 0f, dp.taskbarSize * TASK_SCALE) - assertThat(params.mCurrentDrawnInsets).isEqualTo(expectedClippedInsets) + val expectedRadius = QuickStepContract.getWindowCornerRadius(context) + assertThat(params.mCurrentDrawnCornerRadius).isEqualTo(expectedRadius) } @Test - fun setFullProgress_currentDrawnInsets_clipTaskbarSizeFromBottomForTablets_splitPortrait() { - initializeVarsForTablet() + fun setStartProgress_correctCornerRadiusForPhone() { + initializeVarsForPhone() val dp = newDP() val previewRect = Rect(0, 0, 100, 100) val canvasWidth = (dp.widthPx * TASK_SCALE).roundToInt() - val canvasHeight = (dp.heightPx * TASK_SCALE / 2).roundToInt() - val currentRotation = 0 - val isRtl = false - // portrait/vertical split apps - val dividerSize = 10 - val splitBounds = - SplitBounds( - Rect(0, 0, dp.widthPx, (dp.heightPx - dividerSize) / 2), - Rect(0, (dp.heightPx + dividerSize) / 2, dp.widthPx, dp.heightPx), - 0 /*lefTopTaskId*/, - 0 /*rightBottomTaskId*/ - ) - mPreviewPositionHelper.setSplitBounds(splitBounds, STAGE_POSITION_BOTTOM_OR_RIGHT) - - mPreviewPositionHelper.updateThumbnailMatrix( - previewRect, - mThumbnailData, - canvasWidth, - canvasHeight, - dp.widthPx, - dp.heightPx, - dp.taskbarSize, - dp.isTablet, - currentRotation, - isRtl - ) - params.setProgress( - /* fullscreenProgress= */ 1.0f, - /* parentScale= */ 1.0f, - /* taskViewScale= */ 1.0f, - /* previewWidth= */ 0, - dp, - mPreviewPositionHelper - ) - - // Probably unhelpful, but also unclear how to test otherwise ¯\_(ツ)_/¯ - val fullscreenTaskHeight = - dp.heightPx * (1 - (splitBounds.topTaskPercent + splitBounds.dividerHeightPercent)) - val canvasScreenRatio = canvasHeight / fullscreenTaskHeight - val expectedBottomHint = dp.taskbarSize * canvasScreenRatio - assertThat(params.mCurrentDrawnInsets.bottom).isWithin(1f).of(expectedBottomHint) - } - - @Test - fun setFullProgress_currentDrawnInsets_clipTaskbarSizeFromTopForTablets_splitPortrait() { - initializeVarsForTablet() - val dp = newDP() - val previewRect = Rect(0, 0, 100, 100) - val canvasWidth = (dp.widthPx * TASK_SCALE).roundToInt() - val canvasHeight = (dp.heightPx * TASK_SCALE / 2).roundToInt() - val currentRotation = 0 - val isRtl = false - // portrait/vertical split apps - val dividerSize = 10 - val splitBounds = - SplitBounds( - Rect(0, 0, dp.widthPx, (dp.heightPx - dividerSize) / 2), - Rect(0, (dp.heightPx + dividerSize) / 2, dp.widthPx, dp.heightPx), - 0 /*lefTopTaskId*/, - 0 /*rightBottomTaskId*/ - ) - mPreviewPositionHelper.setSplitBounds(splitBounds, STAGE_POSITION_TOP_OR_LEFT) - - mPreviewPositionHelper.updateThumbnailMatrix( - previewRect, - mThumbnailData, - canvasWidth, - canvasHeight, - dp.widthPx, - dp.heightPx, - dp.taskbarSize, - dp.isTablet, - currentRotation, - isRtl - ) - params.setProgress( - /* fullscreenProgress= */ 1.0f, - /* parentScale= */ 1.0f, - /* taskViewScale= */ 1.0f, - /* previewWidth= */ 0, - dp, - mPreviewPositionHelper - ) - - assertThat(params.mCurrentDrawnInsets.bottom).isWithin(1f).of((0f)) - } - - @Test - fun setFullProgress_currentDrawnInsets_clipTaskbarSizeFromBottomForTablets_splitLandscape() { - initializeVarsForTablet(isLandscape = true) - val dp = newDP() - val previewRect = Rect(0, 0, 100, 100) - val canvasWidth = (dp.widthPx * TASK_SCALE / 2).roundToInt() val canvasHeight = (dp.heightPx * TASK_SCALE).roundToInt() val currentRotation = 0 val isRtl = false - // portrait/vertical split apps - val dividerSize = 10 - val splitBounds = - SplitBounds( - Rect(0, 0, (dp.widthPx - dividerSize) / 2, dp.heightPx), - Rect((dp.widthPx + dividerSize) / 2, 0, dp.widthPx, dp.heightPx), - 0 /*lefTopTaskId*/, - 0 /*rightBottomTaskId*/ - ) - mPreviewPositionHelper.setSplitBounds(splitBounds, STAGE_POSITION_BOTTOM_OR_RIGHT) mPreviewPositionHelper.updateThumbnailMatrix( previewRect, @@ -210,7 +140,7 @@ class FullscreenDrawParamsTest : FakeInvariantDeviceProfileTest() { isRtl ) params.setProgress( - /* fullscreenProgress= */ 1.0f, + /* fullscreenProgress= */ 0f, /* parentScale= */ 1.0f, /* taskViewScale= */ 1.0f, /* previewWidth= */ 0, @@ -218,11 +148,12 @@ class FullscreenDrawParamsTest : FakeInvariantDeviceProfileTest() { mPreviewPositionHelper ) - assertThat(params.mCurrentDrawnInsets.bottom).isWithin(1f).of((dp.taskbarSize * TASK_SCALE)) + val expectedRadius = TaskCornerRadius.get(context) + assertThat(params.mCurrentDrawnCornerRadius).isEqualTo(expectedRadius) } @Test - fun setFullProgress_currentDrawnInsets_doNotClipTaskbarSizeFromBottomForPhones() { + fun setFullProgress_correctCornerRadiusForPhone() { initializeVarsForPhone() val dp = newDP() val previewRect = Rect(0, 0, 100, 100) @@ -252,7 +183,7 @@ class FullscreenDrawParamsTest : FakeInvariantDeviceProfileTest() { mPreviewPositionHelper ) - val expectedClippedInsets = RectF(0f, 0f, 0f, 0f) - assertThat(params.mCurrentDrawnInsets).isEqualTo(expectedClippedInsets) + val expectedRadius = QuickStepContract.getWindowCornerRadius(context) + assertThat(params.mCurrentDrawnCornerRadius).isEqualTo(expectedRadius) } } diff --git a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java index 75378f6af5..089b3ac4b1 100644 --- a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java +++ b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java @@ -613,8 +613,7 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler { ? splitInfo.dividerHeightPercent : splitInfo.dividerWidthPercent; - int deviceHeightWithoutTaskbar = dp.availableHeightPx - dp.taskbarSize; - float scale = (float) outRect.height() / deviceHeightWithoutTaskbar; + float scale = (float) outRect.height() / dp.availableHeightPx; float topTaskHeight = dp.availableHeightPx * topLeftTaskPercent; float scaledTopTaskHeight = topTaskHeight * scale; float dividerHeight = dp.availableHeightPx * dividerBarPercent; @@ -667,8 +666,7 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler { } secondarySnapshot.setTranslationY(spaceAboveSnapshot); } else { - int deviceHeightWithoutTaskbar = dp.availableHeightPx - dp.taskbarSize; - float scale = (float) totalThumbnailHeight / deviceHeightWithoutTaskbar; + float scale = (float) totalThumbnailHeight / dp.availableHeightPx; float topTaskHeight = dp.availableHeightPx * taskPercent; float finalDividerHeight = dividerBar * scale; float scaledTopTaskHeight = topTaskHeight * scale;