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. 26
      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 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文本的颜色
}
}
}

@ -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)
}

@ -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<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?) {
@ -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)

@ -1,9 +1,18 @@
<?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">
<item
android:id="@+id/menu_share_it"
android:title="@string/share"
android:icon="@drawable/ic_share"
app:showAsAction="always"
tools:ignore="AlwaysShowAction" />
<item
android:id="@+id/menu_scoring"
android:title="@string/scoring"
android:icon="@drawable/ic_star_border"
app:showAsAction="always" />
</menu>

@ -18,29 +18,49 @@
android:title="@string/update_log"
app:iconSpaceReserved="false" />
<io.legado.app.lib.theme.prefs.ATEPreferenceCategory
android:title="联系我们"
app:iconSpaceReserved="false">
<androidx.preference.Preference
android:key="gzGzh"
android:title="关注公众号"
android:summary="开源阅读软件"
app:iconSpaceReserved="false" />
<androidx.preference.Preference
android:key="qq"
android:title="@string/join_qq_group"
android:summary="点击加入"
app:iconSpaceReserved="false" />
<androidx.preference.Preference
android:key="mail"
android:title="@string/send_mail"
android:summary="kunfei.ge@gmail.com"
app:iconSpaceReserved="false" />
<androidx.preference.Preference
android:key="git"
android:title="@string/git_hub"
android:summary="@string/this_github_url"
app:iconSpaceReserved="false" />
<androidx.preference.Preference
android:key="home_page"
android:title="@string/home_page"
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="share_app"
android:title="@string/share_app"
android:key="license"
android:title="开源许可"
app:iconSpaceReserved="false" />
<androidx.preference.Preference
@ -48,4 +68,6 @@
android:title="@string/disclaimer"
app:iconSpaceReserved="false" />
</io.legado.app.lib.theme.prefs.ATEPreferenceCategory>
</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"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
<network-security-config xmlns:tools="http://schemas.android.com/tools">
<base-config
cleartextTrafficPermitted="true"
tools:ignore="InsecureBaseConfiguration" />
</network-security-config>
Loading…
Cancel
Save