Clip taskbar size from bottom of thumbnail in overview.
Remove other TaskView clipping logic as it is always false for other sides.
Fix: 234007059
Test: TaskThumbnailViewTest
Change-Id: I56210605fb8c2f433236a82932aaa2800afe392b
diff --git a/quickstep/src/com/android/quickstep/BaseActivityInterface.java b/quickstep/src/com/android/quickstep/BaseActivityInterface.java
index 52abb92..6354282 100644
--- a/quickstep/src/com/android/quickstep/BaseActivityInterface.java
+++ b/quickstep/src/com/android/quickstep/BaseActivityInterface.java
@@ -60,7 +60,6 @@
import com.android.quickstep.util.ActivityInitListener;
import com.android.quickstep.util.AnimatorControllerWithResistance;
import com.android.quickstep.views.RecentsView;
-import com.android.quickstep.views.TaskView;
import com.android.systemui.shared.recents.model.ThumbnailData;
import com.android.systemui.shared.system.RemoteAnimationTargetCompat;
@@ -280,17 +279,8 @@
public static void getTaskDimension(DeviceProfile dp, PointF out) {
out.x = dp.widthPx;
out.y = dp.heightPx;
- if (TaskView.clipLeft(dp)) {
- out.x -= dp.getInsets().left;
- }
- if (TaskView.clipRight(dp)) {
- out.x -= dp.getInsets().right;
- }
- if (TaskView.clipTop(dp)) {
- out.y -= dp.getInsets().top;
- }
- if (TaskView.clipBottom(dp)) {
- out.y -= Math.max(dp.getInsets().bottom, dp.taskbarSize);
+ if (dp.isTablet) {
+ out.y -= dp.taskbarSize;
}
}
diff --git a/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java b/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java
index f2fcd06..dec934a 100644
--- a/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java
+++ b/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java
@@ -53,7 +53,6 @@
import com.android.quickstep.BaseActivityInterface;
import com.android.quickstep.SystemUiProxy;
import com.android.quickstep.TaskAnimationManager;
-import com.android.quickstep.views.TaskView;
import java.lang.annotation.Retention;
import java.util.function.IntConsumer;
@@ -399,31 +398,10 @@
* Returns the scale and pivot so that the provided taskRect can fit the provided full size
*/
public float getFullScreenScaleAndPivot(Rect taskView, DeviceProfile dp, PointF outPivot) {
- Rect insets = dp.getInsets();
- float fullWidth = dp.widthPx;
- float fullHeight = dp.heightPx;
- if (TaskView.clipLeft(dp)) {
- fullWidth -= insets.left;
- }
- if (TaskView.clipRight(dp)) {
- fullWidth -= insets.right;
- }
- if (TaskView.clipTop(dp)) {
- fullHeight -= insets.top;
- }
- if (TaskView.clipBottom(dp)) {
- fullHeight -= insets.bottom;
- }
-
getTaskDimension(dp, outPivot);
float scale = Math.min(outPivot.x / taskView.width(), outPivot.y / taskView.height());
- // We also scale the preview as part of fullScreenParams, so account for that as well.
- if (fullWidth > 0) {
- scale = scale * dp.widthPx / fullWidth;
- }
-
if (scale == 1) {
- outPivot.set(fullWidth / 2, fullHeight / 2);
+ outPivot.set(taskView.centerX(), taskView.centerY());
} else {
float factor = scale / (scale - 1);
outPivot.set(taskView.left * factor, taskView.top * factor);
diff --git a/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
index 32dc4d8..eb9b0b0 100644
--- a/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
@@ -238,13 +238,9 @@
boundsToBitmapSpace.mapRect(boundsInBitmapSpace, viewRect);
DeviceProfile dp = mActivity.getDeviceProfile();
- int leftInset = TaskView.clipLeft(dp) ? Math.round(boundsInBitmapSpace.left) : 0;
- int topInset = TaskView.clipTop(dp) ? Math.round(boundsInBitmapSpace.top) : 0;
- int rightInset = TaskView.clipRight(dp) ? Math.round(
- bitmapRect.right - boundsInBitmapSpace.right) : 0;
- int bottomInset = TaskView.clipBottom(dp)
+ int bottomInset = dp.isTablet
? Math.round(bitmapRect.bottom - boundsInBitmapSpace.bottom) : 0;
- return Insets.of(leftInset, topInset, rightInset, bottomInset);
+ return Insets.of(0, 0, 0, bottomInset);
}
@@ -435,18 +431,9 @@
int thumbnailRotation = thumbnailData.rotation;
int deltaRotate = getRotationDelta(currentRotation, thumbnailRotation);
RectF thumbnailClipHint = new RectF();
- if (TaskView.clipLeft(dp)) {
- thumbnailClipHint.left = thumbnailData.insets.left;
- }
- if (TaskView.clipRight(dp)) {
- thumbnailClipHint.right = thumbnailData.insets.right;
- }
- if (TaskView.clipTop(dp)) {
- thumbnailClipHint.top = thumbnailData.insets.top;
- }
- if (TaskView.clipBottom(dp)) {
- thumbnailClipHint.bottom = thumbnailData.insets.bottom;
- }
+ float canvasScreenRatio = canvasWidth / (float) dp.widthPx;
+ float scaledTaskbarSize = dp.taskbarSize * canvasScreenRatio;
+ thumbnailClipHint.bottom = dp.isTablet ? scaledTaskbarSize : 0;
float scale = thumbnailData.scale;
final float thumbnailScale;
@@ -486,18 +473,10 @@
if (isAspectLargelyDifferent) {
// Crop letterbox insets if insets isn't already clipped
- if (!TaskView.clipLeft(dp)) {
- thumbnailClipHint.left = thumbnailData.letterboxInsets.left;
- }
- if (!TaskView.clipRight(dp)) {
- thumbnailClipHint.right = thumbnailData.letterboxInsets.right;
- }
- if (!TaskView.clipTop(dp)) {
- thumbnailClipHint.top = thumbnailData.letterboxInsets.top;
- }
- if (!TaskView.clipBottom(dp)) {
- thumbnailClipHint.bottom = thumbnailData.letterboxInsets.bottom;
- }
+ thumbnailClipHint.left = thumbnailData.letterboxInsets.left;
+ thumbnailClipHint.right = thumbnailData.letterboxInsets.right;
+ thumbnailClipHint.top = thumbnailData.letterboxInsets.top;
+ thumbnailClipHint.bottom = thumbnailData.letterboxInsets.bottom;
availableWidth = surfaceWidth
- (thumbnailClipHint.left + thumbnailClipHint.right);
availableHeight = surfaceHeight
@@ -568,8 +547,7 @@
setThumbnailRotation(deltaRotate, thumbnailBounds);
}
- float canvasScreenRatio = canvasWidth / (float) dp.widthPx;
- mClippedInsets.set(0, 0, 0, dp.taskbarSize * canvasScreenRatio);
+ mClippedInsets.set(0, 0, 0, scaledTaskbarSize);
mMatrix.postScale(thumbnailScale, thumbnailScale);
mIsOrientationChanged = isOrientationDifferent;
diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java
index 68e9f5a..1bc5386 100644
--- a/quickstep/src/com/android/quickstep/views/TaskView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskView.java
@@ -136,34 +136,6 @@
/** The maximum amount that a task view can be scrimmed, dimmed or tinted. */
public static final float MAX_PAGE_SCRIM_ALPHA = 0.4f;
- /**
- * Should the TaskView display clip off the left inset in RecentsView.
- */
- public static boolean clipLeft(DeviceProfile deviceProfile) {
- return false;
- }
-
- /**
- * Should the TaskView display clip off the top inset in RecentsView.
- */
- public static boolean clipTop(DeviceProfile deviceProfile) {
- return false;
- }
-
- /**
- * Should the TaskView display clip off the right inset in RecentsView.
- */
- public static boolean clipRight(DeviceProfile deviceProfile) {
- return false;
- }
-
- /**
- * Should the TaskView display clip off the bottom inset in RecentsView.
- */
- public static boolean clipBottom(DeviceProfile deviceProfile) {
- return deviceProfile.isTablet;
- }
-
private static final float EDGE_SCALE_DOWN_FACTOR_CAROUSEL = 0.03f;
private static final float EDGE_SCALE_DOWN_FACTOR_GRID = 0.00f;
diff --git a/quickstep/tests/src/com/android/quickstep/TaskThumbnailViewTest.kt b/quickstep/tests/src/com/android/quickstep/TaskThumbnailViewTest.kt
new file mode 100644
index 0000000..cf3c8c9
--- /dev/null
+++ b/quickstep/tests/src/com/android/quickstep/TaskThumbnailViewTest.kt
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+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.DeviceProfileBaseTest
+import com.android.quickstep.views.TaskThumbnailView.PreviewPositionHelper
+import com.android.systemui.shared.recents.model.ThumbnailData
+import com.google.common.truth.Truth.assertThat
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.Mockito.mock
+
+/**
+ * Test for TaskThumbnailView class.
+ */
+@SmallTest
+@RunWith(AndroidJUnit4::class)
+class TaskThumbnailViewTest : DeviceProfileBaseTest() {
+
+ private var mThumbnailData: ThumbnailData = mock(ThumbnailData::class.java)
+
+ private val mPreviewPositionHelper = PreviewPositionHelper()
+
+ @Test
+ fun getInsetsToDrawInFullscreen_clipTaskbarSizeFromBottomForTablets() {
+ initializeVarsForTablet()
+ val dp = newDP()
+ val previewRect = Rect(0, 0, 100, 100)
+ val canvasWidth = dp.widthPx / 2
+ val canvasHeight = dp.heightPx / 2
+ val currentRotation = 0
+ val isRtl = false
+
+ mPreviewPositionHelper.updateThumbnailMatrix(previewRect, mThumbnailData, canvasWidth,
+ canvasHeight, dp, currentRotation, isRtl)
+
+ val expectedClippedInsets = RectF(0f, 0f, 0f, dp.taskbarSize / 2f)
+ assertThat(mPreviewPositionHelper.getInsetsToDrawInFullscreen(dp))
+ .isEqualTo(expectedClippedInsets)
+ }
+
+ @Test
+ fun getInsetsToDrawInFullscreen_doNotClipTaskbarSizeFromBottomForPhones() {
+ initializeVarsForPhone()
+ val dp = newDP()
+ val previewRect = Rect(0, 0, 100, 100)
+ val canvasWidth = dp.widthPx / 2
+ val canvasHeight = dp.heightPx / 2
+ val currentRotation = 0
+ val isRtl = false
+
+ mPreviewPositionHelper.updateThumbnailMatrix(previewRect, mThumbnailData, canvasWidth,
+ canvasHeight, dp, currentRotation, isRtl)
+
+ val expectedClippedInsets = RectF(0f, 0f, 0f, 0f)
+ assertThat(mPreviewPositionHelper.getInsetsToDrawInFullscreen(dp))
+ .isEqualTo(expectedClippedInsets)
+ }
+}
\ No newline at end of file