Merge "Use target size to scale down a widget preview image" into sc-v2-dev am: 26b25c222c

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/15502874

Change-Id: Ia19857bb3e28727fd0a96e40901d418acf33b9a6
This commit is contained in:
TreeHugger Robot
2021-08-10 19:11:03 +00:00
committed by Automerger Merge Worker
@@ -325,10 +325,10 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener {
return;
}
if (drawable != null) {
// Scale down the preview size if it's wider than the cell.
float scale = 1f;
if (getWidth() > 0 && getHeight() > 0) {
// Scale down the preview size if it's wider than the cell.
float maxWidth = getWidth();
if (mTargetPreviewWidth > 0) {
float maxWidth = mTargetPreviewWidth;
float previewWidth = drawable.getIntrinsicWidth() * mPreviewContainerScale;
scale = Math.min(maxWidth / previewWidth, 1);
}