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

Commit accd0f68 authored by Shamali Patwa's avatar Shamali Patwa Committed by Android (Google) Code Review
Browse files

Merge "Update the scale on corner radii on scaled image drawable." into main

parents 0ad76ac0 c7e1b5c9
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@ import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;

import com.android.launcher3.icons.RoundDrawableWrapper;

/**
 * View that draws a bitmap horizontally centered. If the image width is greater than the view
 * width, the image is scaled down appropriately.
@@ -85,6 +87,11 @@ public class WidgetImageView extends View {
        final float scale = bitmapAspectRatio > containerAspectRatio ? myWidth / bitmapWidth
                : myHeight / bitmapHeight;

        // When updating the scale, also update scale on drawable if it has rounding.
        if (mDrawable instanceof RoundDrawableWrapper && scale <= 1) {
            ((RoundDrawableWrapper) mDrawable).setCornerRadiusScale(scale);
        }

        final float scaledWidth = bitmapWidth * scale;
        final float scaledHeight = bitmapHeight * scale;

+1 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ val HANDHELD_WIDGET_PREVIEW_SIZES: List<WidgetPreviewContainerSize> =
        WidgetPreviewContainerSize(spanX = 2, spanY = 3),
        WidgetPreviewContainerSize(spanX = 2, spanY = 2),
        WidgetPreviewContainerSize(spanX = 4, spanY = 1),
        WidgetPreviewContainerSize(spanX = 3, spanY = 1),
        WidgetPreviewContainerSize(spanX = 2, spanY = 1),
        WidgetPreviewContainerSize(spanX = 1, spanY = 1),
    )
+2 −1
Original line number Diff line number Diff line
@@ -85,7 +85,8 @@ class WidgetPreviewContainerSizesTest {
                Point(1, 1) to WidgetPreviewContainerSize(1, 1),
                // 2x1
                Point(2, 1) to WidgetPreviewContainerSize(2, 1),
                Point(3, 1) to WidgetPreviewContainerSize(2, 1),
                // 3x1
                Point(3, 1) to WidgetPreviewContainerSize(3, 1),
                // 4x1
                Point(4, 1) to WidgetPreviewContainerSize(4, 1),
                // 2x2