From f66b556a437c10b543342a384ced5a9631f596e7 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 24 Jan 2020 11:59:25 +0800 Subject: [PATCH] up --- .../java/io/legado/app/ui/about/AboutFragment.kt | 16 +++++----------- 1 file changed, 5 insertions(+), 11 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 08a5fa6a1..e48ef9354 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 @@ -8,6 +8,7 @@ import androidx.preference.Preference import androidx.preference.PreferenceFragmentCompat import io.legado.app.App import io.legado.app.R +import io.legado.app.utils.shareText import io.legado.app.utils.toast class AboutFragment : PreferenceFragmentCompat() { @@ -29,7 +30,10 @@ class AboutFragment : PreferenceFragmentCompat() { "mail" -> openIntent(Intent.ACTION_SENDTO, "mailto:kunfei.ge@gmail.com") "git" -> openIntent(Intent.ACTION_VIEW, getString(R.string.this_github_url)) "home_page" -> openIntent(Intent.ACTION_VIEW, getString(R.string.home_page_url)) - "share_app" -> shareText("App Share",getString(R.string.app_share_description)) + "share_app" -> activity?.shareText( + "App Share", + getString(R.string.app_share_description) + ) } return super.onPreferenceTreeClick(preference) } @@ -44,14 +48,4 @@ class AboutFragment : PreferenceFragmentCompat() { } } - private fun shareText(title: String, text: String) { - try { - val textIntent = Intent(Intent.ACTION_SEND) - textIntent.type = "text/plain" - textIntent.putExtra(Intent.EXTRA_TEXT, text) - startActivity(Intent.createChooser(textIntent, title)) - } catch (e: Exception) { - toast(R.string.can_not_share) - } - } } \ No newline at end of file