fix direct share shortcuts

This commit is contained in:
adbenitez
2025-08-16 20:10:53 +02:00
parent 7d7f62dae1
commit 17e3f3afdd
2 changed files with 12 additions and 1 deletions
@@ -32,6 +32,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.pm.ShortcutManagerCompat;
import com.b44t.messenger.DcContext;
@@ -209,6 +210,16 @@ public class ShareActivity extends PassphraseRequiredActionBarActivity implement
int accId = intent.getIntExtra(EXTRA_ACC_ID, -1);
int chatId = intent.getIntExtra(EXTRA_CHAT_ID, -1);
// the intent coming from shortcuts in the share selector might not include the custom extras but the shortcut ID
String shortcutId = intent.getStringExtra(ShortcutManagerCompat.EXTRA_SHORTCUT_ID);
if ((chatId == -1 || accId == -1) && shortcutId != null && shortcutId.startsWith("chat-")) {
String[] args = shortcutId.split("-");
if (args.length == 3) {
accId = Integer.parseInt(args[1]);
chatId = Integer.parseInt(args[2]);
}
}
String[] extraEmail = getIntent().getStringArrayExtra(Intent.EXTRA_EMAIL);
/*
usually, external app will try to start "e-mail sharing" intent, providing it:
@@ -128,7 +128,7 @@ public class DirectShareUtil {
Recipient recipient = new Recipient(context, chat);
Bitmap avatar = getIconForShortcut(context, recipient);
results.add(new ShortcutInfoCompat.Builder(context, Integer.toString(chat.getId()))
results.add(new ShortcutInfoCompat.Builder(context, "chat-" + dcContext.getAccountId() + "-" + chat.getId())
.setShortLabel(chat.getName())
.setLongLived(true)
.setRank(i+1)