From cc9aed8d18a34ef80f3570b97b64219629a2ab51 Mon Sep 17 00:00:00 2001 From: Naveen Date: Tue, 30 Aug 2022 15:46:30 +0530 Subject: [PATCH] Add `Context.sendEmailIntent` extension --- .../com/simplemobiletools/commons/extensions/Context.kt | 7 +++++++ .../com/simplemobiletools/commons/helpers/Constants.kt | 1 + 2 files changed, 8 insertions(+) diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Context.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Context.kt index 6ec7fd70b..792bc009d 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Context.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Context.kt @@ -1029,3 +1029,10 @@ fun Context.updateBottomTabItemColors(view: View?, isActive: Boolean) { view?.findViewById(R.id.tab_item_icon)?.applyColorFilter(color) view?.findViewById(R.id.tab_item_label)?.setTextColor(color) } + +fun Context.sendEmailIntent(recipient: String) { + Intent(Intent.ACTION_SENDTO).apply { + data = Uri.fromParts(KEY_MAILTO, recipient, null) + launchActivityIntent(this) + } +} diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/helpers/Constants.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/helpers/Constants.kt index 38781d448..8fa09ec38 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/helpers/Constants.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/helpers/Constants.kt @@ -35,6 +35,7 @@ const val SAVE_DISCARD_PROMPT_INTERVAL = 1000L const val SD_OTG_PATTERN = "^/storage/[A-Za-z0-9]{4}-[A-Za-z0-9]{4}$" const val SD_OTG_SHORT = "^[A-Za-z0-9]{4}-[A-Za-z0-9]{4}$" const val KEY_PHONE = "phone" +const val KEY_MAILTO = "mailto" const val CONTACT_ID = "contact_id" const val IS_PRIVATE = "is_private" const val MD5 = "MD5"