From 0a1661692239298c4a8cd39ac909b07133858f60 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 14 Feb 2020 13:19:41 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/theme/prefs/ATEPreferenceCategory.kt | 4 +- .../io/legado/app/ui/about/AboutActivity.kt | 5 ++ .../io/legado/app/ui/about/AboutFragment.kt | 28 +++++--- app/src/main/res/menu/about.xml | 11 ++- app/src/main/res/xml/about.xml | 70 ++++++++++++------- app/src/main/res/xml/donate.xml | 4 ++ .../main/res/xml/network_security_config.xml | 6 +- 7 files changed, 89 insertions(+), 39 deletions(-) create mode 100644 app/src/main/res/xml/donate.xml diff --git a/app/src/main/java/io/legado/app/lib/theme/prefs/ATEPreferenceCategory.kt b/app/src/main/java/io/legado/app/lib/theme/prefs/ATEPreferenceCategory.kt index 16f9e168f..7d5a704c3 100644 --- a/app/src/main/java/io/legado/app/lib/theme/prefs/ATEPreferenceCategory.kt +++ b/app/src/main/java/io/legado/app/lib/theme/prefs/ATEPreferenceCategory.kt @@ -5,7 +5,7 @@ import android.util.AttributeSet import android.widget.TextView import androidx.preference.PreferenceCategory import androidx.preference.PreferenceViewHolder -import io.legado.app.lib.theme.ThemeStore +import io.legado.app.lib.theme.accentColor class ATEPreferenceCategory(context: Context, attrs: AttributeSet) : @@ -16,7 +16,7 @@ class ATEPreferenceCategory(context: Context, attrs: AttributeSet) : holder?.let { val view = it.findViewById(android.R.id.title) if (view is TextView) { - view.setTextColor(ThemeStore.accentColor(view.getContext()))//设置title文本的颜色 + view.setTextColor(context.accentColor)//设置title文本的颜色 } } } diff --git a/app/src/main/java/io/legado/app/ui/about/AboutActivity.kt b/app/src/main/java/io/legado/app/ui/about/AboutActivity.kt index f5636c134..18e3bcdb9 100644 --- a/app/src/main/java/io/legado/app/ui/about/AboutActivity.kt +++ b/app/src/main/java/io/legado/app/ui/about/AboutActivity.kt @@ -7,6 +7,7 @@ import android.view.Menu import android.view.MenuItem import io.legado.app.R import io.legado.app.base.BaseActivity +import io.legado.app.utils.shareText import org.jetbrains.anko.toast class AboutActivity : BaseActivity(R.layout.activity_about) { @@ -28,6 +29,10 @@ class AboutActivity : BaseActivity(R.layout.activity_about) { override fun onCompatOptionsItemSelected(item: MenuItem): Boolean { when (item.itemId) { R.id.menu_scoring -> openIntent("market://details?id=$packageName") + R.id.menu_share_it -> shareText( + "App Share", + getString(R.string.app_share_description) + ) } return super.onCompatOptionsItemSelected(item) } 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 e48ef9354..b4fbdb149 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 @@ -4,17 +4,22 @@ import android.content.Intent import android.net.Uri import android.os.Bundle import android.view.View +import androidx.annotation.StringRes 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() { + + private val licenseUrl = "https://github.com/gedoor/legado/blob/master/LICENSE" + private val disclaimerUrl = "https://gedoor.github.io/MyBookshelf/disclaimer.html" + override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { addPreferencesFromResource(R.xml.about) - findPreference("check_update")?.summary = getString(R.string.version) + " " + App.INSTANCE.versionName + findPreference("check_update")?.summary = + getString(R.string.version) + " " + App.INSTANCE.versionName } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { @@ -24,20 +29,23 @@ class AboutFragment : PreferenceFragmentCompat() { override fun onPreferenceTreeClick(preference: Preference?): Boolean { when (preference?.key) { - "contributors" -> openIntent(Intent.ACTION_VIEW, getString(R.string.contributors_url)) + "contributors" -> openIntent(Intent.ACTION_VIEW, R.string.contributors_url) "update_log" -> UpdateLog().show(childFragmentManager, "update_log") - "check_update" -> openIntent(Intent.ACTION_VIEW, getString(R.string.latest_release_url)) + "check_update" -> openIntent(Intent.ACTION_VIEW, R.string.latest_release_url) "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" -> activity?.shareText( - "App Share", - getString(R.string.app_share_description) - ) + "git" -> openIntent(Intent.ACTION_VIEW, R.string.this_github_url) + "home_page" -> openIntent(Intent.ACTION_VIEW, R.string.home_page_url) + "license" -> openIntent(Intent.ACTION_VIEW, licenseUrl) + "disclaimer" -> openIntent(Intent.ACTION_VIEW, disclaimerUrl) } return super.onPreferenceTreeClick(preference) } + @Suppress("SameParameterValue") + private fun openIntent(intentName: String, @StringRes addressID: Int) { + openIntent(intentName, getString(addressID)) + } + private fun openIntent(intentName: String, address: String) { try { val intent = Intent(intentName) diff --git a/app/src/main/res/menu/about.xml b/app/src/main/res/menu/about.xml index 7dd8f1e86..d8d4d3194 100644 --- a/app/src/main/res/menu/about.xml +++ b/app/src/main/res/menu/about.xml @@ -1,9 +1,18 @@ - + + \ No newline at end of file diff --git a/app/src/main/res/xml/about.xml b/app/src/main/res/xml/about.xml index ff8e16c44..8139d9553 100644 --- a/app/src/main/res/xml/about.xml +++ b/app/src/main/res/xml/about.xml @@ -18,34 +18,56 @@ android:title="@string/update_log" app:iconSpaceReserved="false" /> - + - + - + - + - + - + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/xml/donate.xml b/app/src/main/res/xml/donate.xml new file mode 100644 index 000000000..65a47daa7 --- /dev/null +++ b/app/src/main/res/xml/donate.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/xml/network_security_config.xml b/app/src/main/res/xml/network_security_config.xml index dca93c079..2c950a5b6 100644 --- a/app/src/main/res/xml/network_security_config.xml +++ b/app/src/main/res/xml/network_security_config.xml @@ -1,4 +1,6 @@ - - + + \ No newline at end of file