feat: 优化代码

pull/103/head
kunfei 5 years ago
parent e4a9baeb34
commit 0a16616922
  1. 4
      app/src/main/java/io/legado/app/lib/theme/prefs/ATEPreferenceCategory.kt
  2. 5
      app/src/main/java/io/legado/app/ui/about/AboutActivity.kt
  3. 28
      app/src/main/java/io/legado/app/ui/about/AboutFragment.kt
  4. 11
      app/src/main/res/menu/about.xml
  5. 70
      app/src/main/res/xml/about.xml
  6. 4
      app/src/main/res/xml/donate.xml
  7. 6
      app/src/main/res/xml/network_security_config.xml

@ -5,7 +5,7 @@ import android.util.AttributeSet
import android.widget.TextView import android.widget.TextView
import androidx.preference.PreferenceCategory import androidx.preference.PreferenceCategory
import androidx.preference.PreferenceViewHolder import androidx.preference.PreferenceViewHolder
import io.legado.app.lib.theme.ThemeStore import io.legado.app.lib.theme.accentColor
class ATEPreferenceCategory(context: Context, attrs: AttributeSet) : class ATEPreferenceCategory(context: Context, attrs: AttributeSet) :
@ -16,7 +16,7 @@ class ATEPreferenceCategory(context: Context, attrs: AttributeSet) :
holder?.let { holder?.let {
val view = it.findViewById(android.R.id.title) val view = it.findViewById(android.R.id.title)
if (view is TextView) { if (view is TextView) {
view.setTextColor(ThemeStore.accentColor(view.getContext()))//设置title文本的颜色 view.setTextColor(context.accentColor)//设置title文本的颜色
} }
} }
} }

