pull/423/head
gedoor 4 years ago
parent 174d711314
commit bbcbd4c6ec
  1. 51
      app/src/main/java/io/legado/app/help/ReadBookConfig.kt
  2. 2
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivityHelp.kt
  3. 4
      app/src/main/java/io/legado/app/ui/book/read/config/BgTextConfigDialog.kt
  4. 2
      app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt

@ -93,7 +93,7 @@ object ReadBookConfig {
val dm = resources.displayMetrics val dm = resources.displayMetrics
val width = dm.widthPixels val width = dm.widthPixels
val height = dm.heightPixels val height = dm.heightPixels
bg = durConfig.bgDrawable(width, height).apply { bg = durConfig.curBgDrawable(width, height).apply {
if (this is BitmapDrawable) { if (this is BitmapDrawable) {
bgMeanColor = BitmapUtils.getMeanColor(bitmap) bgMeanColor = BitmapUtils.getMeanColor(bitmap)
} else if (this is ColorDrawable) { } else if (this is ColorDrawable) {
@ -413,22 +413,6 @@ object ReadBookConfig {
var hideHeader: Boolean = true, var hideHeader: Boolean = true,
var hideFooter: Boolean = false var hideFooter: Boolean = false
) : Parcelable { ) : Parcelable {
fun setCurBg(bgType: Int, bg: String) {
when {
AppConfig.isEInkMode -> {
bgTypeEInk = bgType
bgStrEInk = bg
}
AppConfig.isNightTheme -> {
bgTypeNight = bgType
bgStrNight = bg
}
else -> {
this.bgType = bgType
bgStr = bg
}
}
}
fun setCurTextColor(color: Int) { fun setCurTextColor(color: Int) {
when { when {
@ -439,7 +423,15 @@ object ReadBookConfig {
ChapterProvider.upStyle() ChapterProvider.upStyle()
} }
fun setStatusIconDark(isDark: Boolean) { fun curTextColor(): Int {
return when {
AppConfig.isEInkMode -> Color.parseColor(textColorEInk)
AppConfig.isNightTheme -> Color.parseColor(textColorNight)
else -> Color.parseColor(textColor)
}
}
fun setCurStatusIconDark(isDark: Boolean) {
when { when {
AppConfig.isEInkMode -> darkStatusIconEInk = isDark AppConfig.isEInkMode -> darkStatusIconEInk = isDark
AppConfig.isNightTheme -> darkStatusIconNight = isDark AppConfig.isNightTheme -> darkStatusIconNight = isDark
@ -447,7 +439,7 @@ object ReadBookConfig {
} }
} }
fun statusIconDark(): Boolean { fun curStatusIconDark(): Boolean {
return when { return when {
AppConfig.isEInkMode -> darkStatusIconEInk AppConfig.isEInkMode -> darkStatusIconEInk
AppConfig.isNightTheme -> darkStatusIconNight AppConfig.isNightTheme -> darkStatusIconNight
@ -469,11 +461,20 @@ object ReadBookConfig {
} }
} }
fun curTextColor(): Int { fun setCurBg(bgType: Int, bg: String) {
return when { when {
AppConfig.isEInkMode -> Color.parseColor(textColorEInk) AppConfig.isEInkMode -> {
AppConfig.isNightTheme -> Color.parseColor(textColorNight) bgTypeEInk = bgType
else -> Color.parseColor(textColor) bgStrEInk = bg
}
AppConfig.isNightTheme -> {
bgTypeNight = bgType
bgStrNight = bg
}
else -> {
this.bgType = bgType
bgStr = bg
}
} }
} }
@ -493,7 +494,7 @@ object ReadBookConfig {
} }
} }
fun bgDrawable(width: Int, height: Int): Drawable { fun curBgDrawable(width: Int, height: Int): Drawable {
var bgDrawable: Drawable? = null var bgDrawable: Drawable? = null
val resources = App.INSTANCE.resources val resources = App.INSTANCE.resources
try { try {

@ -59,7 +59,7 @@ object ReadBookActivityHelp {
} }
window.decorView.systemUiVisibility = flag window.decorView.systemUiVisibility = flag
if (toolBarHide) { if (toolBarHide) {
ATH.setLightStatusBar(window, ReadBookConfig.durConfig.statusIconDark()) ATH.setLightStatusBar(window, ReadBookConfig.durConfig.curStatusIconDark())
} else { } else {
ATH.setLightStatusBarAuto( ATH.setLightStatusBarAuto(
window, window,

@ -108,7 +108,7 @@ class BgTextConfigDialog : BaseDialogFragment(), FileChooserDialog.CallBack {
@SuppressLint("InflateParams") @SuppressLint("InflateParams")
private fun initData() = with(ReadBookConfig.durConfig) { private fun initData() = with(ReadBookConfig.durConfig) {
sw_dark_status_icon.isChecked = statusIconDark() sw_dark_status_icon.isChecked = curStatusIconDark()
adapter = BgAdapter(requireContext()) adapter = BgAdapter(requireContext())
recycler_view.adapter = adapter recycler_view.adapter = adapter
val headerView = LayoutInflater.from(requireContext()) val headerView = LayoutInflater.from(requireContext())
@ -127,7 +127,7 @@ class BgTextConfigDialog : BaseDialogFragment(), FileChooserDialog.CallBack {
private fun initEvent() = with(ReadBookConfig.durConfig) { private fun initEvent() = with(ReadBookConfig.durConfig) {
sw_dark_status_icon.onCheckedChange { buttonView, isChecked -> sw_dark_status_icon.onCheckedChange { buttonView, isChecked ->
if (buttonView?.isPressed == true) { if (buttonView?.isPressed == true) {
setStatusIconDark(isChecked) setCurStatusIconDark(isChecked)
(activity as? ReadBookActivity)?.upSystemUiVisibility() (activity as? ReadBookActivity)?.upSystemUiVisibility()
} }
} }

@ -247,7 +247,7 @@ class ReadStyleDialog : BaseDialogFragment(), FontSelectDialog.CallBack {
) { ) {
holder.itemView.apply { holder.itemView.apply {
iv_style.setTextColor(item.curTextColor()) iv_style.setTextColor(item.curTextColor())
iv_style.setImageDrawable(item.bgDrawable(100, 150)) iv_style.setImageDrawable(item.curBgDrawable(100, 150))
if (ReadBookConfig.styleSelect == holder.layoutPosition) { if (ReadBookConfig.styleSelect == holder.layoutPosition) {
iv_style.borderColor = accentColor iv_style.borderColor = accentColor
iv_style.setTextBold(true) iv_style.setTextBold(true)

Loading…
Cancel
Save