[#1597] Improve EmailUtils Intent for more clients

- Closes #1597
- Changelogs update
This commit is contained in:
Honza Rychnovský 2024-09-20 08:55:57 +02:00 committed by GitHub
parent c2cd2404e7
commit 8e24a2273c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 27 additions and 1 deletions

View File

@ -13,6 +13,9 @@ and this application adheres to [Semantic Versioning](https://semver.org/spec/v2
- The Message text field on the Send Form screen has been updated to provide the Return key on the software keyboard
and make auto-capitalization on the beginning of every sentence or new line.
### Fixed
- `EmailUtils.newMailActivityIntent` has been updated to produce an `Intent` that more e-mail clients can understand
## [1.2 (731)] - 2024-09-16
### Changed

View File

@ -16,6 +16,9 @@ directly impact users rather than highlighting other key architectural updates.*
- The Message text field on the Send Form screen has been updated to provide the Return key on the software keyboard
and make auto-capitalization on the beginning of every sentence or new line.
### Fixed
- `EmailUtils.newMailActivityIntent` has been updated to produce an `Intent` that more e-mail clients can understand
## [1.2 (731)] - 2024-09-16
### Added

View File

@ -1,3 +1,5 @@
@file:Suppress("UnusedPrivateMember")
package co.electriccoin.zcash.ui.util
import android.content.Intent
@ -24,7 +26,7 @@ object EmailUtil {
recipientAddress: String,
messageSubject: String,
messageBody: String
): Intent = newIntentAsUri(recipientAddress, messageSubject, messageBody)
): Intent = newIntentAsUriAndExtras(recipientAddress, messageSubject, messageBody)
private fun newIntentAsUri(
recipientAddress: String,
@ -69,6 +71,24 @@ object EmailUtil {
}
}
// This approach combines both adding data to Uri and Extras to ensure that most of the available e-mail client
// apps can understand the output Intent. Tested with Gmail, Proton mail, Yahoo, and Seznam.cz.
private fun newIntentAsUriAndExtras(
recipientAddress: String,
messageSubject: String,
messageBody: String
) = Intent(Intent.ACTION_SENDTO).apply {
data = Uri.parse(newMailToUriString(recipientAddress, messageSubject, messageBody))
putExtra(
Intent.EXTRA_EMAIL,
arrayOf(
recipientAddress
)
)
putExtra(Intent.EXTRA_SUBJECT, messageSubject)
putExtra(Intent.EXTRA_TEXT, messageBody)
}
internal fun formatMessage(
prefix: String? = null,
body: String? = null,