capacitor-assets icon indicating copy to clipboard operation
capacitor-assets copied to clipboard

Support for themed app icons (Android 13+)

Open linuslabo opened this issue 3 years ago • 4 comments

It would be great to have support for Android 13+ themed Icons, as promoted here and with more details here

It should be sufficient to add a monochromatic version of the icon and generate the corresponding drawable:

<?xml version="1.0" encoding="utf-8"?>
...
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
    <background android:drawable="@drawable/ic_launcher_background" />
    <foreground android:drawable="@drawable/ic_launcher_foreground" />
    
    // Starting with Android 13 (API level 33), you can opt-in to providing a
    // <monochrome> drawable.
    <monochrome android:drawable="@drawable/ic_launcher_monochrome" />
</adaptive-icon>
...

linuslabo avatar Nov 15 '22 12:11 linuslabo

Is there a possibility of this being implemented?

SoCuul avatar Jul 12 '23 05:07 SoCuul

This should be simple if we can provide a icon-monochrome.png and it just applies the same resizing logic and outputs the icons as ic_launcher_monochrome.png and adds it to ic_launcher.xml.

orjandh avatar Dec 21 '23 14:12 orjandh

I've been looking into this, and trying to implement something, but I'd like to share my initial findings because I'm not quite sure what the best approach could be. I found a few different strategies:

  • Using <monochrome android:drawable="@drawable/ic_launcher_foreground" /> works for our app icon. Our foreground icon is a "monochrome" image, in the sense that it's of a single colour, but that colour is not #000000. I'm not sure what Android did, but it looks like it applies a threshold, and in the end shows it correctly. Converting the logo to full black has the same result. I thought it could be used as a default^1 if the user does not provide a monochrome icon, but probably it would not apply to everyone.
  • Another idea, would be to try to use Sharp (and maybe add some CLI options), to let users apply a custom threshold/grayscale. Again with the idea of allowing this to work in "simple mode", and still having a default fallback behaviour.
  • Finally, probably the most scalable and flexible solution, but also most complex, would be to allow a new android/icon-monochrome icon to be provided as input^2. However, this does require some rethinking when it comes to the ic_launcher.xml generation^1, as now the <monochrome /> element should only be created on demand.

It'd be great to hear from the Ionic team! Then I'm happy to implement this

borgoat avatar Jan 05 '24 10:01 borgoat

image there's no way to make it happen now, is there?

reslear avatar Jul 04 '24 18:07 reslear