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** 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..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 @@ -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, 99) + if (maxLine < 10) { + return 99 + } + return maxLine + } + set(value) { + appCtx.putPrefInt(PreferKey.sourceEditMaxLine, value) + } } 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..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}") } } } catch (e: Exception) { @@ -131,25 +131,34 @@ 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) { - 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("#")) { + val isFirstResource = chapter.url.substringBeforeLast("#") == res.href + val isNextChapterResource = res.href == nextUrl?.substringBeforeLast("#") + if (isFirstResource) { + // add first resource to elements + elements.add( + /* pass endFragmentId if only has one resource */ + getBody(res, startFragmentId, endFragmentId) + ) + // check current resource + 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, 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 @@ -340,4 +349,4 @@ class EpubFile(var book: Book) { } } -} \ No newline at end of file +} 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()) + } } } @@ -170,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/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 \ No newline at end of file diff --git a/app/src/main/res/layout/item_source_edit.xml b/app/src/main/res/layout/item_source_edit.xml index 6f05121f0..cd14a6fe4 100644 --- a/app/src/main/res/layout/item_source_edit.xml +++ b/app/src/main/res/layout/item_source_edit.xml @@ -9,7 +9,6 @@ android:id="@+id/editText" android:layout_width="match_parent" android:layout_height="wrap_content" - android:inputType="textMultiLine" - android:maxLines="12" /> + 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..2c8b223e8 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,6 @@ 本地未分组 多线程导出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 448507a49..75fd4a999 100644 --- a/app/src/main/res/values-ja-rJP/strings.xml +++ b/app/src/main/res/values-ja-rJP/strings.xml @@ -1040,4 +1040,6 @@ 本地未分组 多线程导出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 e2316f37c..65de2d1fb 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -1040,4 +1040,6 @@ 本地未分组 多线程导出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 a8cb317f0..bad47a622 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -1037,4 +1037,6 @@ 本地未分组 多线程导出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 bac10fc7f..20d2fe194 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -1039,4 +1039,6 @@ 本地未分组 多线程导出TXT 进度条行为 + 源编辑框最大行数 + %s,设置行数小于屏幕可显示的最大行数可以更方便的滑动到其他的字段进行编辑 diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 7a706bbc2..c9026dc78 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -1039,4 +1039,6 @@ 本地未分组 多线程导出TXT 进度条行为 + 源编辑框最大行数 + %s,设置行数小于屏幕可显示的最大行数可以更方便的滑动到其他的字段进行编辑 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1d2d888ec..5a7ec3881 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1040,4 +1040,6 @@ 本地未分组 多线程导出TXT 进度条行为 + 源编辑框最大行数 + %s,设置行数小于屏幕可显示的最大行数可以更方便的滑动到其他的字段进行编辑 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" /> + +