pull/241/head
383bjz82bu 5 years ago
parent 695696438b
commit f3aeba29bf
  1. 2
      app/src/main/java/io/legado/app/help/AppConfig.kt
  2. 15
      app/src/main/java/io/legado/app/help/ReadBookConfig.kt
  3. 4
      app/src/main/java/io/legado/app/ui/about/AboutFragment.kt
  4. 4
      app/src/main/java/io/legado/app/ui/about/DonateFragment.kt
  5. 8
      app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt
  6. 4
      app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt
  7. 4
      app/src/main/java/io/legado/app/ui/book/read/config/ReadAloudConfigDialog.kt
  8. 4
      app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt
  9. 3
      app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt
  10. 3
      app/src/main/java/io/legado/app/ui/config/ThemeConfigFragment.kt
  11. 5
      app/src/main/java/io/legado/app/ui/main/my/MyFragment.kt
  12. 17
      app/src/main/java/io/legado/app/utils/AnimationUtilsSupport.kt
  13. 41
      app/src/main/java/io/legado/app/utils/PreferenceFragmentSupport.kt

@ -81,7 +81,7 @@ object AppConfig {
get() = App.INSTANCE.getPrefString(PreferKey.ttsSpeechPer) ?: "0"
val isEInkMode: Boolean
get() = App.INSTANCE.getPrefBoolean("isEInkMode")
get() = App.INSTANCE.getPrefBoolean(PreferKey.einkMode)
val clickAllNext: Boolean get() = App.INSTANCE.getPrefBoolean(PreferKey.clickAllNext, false)

@ -26,12 +26,25 @@ object ReadBookConfig {
val json = String(App.INSTANCE.assets.open(readConfigFileName).readBytes())
GSON.fromJsonArray<Config>(json)!!
}
val durConfig get() = getConfig(styleSelect)
val durConfig get() =
if (AppConfig.isEInkMode)
einkConfig
else
getConfig(styleSelect)
var bg: Drawable? = null
var bgMeanColor: Int = 0
val einkConfig:Config
init {
upConfig()
einkConfig = Config(
bgStr = "#FFFFFF",
bgStrNight = "#FFFFFF",
textColor = "#000000",
textColorNight = "#000000",
darkStatusIconNight = true
)
}
@Synchronized

@ -6,16 +6,16 @@ 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.lib.dialogs.alert
import io.legado.app.ui.widget.dialog.TextDialog
import io.legado.app.utils.PreferenceFragmentSupport
import io.legado.app.utils.openUrl
import io.legado.app.utils.sendToClip
import io.legado.app.utils.toast
class AboutFragment : PreferenceFragmentCompat() {
class AboutFragment : PreferenceFragmentSupport() {
private val licenseUrl = "https://github.com/gedoor/legado/blob/master/LICENSE"
private val disclaimerUrl = "https://gedoor.github.io/MyBookshelf/disclaimer.html"

@ -5,14 +5,14 @@ import android.content.Intent
import android.os.Bundle
import android.view.View
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import io.legado.app.R
import io.legado.app.utils.ACache
import io.legado.app.utils.PreferenceFragmentSupport
import io.legado.app.utils.openUrl
import io.legado.app.utils.sendToClip
import org.jetbrains.anko.longToast
class DonateFragment : PreferenceFragmentCompat() {
class DonateFragment : PreferenceFragmentSupport() {
private val zfbHbRwmUrl = "https://gitee.com/gekunfei/Donate/raw/master/zfbhbrwm.png"
private val zfbSkRwmUrl = "https://gitee.com/gekunfei/Donate/raw/master/zfbskrwm.jpg"

@ -194,8 +194,8 @@ class ReadMenu : FrameLayout {
}
private fun initAnimation() {
menuTopIn = AnimationUtils.loadAnimation(context, R.anim.anim_readbook_top_in)
menuBottomIn = AnimationUtils.loadAnimation(context, R.anim.anim_readbook_bottom_in)
menuTopIn = AnimationUtilsSupport.loadAnimation(context, R.anim.anim_readbook_top_in)
menuBottomIn = AnimationUtilsSupport.loadAnimation(context, R.anim.anim_readbook_bottom_in)
menuTopIn.setAnimationListener(object : Animation.AnimationListener {
override fun onAnimationStart(animation: Animation) {
callBack?.upSystemUiVisibility()
@ -217,8 +217,8 @@ class ReadMenu : FrameLayout {
})
//隐藏菜单
menuTopOut = AnimationUtils.loadAnimation(context, R.anim.anim_readbook_top_out)
menuBottomOut = AnimationUtils.loadAnimation(context, R.anim.anim_readbook_bottom_out)
menuTopOut = AnimationUtilsSupport.loadAnimation(context, R.anim.anim_readbook_top_out)
menuBottomOut = AnimationUtilsSupport.loadAnimation(context, R.anim.anim_readbook_bottom_out)
menuTopOut.setAnimationListener(object : Animation.AnimationListener {
override fun onAnimationStart(animation: Animation) {
vw_menu_bg.setOnClickListener(null)

@ -10,7 +10,6 @@ import android.view.ViewGroup
import android.widget.LinearLayout
import androidx.fragment.app.DialogFragment
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import io.legado.app.R
import io.legado.app.constant.EventBus
import io.legado.app.constant.PreferKey
@ -18,6 +17,7 @@ import io.legado.app.help.ReadBookConfig
import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.bottomBackground
import io.legado.app.ui.book.read.Help
import io.legado.app.utils.PreferenceFragmentSupport
import io.legado.app.utils.dp
import io.legado.app.utils.getPrefBoolean
import io.legado.app.utils.postEvent
@ -64,7 +64,7 @@ class MoreConfigDialog : DialogFragment() {
.commit()
}
class ReadPreferenceFragment : PreferenceFragmentCompat(),
class ReadPreferenceFragment : PreferenceFragmentSupport(),
SharedPreferences.OnSharedPreferenceChangeListener {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {

@ -10,7 +10,6 @@ import android.widget.LinearLayout
import androidx.fragment.app.DialogFragment
import androidx.preference.ListPreference
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import io.legado.app.R
import io.legado.app.constant.EventBus
import io.legado.app.constant.PreferKey
@ -20,6 +19,7 @@ import io.legado.app.lib.theme.backgroundColor
import io.legado.app.service.BaseReadAloudService
import io.legado.app.service.help.ReadAloud
import io.legado.app.ui.book.read.Help
import io.legado.app.utils.PreferenceFragmentSupport
import io.legado.app.utils.postEvent
class ReadAloudConfigDialog : DialogFragment() {
@ -59,7 +59,7 @@ class ReadAloudConfigDialog : DialogFragment() {
.commit()
}
class ReadAloudPreferenceFragment : PreferenceFragmentCompat(),
class ReadAloudPreferenceFragment : PreferenceFragmentSupport(),
SharedPreferences.OnSharedPreferenceChangeListener {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {

@ -8,15 +8,15 @@ import android.view.View
import androidx.preference.EditTextPreference
import androidx.preference.ListPreference
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import io.legado.app.R
import io.legado.app.constant.PreferKey
import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.accentColor
import io.legado.app.ui.filechooser.FileChooserDialog
import io.legado.app.utils.PreferenceFragmentSupport
import io.legado.app.utils.getPrefString
class BackupConfigFragment : PreferenceFragmentCompat(),
class BackupConfigFragment : PreferenceFragmentSupport(),
SharedPreferences.OnSharedPreferenceChangeListener,
FileChooserDialog.CallBack {

@ -7,7 +7,6 @@ import android.os.Bundle
import android.view.View
import androidx.preference.ListPreference
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import io.legado.app.App
import io.legado.app.R
import io.legado.app.constant.EventBus
@ -21,7 +20,7 @@ import io.legado.app.ui.widget.number.NumberPickerDialog
import io.legado.app.utils.*
class OtherConfigFragment : PreferenceFragmentCompat(),
class OtherConfigFragment : PreferenceFragmentSupport(),
SharedPreferences.OnSharedPreferenceChangeListener {
private val packageManager = App.INSTANCE.packageManager

@ -9,7 +9,6 @@ import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import io.legado.app.App
import io.legado.app.R
import io.legado.app.constant.EventBus
@ -26,7 +25,7 @@ import io.legado.app.ui.widget.prefs.IconListPreference
import io.legado.app.utils.*
class ThemeConfigFragment : PreferenceFragmentCompat(), SharedPreferences.OnSharedPreferenceChangeListener {
class ThemeConfigFragment : PreferenceFragmentSupport(), SharedPreferences.OnSharedPreferenceChangeListener {
val items = arrayListOf("极简", "曜夜", "经典", "黑白", "A屏黑")

@ -7,13 +7,13 @@ import android.view.Menu
import android.view.MenuItem
import android.view.View
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import io.legado.app.App
import io.legado.app.R
import io.legado.app.base.BaseFragment
import io.legado.app.constant.EventBus
import io.legado.app.constant.PreferKey
import io.legado.app.help.AppConfig
import io.legado.app.help.ReadBookConfig
import io.legado.app.lib.theme.ATH
import io.legado.app.service.WebService
import io.legado.app.ui.about.AboutActivity
@ -65,7 +65,7 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config), FileChooserDialog.
BackupRestoreUi.onActivityResult(requestCode, resultCode, data)
}
class PreferenceFragment : PreferenceFragmentCompat(),
class PreferenceFragment : PreferenceFragmentSupport(),
SharedPreferences.OnSharedPreferenceChangeListener {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
@ -123,6 +123,7 @@ class MyFragment : BaseFragment(R.layout.fragment_my_config), FileChooserDialog.
"recordLog" -> LogUtils.upLevel()
PreferKey.einkMode -> {
postEvent(EventBus.RECREATE, "")
ReadBookConfig.pageAnim = 4
}
}
}

@ -0,0 +1,17 @@
package io.legado.app.utils
import android.content.Context
import android.view.animation.Animation
import android.view.animation.AnimationUtils
import androidx.annotation.AnimRes
import io.legado.app.help.AppConfig
object AnimationUtilsSupport {
fun loadAnimation(context: Context, @AnimRes id: Int): Animation {
val animation = AnimationUtils.loadAnimation(context, id)
if (AppConfig.isEInkMode) {
animation.duration = 0
}
return animation
}
}

@ -0,0 +1,41 @@
package io.legado.app.utils
import android.content.pm.PackageManager
import android.os.Bundle
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.core.view.setPadding
import androidx.preference.PreferenceFragmentCompat
import androidx.preference.PreferenceRecyclerViewAccessibilityDelegate
import androidx.recyclerview.widget.RecyclerView
import fadeapp.widgets.ScrollLessRecyclerView
import io.legado.app.R
import io.legado.app.help.AppConfig
abstract class PreferenceFragmentSupport : PreferenceFragmentCompat(){
override fun onCreateRecyclerView(
inflater: LayoutInflater,
parent: ViewGroup,
savedInstanceState: Bundle?
): RecyclerView {
if (context?.packageManager?.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)==true) {
val recyclerView: RecyclerView?= parent.findViewById(R.id.recycler_view)
if (recyclerView != null) {
return recyclerView
}
}
val recyclerView = ScrollLessRecyclerView(inflater.context,null,R.attr.preferenceFragmentListStyle)
recyclerView.id = R.id.recycler_view
recyclerView.setPadding(0)
recyclerView.clipToPadding = false
recyclerView.isEnableScroll = !AppConfig.isEInkMode
recyclerView.layoutManager = onCreateLayoutManager()
recyclerView.setAccessibilityDelegateCompat(
PreferenceRecyclerViewAccessibilityDelegate(recyclerView)
)
return recyclerView
}
}
Loading…
Cancel
Save