From 60045b56cd9d77809d43d030b9bd7945b86b9436 Mon Sep 17 00:00:00 2001 From: Inhishonor Date: Sun, 6 Sep 2026 11:08:11 -0700 Subject: [PATCH] fix(compose): Properly handle attachments when forwarding Previously there was no differentiation between one or many attachments, which was causing forwarding attachments to fail. Now, the code determines which intent to use based on number of attachments. --- .../java/com/moez/QKSMS/common/Navigator.kt | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/presentation/src/main/java/com/moez/QKSMS/common/Navigator.kt b/presentation/src/main/java/com/moez/QKSMS/common/Navigator.kt index 2efeb141..ca50ffc1 100644 --- a/presentation/src/main/java/com/moez/QKSMS/common/Navigator.kt +++ b/presentation/src/main/java/com/moez/QKSMS/common/Navigator.kt @@ -59,15 +59,20 @@ class Navigator @Inject constructor( val intent = Intent(context, ComposeActivity::class.java) intent.putExtra(Intent.EXTRA_TEXT, body) intent.putExtra("mode", mode) - - attachments + val forwardAttachments = attachments + ?.filter { it.resourceExists(context) } ?.takeIf { it.isNotEmpty() } - ?.mapNotNull { - if (it.resourceExists(context)) it - else null + forwardAttachments?.size?.let { attachmentNumber -> + if (attachmentNumber == 1) { + intent.action = Intent.ACTION_SEND + intent.putExtra(Intent.EXTRA_STREAM, forwardAttachments.first()) + } else { + intent.action = Intent.ACTION_SEND_MULTIPLE + intent.putParcelableArrayListExtra( + Intent.EXTRA_STREAM, ArrayList(forwardAttachments) + ) } - ?.let { intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, ArrayList(it)) } - + } startActivity(intent) }