Merge pull request #1929 from Xwite/master

fix: skip to load volume content
pull/1935/head
kunfei 3 years ago committed by GitHub
commit eca81ce75f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      app/src/main/assets/help/readMenuHelp.md
  2. 2
      app/src/main/java/io/legado/app/help/ContentProcessor.kt
  3. 26
      app/src/main/java/io/legado/app/model/localBook/EpubFile.kt
  4. 2
      app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentViewModel.kt
  5. 2
      app/src/main/res/values-es-rES/strings.xml
  6. 2
      app/src/main/res/values-ja-rJP/strings.xml
  7. 2
      app/src/main/res/values-pt-rBR/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,6 +15,10 @@
* 界面->所有排版设置都在里面 * 界面->所有排版设置都在里面
* 设置->其它一些设置,找不到的设置去这里看看,可滚动 * 设置->其它一些设置,找不到的设置去这里看看,可滚动
## 全文搜索
搜索本地缓存或者本地文件,不能搜索在线内容
如果搜索结果不符合预期,确保`替换净化`没有启用`内容替换`类规则(如替换主人公姓名)
## 朗读设置界面 ## 朗读设置界面
* 后台->进入后台朗读,可以做一些其它事 * 后台->进入后台朗读,可以做一些其它事
* 设置->朗读引擎设置,可以切换本地TTS和在线朗读,在线朗读可自定义 * 设置->朗读引擎设置,可以切换本地TTS和在线朗读,在线朗读可自定义

