Merge pull request #1565 from Xwite/master

书源校验
pull/1578/head
kunfei 3 years ago committed by GitHub
commit c8a88000b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      app/src/main/java/io/legado/app/constant/AppPattern.kt
  2. 2
      app/src/main/java/io/legado/app/model/CheckSource.kt
  3. 3
      app/src/main/java/io/legado/app/model/Debug.kt
  4. 42
      app/src/main/java/io/legado/app/ui/config/CheckSourceConfig.kt
  5. 10
      app/src/main/res/layout/dialog_check_source_config.xml
  6. 1
      app/src/main/res/values/strings.xml

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

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

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

Loading…
Cancel
Save