添加重新分段功能,针对每本书,在菜单里

pull/443/head
gedoor 4 years ago
parent 703e503810
commit 3ba16a7727
  1. 21
      app/src/main/java/io/legado/app/help/BookHelp.kt
  2. 8
      app/src/main/java/io/legado/app/service/help/ReadBook.kt
  3. 8
      app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentActivity.kt

@ -318,23 +318,24 @@ object BookHelp {
} }
suspend fun disposeContent( suspend fun disposeContent(
book: Book,
title: String, title: String,
name: String,
origin: String?,
content: String, content: String,
enableReplace: Boolean,
): List<String> { ): List<String> {
var title1 = title var title1 = title
var content1 = content var content1 = content
if (enableReplace) { if (book.getReSegment()) {
content1 = ContentHelp.reSegment(content1, title1)
}
if (book.getUseReplaceRule()) {
synchronized(this) { synchronized(this) {
if (bookName != name || bookOrigin != origin) { if (bookName != book.name || bookOrigin != book.origin) {
bookName = name bookName = book.name
bookOrigin = origin bookOrigin = book.origin
replaceRules = if (origin.isNullOrEmpty()) { replaceRules = if (bookOrigin.isNullOrEmpty()) {
App.db.replaceRuleDao().findEnabledByScope(name) App.db.replaceRuleDao().findEnabledByScope(bookName!!)
} else { } else {
App.db.replaceRuleDao().findEnabledByScope(name, origin) App.db.replaceRuleDao().findEnabledByScope(bookName!!, bookOrigin!!)
} }
} }
} }

@ -378,13 +378,7 @@ object ReadBook {
2 -> HanLP.convertToTraditionalChinese(chapter.title) 2 -> HanLP.convertToTraditionalChinese(chapter.title)
else -> chapter.title else -> chapter.title
} }
val contents = BookHelp.disposeContent( val contents = BookHelp.disposeContent(book, chapter.title, content)
chapter.title,
book.name,
webBook?.bookSource?.bookSourceUrl,
content,
book.getUseReplaceRule()
)
when (chapter.index) { when (chapter.index) {
durChapterIndex -> { durChapterIndex -> {
curTextChapter = curTextChapter =

@ -177,13 +177,7 @@ class SearchContentActivity :
2 -> HanLP.convertToTraditionalChinese(chapter.title) 2 -> HanLP.convertToTraditionalChinese(chapter.title)
else -> chapter.title else -> chapter.title
} }
replaceContents = BookHelp.disposeContent( replaceContents = BookHelp.disposeContent(book, chapter.title, bookContent)
chapter.title,
book.name,
book.bookUrl,
bookContent,
book.getUseReplaceRule()
)
} }
job.await() job.await()
while (replaceContents == null) { while (replaceContents == null) {

Loading…
Cancel
Save