Merge changes I438e45d8,I1330cec3 into ub-launcher3-master
* changes:
Show overview tiles in the orientation screenshot was taken
Prevent edge gradient for screenshots in correct orientation
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index f75d6bc..41ac6b1 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -373,11 +373,31 @@
padding.bottom = profile.availableHeightPx - padding.top - sTempStableInsets.top
- Math.round(overviewHeight);
padding.left = padding.right = (int) ((profile.availableWidthPx - overviewWidth) / 2);
+
+ // If the height ratio is larger than the width ratio, the screenshot will get cropped
+ // at the bottom when swiping up. In this case, increase the top/bottom padding to make it
+ // the same aspect ratio.
+ Rect pageRect = new Rect();
+ getPageRect(profile, context, pageRect, padding);
+ float widthRatio = (float) pageRect.width() / taskWidth;
+ float heightRatio = (float) pageRect.height() / taskHeight;
+ if (heightRatio > widthRatio) {
+ float additionalVerticalPadding = pageRect.height() - widthRatio * taskHeight;
+ additionalVerticalPadding = Math.round(additionalVerticalPadding);
+ padding.top += additionalVerticalPadding / 2;
+ padding.bottom += additionalVerticalPadding / 2;
+ }
+
return padding;
}
public static void getPageRect(DeviceProfile grid, Context context, Rect outRect) {
Rect targetPadding = getPadding(grid, context);
+ getPageRect(grid, context, outRect, targetPadding);
+ }
+
+ private static void getPageRect(DeviceProfile grid, Context context, Rect outRect,
+ Rect targetPadding) {
Rect insets = grid.getInsets();
outRect.set(
targetPadding.left + insets.left,
diff --git a/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
index 87bb53b..e443eea 100644
--- a/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
@@ -36,6 +36,7 @@
import com.android.launcher3.BaseActivity;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R;
+import com.android.launcher3.config.FeatureFlags;
import com.android.quickstep.TaskOverlayFactory;
import com.android.quickstep.TaskOverlayFactory.TaskOverlay;
import com.android.systemui.shared.recents.model.Task;
@@ -146,6 +147,9 @@
(mThumbnailData.insets.top + mThumbnailData.insets.bottom) * scale;
final float thumbnailScale;
+ boolean rotate = false;
+ final DeviceProfile profile = BaseActivity.fromContext(getContext())
+ .getDeviceProfile();
if (getMeasuredWidth() == 0) {
// If we haven't measured , skip the thumbnail drawing and only draw the background
// color
@@ -153,43 +157,71 @@
} else {
final Configuration configuration =
getContext().getApplicationContext().getResources().getConfiguration();
- final DeviceProfile profile = BaseActivity.fromContext(getContext())
- .getDeviceProfile();
if (configuration.orientation == mThumbnailData.orientation) {
// If we are in the same orientation as the screenshot, just scale it to the
// width of the task view
thumbnailScale = getMeasuredWidth() / thumbnailWidth;
- } else if (configuration.orientation == Configuration.ORIENTATION_PORTRAIT) {
- // Scale the landscape thumbnail up to app size, then scale that to the task
- // view size to match other portrait screenshots
- thumbnailScale = ((float) getMeasuredWidth() / profile.widthPx);
} else {
- // Otherwise, scale the screenshot to fit 1:1 in the current orientation
- thumbnailScale = 1;
+ if (FeatureFlags.OVERVIEW_USE_SCREENSHOT_ORIENTATION) {
+ rotate = true;
+ // Scale the height (will be width after rotation) to the width of this view
+ thumbnailScale = getMeasuredWidth() / thumbnailHeight;
+ } else {
+ if (configuration.orientation == Configuration.ORIENTATION_PORTRAIT) {
+ // Scale the landscape thumbnail up to app size, then scale that to the
+ // task view size to match other portrait screenshots
+ thumbnailScale = ((float) getMeasuredWidth() / profile.widthPx);
+ } else {
+ // Otherwise, scale the screenshot to fit 1:1 in the current orientation
+ thumbnailScale = 1;
+ }
+ }
}
}
- mMatrix.setTranslate(-mThumbnailData.insets.left * scale,
- -mThumbnailData.insets.top * scale);
+ if (rotate) {
+ int rotationDir = profile.isVerticalBarLayout() && !profile.isSeascape() ? -1 : 1;
+ mMatrix.setRotate(90 * rotationDir);
+ Rect thumbnailInsets = mThumbnailData.insets;
+ int newLeftInset = rotationDir == 1 ? thumbnailInsets.bottom : thumbnailInsets.top;
+ int newTopInset = rotationDir == 1 ? thumbnailInsets.left : thumbnailInsets.right;
+ mMatrix.postTranslate(-newLeftInset * scale, -newTopInset * scale);
+ if (rotationDir == -1) {
+ // Crop the right/bottom side of the screenshot rather than left/top
+ float excessHeight = thumbnailWidth * thumbnailScale - getMeasuredHeight();
+ mMatrix.postTranslate(0, -excessHeight);
+ }
+ // Move the screenshot to the thumbnail window (rotation moved it out).
+ if (rotationDir == 1) {
+ mMatrix.postTranslate(mThumbnailData.thumbnail.getHeight(), 0);
+ } else {
+ mMatrix.postTranslate(0, mThumbnailData.thumbnail.getWidth());
+ }
+ } else {
+ mMatrix.setTranslate(-mThumbnailData.insets.left * scale,
+ -mThumbnailData.insets.top * scale);
+ }
mMatrix.postScale(thumbnailScale, thumbnailScale);
mBitmapShader.setLocalMatrix(mMatrix);
- float bitmapHeight = Math.max(thumbnailHeight * thumbnailScale, 0);
Shader shader = mBitmapShader;
- if (bitmapHeight < getMeasuredHeight()) {
- int color = mPaint.getColor();
- LinearGradient fade = new LinearGradient(
- 0, bitmapHeight - mFadeLength, 0, bitmapHeight,
- color & 0x00FFFFFF, color, Shader.TileMode.CLAMP);
- shader = new ComposeShader(fade, shader, Mode.DST_OVER);
- }
+ if (!FeatureFlags.OVERVIEW_USE_SCREENSHOT_ORIENTATION) {
+ float bitmapHeight = Math.max(thumbnailHeight * thumbnailScale, 0);
+ if (Math.round(bitmapHeight) < getMeasuredHeight()) {
+ int color = mPaint.getColor();
+ LinearGradient fade = new LinearGradient(
+ 0, bitmapHeight - mFadeLength, 0, bitmapHeight,
+ color & 0x00FFFFFF, color, Shader.TileMode.CLAMP);
+ shader = new ComposeShader(fade, shader, Mode.DST_OVER);
+ }
- float bitmapWidth = Math.max(thumbnailWidth * thumbnailScale, 0);
- if (bitmapWidth < getMeasuredWidth()) {
- int color = mPaint.getColor();
- LinearGradient fade = new LinearGradient(
- bitmapWidth - mFadeLength, 0, bitmapWidth, 0,
- color & 0x00FFFFFF, color, Shader.TileMode.CLAMP);
- shader = new ComposeShader(fade, shader, Mode.DST_OVER);
+ float bitmapWidth = Math.max(thumbnailWidth * thumbnailScale, 0);
+ if (Math.round(bitmapWidth) < getMeasuredWidth()) {
+ int color = mPaint.getColor();
+ LinearGradient fade = new LinearGradient(
+ bitmapWidth - mFadeLength, 0, bitmapWidth, 0,
+ color & 0x00FFFFFF, color, Shader.TileMode.CLAMP);
+ shader = new ComposeShader(fade, shader, Mode.DST_OVER);
+ }
}
mPaint.setShader(shader);
}
diff --git a/src/com/android/launcher3/config/BaseFlags.java b/src/com/android/launcher3/config/BaseFlags.java
index 78ea419..f4c6380 100644
--- a/src/com/android/launcher3/config/BaseFlags.java
+++ b/src/com/android/launcher3/config/BaseFlags.java
@@ -51,4 +51,8 @@
// When enabled shows a work profile tab in all apps
public static final boolean ALL_APPS_TABS_ENABLED = true;
+
+ // When true, overview shows screenshots in the orientation they were taken rather than
+ // trying to make them fit the orientation the device is in.
+ public static final boolean OVERVIEW_USE_SCREENSHOT_ORIENTATION = true;
}