Merge pull request #1565 from Xwite/master

书源校验
This commit is contained in:
kunfei
2022-01-28 17:50:43 +08:00
committed by GitHub
6 changed files with 46 additions and 15 deletions
@@ -16,6 +16,9 @@ object AppPattern {
val fileNameRegex = Regex("[\\\\/:*?\"<>|.]")
val splitGroupRegex = Regex("[,;,;]")
//书源调试信息中的各种符号
val debugMessageSymbolRegex = Regex("[⇒◇┌└≡]")
/**
* 所有标点
*/
@@ -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)
@@ -1,6 +1,7 @@
package io.legado.app.model
import android.annotation.SuppressLint
import io.legado.app.constant.AppPattern
import io.legado.app.data.entities.*
import io.legado.app.help.coroutine.CompositeCoroutine
import io.legado.app.model.rss.Rss
@@ -56,7 +57,7 @@ object Debug {
if (showTime && debugTimeMap[sourceUrl] != null) {
val time =
debugTimeFormat.format(Date(System.currentTimeMillis() - debugTimeMap[sourceUrl]!!))
printMsg = printMsg.substring(1)
printMsg = printMsg.replace(AppPattern.debugMessageSymbolRegex,"")
debugMessageMap[sourceUrl] = "$time $printMsg"
}
}
@@ -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