From 9461c4708280c8a70f05aba3f71e9e6c0c3a790c Mon Sep 17 00:00:00 2001 From: Mis012 Date: Sun, 8 Jun 2025 02:14:01 +0200 Subject: [PATCH] AdaptiveIconDrawable: add hacks to make it work We don't currently have "shaders" implemented properly, so just draw the layers and don't mask anything. --- .../graphics/drawable/AdaptiveIconDrawable.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/api-impl/android/graphics/drawable/AdaptiveIconDrawable.java b/src/api-impl/android/graphics/drawable/AdaptiveIconDrawable.java index 89fef5d5..2233183c 100644 --- a/src/api-impl/android/graphics/drawable/AdaptiveIconDrawable.java +++ b/src/api-impl/android/graphics/drawable/AdaptiveIconDrawable.java @@ -348,12 +348,13 @@ public class AdaptiveIconDrawable extends Drawable implements Drawable.Callback continue; } - int insetWidth = (int)(bounds.width() / (DEFAULT_VIEW_PORT_SCALE * 2)); + /*int insetWidth = (int)(bounds.width() / (DEFAULT_VIEW_PORT_SCALE * 2)); int insetHeight = (int)(bounds.height() / (DEFAULT_VIEW_PORT_SCALE * 2)); final Rect outRect = mTmpOutRect; outRect.set(cX - insetWidth, cY - insetHeight, cX + insetWidth, cY + insetHeight); - d.setBounds(outRect); + d.setBounds(outRect);*/ + d.setBounds(bounds); } } @@ -376,7 +377,7 @@ public class AdaptiveIconDrawable extends Drawable implements Drawable.Callback @Override public void draw(Canvas canvas) { - if (mLayersBitmap == null) { + /* if (mLayersBitmap == null) { return; } if (mLayersShader == null) { @@ -397,6 +398,16 @@ public class AdaptiveIconDrawable extends Drawable implements Drawable.Callback canvas.drawPath(mMaskScaleOnly, mPaint); canvas.translate(-bounds.left, -bounds.top); } + */ + Rect bounds = getBounds(); + canvas.translate(bounds.left, bounds.top); + if (mLayerState.mChildren[BACKGROUND_ID].mDrawable != null) { + mLayerState.mChildren[BACKGROUND_ID].mDrawable.draw(canvas); + } + if (mLayerState.mChildren[FOREGROUND_ID].mDrawable != null) { + mLayerState.mChildren[FOREGROUND_ID].mDrawable.draw(canvas); + } + canvas.translate(-bounds.left, -bounds.top); } @Override