From 5cc47e5383a472c96a4f6f029c5a4d41ab29b3d8 Mon Sep 17 00:00:00 2001 From: Matt Casey Date: Sat, 20 Mar 2021 17:11:14 -0400 Subject: [PATCH] Fix CropView sizing on full-width images Full width images happen when the long screenshot isn't particularly long, typically an error case. - Ensure that ImageView and CropView take up the whole space defined by constraints. - Set padding on ImageView, factor that padding into the image size computation for CropView. Bug: 183278746 Test: Validate correct crop bounds display on a full height and a full width long screenshot. Change-Id: I0f71ddc051f8cf6d295a348fe3cae3cbe00e4077 --- packages/SystemUI/res/layout/long_screenshot.xml | 10 +++++----- .../systemui/screenshot/LongScreenshotActivity.java | 6 ++++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/SystemUI/res/layout/long_screenshot.xml b/packages/SystemUI/res/layout/long_screenshot.xml index 7ba28a8483c39..b2b99a78de6a0 100644 --- a/packages/SystemUI/res/layout/long_screenshot.xml +++ b/packages/SystemUI/res/layout/long_screenshot.xml @@ -72,10 +72,10 @@ viewRatio) { // Image is full width and height is constrained, compute extra padding to inform @@ -423,7 +425,7 @@ public class LongScreenshotActivity extends Activity { float imageHeight = mPreview.getHeight() * viewRatio / imageRatio; int extraPadding = (int) (mPreview.getHeight() - imageHeight) / 2; mCropView.setExtraPadding(extraPadding, extraPadding); - mCropView.setImageWidth(mPreview.getWidth()); + mCropView.setImageWidth(previewWidth); } else { // Image is full height mCropView.setExtraPadding(0, 0);