diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java index 17e21ad5e70f..d49343855772 100644 --- a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java +++ b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java @@ -848,6 +848,9 @@ protected void setCurrentGame(String target) { ScummVMActivity.this, ScummVMActivity.class); setIntent(intent); Log.d(ScummVM.LOG_TAG, "Current activity Intent is: " + data); + if (target != null) { + ShortcutCreatorActivity.pushShortcut(ScummVMActivity.this, target, intent); + } } @Override diff --git a/backends/platform/android/org/scummvm/scummvm/ShortcutCreatorActivity.java b/backends/platform/android/org/scummvm/scummvm/ShortcutCreatorActivity.java index 03d4cf130752..814a35b0d926 100644 --- a/backends/platform/android/org/scummvm/scummvm/ShortcutCreatorActivity.java +++ b/backends/platform/android/org/scummvm/scummvm/ShortcutCreatorActivity.java @@ -55,6 +55,37 @@ public class ShortcutCreatorActivity extends Activity { private IconsCache _cache; + static void pushShortcut(Context context, String gameId, Intent intent) { + Map> parsedIniMap; + try (FileReader reader = new FileReader(new File(context.getFilesDir(), "scummvm.ini"))) { + parsedIniMap = INIParser.parse(reader); + } catch(FileNotFoundException ignored) { + parsedIniMap = null; + } catch(IOException ignored) { + parsedIniMap = null; + } + + if (parsedIniMap == null) { + return; + } + + Game game = Game.loadGame(parsedIniMap, gameId); + if (game == null) { + return; + } + + FileInputStream defaultStream = openFile(new File(context.getFilesDir(), "gui-icons.dat")); + + File iconsPath = INIParser.getPath(parsedIniMap, "scummvm", "iconspath", + new File(context.getFilesDir(), "icons")); + FileInputStream[] packsStream = openFiles(context, iconsPath, "gui-icons.*\\.dat"); + + IconsCache cache = new IconsCache(context, defaultStream, packsStream); + final Drawable icon = cache.getGameIcon(game); + + CompatHelpers.ShortcutCreator.pushDynamicShortcut(context, game.getTarget(), intent, game.getDescription(), icon, R.drawable.ic_no_game_icon); + } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);