Merge pull request #1565 from Xwite/master

书源校验
This commit is contained in:
kunfei 2022-01-28 17:50:43 +08:00 committed by GitHub
commit c8a88000b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 46 additions and 15 deletions

View File

@ -16,6 +16,9 @@ object AppPattern {
val fileNameRegex = Regex("[\\\\/:*?\"<>|.]")
val splitGroupRegex = Regex("[,;]")
//书源调试信息中的各种符号
val debugMessageSymbolRegex = Regex("[⇒◇┌└≡]")
/**
* 所有标点
*/

View File

@ -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)

View File

@ -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"
}
}

View File

@ -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

View File

@ -18,6 +18,8 @@
<io.legado.app.ui.widget.text.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:paddingTop="3dp">
<io.legado.app.lib.theme.view.ThemeEditText
@ -30,15 +32,15 @@
</io.legado.app.ui.widget.text.TextInputLayout>
<io.legado.app.ui.widget.text.AccentTextView
android:paddingLeft="5dp"
android:paddingLeft="12dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/check_source_item" />
<com.google.android.flexbox.FlexboxLayout
android:layout_width="match_parent"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:layout_height="wrap_content"
app:flexWrap="wrap"
app:justifyContent="space_between">
@ -74,8 +76,8 @@
<com.google.android.flexbox.FlexboxLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="12dp"
android:paddingRight="12dp"
app:flexWrap="wrap"
app:justifyContent="flex_end">
<io.legado.app.ui.widget.text.AccentTextView

View File

@ -928,7 +928,6 @@
<string name="timeout">超时</string>
<string name="seconds"></string>
<string name="less_than">小于</string>
<string name="error_check_source_config">搜索发现至少校验一个</string>
<string name="check_source_config_summary">校验超时: %1$s秒\n校验项目:%2$s</string>
<!-- string end -->
</resources>