pull/1303/head
gedoor 3 years ago
parent 9ea725b2ca
commit b6c5a3ab8d
  1. 11
      app/src/main/java/io/legado/app/help/ContentProcessor.kt
  2. 17
      app/src/main/java/io/legado/app/ui/book/cache/CacheViewModel.kt
  3. 4
      app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentActivity.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<String> {
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()) {
if (reSegment && book.getReSegment()) {
content1 = ContentHelp.reSegment(content1, title)
}
if (chineseConvert) {
try {
when (AppConfig.chineseConverterType) {
1 -> content1 = ChineseUtils.t2s(content1)

@ -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,

@ -185,7 +185,9 @@ class SearchContentActivity :
viewModel.contentProcessor!!.getContent(
book,
chapter.title,
bookContent
bookContent,
chineseConvert = false,
reSegment = false
)
}
totalContents = replaceContents?.joinToString("") ?: bookContent

Loading…
Cancel
Save