Skip to content

Commit 152360d

Browse files
authored
Merge pull request #3888 from deltachat/adb/issue-3853
fix direct share shortcuts
2 parents 7d7f62d + 8513f7c commit 152360d

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
## Unreleased
44

55
* target Android 15
6-
* Improve readability of info messages in dark mode
6+
* improve readability of info messages in dark mode
7+
* fix Direct Share shortcuts
78

89
## v2.11.0
910
2025-08

src/main/java/org/thoughtcrime/securesms/ShareActivity.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import androidx.annotation.Nullable;
3333
import androidx.appcompat.app.ActionBar;
3434
import androidx.appcompat.widget.Toolbar;
35+
import androidx.core.content.pm.ShortcutManagerCompat;
3536

3637
import com.b44t.messenger.DcContext;
3738

@@ -209,6 +210,16 @@ private void handleResolvedMedia(Intent intent) {
209210
int accId = intent.getIntExtra(EXTRA_ACC_ID, -1);
210211
int chatId = intent.getIntExtra(EXTRA_CHAT_ID, -1);
211212

213+
// the intent coming from shortcuts in the share selector might not include the custom extras but the shortcut ID
214+
String shortcutId = intent.getStringExtra(ShortcutManagerCompat.EXTRA_SHORTCUT_ID);
215+
if ((chatId == -1 || accId == -1) && shortcutId != null && shortcutId.startsWith("chat-")) {
216+
String[] args = shortcutId.split("-");
217+
if (args.length == 3) {
218+
accId = Integer.parseInt(args[1]);
219+
chatId = Integer.parseInt(args[2]);
220+
}
221+
}
222+
212223
String[] extraEmail = getIntent().getStringArrayExtra(Intent.EXTRA_EMAIL);
213224
/*
214225
usually, external app will try to start "e-mail sharing" intent, providing it:

src/main/java/org/thoughtcrime/securesms/connect/DirectShareUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ private static List<ShortcutInfoCompat> getChooserTargets(Context context) {
128128

129129
Recipient recipient = new Recipient(context, chat);
130130
Bitmap avatar = getIconForShortcut(context, recipient);
131-
results.add(new ShortcutInfoCompat.Builder(context, Integer.toString(chat.getId()))
131+
results.add(new ShortcutInfoCompat.Builder(context, "chat-" + dcContext.getAccountId() + "-" + chat.getId())
132132
.setShortLabel(chat.getName())
133133
.setLongLived(true)
134134
.setRank(i+1)

0 commit comments

Comments
 (0)