输入url参数对话框
This commit is contained in:
@@ -107,7 +107,10 @@ class ContentProcessor private constructor(
|
||||
}
|
||||
if (includeTitle) {
|
||||
//重新添加标题
|
||||
mContent = chapter.getDisplayTitle(getTitleReplaceRules()) + "\n" + mContent
|
||||
mContent = chapter.getDisplayTitle(
|
||||
getTitleReplaceRules(),
|
||||
useReplace = useReplace && book.getUseReplaceRule()
|
||||
) + "\n" + mContent
|
||||
}
|
||||
val contents = arrayListOf<String>()
|
||||
mContent.split("\n").forEach { str ->
|
||||
|
||||
@@ -152,7 +152,7 @@ class RssSourceEditActivity :
|
||||
binding.recyclerView.adapter = adapter
|
||||
binding.composeView.setContent {
|
||||
UrlOptionDialog(openState = urlOptionDialogState) {
|
||||
|
||||
sendText(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,15 +4,20 @@ import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.AlertDialog
|
||||
import androidx.compose.material.Checkbox
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.material.TextButton
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import io.legado.app.R
|
||||
import io.legado.app.model.analyzeRule.AnalyzeUrl
|
||||
import io.legado.app.ui.theme.AppTheme
|
||||
import io.legado.app.ui.widget.checkbox.LabelledCheckBox
|
||||
import io.legado.app.utils.GSON
|
||||
import splitties.init.appCtx
|
||||
|
||||
|
||||
@Composable
|
||||
@@ -26,32 +31,44 @@ fun UrlOptionDialog(openState: MutableState<Boolean>, confirm: (String) -> Unit)
|
||||
},
|
||||
confirmButton = {
|
||||
TextButton(onClick = {
|
||||
confirm.invoke("")
|
||||
openState.value = false
|
||||
confirm.invoke(GSON.toJson(urlOption))
|
||||
}) {
|
||||
Text(text = "OK")
|
||||
Text(text = appCtx.getString(R.string.ok))
|
||||
}
|
||||
},
|
||||
dismissButton = {
|
||||
TextButton(onClick = {
|
||||
openState.value = false
|
||||
}) { Text(text = "Cancel") }
|
||||
}) { Text(text = appCtx.getString(R.string.cancel)) }
|
||||
},
|
||||
title = {
|
||||
Text(text = "url参数")
|
||||
},
|
||||
text = {
|
||||
Column(Modifier.padding(12.dp)) {
|
||||
Row(Modifier.padding(3.dp)) {
|
||||
Checkbox(
|
||||
checked = urlOption.useWebView(),
|
||||
onCheckedChange = {
|
||||
urlOption.webView = it
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
UrlOptionView(urlOption = urlOption)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun UrlOptionView(urlOption: AnalyzeUrl.UrlOption) {
|
||||
val useWebView = remember {
|
||||
mutableStateOf(urlOption.useWebView())
|
||||
}
|
||||
urlOption.webView = useWebView.value
|
||||
Column(Modifier.padding(6.dp)) {
|
||||
Row(Modifier.padding(3.dp)) {
|
||||
LabelledCheckBox(
|
||||
checked = useWebView.value,
|
||||
onCheckedChange = {
|
||||
useWebView.value = it
|
||||
},
|
||||
label = "useWebView"
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package io.legado.app.ui.widget.checkbox
|
||||
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material.ButtonDefaults
|
||||
import androidx.compose.material.Checkbox
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.material.ripple.rememberRipple
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
@Composable
|
||||
fun LabelledCheckBox(
|
||||
checked: Boolean,
|
||||
onCheckedChange: ((Boolean) -> Unit),
|
||||
label: String,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = modifier
|
||||
.clip(MaterialTheme.shapes.small)
|
||||
.clickable(
|
||||
indication = rememberRipple(color = MaterialTheme.colors.primary),
|
||||
interactionSource = remember { MutableInteractionSource() },
|
||||
onClick = { onCheckedChange(!checked) }
|
||||
)
|
||||
.requiredHeight(ButtonDefaults.MinHeight)
|
||||
.padding(4.dp)
|
||||
) {
|
||||
Checkbox(
|
||||
checked = checked,
|
||||
onCheckedChange = null
|
||||
)
|
||||
|
||||
Spacer(Modifier.size(6.dp))
|
||||
|
||||
Text(
|
||||
text = label,
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user