Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit caf2e5f3 authored by Steven Ng's avatar Steven Ng
Browse files

Use target size to scale down a widget preview image

WidgetCells are being recycled in WidgetFullSheet. getWidth/getHeight
could be a recycled dimension. There is also no guarantee that measure
has taken placed before the scale down logic. Let's use the targeted
width for the scale down logic instead.

Test: Manual
Fix: 195417705
Change-Id: Idfb3cc485604d19658e210709bebde6f163003cf
parent 0a39f6da
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -325,10 +325,10 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener {
            return;
        }
        if (drawable != null) {
            float scale = 1f;
            if (getWidth() > 0 && getHeight() > 0) {
            // Scale down the preview size if it's wider than the cell.
                float maxWidth = getWidth();
            float scale = 1f;
            if (mTargetPreviewWidth > 0) {
                float maxWidth = mTargetPreviewWidth;
                float previewWidth = drawable.getIntrinsicWidth() * mPreviewContainerScale;
                scale = Math.min(maxWidth / previewWidth, 1);
            }