@ -85,7 +85,7 @@ class ContentProcessor private constructor(
try { try {
val name = Pattern.quote(book.name) val name = Pattern.quote(book.name)
val title = Pattern.quote(chapter.title) val title = Pattern.quote(chapter.title)
val titleRegex = "^(\\s|\\p{P}|${name})*${title}(\\s)+".toRegex() val titleRegex = "^(\\s|\\p{P}|${name})*${title}(\\s)*".toRegex()
mContent = mContent.replace(titleRegex, "") mContent = mContent.replace(titleRegex, "")
} catch (e: Exception) { } catch (e: Exception) {
AppLog.put("去除重复标题出错\n${e.localizedMessage}", e) AppLog.put("去除重复标题出错\n${e.localizedMessage}", e)

@ -121,14 +121,11 @@ class EpubFile(var book: Book) {
} }
private fun getContent(chapter: BookChapter): String? { private fun getContent(chapter: BookChapter): String? {
/*获取当前章节文本*/
epubBook?.let { epubBook ->
val nextUrl = chapter.getVariable("nextUrl") val nextUrl = chapter.getVariable("nextUrl")
val startFragmentId = chapter.startFragmentId val startFragmentId = chapter.startFragmentId
val endFragmentId = chapter.endFragmentId val endFragmentId = chapter.endFragmentId
/*当前章节resource href 和下一章href相同时 应该视为二级目录 返回空白*/
//fix https://github.com/gedoor/legado/issues/1927 加载全部内容的bug
if (chapter.isVolume) return ""
/*获取当前章节文本*/
epubBook?.let { epubBook ->
val elements = Elements() val elements = Elements()
var isChapter = false var isChapter = false
/*一些书籍依靠href索引的resource会包含多个章节,需要依靠fragmentId来截取到当前章节的内容*/ /*一些书籍依靠href索引的resource会包含多个章节,需要依靠fragmentId来截取到当前章节的内容*/
@ -137,6 +134,12 @@ class EpubFile(var book: Book) {
if (chapter.url.substringBeforeLast("#") == res.href) { if (chapter.url.substringBeforeLast("#") == res.href) {
elements.add(getBody(res, startFragmentId, endFragmentId)) elements.add(getBody(res, startFragmentId, endFragmentId))
isChapter = true isChapter = true
/**
* fix https://github.com/gedoor/legado/issues/1927 加载全部内容的bug
* content src text/000001.html当前章节
- * content src text/000001.html#toc_id_x (下一章节
*/
if (!nextUrl.isNullOrBlank() && res.href == nextUrl!!.substringBeforeLast("#")) break
} else if (isChapter) { } else if (isChapter) {
if (nextUrl.isNullOrBlank() || res.href == nextUrl.substringBeforeLast("#")) { if (nextUrl.isNullOrBlank() || res.href == nextUrl.substringBeforeLast("#")) {
break break
@ -160,7 +163,10 @@ class EpubFile(var book: Book) {
body.getElementById(startFragmentId)?.previousElementSiblings()?.remove() body.getElementById(startFragmentId)?.previousElementSiblings()?.remove()
} }
if (!endFragmentId.isNullOrBlank() && endFragmentId != startFragmentId) { if (!endFragmentId.isNullOrBlank() && endFragmentId != startFragmentId) {
body.getElementById(endFragmentId)?.nextElementSiblings()?.remove() body.getElementById(endFragmentId)?.run {
nextElementSiblings()?.remove()
remove()
}
} }
/*选择去除正文中的H标签,部分书籍标题与阅读标题重复待优化*/ /*选择去除正文中的H标签,部分书籍标题与阅读标题重复待优化*/
val tag = Book.hTag val tag = Book.hTag
@ -311,18 +317,12 @@ class EpubFile(var book: Book) {
chapter.url = ref.completeHref chapter.url = ref.completeHref
chapter.startFragmentId = ref.fragmentId chapter.startFragmentId = ref.fragmentId
chapterList.lastOrNull()?.endFragmentId = chapter.startFragmentId chapterList.lastOrNull()?.endFragmentId = chapter.startFragmentId
/**
* 二级目录判定
* content src text/000001.html (二级目录上一章节
* content src text/000001.html#toc_id_x (当前章节
*/
val isVolume = chapter.url.substringBeforeLast("#") == chapterList.lastOrNull()?.url?.substringBeforeLast("#")
chapterList.lastOrNull()?.isVolume = isVolume
chapterList.lastOrNull()?.putVariable("nextUrl", chapter.url) chapterList.lastOrNull()?.putVariable("nextUrl", chapter.url)
chapterList.add(chapter) chapterList.add(chapter)
durIndex++ durIndex++
} }
if (ref.children != null && ref.children.isNotEmpty()) { if (ref.children != null && ref.children.isNotEmpty()) {
chapterList.lastOrNull()?.isVolume = true
parseMenu(chapterList, ref.children, level + 1) parseMenu(chapterList, ref.children, level + 1)
} }
} }

@ -50,7 +50,7 @@ class SearchContentViewModel(application: Application) : BaseViewModel(applicati
} }
mContent = contentProcessor!!.getContent( mContent = contentProcessor!!.getContent(
book, chapter, chapterContent, book, chapter, chapterContent,
chineseConvert = false, chineseConvert = true,
reSegment = false, reSegment = false,
useReplace = false useReplace = false
).joinToString("") ).joinToString("")

@ -910,7 +910,7 @@
<string name="font_scale">字体大小</string> <string name="font_scale">字体大小</string>
<string name="font_scale_summary">当前字体大小:%.1f</string> <string name="font_scale_summary">当前字体大小:%.1f</string>
<string name="search_content_size">search result</string> <string name="search_content_size">search result</string>
<string name="search_content_empty">search result is empty</string> <string name="search_content_empty">Empty search result, check conversation settings</string>
<string name="tts_speech_reduce">语速减</string> <string name="tts_speech_reduce">语速减</string>
<string name="tts_speech_add">语速加</string> <string name="tts_speech_add">语速加</string>
<string name="open_sys_dir_picker_error">打开系统文件夹选择器出错,自动打开应用文件夹选择器</string> <string name="open_sys_dir_picker_error">打开系统文件夹选择器出错,自动打开应用文件夹选择器</string>

@ -913,7 +913,7 @@
<string name="font_scale">字体大小</string> <string name="font_scale">字体大小</string>
<string name="font_scale_summary">当前字体大小:%.1f</string> <string name="font_scale_summary">当前字体大小:%.1f</string>
<string name="search_content_size">search result</string> <string name="search_content_size">search result</string>
<string name="search_content_empty">search result is empty</string> <string name="search_content_empty">Empty search result, check conversation settings</string>
<string name="tts_speech_reduce">语速减</string> <string name="tts_speech_reduce">语速减</string>
<string name="tts_speech_add">语速加</string> <string name="tts_speech_add">语速加</string>
<string name="open_sys_dir_picker_error">打开系统文件夹选择器出错,自动打开应用文件夹选择器</string> <string name="open_sys_dir_picker_error">打开系统文件夹选择器出错,自动打开应用文件夹选择器</string>

@ -911,7 +911,7 @@
<string name="font_scale">字体大小</string> <string name="font_scale">字体大小</string>
<string name="font_scale_summary">当前字体大小:%.1f</string> <string name="font_scale_summary">当前字体大小:%.1f</string>
<string name="search_content_size">search result</string> <string name="search_content_size">search result</string>
<string name="search_content_empty">search result is empty</string> <string name="search_content_empty">Empty search result, check conversation settings</string>
<string name="tts_speech_reduce">语速减</string> <string name="tts_speech_reduce">语速减</string>
<string name="tts_speech_add">语速加</string> <string name="tts_speech_add">语速加</string>
<string name="open_sys_dir_picker_error">打开系统文件夹选择器出错,自动打开应用文件夹选择器</string> <string name="open_sys_dir_picker_error">打开系统文件夹选择器出错,自动打开应用文件夹选择器</string>

@ -904,7 +904,7 @@
<string name="use_browser_open">是否使用外部瀏覽器打開?</string> <string name="use_browser_open">是否使用外部瀏覽器打開?</string>
<string name="see">查看</string> <string name="see">查看</string>
<string name="search_content_size">搜索結果</string> <string name="search_content_size">搜索結果</string>
<string name="search_content_empty">搜索結果为空</string> <string name="search_content_empty">搜索内容为空,检查净化/简繁设置</string>
<string name="open">打開</string> <string name="open">打開</string>
<string name="del_login_header">刪除登錄頭</string> <string name="del_login_header">刪除登錄頭</string>
<string name="show_login_header">查看登錄頭</string> <string name="show_login_header">查看登錄頭</string>

@ -917,7 +917,7 @@
<string name="open_sys_doc_picker_error">打開系統檔案選擇器出錯,自動打開應用文件選擇器</string> <string name="open_sys_doc_picker_error">打開系統檔案選擇器出錯,自動打開應用文件選擇器</string>
<string name="expand_text_menu">展開文字選擇選單</string> <string name="expand_text_menu">展開文字選擇選單</string>
<string name="search_content_size">搜尋結果</string> <string name="search_content_size">搜尋結果</string>
<string name="search_content_empty">尋結果為空</string> <string name="search_content_empty">索内容为空,检查净化/简繁设置</string>
<string name="book_tree_uri_t">書籍儲存位置</string> <string name="book_tree_uri_t">書籍儲存位置</string>
<string name="book_tree_uri_s">從其它應用程式打開的書籍儲存位置</string> <string name="book_tree_uri_s">從其它應用程式打開的書籍儲存位置</string>
<string name="select_book_folder">選擇儲存書籍的資料夾</string> <string name="select_book_folder">選擇儲存書籍的資料夾</string>

@ -780,7 +780,7 @@
<string name="sort_by_lastUpdateTime">更新时间排序</string> <string name="sort_by_lastUpdateTime">更新时间排序</string>
<string name="search_content">全文搜索</string> <string name="search_content">全文搜索</string>
<string name="search_content_size">搜索结果</string> <string name="search_content_size">搜索结果</string>
<string name="search_content_empty">搜索结果为空</string> <string name="search_content_empty">搜索内容为空,检查净化/简繁设置</string>
<string name="rss_source_empty">Empty now!</string> <string name="rss_source_empty">Empty now!</string>
<string name="explore_empty">当前没有发现源!</string> <string name="explore_empty">当前没有发现源!</string>
<string name="page_key_set_help">将焦点放到输入框按下物理按键会自动录入键值,多个按键会自动用英文逗号隔开.</string> <string name="page_key_set_help">将焦点放到输入框按下物理按键会自动录入键值,多个按键会自动用英文逗号隔开.</string>

@ -913,7 +913,7 @@
<string name="font_scale">font scale</string> <string name="font_scale">font scale</string>
<string name="font_scale_summary">font scale:%.1f</string> <string name="font_scale_summary">font scale:%.1f</string>
<string name="search_content_size">search result</string> <string name="search_content_size">search result</string>
<string name="search_content_empty">search result is empty</string> <string name="search_content_empty">Empty search result, check conversation settings</string>
<string name="tts_speech_reduce">语速减</string> <string name="tts_speech_reduce">语速减</string>
<string name="tts_speech_add">语速加</string> <string name="tts_speech_add">语速加</string>
<string name="open_sys_dir_picker_error">打开系统文件夹选择器出错,自动打开应用文件夹选择器</string> <string name="open_sys_dir_picker_error">打开系统文件夹选择器出错,自动打开应用文件夹选择器</string>

Loading…
Cancel
Save