@ -7,6 +7,7 @@ import android.view.Menu
import android.view.MenuItem import android.view.MenuItem
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.BaseActivity import io.legado.app.base.BaseActivity
import io.legado.app.utils.shareText
import org.jetbrains.anko.toast import org.jetbrains.anko.toast
class AboutActivity : BaseActivity(R.layout.activity_about) { class AboutActivity : BaseActivity(R.layout.activity_about) {
@ -28,6 +29,10 @@ class AboutActivity : BaseActivity(R.layout.activity_about) {
override fun onCompatOptionsItemSelected(item: MenuItem): Boolean { override fun onCompatOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) { when (item.itemId) {
R.id.menu_scoring -> openIntent("market://details?id=$packageName") 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) return super.onCompatOptionsItemSelected(item)
} }

@ -4,17 +4,22 @@ import android.content.Intent
import android.net.Uri import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import androidx.annotation.StringRes
import androidx.preference.Preference import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceFragmentCompat
import io.legado.app.App import io.legado.app.App
import io.legado.app.R import io.legado.app.R
import io.legado.app.utils.shareText
import io.legado.app.utils.toast import io.legado.app.utils.toast
class AboutFragment : PreferenceFragmentCompat() { 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?) { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
addPreferencesFromResource(R.xml.about) addPreferencesFromResource(R.xml.about)
findPreference<Preference>("check_update")?.summary = getString(R.string.version) + " " + App.INSTANCE.versionName findPreference<Preference>("check_update")?.summary =
getString(R.string.version) + " " + App.INSTANCE.versionName
} }
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
@ -24,20 +29,23 @@ class AboutFragment : PreferenceFragmentCompat() {
override fun onPreferenceTreeClick(preference: Preference?): Boolean { override fun onPreferenceTreeClick(preference: Preference?): Boolean {
when (preference?.key) { 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") "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") "mail" -> openIntent(Intent.ACTION_SENDTO, "mailto:kunfei.ge@gmail.com")
"git" -> openIntent(Intent.ACTION_VIEW, getString(R.string.this_github_url)) "git" -> openIntent(Intent.ACTION_VIEW, R.string.this_github_url)
"home_page" -> openIntent(Intent.ACTION_VIEW, getString(R.string.home_page_url)) "home_page" -> openIntent(Intent.ACTION_VIEW, R.string.home_page_url)
"share_app" -> activity?.shareText( "license" -> openIntent(Intent.ACTION_VIEW, licenseUrl)
"App Share", "disclaimer" -> openIntent(Intent.ACTION_VIEW, disclaimerUrl)
getString(R.string.app_share_description)
)
} }
return super.onPreferenceTreeClick(preference) 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) { private fun openIntent(intentName: String, address: String) {
try { try {
val intent = Intent(intentName) val intent = Intent(intentName)

@ -1,9 +1,18 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<menu xmlns:app="http://schemas.android.com/apk/res-auto" <menu xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"> xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/menu_share_it"
android:title="@string/share"
android:icon="@drawable/ic_share"
app:showAsAction="always"
tools:ignore="AlwaysShowAction" />
<item <item
android:id="@+id/menu_scoring" android:id="@+id/menu_scoring"
android:title="@string/scoring" android:title="@string/scoring"
android:icon="@drawable/ic_star_border"
app:showAsAction="always" /> app:showAsAction="always" />
</menu> </menu>

@ -18,34 +18,56 @@
android:title="@string/update_log" android:title="@string/update_log"
app:iconSpaceReserved="false" /> app:iconSpaceReserved="false" />
<androidx.preference.Preference <io.legado.app.lib.theme.prefs.ATEPreferenceCategory
android:key="qq" android:title="联系我们"
android:title="@string/join_qq_group" app:iconSpaceReserved="false">
app:iconSpaceReserved="false" />
<androidx.preference.Preference <androidx.preference.Preference
android:key="mail" android:key="gzGzh"
android:title="@string/send_mail" android:title="关注公众号"
app:iconSpaceReserved="false" /> android:summary="开源阅读软件"
app:iconSpaceReserved="false" />
<androidx.preference.Preference <androidx.preference.Preference
android:key="git" android:key="qq"
android:title="@string/git_hub" android:title="@string/join_qq_group"
app:iconSpaceReserved="false" /> android:summary="点击加入"
app:iconSpaceReserved="false" />
<androidx.preference.Preference <androidx.preference.Preference
android:key="home_page" android:key="mail"
android:title="@string/home_page" android:title="@string/send_mail"
app:iconSpaceReserved="false" /> android:summary="kunfei.ge@gmail.com"
app:iconSpaceReserved="false" />
<androidx.preference.Preference <androidx.preference.Preference
android:key="share_app" android:key="git"
android:title="@string/share_app" android:title="@string/git_hub"
app:iconSpaceReserved="false" /> android:summary="@string/this_github_url"
app:iconSpaceReserved="false" />
<androidx.preference.Preference <androidx.preference.Preference
android:key="disclaimer" android:key="home_page"
android:title="@string/disclaimer" android:title="@string/home_page"
app:iconSpaceReserved="false" /> android:summary="@string/home_page_url"
app:iconSpaceReserved="false" />
</io.legado.app.lib.theme.prefs.ATEPreferenceCategory>
<io.legado.app.lib.theme.prefs.ATEPreferenceCategory
android:title="其它"
app:iconSpaceReserved="false">
<androidx.preference.Preference
android:key="license"
android:title="开源许可"
app:iconSpaceReserved="false" />
<androidx.preference.Preference
android:key="disclaimer"
android:title="@string/disclaimer"
app:iconSpaceReserved="false" />
</io.legado.app.lib.theme.prefs.ATEPreferenceCategory>
</androidx.preference.PreferenceScreen> </androidx.preference.PreferenceScreen>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen>
</PreferenceScreen>

@ -1,4 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<network-security-config> <network-security-config xmlns:tools="http://schemas.android.com/tools">
<base-config cleartextTrafficPermitted="true" /> <base-config
cleartextTrafficPermitted="true"
tools:ignore="InsecureBaseConfiguration" />
</network-security-config> </network-security-config>
Loading…
Cancel
Save