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") + } +} + /** * 系统是否暗色主题 */