From 5584a22637d8e7d63192b7e8f300ddfe158f8b11 Mon Sep 17 00:00:00 2001 From: AndyBernie Date: Tue, 22 Sep 2020 11:00:31 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=8D=A2=E6=BA=90=E6=97=B6=E6=97=A0?= =?UTF-8?q?=E6=9C=80=E6=96=B0=E7=AB=A0=E8=8A=82=E6=97=B6=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E8=AF=A6=E6=83=85=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../book/changesource/ChangeSourceViewModel.kt | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt index ec423c3dd..581ad9f41 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt @@ -120,12 +120,8 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio .onSuccess(IO) { it.forEach { searchBook -> if (searchBook.name == name && searchBook.author == author) { - if (context.getPrefBoolean(PreferKey.changeSourceLoadToc)) { - if (searchBook.tocUrl.isEmpty()) { - loadBookInfo(searchBook.toBook()) - } else { - loadChapter(searchBook.toBook()) - } + if (searchBook.latestChapterTitle.isNullOrEmpty()) { + loadBookInfo(searchBook.toBook()) } else { searchFinish(searchBook) } @@ -156,7 +152,14 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio App.db.bookSourceDao().getBookSource(book.origin)?.let { bookSource -> WebBook(bookSource).getBookInfo(book, this) .onSuccess { - loadChapter(it) + if (context.getPrefBoolean(PreferKey.changeSourceLoadToc)) { + loadChapter(it) + } else { + //从详情页里获取最新章节 + book.latestChapterTitle = it.latestChapterTitle + val searchBook = book.toSearchBook() + searchFinish(searchBook) + } }.onError { debug { context.getString(R.string.error_get_book_info) } } From 273d465e080304e49922bbdc0ce9f3ac7a023a2f Mon Sep 17 00:00:00 2001 From: AndyBernie Date: Tue, 22 Sep 2020 12:31:23 +0800 Subject: [PATCH 2/3] add options --- app/src/main/java/io/legado/app/constant/PreferKey.kt | 1 + .../legado/app/ui/book/changesource/ChangeSourceDialog.kt | 6 ++++++ .../app/ui/book/changesource/ChangeSourceViewModel.kt | 4 +++- app/src/main/res/menu/change_source.xml | 6 ++++++ 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, 20 insertions(+), 1 deletion(-) 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 f40091b0f..7ef56460e 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -35,6 +35,7 @@ object PreferKey { const val webDavCreateDir = "webDavCreateDir" const val webDavCacheBackup = "webDavCacheBackup" const val changeSourceLoadToc = "changeSourceLoadToc" + const val changeSourceLoadInfo = "changeSourceLoadInfo" const val chineseConverterType = "chineseConverterType" const val launcherIcon = "launcherIcon" const val textSelectAble = "selectText" diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt index bbd627466..e73b443a6 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt @@ -88,6 +88,8 @@ class ChangeSourceDialog : BaseDialogFragment(), tool_bar.setOnMenuItemClickListener(this) tool_bar.menu.findItem(R.id.menu_load_toc)?.isChecked = getPrefBoolean(PreferKey.changeSourceLoadToc) + tool_bar.menu.findItem(R.id.menu_load_info)?.isChecked = + getPrefBoolean(PreferKey.changeSourceLoadInfo) } private fun initRecyclerView() { @@ -159,6 +161,10 @@ class ChangeSourceDialog : BaseDialogFragment(), putPrefBoolean(PreferKey.changeSourceLoadToc, !item.isChecked) item.isChecked = !item.isChecked } + R.id.menu_load_info -> { + putPrefBoolean(PreferKey.changeSourceLoadInfo, !item.isChecked) + item.isChecked = !item.isChecked + } R.id.menu_stop -> viewModel.stopSearch() } return false diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt index 581ad9f41..6633a889d 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt @@ -121,7 +121,9 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio it.forEach { searchBook -> if (searchBook.name == name && searchBook.author == author) { if (searchBook.latestChapterTitle.isNullOrEmpty()) { - loadBookInfo(searchBook.toBook()) + if (context.getPrefBoolean(PreferKey.changeSourceLoadInfo)) { + loadBookInfo(searchBook.toBook()) + } } else { searchFinish(searchBook) } diff --git a/app/src/main/res/menu/change_source.xml b/app/src/main/res/menu/change_source.xml index ab2bfee4c..dd2deae1b 100644 --- a/app/src/main/res/menu/change_source.xml +++ b/app/src/main/res/menu/change_source.xml @@ -24,4 +24,10 @@ android:checkable="true" app:showAsAction="never" /> + + \ No newline at end of file diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 72b0eaa2f..4d38941b5 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -568,6 +568,7 @@ 導出所選 導出 加載目錄 + 加載詳情頁 TTS WebDav 密碼 輸入你的 WebDav 授權密碼 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 69c410eaa..6335186ca 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -569,6 +569,7 @@ 匯出所選 匯出 載入目錄 + 載入詳情頁 TTS WebDav 密碼 輸入你的WebDav授權密碼 diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 76b0b02c1..92977d3f5 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -575,6 +575,7 @@ 导出所选 导出 加载目录 + 加载详情页 TTS WebDav 密码 输入你的WebDav授权密码 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4343ffa11..4779b5909 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -577,6 +577,7 @@ Export selected Export Load chapters + Load book detail TTS WebDav password Input you WebDav authorized password From be931db1a0cb84719c2652ec11ecff5e821d3928 Mon Sep 17 00:00:00 2001 From: AndyBernie Date: Tue, 22 Sep 2020 12:49:28 +0800 Subject: [PATCH 3/3] update --- app/src/main/assets/updateLog.md | 1 + .../legado/app/ui/book/changesource/ChangeSourceViewModel.kt | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 0e4cfb8b6..6b5ff9e46 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -5,6 +5,7 @@ **2020/09/21** * 修复规则解析bug +* 换源时无最新章节信息时可加载详情页来获取(默认关闭) **2020/09/20** * 优化正文搜索 diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt index 6633a889d..0cbc1e2ee 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt @@ -121,8 +121,10 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio it.forEach { searchBook -> if (searchBook.name == name && searchBook.author == author) { if (searchBook.latestChapterTitle.isNullOrEmpty()) { - if (context.getPrefBoolean(PreferKey.changeSourceLoadInfo)) { + if (context.getPrefBoolean(PreferKey.changeSourceLoadInfo) || context.getPrefBoolean(PreferKey.changeSourceLoadToc)) { loadBookInfo(searchBook.toBook()) + } else { + searchFinish(searchBook) } } else { searchFinish(searchBook)