txt均分目录添加开关

pull/1592/head
Xwite 3 years ago
parent f528d3a550
commit 1c721dfb0c
  1. 2
      app/src/main/assets/updateLog.md
  2. 9
      app/src/main/java/io/legado/app/data/entities/Book.kt
  3. 3
      app/src/main/java/io/legado/app/model/localBook/TextFile.kt
  4. 12
      app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt
  5. 6
      app/src/main/res/menu/book_info.xml
  6. 2
      app/src/main/res/values-es-rES/strings.xml
  7. 2
      app/src/main/res/values-ja-rJP/strings.xml
  8. 2
      app/src/main/res/values-zh-rHK/strings.xml
  9. 2
      app/src/main/res/values-zh-rTW/strings.xml
  10. 2
      app/src/main/res/values-zh/strings.xml
  11. 2
      app/src/main/res/values/strings.xml

@ -15,7 +15,7 @@
* 校验失效分组具体到搜索发现目录正文
* txt文件初次解析目录不选择禁用的正则
* txt单章字数超102400均分txt
* txt单章字数超102400均分txt,添加开关
**2022/02/03**

@ -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,//去除标签

@ -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<Pattern>()
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()
}

@ -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<AppLogDialog>()
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)
}

@ -55,6 +55,12 @@
android:checkable="true"
app:showAsAction="never" />
<item
android:id="@+id/menu_limit_content_length"
android:title="@string/limit_content_length"
android:checkable="true"
app:showAsAction="never" />
<item
android:id="@+id/menu_clear_cache"
android:title="@string/clear_cache"

@ -334,6 +334,8 @@
<string name="tip_margin_change">Ajuste de margen</string>
<string name="allow_update">Activar actualizaciones</string>
<string name="disable_update">Desactivar actualizaciones</string>
<string name="limit_content_length">限制正文长度</string>
<string name="need_more_time_load_content">正文长度过长时,加载正文可能会花费更多时间</string>
<string name="revert_selection">Invertir</string>
<string name="search_book_key">Buscar libro por nombre o autor</string>
<string name="debug_hint">Nombre del libro, autor, URL</string>

@ -338,6 +338,8 @@
<string name="tip_margin_change">Margin adjustment</string>
<string name="allow_update">Enable update</string>
<string name="disable_update">Disable update</string>
<string name="limit_content_length">限制正文长度</string>
<string name="need_more_time_load_content">正文长度过长时,加载正文可能会花费更多时间</string>
<string name="revert_selection">Inverse</string>
<string name="search_book_key">Search book name/author</string>
<string name="debug_hint">Book name,Author,URL</string>

@ -335,6 +335,8 @@
<string name="tip_margin_change">Tip 邊距跟隨邊距調整</string>
<string name="allow_update">允許更新</string>
<string name="disable_update">禁止更新</string>
<string name="limit_content_length">限制正文长度</string>
<string name="need_more_time_load_content">正文长度过长时,加载正文可能会花费更多时间</string>
<string name="revert_selection">反選</string>
<string name="search_book_key">搜索書名、作者</string>
<string name="debug_hint">書名、作者、URL</string>

@ -337,6 +337,8 @@
<string name="tip_margin_change">Tip邊距跟隨邊距調整</string>
<string name="allow_update">允許更新</string>
<string name="disable_update">禁止更新</string>
<string name="limit_content_length">限制正文长度</string>
<string name="need_more_time_load_content">正文长度过长时,加载正文可能会花费更多时间</string>
<string name="revert_selection">反選</string>
<string name="search_book_key">搜尋書名、作者</string>
<string name="debug_hint">書名、作者、URL</string>

@ -337,6 +337,8 @@
<string name="tip_margin_change">Tip边距跟随边距调整</string>
<string name="allow_update">允许更新</string>
<string name="disable_update">禁止更新</string>
<string name="limit_content_length">限制正文长度</string>
<string name="need_more_time_load_content">正文长度过长时,加载正文可能会花费更多时间</string>
<string name="revert_selection">反选</string>
<string name="search_book_key">搜索书名、作者</string>
<string name="debug_hint">书名、作者、URL</string>

@ -338,6 +338,8 @@
<string name="tip_margin_change">Margin adjustment</string>
<string name="allow_update">Enable update</string>
<string name="disable_update">Disable update</string>
<string name="limit_content_length">限制正文长度</string>
<string name="need_more_time_load_content">正文长度过长时,加载正文可能会花费更多时间</string>
<string name="revert_selection">Inverse</string>
<string name="search_book_key">Search book name/author</string>
<string name="debug_hint">Book name,Author,URL</string>

Loading…
Cancel
Save