From d4d35f680ecfa6a2c3499208969b2792b3a7434b Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 2 Oct 2020 12:50:02 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BF=BB=E9=A1=B5=E5=8A=A8=E7=94=BB=E8=B7=9F?= =?UTF-8?q?=E9=9A=8F=E8=83=8C=E6=99=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/help/ReadBookConfig.kt | 29 +++++++++++++++---- .../io/legado/app/help/storage/Restore.kt | 2 -- .../ui/book/read/config/ReadStyleDialog.kt | 16 +++++----- app/src/main/res/values-zh-rHK/strings.xml | 1 - app/src/main/res/values-zh-rTW/strings.xml | 1 - app/src/main/res/values-zh/strings.xml | 1 - app/src/main/res/values/strings.xml | 1 - 7 files changed, 30 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt index 5cceab22d..118f5b6ca 100644 --- a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt +++ b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt @@ -158,12 +158,6 @@ object ReadBookConfig { App.INSTANCE.putPrefBoolean(PreferKey.shareLayout, value) } } - var pageAnim: Int - get() = if (AppConfig.isEInkMode) -1 else App.INSTANCE.getPrefInt(PreferKey.pageAnim) - set(value) { - App.INSTANCE.putPrefInt(PreferKey.pageAnim, value) - isScroll = pageAnim == 3 - } var isScroll = pageAnim == 3 val clickTurnPage get() = App.INSTANCE.getPrefBoolean(PreferKey.clickTurnPage, true) val textFullJustify get() = App.INSTANCE.getPrefBoolean(PreferKey.textFullJustify, true) @@ -182,6 +176,13 @@ object ReadBookConfig { val config get() = if (shareLayout) shareConfig else durConfig + var pageAnim: Int + get() = config.pageAnim() + set(value) { + config.setPageAnim(value) + isScroll = pageAnim == 3 + } + var textFont: String get() = config.textFont set(value) { @@ -379,6 +380,8 @@ object ReadBookConfig { private var textColor: String = "#3E3D3B",//白天文字颜色 private var textColorNight: String = "#ADADAD",//夜间文字颜色 private var textColorEInk: String = "#000000", + private var pageAnim: Int = 0, + private var pageAnimEInk: Int = 3, var textFont: String = "",//字体 var textBold: Int = 0,//是否粗体字 0:正常, 1:粗体, 2:细体 var textSize: Int = 20,//文字大小 @@ -454,6 +457,20 @@ object ReadBookConfig { } } + fun setPageAnim(anim: Int) { + when { + AppConfig.isEInkMode -> pageAnimEInk = anim + else -> pageAnim = anim + } + } + + fun pageAnim(): Int { + return when { + AppConfig.isEInkMode -> pageAnimEInk + else -> pageAnim + } + } + fun textColor(): Int { return when { AppConfig.isEInkMode -> Color.parseColor(textColorEInk) diff --git a/app/src/main/java/io/legado/app/help/storage/Restore.kt b/app/src/main/java/io/legado/app/help/storage/Restore.kt index 18880822e..b98a248d1 100644 --- a/app/src/main/java/io/legado/app/help/storage/Restore.kt +++ b/app/src/main/java/io/legado/app/help/storage/Restore.kt @@ -61,7 +61,6 @@ object Restore { private val readPrefKeys = arrayOf( PreferKey.readStyleSelect, PreferKey.shareLayout, - PreferKey.pageAnim, PreferKey.hideStatusBar, PreferKey.hideNavigationBar, PreferKey.bodyIndent, @@ -215,7 +214,6 @@ object Restore { ReadBookConfig.apply { styleSelect = App.INSTANCE.getPrefInt(PreferKey.readStyleSelect) shareLayout = App.INSTANCE.getPrefBoolean(PreferKey.shareLayout) - pageAnim = App.INSTANCE.getPrefInt(PreferKey.pageAnim) hideStatusBar = App.INSTANCE.getPrefBoolean(PreferKey.hideStatusBar) hideNavigationBar = App.INSTANCE.getPrefBoolean(PreferKey.hideNavigationBar) bodyIndentCount = App.INSTANCE.getPrefInt(PreferKey.bodyIndent, 2) diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt index 12201ae29..a791e6939 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt @@ -104,12 +104,7 @@ class ReadStyleDialog : BaseDialogFragment(), FontSelectDialog.CallBack { private fun initData() { cb_share_layout.isChecked = ReadBookConfig.shareLayout - ReadBookConfig.pageAnim.let { - if (it >= 0 && it < rg_page_anim.childCount) { - rg_page_anim.check(rg_page_anim[it].id) - } - } - upStyle() + upView() styleAdapter.setItems(ReadBookConfig.configList) } @@ -149,7 +144,7 @@ class ReadStyleDialog : BaseDialogFragment(), FontSelectDialog.CallBack { cb_share_layout.onCheckedChangeListener = { checkBox, isChecked -> if (checkBox.isPressed) { ReadBookConfig.shareLayout = isChecked - upStyle() + upView() postEvent(EventBus.UP_CONFIG, true) } } @@ -206,7 +201,7 @@ class ReadStyleDialog : BaseDialogFragment(), FontSelectDialog.CallBack { if (index != oldIndex) { ReadBookConfig.styleSelect = index ReadBookConfig.upBg() - upStyle() + upView() styleAdapter.notifyItemChanged(oldIndex) styleAdapter.notifyItemChanged(index) postEvent(EventBus.UP_CONFIG, true) @@ -220,8 +215,11 @@ class ReadStyleDialog : BaseDialogFragment(), FontSelectDialog.CallBack { return true } - private fun upStyle() { + private fun upView() { ReadBookConfig.let { + if (it.pageAnim >= 0 && it.pageAnim < rg_page_anim.childCount) { + rg_page_anim.check(rg_page_anim[it.pageAnim].id) + } dsb_text_size.progress = it.textSize - 5 dsb_text_letter_spacing.progress = (it.letterSpacing * 100).toInt() + 50 dsb_line_size.progress = it.lineSpacingExtra diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index de31599a4..7fb96aa3c 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -733,7 +733,6 @@ 替换规则(replaceRegex) 分組名稱 備註內容 - E-Ink模式下只有白纸黑字,不显示其它背景 默认启用替换净化 新加入书架的书是否启用替换净化 选择恢复文件 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 0d44a8fae..fe8f2752e 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -733,7 +733,6 @@ 取代規則(replaceRegex) 分組名稱 備註內容 - E-Ink模式下只有白紙黑字,不顯示其它背景 預設啟用取代淨化 新加入書架的書是否啟用取代淨化 選擇復原文件 diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index e3cc6c436..d9a62c811 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -738,7 +738,6 @@ 替换规则(replaceRegex) 分组名称 备注内容 - E-Ink模式下只有白纸黑字,不显示其它背景 默认启用替换净化 新加入书架的书是否启用替换净化 选择恢复文件 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b7fe8a37f..7e59bf3cf 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -739,7 +739,6 @@ Reading interface settings Group name Remarks section - Only white page black text in E-Ink mode Enable replace rule by default For new added books Select restore file