From b55d511ce01ad9daa5e03e8a4e9b4f1e00ef0c9d Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 20 Oct 2020 14:26:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/about/AboutFragment.kt | 14 ++------------ .../java/io/legado/app/utils/ContextExtensions.kt | 10 ++++++++++ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/about/AboutFragment.kt b/app/src/main/java/io/legado/app/ui/about/AboutFragment.kt index 8744f8f92..eea2feba4 100644 --- a/app/src/main/java/io/legado/app/ui/about/AboutFragment.kt +++ b/app/src/main/java/io/legado/app/ui/about/AboutFragment.kt @@ -13,8 +13,8 @@ import io.legado.app.lib.dialogs.alert import io.legado.app.ui.widget.dialog.TextDialog import io.legado.app.utils.applyTint import io.legado.app.utils.openUrl +import io.legado.app.utils.sendMail import io.legado.app.utils.sendToClip -import io.legado.app.utils.toast class AboutFragment : PreferenceFragmentCompat() { @@ -48,7 +48,7 @@ class AboutFragment : PreferenceFragmentCompat() { "contributors" -> openUrl(R.string.contributors_url) "update_log" -> showUpdateLog() "check_update" -> openUrl(R.string.latest_release_url) - "mail" -> sendMail() + "mail" -> requireContext().sendMail("kunfei.ge@gmail.com") "sourceRuleSummary" -> openUrl(R.string.source_rule_url) "git" -> openUrl(R.string.this_github_url) "home_page" -> openUrl(R.string.home_page_url) @@ -66,16 +66,6 @@ class AboutFragment : PreferenceFragmentCompat() { requireContext().openUrl(getString(addressID)) } - private fun sendMail() { - try { - val intent = Intent(Intent.ACTION_SENDTO) - intent.data = Uri.parse("mailto:kunfei.ge@gmail.com") - startActivity(intent) - } catch (e: Exception) { - toast(e.localizedMessage ?: "Error") - } - } - private fun showUpdateLog() { val log = String(requireContext().assets.open("updateLog.md").readBytes()) TextDialog.show(childFragmentManager, log, TextDialog.MD) diff --git a/app/src/main/java/io/legado/app/utils/ContextExtensions.kt b/app/src/main/java/io/legado/app/utils/ContextExtensions.kt index 489f5d508..b99f935eb 100644 --- a/app/src/main/java/io/legado/app/utils/ContextExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/ContextExtensions.kt @@ -156,6 +156,16 @@ fun Context.getClipText(): String? { return null } +fun Context.sendMail(mail: String) { + try { + val intent = Intent(Intent.ACTION_SENDTO) + intent.data = Uri.parse("mailto:$mail") + startActivity(intent) + } catch (e: Exception) { + toast(e.localizedMessage ?: "Error") + } +} + /** * 系统是否暗色主题 */