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 width = dm.widthPixels
val height = dm.heightPixels
bg = durConfig.bgDrawable(width, height).apply {
bg = durConfig.curBgDrawable(width, height).apply {
if (this is BitmapDrawable) {
bgMeanColor = BitmapUtils.getMeanColor(bitmap)
} else if (this is ColorDrawable) {
@ -413,22 +413,6 @@ object ReadBookConfig {
var hideHeader: Boolean = true,
var hideFooter: Boolean = false
) : 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) {
when {
@ -439,7 +423,15 @@ object ReadBookConfig {
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 {
AppConfig.isEInkMode -> darkStatusIconEInk = isDark
AppConfig.isNightTheme -> darkStatusIconNight = isDark
@ -447,7 +439,7 @@ object ReadBookConfig {
}
}
fun statusIconDark(): Boolean {
fun curStatusIconDark(): Boolean {
return when {
AppConfig.isEInkMode -> darkStatusIconEInk
AppConfig.isNightTheme -> darkStatusIconNight
@ -469,11 +461,20 @@ object ReadBookConfig {
}
}
fun curTextColor(): Int {
return when {
AppConfig.isEInkMode -> Color.parseColor(textColorEInk)
AppConfig.isNightTheme -> Color.parseColor(textColorNight)
else -> Color.parseColor(textColor)
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
}
}
}
@ -493,7 +494,7 @@ object ReadBookConfig {
}
}
fun bgDrawable(width: Int, height: Int): Drawable {
fun curBgDrawable(width: Int, height: Int): Drawable {
var bgDrawable: Drawable? = null
val resources = App.INSTANCE.resources
try {

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

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

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

Loading…
Cancel
Save