Skip to content

Commit

Permalink
ANDROID: Make custom shortcuts really custom
Browse files Browse the repository at this point in the history
Before this change, the user may not have been able to set its own label
if a shortcut with the same name already existed.
  • Loading branch information
lephilousophe committed Nov 12, 2024
1 parent c361462 commit 84f4ea3
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,14 @@ public void onItemClick(AdapterView<?> a, View v, int position, long id) {
builder.setPositiveButton(android.R.string.ok, (dialog, which) -> {
dialog.dismiss();

String label = desc.getText().toString();
// Generate an id which depends on the user description
// Without this, if the user changes the description but already has the same shortcut (also in the dynamic ones), the other label will be reused
String shortcutId = game.getTarget() + String.format("-%08x", label.hashCode());

Intent shortcut = new Intent(Intent.ACTION_MAIN, Uri.fromParts("scummvm", game.getTarget(), null),
ShortcutCreatorActivity.this, SplashActivity.class);
Intent result = CompatHelpers.ShortcutCreator.createShortcutResultIntent(ShortcutCreatorActivity.this, game.getTarget(), shortcut,
Intent result = CompatHelpers.ShortcutCreator.createShortcutResultIntent(ShortcutCreatorActivity.this, shortcutId, shortcut,
desc.getText().toString(), icon, R.drawable.ic_no_game_icon);
setResult(RESULT_OK, result);

Expand Down

0 comments on commit 84f4ea3

Please sign in to comment.