mirror of
https://github.com/ProtonMail/android-mail.git
synced 2026-05-15 09:50:40 +00:00
Make sure mailto parameters respect empty spaces and new lines
ET-4183
This commit is contained in:
committed by
MargeBot
parent
663511ca6e
commit
c46d80ef11
+8
-4
@@ -18,6 +18,8 @@
|
||||
|
||||
package ch.protonmail.android.mailcommon.data.file
|
||||
|
||||
import java.net.URLDecoder
|
||||
import java.nio.charset.StandardCharsets
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
@@ -96,8 +98,8 @@ private fun Intent.getShareInfoForViewAction(): IntentShareInfo {
|
||||
?.split(",")
|
||||
?: getRecipientBcc()
|
||||
|
||||
val subject = mailTo.subject ?: getSubject()
|
||||
val body = mailTo.body ?: getEmailBody()
|
||||
val subject = mailTo.subject?.decode() ?: getSubject()
|
||||
val body = mailTo.body?.decode() ?: getEmailBody()
|
||||
|
||||
IntentShareInfo(
|
||||
attachmentUris = emptyList(),
|
||||
@@ -169,7 +171,7 @@ private fun Intent.getFileUrisForActionSendMultiple(): List<Uri> {
|
||||
return fileUris
|
||||
}
|
||||
|
||||
private fun Intent.getSubject(): String? = getStringExtra(Intent.EXTRA_SUBJECT)
|
||||
private fun Intent.getSubject(): String? = getStringExtra(Intent.EXTRA_SUBJECT)?.decode()
|
||||
|
||||
private fun Intent.getRecipientTo(): List<String> = getStringArrayExtra(Intent.EXTRA_EMAIL)?.toList() ?: emptyList()
|
||||
|
||||
@@ -177,7 +179,9 @@ private fun Intent.getRecipientCc(): List<String> = getStringArrayExtra(Intent.E
|
||||
|
||||
private fun Intent.getRecipientBcc(): List<String> = getStringArrayExtra(Intent.EXTRA_BCC)?.toList() ?: emptyList()
|
||||
|
||||
private fun Intent.getEmailBody(): String? = getStringExtra(Intent.EXTRA_TEXT)
|
||||
private fun Intent.getEmailBody(): String? = getStringExtra(Intent.EXTRA_TEXT)?.decode()
|
||||
|
||||
private fun String.decode(): String = URLDecoder.decode(this, StandardCharsets.UTF_8.toString())
|
||||
|
||||
/**
|
||||
* Intent data can be a [Uri] with a mailto scheme instead of a shared file.
|
||||
|
||||
+5
-1
@@ -417,10 +417,14 @@ class ComposerViewModel @AssistedInject constructor(
|
||||
}
|
||||
|
||||
private suspend fun prefillDraftFieldsFromShareInfo(intentShareInfo: IntentShareInfo): DraftFields {
|
||||
val emailBody = when (composerStates.value.main.draftType) {
|
||||
DraftMimeType.PlainText -> intentShareInfo.emailBody
|
||||
DraftMimeType.Html -> intentShareInfo.emailBody?.replace("\n", "<br>")
|
||||
}
|
||||
val draftBody = DraftBody(
|
||||
// Temporarily concatenate the shared text + the initial Rust body (to include the signature if present)
|
||||
buildString {
|
||||
append(intentShareInfo.emailBody ?: "")
|
||||
append(emailBody ?: "")
|
||||
appendLine()
|
||||
append(bodyTextField.text)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user