diff --git a/app/src/main/java/io/legado/app/constant/EventBus.kt b/app/src/main/java/io/legado/app/constant/EventBus.kt index 06264871c..0f93c36c0 100644 --- a/app/src/main/java/io/legado/app/constant/EventBus.kt +++ b/app/src/main/java/io/legado/app/constant/EventBus.kt @@ -30,4 +30,5 @@ object EventBus { const val SEARCH_RESULT = "searchResult" const val FILE_SOURCE_DOWNLOAD_DONE = "fileSourceDownloadDone" const val updateReadActionBar = "updateReadActionBar" + const val UP_SEEK_BAR = "upSeekBar" } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/constant/PreferKey.kt b/app/src/main/java/io/legado/app/constant/PreferKey.kt index c2cd4488a..de97e0f18 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -114,6 +114,7 @@ object PreferKey { const val asyncLoadImage = "asyncLoadImage" const val ignoreAudioFocus = "ignoreAudioFocus" const val parallelExportBook = "parallelExportBook" + const val progressBarBehavior = "progressBarBehavior" const val cPrimary = "colorPrimary" const val cAccent = "colorAccent" diff --git a/app/src/main/java/io/legado/app/help/book/ContentProcessor.kt b/app/src/main/java/io/legado/app/help/book/ContentProcessor.kt index d600aafd6..615f5e6fc 100644 --- a/app/src/main/java/io/legado/app/help/book/ContentProcessor.kt +++ b/app/src/main/java/io/legado/app/help/book/ContentProcessor.kt @@ -136,6 +136,7 @@ class ContentProcessor private constructor( suspend fun replaceContent(content: String): String { var mContent = content + mContent = mContent.lines().joinToString("\n") { it.trim() } getContentReplaceRules().forEach { item -> if (item.pattern.isNotEmpty()) { try { diff --git a/app/src/main/java/io/legado/app/help/config/AppConfig.kt b/app/src/main/java/io/legado/app/help/config/AppConfig.kt index 16006ccc8..f384fdd35 100644 --- a/app/src/main/java/io/legado/app/help/config/AppConfig.kt +++ b/app/src/main/java/io/legado/app/help/config/AppConfig.kt @@ -339,6 +339,9 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener { val doublePageHorizontal: String? get() = appCtx.getPrefString(PreferKey.doublePageHorizontal) + val progressBarBehavior: String? + get() = appCtx.getPrefString(PreferKey.progressBarBehavior, "page") + var searchGroup: String get() = appCtx.getPrefString("searchGroup") ?: "" set(value) { diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index 92c1b84ff..f0039099a 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -757,7 +757,7 @@ class ReadBookActivity : BaseReadBookActivity(), launch { autoPageProgress = 0 binding.readView.upContent(relativePosition, resetPageOffset) - binding.readMenu.setSeekPage(ReadBook.durPageIndex) + upSeekBarProgress() loadStates = false success?.invoke() } @@ -775,11 +775,22 @@ class ReadBookActivity : BaseReadBookActivity(), override fun pageChanged() { launch { autoPageProgress = 0 - binding.readMenu.setSeekPage(ReadBook.durPageIndex) + upSeekBarProgress() startBackupJob() } } + /** + * 更新进度条位置 + */ + private fun upSeekBarProgress() { + val progress = when (AppConfig.progressBarBehavior) { + "page" -> ReadBook.durPageIndex + else /* chapter */ -> ReadBook.durChapterIndex + } + binding.readMenu.setSeekPage(progress) + } + /** * 显示菜单 */ @@ -915,6 +926,13 @@ class ReadBookActivity : BaseReadBookActivity(), } } + /** + * 跳转到指定章节 + */ + override fun skipToChapter(index: Int) { + viewModel.openChapter(index) + } + /** * 打开搜索界面 */ @@ -1282,6 +1300,9 @@ class ReadBookActivity : BaseReadBookActivity(), observeEvent(EventBus.updateReadActionBar) { binding.readMenu.reset() } + observeEvent(EventBus.UP_SEEK_BAR) { + binding.readMenu.upSeekBar() + } } private fun upScreenTimeOut() { diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt index 0f2c29aa5..0de1c6fb2 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt @@ -45,6 +45,7 @@ class ReadMenu @JvmOverloads constructor( var cnaShowMenu: Boolean = false private val callBack: CallBack get() = activity as CallBack private val binding = ViewReadMenuBinding.inflate(LayoutInflater.from(context), this, true) + private var confirmSkipToChapter: Boolean = false private val menuTopIn: Animation by lazy { loadAnimation(context, R.anim.anim_readbook_top_in) } @@ -370,7 +371,27 @@ class ReadMenu @JvmOverloads constructor( seekReadPage.setOnSeekBarChangeListener(object : SeekBarChangeListener { override fun onStopTrackingTouch(seekBar: SeekBar) { - ReadBook.skipToPage(seekBar.progress) + when (AppConfig.progressBarBehavior) { + "page" -> ReadBook.skipToPage(seekBar.progress) + "chapter" -> { + if (confirmSkipToChapter) { + callBack.skipToChapter(seekBar.progress) + } else { + context.alert("章节跳转确认", "确定要跳转章节吗?") { + yesButton { + confirmSkipToChapter = true + callBack.skipToChapter(seekBar.progress) + } + noButton { + upSeekBar() + } + onCancelled { + upSeekBar() + } + } + } + } + } } }) @@ -453,8 +474,7 @@ class ReadMenu @JvmOverloads constructor( } else { binding.tvChapterUrl.gone() } - binding.seekReadPage.max = it.pageSize.minus(1) - binding.seekReadPage.progress = ReadBook.durPageIndex + upSeekBar() binding.tvPre.isEnabled = ReadBook.durChapterIndex != 0 binding.tvNext.isEnabled = ReadBook.durChapterIndex != ReadBook.chapterSize - 1 } ?: let { @@ -463,6 +483,23 @@ class ReadMenu @JvmOverloads constructor( } } + fun upSeekBar() { + binding.seekReadPage.apply { + when (AppConfig.progressBarBehavior) { + "page" -> { + ReadBook.curTextChapter?.let { + max = it.pageSize.minus(1) + progress = ReadBook.durPageIndex + } + } + "chapter" -> { + max = ReadBook.chapterSize - 1 + progress = ReadBook.durChapterIndex + } + } + } + } + fun setSeekPage(seek: Int) { binding.seekReadPage.progress = seek } @@ -493,6 +530,7 @@ class ReadMenu @JvmOverloads constructor( fun showLogin() fun payAction() fun disableSource() + fun skipToChapter(index: Int) } } diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt index 3c194fc88..c1cef9cda 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt @@ -137,6 +137,9 @@ class MoreConfigDialog : DialogFragment() { PreferKey.readBarStyleFollowPage -> { postEvent(EventBus.updateReadActionBar, true) } + PreferKey.progressBarBehavior -> { + postEvent(EventBus.UP_SEEK_BAR, true) + } } } diff --git a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt index 3b5270e19..6b6ed9c71 100644 --- a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt +++ b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt @@ -234,6 +234,9 @@ class MainActivity : VMBaseActivity(), mode = HandleFileContract.DIR_SYS } } + neutralButton("不想设置") { + AppConfig.defaultBookTreeUri = "null" + } noButton() } } diff --git a/app/src/main/res/values-es-rES/strings.xml b/app/src/main/res/values-es-rES/strings.xml index 56b1127ea..55004a263 100644 --- a/app/src/main/res/values-es-rES/strings.xml +++ b/app/src/main/res/values-es-rES/strings.xml @@ -1036,4 +1036,5 @@ 网络未分组 本地未分组 多线程导出TXT + 进度条行为 diff --git a/app/src/main/res/values-ja-rJP/strings.xml b/app/src/main/res/values-ja-rJP/strings.xml index 2a7944adb..448507a49 100644 --- a/app/src/main/res/values-ja-rJP/strings.xml +++ b/app/src/main/res/values-ja-rJP/strings.xml @@ -1039,4 +1039,5 @@ 网络未分组 本地未分组 多线程导出TXT + 进度条行为 diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index cbcf6aec8..e2316f37c 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -1039,4 +1039,5 @@ 网络未分组 本地未分组 多线程导出TXT + 进度条行为 diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index b1e5be0ef..a8cb317f0 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -1036,4 +1036,5 @@ 网络未分组 本地未分组 多线程导出TXT + 进度条行为 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 981bf2d92..bac10fc7f 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -1038,4 +1038,5 @@ 网络未分组 本地未分组 多线程导出TXT + 进度条行为 diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 44c0a32ef..7a706bbc2 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -1038,4 +1038,5 @@ 网络未分组 本地未分组 多线程导出TXT + 进度条行为 diff --git a/app/src/main/res/values/array_values.xml b/app/src/main/res/values/array_values.xml index fe4cf386d..a6d6ce6c8 100644 --- a/app/src/main/res/values/array_values.xml +++ b/app/src/main/res/values/array_values.xml @@ -39,6 +39,11 @@ 2 + + page + chapter + + auto zh diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index d5202d585..7ae91f3d4 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -67,6 +67,11 @@ 横屏双页 竖屏单页 + + 调整本章页数 + 调整章节位置 + + iconMain icon1 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5cb0268b9..1d2d888ec 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1039,4 +1039,5 @@ 网络未分组 本地未分组 多线程导出TXT + 进度条行为 diff --git a/app/src/main/res/xml/pref_config_read.xml b/app/src/main/res/xml/pref_config_read.xml index 7dd8acfe4..b33a9b1e5 100644 --- a/app/src/main/res/xml/pref_config_read.xml +++ b/app/src/main/res/xml/pref_config_read.xml @@ -50,6 +50,15 @@ app:iconSpaceReserved="false" app:isBottomBackground="true" /> + +