diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 61be7e0ee..19101632f 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -15,7 +15,7 @@ * 校验失效分组具体到搜索发现目录正文 * txt文件初次解析目录不选择禁用的正则 -* txt单章字数超102400均分txt +* txt单章字数超102400均分txt,添加开关 **2022/02/03** diff --git a/app/src/main/java/io/legado/app/data/entities/Book.kt b/app/src/main/java/io/legado/app/data/entities/Book.kt index 999a40c2e..8384e7305 100644 --- a/app/src/main/java/io/legado/app/data/entities/Book.kt +++ b/app/src/main/java/io/legado/app/data/entities/Book.kt @@ -160,6 +160,14 @@ data class Book( config().reSegment = reSegment } + fun getLimitContentLength(): Boolean { + return config().limitContentLength + } + + fun setLimitContentLength(limitContentLength: Boolean) { + config().limitContentLength = limitContentLength + } + fun getPageAnim(): Int { return config().pageAnim } @@ -270,6 +278,7 @@ data class Book( var reverseToc: Boolean = false, var pageAnim: Int = -1, var reSegment: Boolean = false, + var limitContentLength: Boolean = true, //txt规则解析目录时超过规定的最大字数时均分txt var imageStyle: String? = null, var useReplaceRule: Boolean = AppConfig.replaceEnableDefault,// 正文使用净化替换规则 var delTag: Long = 0L,//去除标签 diff --git a/app/src/main/java/io/legado/app/model/localBook/TextFile.kt b/app/src/main/java/io/legado/app/model/localBook/TextFile.kt index e39c4f007..3cef1f76e 100644 --- a/app/src/main/java/io/legado/app/model/localBook/TextFile.kt +++ b/app/src/main/java/io/legado/app/model/localBook/TextFile.kt @@ -47,6 +47,7 @@ class TextFile(private val book: Book) { private val maxLengthWithNoToc = 10 * 1024 //使用正则划分目录,每个章节的最大允许长度 private val maxLengthWithToc = 102400 + private val limitContentLength = book.getLimitContentLength() private val tocRules = arrayListOf() private var charset: Charset = book.fileCharset() @@ -128,7 +129,7 @@ class TextFile(private val book: Book) { val chapterContent = blockContent.substring(seekPos, chapterStart) val chapterLength = chapterContent.toByteArray(charset).size val lastStart = toc.lastOrNull()?.start ?: curOffset - if (curOffset + chapterLength - lastStart > maxLengthWithToc) { + if (limitContentLength && curOffset + chapterLength - lastStart > maxLengthWithToc) { bis.close() return analyze() } diff --git a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt index 12e8d132f..7a48b95c9 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt @@ -118,12 +118,16 @@ class BookInfoActivity : override fun onMenuOpened(featureId: Int, menu: Menu): Boolean { menu.findItem(R.id.menu_can_update)?.isChecked = viewModel.bookData.value?.canUpdate ?: true + menu.findItem(R.id.menu_limit_content_length)?.isChecked = + viewModel.bookData.value?.getLimitContentLength() ?: false menu.findItem(R.id.menu_login)?.isVisible = !viewModel.bookSource?.loginUrl.isNullOrBlank() menu.findItem(R.id.menu_set_source_variable)?.isVisible = viewModel.bookSource != null menu.findItem(R.id.menu_set_book_variable)?.isVisible = viewModel.bookSource != null + menu.findItem(R.id.menu_limit_content_length)?.isVisible = + viewModel.bookSource == null return super.onMenuOpened(featureId, menu) } @@ -183,6 +187,14 @@ class BookInfoActivity : } R.id.menu_clear_cache -> viewModel.clearCache() R.id.menu_log -> showDialogFragment() + R.id.menu_limit_content_length -> { + upLoading(true) + viewModel.bookData.value?.let { + it.setLimitContentLength(!item.isChecked) + viewModel.loadBookInfo(it, false) + } + if (item.isChecked) longToastOnUi(R.string.need_more_time_load_content) + } } return super.onCompatOptionsItemSelected(item) } diff --git a/app/src/main/res/menu/book_info.xml b/app/src/main/res/menu/book_info.xml index 99b8c39ca..d324786f8 100644 --- a/app/src/main/res/menu/book_info.xml +++ b/app/src/main/res/menu/book_info.xml @@ -55,6 +55,12 @@ android:checkable="true" app:showAsAction="never" /> + + Ajuste de margen Activar actualizaciones Desactivar actualizaciones + 限制正文长度 + 正文长度过长时,加载正文可能会花费更多时间 Invertir Buscar libro por nombre o autor Nombre del libro, autor, URL diff --git a/app/src/main/res/values-ja-rJP/strings.xml b/app/src/main/res/values-ja-rJP/strings.xml index 7ee8d230b..353806354 100644 --- a/app/src/main/res/values-ja-rJP/strings.xml +++ b/app/src/main/res/values-ja-rJP/strings.xml @@ -338,6 +338,8 @@ Margin adjustment Enable update Disable update + 限制正文长度 + 正文长度过长时,加载正文可能会花费更多时间 Inverse Search book name/author Book name,Author,URL diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 891ea6dcb..ed5ae5cab 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -335,6 +335,8 @@ Tip 邊距跟隨邊距調整 允許更新 禁止更新 + 限制正文长度 + 正文长度过长时,加载正文可能会花费更多时间 反選 搜索書名、作者 書名、作者、URL diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index c1dd02fc1..e754d45f7 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -337,6 +337,8 @@ Tip邊距跟隨邊距調整 允許更新 禁止更新 + 限制正文长度 + 正文长度过长时,加载正文可能会花费更多时间 反選 搜尋書名、作者 書名、作者、URL diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 87e293862..219fdff47 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -337,6 +337,8 @@ Tip边距跟随边距调整 允许更新 禁止更新 + 限制正文长度 + 正文长度过长时,加载正文可能会花费更多时间 反选 搜索书名、作者 书名、作者、URL diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a8314a49f..17148d869 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -338,6 +338,8 @@ Margin adjustment Enable update Disable update + 限制正文长度 + 正文长度过长时,加载正文可能会花费更多时间 Inverse Search book name/author Book name,Author,URL