输入url参数对话框
This commit is contained in:
@@ -172,7 +172,7 @@ class AnalyzeUrl(
|
|||||||
option.getMethod()?.let {
|
option.getMethod()?.let {
|
||||||
if (it.equals("POST", true)) method = RequestMethod.POST
|
if (it.equals("POST", true)) method = RequestMethod.POST
|
||||||
}
|
}
|
||||||
option.getHeaders()?.forEach { entry ->
|
option.getHeaderMap()?.forEach { entry ->
|
||||||
headerMap[entry.key.toString()] = entry.value.toString()
|
headerMap[entry.key.toString()] = entry.value.toString()
|
||||||
}
|
}
|
||||||
option.getBody()?.let {
|
option.getBody()?.let {
|
||||||
@@ -558,8 +558,8 @@ class AnalyzeUrl(
|
|||||||
private var charset: String? = null,
|
private var charset: String? = null,
|
||||||
private var headers: Any? = null,
|
private var headers: Any? = null,
|
||||||
private var body: Any? = null,
|
private var body: Any? = null,
|
||||||
private var type: String? = null,
|
|
||||||
private var retry: Int? = null,
|
private var retry: Int? = null,
|
||||||
|
private var type: String? = null,
|
||||||
private var webView: Any? = null,
|
private var webView: Any? = null,
|
||||||
private var webJs: String? = null,
|
private var webJs: String? = null,
|
||||||
private var js: String? = null,
|
private var js: String? = null,
|
||||||
@@ -580,6 +580,14 @@ class AnalyzeUrl(
|
|||||||
return charset
|
return charset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setRetry(value: String?) {
|
||||||
|
retry = if (value.isNullOrEmpty()) null else value.toIntOrNull()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getRetry(): Int {
|
||||||
|
return retry ?: 0
|
||||||
|
}
|
||||||
|
|
||||||
fun setType(value: String?) {
|
fun setType(value: String?) {
|
||||||
type = if (value.isNullOrBlank()) null else value
|
type = if (value.isNullOrBlank()) null else value
|
||||||
}
|
}
|
||||||
@@ -588,14 +596,6 @@ class AnalyzeUrl(
|
|||||||
return type
|
return type
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setRetry(value: Int?) {
|
|
||||||
retry = if (value == null || value <= 0) null else value
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getRetry(): Int {
|
|
||||||
return retry ?: 0
|
|
||||||
}
|
|
||||||
|
|
||||||
fun useWebView(): Boolean {
|
fun useWebView(): Boolean {
|
||||||
return when (webView) {
|
return when (webView) {
|
||||||
null, "", false, "false" -> false
|
null, "", false, "false" -> false
|
||||||
@@ -615,7 +615,7 @@ class AnalyzeUrl(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getHeaders(): Map<*, *>? {
|
fun getHeaderMap(): Map<*, *>? {
|
||||||
return when (val value = headers) {
|
return when (val value = headers) {
|
||||||
is Map<*, *> -> value
|
is Map<*, *> -> value
|
||||||
is String -> GSON.fromJsonObject<Map<String, Any>>(value).getOrNull()
|
is String -> GSON.fromJsonObject<Map<String, Any>>(value).getOrNull()
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ 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.Row
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.text.KeyboardOptions
|
||||||
import androidx.compose.material.AlertDialog
|
import androidx.compose.material.AlertDialog
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material.Text
|
||||||
import androidx.compose.material.TextButton
|
import androidx.compose.material.TextButton
|
||||||
@@ -11,8 +11,7 @@ import androidx.compose.runtime.Composable
|
|||||||
import androidx.compose.runtime.MutableState
|
import androidx.compose.runtime.MutableState
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.text.input.KeyboardType
|
||||||
import androidx.compose.ui.unit.dp
|
|
||||||
import io.legado.app.R
|
import io.legado.app.R
|
||||||
import io.legado.app.model.analyzeRule.AnalyzeUrl
|
import io.legado.app.model.analyzeRule.AnalyzeUrl
|
||||||
import io.legado.app.ui.theme.AppTheme
|
import io.legado.app.ui.theme.AppTheme
|
||||||
@@ -61,11 +60,27 @@ fun UrlOptionView(urlOption: AnalyzeUrl.UrlOption) {
|
|||||||
}
|
}
|
||||||
urlOption.useWebView(useWebView.value)
|
urlOption.useWebView(useWebView.value)
|
||||||
val method = remember {
|
val method = remember {
|
||||||
mutableStateOf(urlOption.getMethod() ?: "")
|
mutableStateOf("")
|
||||||
}
|
}
|
||||||
urlOption.setMethod(method.value)
|
urlOption.setMethod(method.value)
|
||||||
Column(Modifier.padding(6.dp)) {
|
val charset = remember {
|
||||||
Row(Modifier.padding(3.dp)) {
|
mutableStateOf("")
|
||||||
|
}
|
||||||
|
urlOption.setCharset(charset.value)
|
||||||
|
val headers = remember {
|
||||||
|
mutableStateOf("")
|
||||||
|
}
|
||||||
|
urlOption.setHeaders(headers.value)
|
||||||
|
val body = remember {
|
||||||
|
mutableStateOf("")
|
||||||
|
}
|
||||||
|
urlOption.setBody(body.value)
|
||||||
|
val retry = remember {
|
||||||
|
mutableStateOf("")
|
||||||
|
}
|
||||||
|
urlOption.setRetry(retry.value)
|
||||||
|
Column {
|
||||||
|
Row {
|
||||||
LabelledCheckBox(
|
LabelledCheckBox(
|
||||||
checked = useWebView.value,
|
checked = useWebView.value,
|
||||||
onCheckedChange = {
|
onCheckedChange = {
|
||||||
@@ -80,8 +95,36 @@ fun UrlOptionView(urlOption: AnalyzeUrl.UrlOption) {
|
|||||||
method.value = it
|
method.value = it
|
||||||
},
|
},
|
||||||
label = {
|
label = {
|
||||||
Text(text = "Method")
|
Text(text = "method")
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
TextField(
|
||||||
|
value = method.value,
|
||||||
|
onValueChange = {
|
||||||
|
charset.value = it
|
||||||
|
},
|
||||||
|
label = {
|
||||||
|
Text(text = "charset")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
TextField(
|
||||||
|
value = headers.value,
|
||||||
|
onValueChange = {
|
||||||
|
charset.value = it
|
||||||
|
},
|
||||||
|
label = {
|
||||||
|
Text(text = "headers")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
TextField(
|
||||||
|
value = retry.value,
|
||||||
|
onValueChange = {
|
||||||
|
retry.value = it
|
||||||
|
},
|
||||||
|
label = {
|
||||||
|
Text(text = "retry")
|
||||||
|
},
|
||||||
|
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user