Update the scale on corner radii on scaled image drawable.

The RoundedDrawableWrapper applies rounded corners on each draw, so,
on scaling, the corners look odd for small widgets.

This change, applies the same scale to corner radius as well.
There are some widgets whose preview images have embedded transparency,
but we don't do much for such previews.

Bug: 359860747
Test: Manual
Flag: EXEMPT bugfix
Change-Id: I5e58e29765503454f286d99050b13b497531d306
This commit is contained in:
Shamali P committed 2024-08-15 02:54:17 +00:00
1 parent f544f7f164
commit c7e1b5c975
3 files changed
+10 -1

No files matched your search

@@ -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;