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/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 ec423c3dd..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 @@ -120,11 +120,11 @@ 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()) { + if (searchBook.latestChapterTitle.isNullOrEmpty()) { + if (context.getPrefBoolean(PreferKey.changeSourceLoadInfo) || context.getPrefBoolean(PreferKey.changeSourceLoadToc)) { loadBookInfo(searchBook.toBook()) } else { - loadChapter(searchBook.toBook()) + searchFinish(searchBook) } } else { searchFinish(searchBook) @@ -156,7 +156,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) } } 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