From 280b8c34327803f2d2614129ec2117c3a9932ba1 Mon Sep 17 00:00:00 2001 From: mdespesse Date: Fri, 4 Oct 2024 21:57:05 +0200 Subject: [PATCH] add extra shortcut icon resource to pick_icon response --- library/src/main/java/candybar/lib/helpers/IconsHelper.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/src/main/java/candybar/lib/helpers/IconsHelper.java b/library/src/main/java/candybar/lib/helpers/IconsHelper.java index c48cc227..7fd5f318 100644 --- a/library/src/main/java/candybar/lib/helpers/IconsHelper.java +++ b/library/src/main/java/candybar/lib/helpers/IconsHelper.java @@ -210,6 +210,10 @@ public static void selectIcon(@NonNull Context context, int action, Icon icon) { public void handleResult(Bitmap resource) { Intent intent = new Intent(); intent.putExtra("icon", resource); + + // Also add the direct icon resource ID to the intent for launchers that support it + Intent.ShortcutIconResource iconRes = Intent.ShortcutIconResource.fromContext(context, icon.getRes()); + intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconRes); ((AppCompatActivity) context).setResult(resource != null ? Activity.RESULT_OK : Activity.RESULT_CANCELED, intent); ((AppCompatActivity) context).finish();