From b6c5a3ab8d917cbec223d60b697f2addcb00366a Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 8 Sep 2021 16:03:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/help/ContentProcessor.kt | 15 ++++++++------- .../legado/app/ui/book/cache/CacheViewModel.kt | 17 +++++++++++++---- .../book/searchContent/SearchContentActivity.kt | 4 +++- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/ContentProcessor.kt b/app/src/main/java/io/legado/app/help/ContentProcessor.kt index 71311086d..3fc097bdb 100644 --- a/app/src/main/java/io/legado/app/help/ContentProcessor.kt +++ b/app/src/main/java/io/legado/app/help/ContentProcessor.kt @@ -55,12 +55,13 @@ class ContentProcessor private constructor( book: Book, title: String, //已经经过简繁转换 content: String, - isRead: Boolean = true, includeTitle: Boolean = true, - useReplace: Boolean = book.getUseReplaceRule() + useReplace: Boolean = true, + chineseConvert: Boolean = true, + reSegment: Boolean = true ): List { var content1 = content - if (useReplace) { + if (useReplace && book.getUseReplaceRule()) { getReplaceRules().forEach { item -> if (item.pattern.isNotEmpty()) { try { @@ -75,10 +76,10 @@ class ContentProcessor private constructor( } } } - if (isRead) { - if (book.getReSegment()) { - content1 = ContentHelp.reSegment(content1, title) - } + if (reSegment && book.getReSegment()) { + content1 = ContentHelp.reSegment(content1, title) + } + if (chineseConvert) { try { when (AppConfig.chineseConverterType) { 1 -> content1 = ChineseUtils.t2s(content1) diff --git a/app/src/main/java/io/legado/app/ui/book/cache/CacheViewModel.kt b/app/src/main/java/io/legado/app/ui/book/cache/CacheViewModel.kt index 206baf27a..4a60240ff 100644 --- a/app/src/main/java/io/legado/app/ui/book/cache/CacheViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/cache/CacheViewModel.kt @@ -144,9 +144,10 @@ class CacheViewModel(application: Application) : BaseViewModel(application) { book, chapter.title.replace("\\r?\\n".toRegex(), " "), content ?: "null", - false, - !AppConfig.exportNoChapterName, - useReplace + includeTitle = !AppConfig.exportNoChapterName, + useReplace = useReplace, + chineseConvert = false, + reSegment = false ).joinToString("\n") append.invoke("\n\n$content1") } @@ -393,7 +394,15 @@ class CacheViewModel(application: Application) : BaseViewModel(application) { BookHelp.getContent(book, chapter).let { content -> var content1 = fixPic(epubBook, book, content ?: "null", chapter) content1 = contentProcessor - .getContent(book, "", content1, false, useReplace) + .getContent( + book, + chapter.title, + content1, + includeTitle = false, + useReplace = useReplace, + chineseConvert = false, + reSegment = false + ) .joinToString("\n") epubBook.addSection( chapter.title, diff --git a/app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentActivity.kt b/app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentActivity.kt index 77382d7c5..944137d25 100644 --- a/app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentActivity.kt @@ -185,7 +185,9 @@ class SearchContentActivity : viewModel.contentProcessor!!.getContent( book, chapter.title, - bookContent + bookContent, + chineseConvert = false, + reSegment = false ) } totalContents = replaceContents?.joinToString("") ?: bookContent