From 73dad59199f72c2f86ea233f0394b33b5b928237 Mon Sep 17 00:00:00 2001 From: Xwite <82232510+Xwite@users.noreply.github.com> Date: Sun, 9 Oct 2022 16:39:31 +0800 Subject: [PATCH 1/9] Update EpubFile.kt --- .../io/legado/app/model/localBook/EpubFile.kt | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/localBook/EpubFile.kt b/app/src/main/java/io/legado/app/model/localBook/EpubFile.kt index 52f54d313..4238f669b 100644 --- a/app/src/main/java/io/legado/app/model/localBook/EpubFile.kt +++ b/app/src/main/java/io/legado/app/model/localBook/EpubFile.kt @@ -92,7 +92,7 @@ class EpubFile(var book: Book) { cover.compress(Bitmap.CompressFormat.JPEG, 90, out) out.flush() out.close() - } + } ?: AppLog.put("封面获取为空") } } } catch (e: Exception) { @@ -131,22 +131,22 @@ class EpubFile(var book: Book) { val startFragmentId = chapter.startFragmentId val endFragmentId = chapter.endFragmentId val elements = Elements() - var isChapter = false + var hasMoreResources = false + val includeNextChapterResource = endFragmentId.isNullOrBlank() /*一些书籍依靠href索引的resource会包含多个章节,需要依靠fragmentId来截取到当前章节的内容*/ /*注:这里较大增加了内容加载的时间,所以首次获取内容后可存储到本地cache,减少重复加载*/ for (res in epubBook.contents) { - if (chapter.url.substringBeforeLast("#") == res.href) { + val isFirstResource = chapter.url.substringBeforeLast("#") == res.href + val isNextChapterResource = res.href == nextUrl?.substringBeforeLast("#") + if (isFirstResource) { + // add first resource to elements elements.add(getBody(res, startFragmentId, endFragmentId)) - 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 (res.href == nextUrl?.substringBeforeLast("#")) break - } else if (isChapter) { - // fix 最后一章存在多个html时 内容缺失 - if (res.href == nextUrl?.substringBeforeLast("#")) { + // check current resource + if (isNextChapterResource) break + hasMoreResources = true + } else if (hasMoreResources) { + if (isNextChapterResource) { + if (includeNextChapterResource) elements.add(getBody(res, startFragmentId, endFragmentId)) break } elements.add(getBody(res, startFragmentId, endFragmentId)) @@ -340,4 +340,4 @@ class EpubFile(var book: Book) { } } -} \ No newline at end of file +} From e0f74185db3b5130aac9674d5452d7cc45e2c161 Mon Sep 17 00:00:00 2001 From: Xwite <82232510+Xwite@users.noreply.github.com> Date: Sun, 9 Oct 2022 16:44:41 +0800 Subject: [PATCH 2/9] Update EpubFile.kt --- app/src/main/java/io/legado/app/model/localBook/EpubFile.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/model/localBook/EpubFile.kt b/app/src/main/java/io/legado/app/model/localBook/EpubFile.kt index 4238f669b..10a387662 100644 --- a/app/src/main/java/io/legado/app/model/localBook/EpubFile.kt +++ b/app/src/main/java/io/legado/app/model/localBook/EpubFile.kt @@ -132,7 +132,7 @@ class EpubFile(var book: Book) { val endFragmentId = chapter.endFragmentId val elements = Elements() var hasMoreResources = false - val includeNextChapterResource = endFragmentId.isNullOrBlank() + val includeNextChapterResource = !endFragmentId.isNullOrBlank() /*一些书籍依靠href索引的resource会包含多个章节,需要依靠fragmentId来截取到当前章节的内容*/ /*注:这里较大增加了内容加载的时间,所以首次获取内容后可存储到本地cache,减少重复加载*/ for (res in epubBook.contents) { From 5c530751e026a0c5344926f1cea319101fd91932 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 9 Oct 2022 18:42:51 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/layout/activity_search_content.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/layout/activity_search_content.xml b/app/src/main/res/layout/activity_search_content.xml index f72ca833e..12aa83fac 100644 --- a/app/src/main/res/layout/activity_search_content.xml +++ b/app/src/main/res/layout/activity_search_content.xml @@ -86,7 +86,7 @@ android:visibility="invisible" android:contentDescription="@string/stop" app:fabSize="mini" - app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintBottom_toTopOf="@+id/ll_search_base_info" app:layout_constraintRight_toRightOf="parent" /> \ No newline at end of file From ea7fa4d3b347a02a95fd6da475cca727522414bf Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 9 Oct 2022 20:46:25 +0800 Subject: [PATCH 4/9] =?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/constant/PreferKey.kt | 1 + .../java/io/legado/app/help/config/AppConfig.kt | 16 ++++++++++++++-- .../ui/book/source/edit/BookSourceEditAdapter.kt | 7 ++++++- .../legado/app/ui/config/OtherConfigFragment.kt | 15 ++++++++++++++- .../ui/rss/source/edit/RssSourceEditAdapter.kt | 7 ++++++- app/src/main/res/layout/item_source_edit.xml | 3 +-- app/src/main/res/values-es-rES/strings.xml | 3 ++- app/src/main/res/values-ja-rJP/strings.xml | 1 + app/src/main/res/values-pt-rBR/strings.xml | 1 + app/src/main/res/values-zh-rHK/strings.xml | 1 + app/src/main/res/values-zh-rTW/strings.xml | 1 + app/src/main/res/values-zh/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/pref_config_other.xml | 4 ++++ 14 files changed, 54 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/io/legado/app/constant/PreferKey.kt b/app/src/main/java/io/legado/app/constant/PreferKey.kt index de97e0f18..a74c37bfa 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -115,6 +115,7 @@ object PreferKey { const val ignoreAudioFocus = "ignoreAudioFocus" const val parallelExportBook = "parallelExportBook" const val progressBarBehavior = "progressBarBehavior" + const val sourceEditMaxLine = "sourceEditMaxLine" const val cPrimary = "colorPrimary" const val cAccent = "colorAccent" diff --git a/app/src/main/java/io/legado/app/help/config/AppConfig.kt b/app/src/main/java/io/legado/app/help/config/AppConfig.kt index f384fdd35..7f71d72ab 100644 --- a/app/src/main/java/io/legado/app/help/config/AppConfig.kt +++ b/app/src/main/java/io/legado/app/help/config/AppConfig.kt @@ -368,15 +368,27 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener { appCtx.putPrefInt(PreferKey.bitmapCacheSize, value) } - var showReadTitleBarAddition : Boolean + var showReadTitleBarAddition: Boolean get() = appCtx.getPrefBoolean(PreferKey.showReadTitleAddition, true) set(value) { appCtx.putPrefBoolean(PreferKey.showReadTitleAddition, value) } - var readBarStyleFollowPage : Boolean + var readBarStyleFollowPage: Boolean get() = appCtx.getPrefBoolean(PreferKey.readBarStyleFollowPage, false) set(value) { appCtx.putPrefBoolean(PreferKey.readBarStyleFollowPage, value) } + + var sourceEditMaxLine: Int + get() { + val maxLine = appCtx.getPrefInt(PreferKey.sourceEditMaxLine, Int.MAX_VALUE) + if (maxLine < 10) { + return 99 + } + return maxLine + } + set(value) { + appCtx.putPrefInt(PreferKey.sourceEditMaxLine, value) + } } diff --git a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditAdapter.kt b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditAdapter.kt index 0b2c7114b..15f780961 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditAdapter.kt @@ -9,12 +9,15 @@ import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import io.legado.app.R import io.legado.app.databinding.ItemSourceEditBinding +import io.legado.app.help.config.AppConfig import io.legado.app.ui.widget.code.addJsPattern import io.legado.app.ui.widget.code.addJsonPattern import io.legado.app.ui.widget.code.addLegadoPattern class BookSourceEditAdapter : RecyclerView.Adapter() { + val editEntityMaxLine = AppConfig.sourceEditMaxLine + var editEntities: ArrayList = ArrayList() @SuppressLint("NotifyDataSetChanged") set(value) { @@ -39,10 +42,12 @@ class BookSourceEditAdapter : RecyclerView.Adapter { + NumberPickerDialog(requireContext()) + .setTitle(getString(R.string.source_edit_text_max_line)) + .setMaxValue(99) + .setMinValue(10) + .setValue(AppConfig.sourceEditMaxLine) + .show { + AppConfig.sourceEditMaxLine = it + } + } } return super.onPreferenceTreeClick(preference) } @@ -160,6 +170,9 @@ class OtherConfigFragment : PreferenceFragment(), PreferKey.bitmapCacheSize -> { upPreferenceSummary(key, AppConfig.bitmapCacheSize.toString()) } + PreferKey.sourceEditMaxLine -> { + upPreferenceSummary(key, AppConfig.sourceEditMaxLine.toString()) + } } } diff --git a/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditAdapter.kt b/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditAdapter.kt index 4470421ba..a1f053bd8 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditAdapter.kt @@ -9,12 +9,15 @@ import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import io.legado.app.R import io.legado.app.databinding.ItemSourceEditBinding +import io.legado.app.help.config.AppConfig import io.legado.app.ui.widget.code.addJsPattern import io.legado.app.ui.widget.code.addJsonPattern import io.legado.app.ui.widget.code.addLegadoPattern class RssSourceEditAdapter : RecyclerView.Adapter() { + val editEntityMaxLine = AppConfig.sourceEditMaxLine + var editEntities: ArrayList = ArrayList() @SuppressLint("NotifyDataSetChanged") set(value) { @@ -39,9 +42,11 @@ class RssSourceEditAdapter : RecyclerView.Adapter + android:inputType="textMultiLine" /> \ No newline at end of file diff --git a/app/src/main/res/values-es-rES/strings.xml b/app/src/main/res/values-es-rES/strings.xml index 55004a263..a76b40e61 100644 --- a/app/src/main/res/values-es-rES/strings.xml +++ b/app/src/main/res/values-es-rES/strings.xml @@ -1023,7 +1023,7 @@ 删除段评URL(deleteUrl) 标志:发现已启用 标志:发现已禁用 - show read title addition area + show read title addition área read bar style follow page Decode Image(imageDecode) @@ -1037,4 +1037,5 @@ 本地未分组 多线程导出TXT 进度条行为 + 源编辑框最大行数 diff --git a/app/src/main/res/values-ja-rJP/strings.xml b/app/src/main/res/values-ja-rJP/strings.xml index 448507a49..e790fa5ba 100644 --- a/app/src/main/res/values-ja-rJP/strings.xml +++ b/app/src/main/res/values-ja-rJP/strings.xml @@ -1040,4 +1040,5 @@ 本地未分组 多线程导出TXT 进度条行为 + 源编辑框最大行数 diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index e2316f37c..e8ca2756b 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -1040,4 +1040,5 @@ 本地未分组 多线程导出TXT 进度条行为 + 源编辑框最大行数 diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index a8cb317f0..0c8c45318 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -1037,4 +1037,5 @@ 本地未分组 多线程导出TXT 进度条行为 + 源编辑框最大行数 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index bac10fc7f..7a7267b39 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -1039,4 +1039,5 @@ 本地未分组 多线程导出TXT 进度条行为 + 源编辑框最大行数 diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 7a706bbc2..7cfdc2463 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -1039,4 +1039,5 @@ 本地未分组 多线程导出TXT 进度条行为 + 源编辑框最大行数 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1d2d888ec..cd110f332 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1040,4 +1040,5 @@ 本地未分组 多线程导出TXT 进度条行为 + 源编辑框最大行数 diff --git a/app/src/main/res/xml/pref_config_other.xml b/app/src/main/res/xml/pref_config_other.xml index 02aba8f9a..73e3a0113 100644 --- a/app/src/main/res/xml/pref_config_other.xml +++ b/app/src/main/res/xml/pref_config_other.xml @@ -61,6 +61,10 @@ android:summary="@string/book_tree_uri_s" android:title="@string/book_tree_uri_t" /> + + From 6052292cfb363bbf1b9e47028f1feecdeabccaa8 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 9 Oct 2022 20:54:40 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/ui/config/OtherConfigFragment.kt | 5 ++++- app/src/main/res/values-es-rES/strings.xml | 1 + app/src/main/res/values-ja-rJP/strings.xml | 1 + app/src/main/res/values-pt-rBR/strings.xml | 1 + app/src/main/res/values-zh-rHK/strings.xml | 1 + app/src/main/res/values-zh-rTW/strings.xml | 1 + app/src/main/res/values-zh/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 8 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt index 7b2b417f1..dd611e767 100644 --- a/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt @@ -183,7 +183,10 @@ class OtherConfigFragment : PreferenceFragment(), getString(R.string.pre_download_s, value) PreferKey.threadCount -> preference.summary = getString(R.string.threads_num, value) PreferKey.webPort -> preference.summary = getString(R.string.web_port_summary, value) - PreferKey.bitmapCacheSize -> preference.summary = getString(R.string.bitmap_cache_size_summary, value) + PreferKey.bitmapCacheSize -> preference.summary = + getString(R.string.bitmap_cache_size_summary, value) + PreferKey.sourceEditMaxLine -> preference.summary = + getString(R.string.source_edit_max_line_summary, value) else -> if (preference is ListPreference) { val index = preference.findIndexOfValue(value) // Set the summary to reflect the new value. diff --git a/app/src/main/res/values-es-rES/strings.xml b/app/src/main/res/values-es-rES/strings.xml index a76b40e61..2c8b223e8 100644 --- a/app/src/main/res/values-es-rES/strings.xml +++ b/app/src/main/res/values-es-rES/strings.xml @@ -1038,4 +1038,5 @@ 多线程导出TXT 进度条行为 源编辑框最大行数 + %s,设置行数小于屏幕可显示的最大行数可以更方便的滑动到其他的字段进行编辑 diff --git a/app/src/main/res/values-ja-rJP/strings.xml b/app/src/main/res/values-ja-rJP/strings.xml index e790fa5ba..75fd4a999 100644 --- a/app/src/main/res/values-ja-rJP/strings.xml +++ b/app/src/main/res/values-ja-rJP/strings.xml @@ -1041,4 +1041,5 @@ 多线程导出TXT 进度条行为 源编辑框最大行数 + %s,设置行数小于屏幕可显示的最大行数可以更方便的滑动到其他的字段进行编辑 diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index e8ca2756b..65de2d1fb 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -1041,4 +1041,5 @@ 多线程导出TXT 进度条行为 源编辑框最大行数 + %s,设置行数小于屏幕可显示的最大行数可以更方便的滑动到其他的字段进行编辑 diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 0c8c45318..bad47a622 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -1038,4 +1038,5 @@ 多线程导出TXT 进度条行为 源编辑框最大行数 + %s,设置行数小于屏幕可显示的最大行数可以更方便的滑动到其他的字段进行编辑 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 7a7267b39..20d2fe194 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -1040,4 +1040,5 @@ 多线程导出TXT 进度条行为 源编辑框最大行数 + %s,设置行数小于屏幕可显示的最大行数可以更方便的滑动到其他的字段进行编辑 diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 7cfdc2463..c9026dc78 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -1040,4 +1040,5 @@ 多线程导出TXT 进度条行为 源编辑框最大行数 + %s,设置行数小于屏幕可显示的最大行数可以更方便的滑动到其他的字段进行编辑 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index cd110f332..5a7ec3881 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1041,4 +1041,5 @@ 多线程导出TXT 进度条行为 源编辑框最大行数 + %s,设置行数小于屏幕可显示的最大行数可以更方便的滑动到其他的字段进行编辑 From b099b812469845006cef7a7dd4e8c76acac8b61d Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 9 Oct 2022 20:58:45 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/updateLog.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index ac2fe5936..a2ba5343b 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -11,14 +11,15 @@ * 正文出现缺字漏字、内容缺失、排版错乱等情况,有可能是净化规则或简繁转换出现问题。 * 漫画源看书显示乱码,**阅读与其他软件的源并不通用**,请导入阅读的支持的漫画源! -**2022/10/08** +**2022/10/09** -* 添加正文阅读界面进度条(本章/整本)设置 +* 添加源编辑输入框最大行数设置 +* 添加正文阅读界面进度条(本章/整本)设置 by 821938089 * 优化下拉加载更多相关界面 -* 修复横屏竖屏切换后主题改变的bug -* 优化章节替换净化 -* 封面支持svg 正文img标签支持svg图片链接 -* 调整申请设置书籍保存位置的时机 +* 修复横屏竖屏切换后主题改变的bug by 821938089 +* 优化章节替换净化 by Xwite +* 封面支持svg 正文img标签支持svg图片链接 by Xwite +* 调整申请设置书籍保存位置的时机 by Xwite **2022/10/05** From 42b37d9b5aecc950c72096e2e8782f204cf2ccc0 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 9 Oct 2022 21:12:25 +0800 Subject: [PATCH 7/9] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/config/AppConfig.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/help/config/AppConfig.kt b/app/src/main/java/io/legado/app/help/config/AppConfig.kt index 7f71d72ab..d56af3d46 100644 --- a/app/src/main/java/io/legado/app/help/config/AppConfig.kt +++ b/app/src/main/java/io/legado/app/help/config/AppConfig.kt @@ -381,7 +381,7 @@ object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener { var sourceEditMaxLine: Int get() { - val maxLine = appCtx.getPrefInt(PreferKey.sourceEditMaxLine, Int.MAX_VALUE) + val maxLine = appCtx.getPrefInt(PreferKey.sourceEditMaxLine, 99) if (maxLine < 10) { return 99 } From 62973277c6fdffa7cc3dcf033aa478f0925111d8 Mon Sep 17 00:00:00 2001 From: Xwite <82232510+Xwite@users.noreply.github.com> Date: Mon, 10 Oct 2022 09:54:57 +0800 Subject: [PATCH 8/9] =?UTF-8?q?Epub:=20=E4=BF=AE=E5=A4=8DFragmentId?= =?UTF-8?q?=E7=9B=B8=E5=90=8C=E5=AF=BC=E8=87=B4=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/model/localBook/EpubFile.kt | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/localBook/EpubFile.kt b/app/src/main/java/io/legado/app/model/localBook/EpubFile.kt index 10a387662..75221da15 100644 --- a/app/src/main/java/io/legado/app/model/localBook/EpubFile.kt +++ b/app/src/main/java/io/legado/app/model/localBook/EpubFile.kt @@ -92,7 +92,7 @@ class EpubFile(var book: Book) { cover.compress(Bitmap.CompressFormat.JPEG, 90, out) out.flush() out.close() - } ?: AppLog.put("封面获取为空") + } ?: AppLog.putDebug("Epub: 封面获取为空. path: ${book.BookUrl}") } } } catch (e: Exception) { @@ -140,16 +140,25 @@ class EpubFile(var book: Book) { val isNextChapterResource = res.href == nextUrl?.substringBeforeLast("#") if (isFirstResource) { // add first resource to elements - elements.add(getBody(res, startFragmentId, endFragmentId)) + elements.add( + /* pass endFragmentId if only has one resource */ + getBody(res, startFragmentId, endFragmentId) + ) // check current resource - if (isNextChapterResource) break + if (isNextChapterResource) { + /* FragmentId should not be same in same resource */ + if (!endFragmentId.isNullOrBlank() && endFragmentId == startFragmentId) + AppLog.putDebug("Epub: Resource (${res.href}) has same FragmentId, check the file: ${book.bookUrl}") + break + } hasMoreResources = true } else if (hasMoreResources) { if (isNextChapterResource) { - if (includeNextChapterResource) elements.add(getBody(res, startFragmentId, endFragmentId)) + if (includeNextChapterResource) elements.add(getBody(res, null/* FragmentId may be same in different resources, pass null */, endFragmentId)) break } - elements.add(getBody(res, startFragmentId, endFragmentId)) + // rest resource should not have fragmentId, pass null + elements.add(getBody(res, null, null)) } } //title标签中的内容不需要显示在正文中,去除 @@ -226,7 +235,7 @@ class EpubFile(var book: Book) { epubBook?.let { eBook -> val refs = eBook.tableOfContents.tocReferences if (refs == null || refs.isEmpty()) { - AppLog.put("NCX file parse error, check the epub file") + AppLog.putDebug("Epub: NCX file parse error, check the file: ${book.bookUrl}") val spineReferences = eBook.spine.spineReferences var i = 0 val size = spineReferences.size From 77aa00494d9b682b6b7681a5d5acbae891b1f330 Mon Sep 17 00:00:00 2001 From: Xwite <82232510+Xwite@users.noreply.github.com> Date: Mon, 10 Oct 2022 10:12:13 +0800 Subject: [PATCH 9/9] fix: typi --- app/src/main/java/io/legado/app/model/localBook/EpubFile.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/model/localBook/EpubFile.kt b/app/src/main/java/io/legado/app/model/localBook/EpubFile.kt index 75221da15..78a5b0426 100644 --- a/app/src/main/java/io/legado/app/model/localBook/EpubFile.kt +++ b/app/src/main/java/io/legado/app/model/localBook/EpubFile.kt @@ -92,7 +92,7 @@ class EpubFile(var book: Book) { cover.compress(Bitmap.CompressFormat.JPEG, 90, out) out.flush() out.close() - } ?: AppLog.putDebug("Epub: 封面获取为空. path: ${book.BookUrl}") + } ?: AppLog.putDebug("Epub: 封面获取为空. path: ${book.bookUrl}") } } } catch (e: Exception) {