Merge pull request #3888 from deltachat/adb/issue-3853

fix direct share shortcuts
This commit is contained in:
adb 2025-08-16 21:31:26 +02:00 committed by GitHub
commit 152360d94a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 2 deletions

View file

@ -3,7 +3,8 @@
## Unreleased
* target Android 15
* Improve readability of info messages in dark mode
* improve readability of info messages in dark mode
* fix Direct Share shortcuts
## v2.11.0
2025-08

View file

@ -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:

View file

@ -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)