diff --git a/app/src/main/assets/defaultData/coverRuleConfig.json b/app/src/main/assets/defaultData/coverRuleConfig.json index 9f086cd65..63ecb5ad6 100644 --- a/app/src/main/assets/defaultData/coverRuleConfig.json +++ b/app/src/main/assets/defaultData/coverRuleConfig.json @@ -1,4 +1,5 @@ { + "enable": true, "searchUrl": "https://api.yousuu.com/api/search?type=title&value={{key}}&page=1&highlight=0&from=search", "coverRule": "@js:java.getString(\"$..books[?(@.author == '\" + book.author + \"')].cover\")" } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/model/BookCover.kt b/app/src/main/java/io/legado/app/model/BookCover.kt index 2306fad79..5eac81a1a 100644 --- a/app/src/main/java/io/legado/app/model/BookCover.kt +++ b/app/src/main/java/io/legado/app/model/BookCover.kt @@ -68,7 +68,7 @@ object BookCover { suspend fun searchCover(book: Book): String? { val config = coverRuleConfig - if (config.searchUrl.isBlank() || config.coverRule.isBlank()) { + if (!config.enable || config.searchUrl.isBlank() || config.coverRule.isBlank()) { return null } val analyzeUrl = @@ -97,6 +97,7 @@ object BookCover { } data class CoverRuleConfig( + var enable: Boolean = true, var searchUrl: String, var coverRule: String, override var concurrentRate: String? = null, diff --git a/app/src/main/java/io/legado/app/ui/config/CoverRuleConfigDialog.kt b/app/src/main/java/io/legado/app/ui/config/CoverRuleConfigDialog.kt index c92385eaf..ae392358a 100644 --- a/app/src/main/java/io/legado/app/ui/config/CoverRuleConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/config/CoverRuleConfigDialog.kt @@ -28,12 +28,13 @@ class CoverRuleConfigDialog : BaseDialogFragment(R.layout.dialog_cover_rule_conf dismissAllowingStateLoss() } binding.tvOk.onClick { + val enable = binding.cbEnable.isChecked val searchUrl = binding.editSearchUrl.text?.toString() val coverRule = binding.editCoverUrlRule.text?.toString() if (searchUrl.isNullOrBlank() || coverRule.isNullOrBlank()) { toastOnUi("搜索url和cover规则不能为空") } else { - BookCover.CoverRuleConfig(searchUrl, coverRule).let { config -> + BookCover.CoverRuleConfig(enable, searchUrl, coverRule).let { config -> BookCover.saveCoverRuleConfig(config) } dismissAllowingStateLoss() diff --git a/app/src/main/res/layout/dialog_cover_rule_config.xml b/app/src/main/res/layout/dialog_cover_rule_config.xml index 1538b85b2..9d8082502 100644 --- a/app/src/main/res/layout/dialog_cover_rule_config.xml +++ b/app/src/main/res/layout/dialog_cover_rule_config.xml @@ -26,6 +26,12 @@ android:orientation="vertical" android:padding="16dp"> + +