输入url参数对话框

pull/1705/head
kunfei 3 years ago
parent 72a34942d2
commit 347d6a1ecc
  1. 31
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt
  2. 13
      app/src/main/java/io/legado/app/ui/widget/UrlOptionDialog.kt

@ -188,7 +188,7 @@ class AnalyzeUrl(
type = option.type type = option.type
charset = option.charset charset = option.charset
retry = option.retry retry = option.retry
useWebView = option.webView?.toString()?.isNotBlank() == true useWebView = option.useWebView()
webJs = option.webJs webJs = option.webJs
option.js?.let { jsStr -> option.js?.let { jsStr ->
evalJS(jsStr, url)?.toString()?.let { evalJS(jsStr, url)?.toString()?.let {
@ -561,16 +561,25 @@ class AnalyzeUrl(
} }
data class UrlOption( data class UrlOption(
val method: String?, var method: String? = null,
val charset: String?, var charset: String? = null,
val headers: Any?, var headers: Any? = null,
val body: Any?, var body: Any? = null,
val type: String?, var type: String? = null,
val js: String?, var js: String? = null,
val retry: Int = 0, var retry: Int = 0,
val webView: Any?, var webView: Any? = null,
val webJs: String?, var webJs: String? = null,
) ) {
fun useWebView(): Boolean {
return when (webView) {
null, "", false, "false" -> false
else -> true
}
}
}
data class ConcurrentRecord( data class ConcurrentRecord(
val concurrent: Boolean, val concurrent: Boolean,

@ -1,14 +1,17 @@
package io.legado.app.ui.widget package io.legado.app.ui.widget
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.material.AlertDialog import androidx.compose.material.AlertDialog
import androidx.compose.material.Checkbox
import androidx.compose.material.Text import androidx.compose.material.Text
import androidx.compose.material.TextButton import androidx.compose.material.TextButton
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState import androidx.compose.runtime.MutableState
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import io.legado.app.model.analyzeRule.AnalyzeUrl
import io.legado.app.ui.theme.AppTheme import io.legado.app.ui.theme.AppTheme
@ -16,6 +19,7 @@ import io.legado.app.ui.theme.AppTheme
fun UrlOptionDialog(openState: MutableState<Boolean>, confirm: (String) -> Unit) { fun UrlOptionDialog(openState: MutableState<Boolean>, confirm: (String) -> Unit) {
AppTheme { AppTheme {
if (openState.value) { if (openState.value) {
val urlOption = AnalyzeUrl.UrlOption()
AlertDialog( AlertDialog(
onDismissRequest = { onDismissRequest = {
openState.value = false openState.value = false
@ -37,7 +41,14 @@ fun UrlOptionDialog(openState: MutableState<Boolean>, confirm: (String) -> Unit)
}, },
text = { text = {
Column(Modifier.padding(12.dp)) { Column(Modifier.padding(12.dp)) {
Row(Modifier.padding(3.dp)) {
Checkbox(
checked = urlOption.useWebView(),
onCheckedChange = {
urlOption.webView = it
}
)
}
} }
} }
) )

Loading…
Cancel
Save