From dae7898cc11aa90cac08e5e5410802d42791d185 Mon Sep 17 00:00:00 2001 From: Noah Brenner Date: Thu, 10 Nov 2022 11:36:23 -0800 Subject: [PATCH] Compensate for Android launcher icon scaling (#424) Fixes #410 The launcher images created by `capacitor-assets generate` are correct, but the Android platform itself is displaying them scaled and cropped. We can compensate for that by defining an inset in the launcher XML. Credit for this approach goes to: https://stackoverflow.com/questions/66593626/why-does-adaptive-icon-generated-by-android-studio-crop-images-so-much-to-make-u The workaround that twoco pointed out on the linked issue involves adding padding to the icon so that the desired icon size was 2/3 of the actual width. Using those numbers, I added a padding of ~1/6 to each edge, so ~1/3 in total for each dimension. I tested this in android studio. I saw that the icon was fully visible in the launcher. I also tried it with background image that had circles touching the image edges, and I confirmed that they were not visible before this change and *were* visible at the edge of the image after this change. --- src/platforms/android/index.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/platforms/android/index.ts b/src/platforms/android/index.ts index 9756db2..0c1f57b 100644 --- a/src/platforms/android/index.ts +++ b/src/platforms/android/index.ts @@ -361,8 +361,12 @@ export class AndroidAssetGenerator extends AssetGenerator { const icLauncherXml = ` - - + + + + + + `.trim(); @@ -428,8 +432,12 @@ export class AndroidAssetGenerator extends AssetGenerator { const icLauncherXml = ` - - + + + + + + `.trim();