From 1703c5ed1c92bbbb0648e83a5177f7027b551775 Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Fri, 28 Jan 2022 09:55:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=A0=A1=E9=AA=8C=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E5=A4=8D=E9=80=89=E6=A1=86=E9=80=89=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/model/CheckSource.kt | 2 +- .../legado/app/ui/config/CheckSourceConfig.kt | 42 +++++++++++++++---- .../res/layout/dialog_check_source_config.xml | 10 +++-- app/src/main/res/values/strings.xml | 1 - 4 files changed, 41 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/CheckSource.kt b/app/src/main/java/io/legado/app/model/CheckSource.kt index f7056b6c9..dadc16f8f 100644 --- a/app/src/main/java/io/legado/app/model/CheckSource.kt +++ b/app/src/main/java/io/legado/app/model/CheckSource.kt @@ -47,7 +47,7 @@ object CheckSource { } fun putConfig() { - CacheManager.put("checkSourceTimeout", timeout * 1000) + CacheManager.put("checkSourceTimeout", timeout) CacheManager.put("checkSearch", checkSearch) CacheManager.put("checkDiscovery", checkDiscovery) CacheManager.put("checkInfo", checkInfo) diff --git a/app/src/main/java/io/legado/app/ui/config/CheckSourceConfig.kt b/app/src/main/java/io/legado/app/ui/config/CheckSourceConfig.kt index 2eb62df2a..c0a884081 100644 --- a/app/src/main/java/io/legado/app/ui/config/CheckSourceConfig.kt +++ b/app/src/main/java/io/legado/app/ui/config/CheckSourceConfig.kt @@ -31,6 +31,36 @@ class CheckSourceConfig : BaseDialogFragment(R.layout.dialog_check_source_config override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { binding.toolBar.setBackgroundColor(primaryColor) + binding.run { + checkSearch.onClick { + if (!checkSearch.isChecked && !checkDiscovery.isChecked) { + checkDiscovery.isChecked = true + } + } + checkDiscovery.onClick { + if (!checkSearch.isChecked && !checkDiscovery.isChecked) { + checkSearch.isChecked = true + } + } + checkInfo.onClick { + if (!checkInfo.isChecked) { + checkCategory.isChecked = false + checkContent.isChecked = false + checkCategory.isEnabled = false + checkContent.isEnabled = false + } else { + checkCategory.isEnabled = true + } + } + checkCategory.onClick { + if (!checkCategory.isChecked) { + checkContent.isChecked = false + checkContent.isEnabled = false + } else { + checkContent.isEnabled = true + } + } + } CheckSource.run { binding.checkSourceTimeout.setText((timeout / 1000).toString()) binding.checkSearch.isChecked = checkSearch @@ -38,6 +68,8 @@ class CheckSourceConfig : BaseDialogFragment(R.layout.dialog_check_source_config binding.checkInfo.isChecked = checkInfo binding.checkCategory.isChecked = checkCategory binding.checkContent.isChecked = checkContent + binding.checkCategory.isEnabled = checkInfo + binding.checkContent.isEnabled = checkCategory binding.tvCancel.onClick { dismiss() } @@ -60,14 +92,8 @@ class CheckSourceConfig : BaseDialogFragment(R.layout.dialog_check_source_config } else -> timeout = text.toLong() * 1000 } - val mCheckSearch = binding.checkSearch.isChecked - val mCheckDiscovery = binding.checkDiscovery.isChecked - if (!mCheckSearch && !mCheckDiscovery) { - toastOnUi(getString(R.string.error_check_source_config)) - return@onClick - } - checkSearch = mCheckSearch - checkDiscovery = mCheckDiscovery + checkSearch = binding.checkSearch.isChecked + checkDiscovery = binding.checkDiscovery.isChecked checkInfo = binding.checkInfo.isChecked checkCategory = binding.checkCategory.isChecked checkContent = binding.checkContent.isChecked diff --git a/app/src/main/res/layout/dialog_check_source_config.xml b/app/src/main/res/layout/dialog_check_source_config.xml index a925b1162..5a6dd410d 100644 --- a/app/src/main/res/layout/dialog_check_source_config.xml +++ b/app/src/main/res/layout/dialog_check_source_config.xml @@ -18,6 +18,8 @@ @@ -74,8 +76,8 @@ 超时 小于 - 搜索发现至少校验一个 校验超时: %1$s秒\n校验项目:%2$s