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

feat: support bitmap and adaptive icons for Android shortcuts

Open ThatOneCalculator opened this issue 7 months ago • 2 comments

Plugin(s)

  • [x] App Shortcuts

Current problem

Right now, there's no way to set an arbitrary image as the shortcut icon for Android, just the very old predefined drawables.

Preferred solution

Either allowing a bitmap or a resource when registering an icon.

AppShortcuts.set({
  shortcuts: [{
    id: "create",
    title: "Create Content",
    icon:
      Capacitor.getPlatform() === "ios"
        ? "plus.circle"
         : { type: "bitmap", name: "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QC..." }, // bitmap
   }, {
    id: "friends",
    title: "Your Friends",
    icon:
      Capacitor.getPlatform() === "ios"
        ? "person.3"
         : { type: "resource", name: "@drawable/friends" }, // resource
   }],
});

Alternative options

Using https://github.com/NePheus/capacitor-android-shortcuts#availableicontypes

Additional context

https://developer.android.com/develop/ui/views/launch/shortcuts/creating-shortcuts

Before submitting

  • [x] I have read and followed the feature request guidelines.
  • [x] I have attached links to possibly related issues and discussions.

ThatOneCalculator avatar May 14 '25 19:05 ThatOneCalculator

Yes, this feature is missing. The androidIcon property should accept a base64 string. Would you be willing to work on it? It should quiet easy to implement.

robingenz avatar May 14 '25 19:05 robingenz

Unfortunately I know next to nothing about Java/actual Android development -- if you think it wouldn't require too many Java changes I could maybe give it a shot, but I can't guarantee I'd be able to get to it in a timely fashion 😅

ThatOneCalculator avatar May 14 '25 19:05 ThatOneCalculator