mirror of
https://github.com/gkd-kit/gkd.git
synced 2024-11-16 11:42:22 +08:00
perf: some changes
This commit is contained in:
parent
fb5933d104
commit
8c38829b16
|
@ -15,7 +15,7 @@ import kotlinx.serialization.json.jsonArray
|
|||
import kotlinx.serialization.json.jsonObject
|
||||
import kotlinx.serialization.json.jsonPrimitive
|
||||
import kotlinx.serialization.json.long
|
||||
import li.songe.gkd.service.allowPropertyNames
|
||||
import li.songe.gkd.service.checkSelector
|
||||
import li.songe.gkd.util.json
|
||||
import li.songe.gkd.util.json5ToJson
|
||||
import li.songe.gkd.util.toast
|
||||
|
@ -386,14 +386,7 @@ data class RawSubscription(
|
|||
}
|
||||
}
|
||||
allSelector.forEach { s ->
|
||||
s?.nameToTypeList?.forEach { (name, type) ->
|
||||
if (!allowPropertyNames.contains(name)) {
|
||||
return "非法属性名:${name}"
|
||||
}
|
||||
if (type != "null" && allowPropertyNames[name] != type) {
|
||||
return "非法类型:${name}=$type"
|
||||
}
|
||||
}
|
||||
s?.checkSelector()?.let { return it }
|
||||
}
|
||||
rules.forEach { r ->
|
||||
if (r.position?.isValid == false) {
|
||||
|
|
|
@ -161,6 +161,18 @@ val allowPropertyNames by lazy {
|
|||
)
|
||||
}
|
||||
|
||||
fun Selector.checkSelector(): String? {
|
||||
nameToTypeList.forEach { (name, type) ->
|
||||
if (!allowPropertyNames.contains(name)) {
|
||||
return "未知属性:${name}"
|
||||
}
|
||||
if (type != "null" && allowPropertyNames[name] != type) {
|
||||
return "非法类型:${name}=$type"
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
private val getAttr: (AccessibilityNodeInfo, String) -> Any? = { node, name ->
|
||||
when (name) {
|
||||
"id" -> node.viewIdResourceName
|
||||
|
|
|
@ -502,10 +502,8 @@ class GkdAbService : CompositionAbService({
|
|||
fun execAction(gkdAction: GkdAction): ActionResult {
|
||||
val serviceVal = service ?: throw RpcError("无障碍没有运行")
|
||||
val selector = Selector.parseOrNull(gkdAction.selector) ?: throw RpcError("非法选择器")
|
||||
selector.propertyNames.forEach { n ->
|
||||
if (!allowPropertyNames.contains(n)) {
|
||||
throw RpcError("未知属性名:$n")
|
||||
}
|
||||
selector.checkSelector()?.let {
|
||||
throw RpcError(it)
|
||||
}
|
||||
val targetNode =
|
||||
serviceVal.safeActiveWindow?.querySelector(
|
||||
|
|
|
@ -18,6 +18,7 @@ import androidx.compose.material.icons.filled.Edit
|
|||
import androidx.compose.material3.FloatingActionButton
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.LocalContentColor
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Switch
|
||||
|
@ -200,14 +201,23 @@ private fun AppGroupCard(
|
|||
modifier = Modifier.fillMaxWidth()
|
||||
)
|
||||
if (group.valid) {
|
||||
if (!group.desc.isNullOrBlank()) {
|
||||
Text(
|
||||
text = group.desc ?: "",
|
||||
text = group.desc!!,
|
||||
maxLines = 1,
|
||||
softWrap = false,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
fontSize = 14.sp
|
||||
)
|
||||
} else {
|
||||
Text(
|
||||
text = "暂无描述",
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
fontSize = 14.sp,
|
||||
color = LocalContentColor.current.copy(alpha = 0.5f)
|
||||
)
|
||||
}
|
||||
} else {
|
||||
Text(
|
||||
text = "非法选择器",
|
||||
|
|
|
@ -185,7 +185,7 @@ fun AppItemPage(
|
|||
modifier = Modifier.fillMaxWidth()
|
||||
)
|
||||
if (group.valid) {
|
||||
if (group.desc != null) {
|
||||
if (!group.desc.isNullOrBlank()) {
|
||||
Text(
|
||||
text = group.desc,
|
||||
maxLines = 1,
|
||||
|
@ -265,13 +265,7 @@ fun AppItemPage(
|
|||
Text(text = showGroupItemVal.name)
|
||||
},
|
||||
text = {
|
||||
Column {
|
||||
if (showGroupItemVal.enable == false) {
|
||||
Text(text = "该规则组默认不启用")
|
||||
Spacer(modifier = Modifier.height(10.dp))
|
||||
}
|
||||
Text(text = showGroupItemVal.desc ?: "")
|
||||
}
|
||||
},
|
||||
confirmButton = {
|
||||
Row {
|
||||
|
|
|
@ -152,7 +152,7 @@ fun GlobalRulePage(subsItemId: Long, focusGroupKey: Int? = null) {
|
|||
modifier = Modifier.fillMaxWidth()
|
||||
)
|
||||
if (group.valid) {
|
||||
if (group.desc != null) {
|
||||
if (!group.desc.isNullOrBlank()) {
|
||||
Text(
|
||||
text = group.desc,
|
||||
maxLines = 1,
|
||||
|
@ -402,13 +402,7 @@ fun GlobalRulePage(subsItemId: Long, focusGroupKey: Int? = null) {
|
|||
Text(text = showGroupItem.name)
|
||||
},
|
||||
text = {
|
||||
Column {
|
||||
if (showGroupItem.enable == false) {
|
||||
Text(text = "该规则组默认不启用")
|
||||
Spacer(modifier = Modifier.height(10.dp))
|
||||
}
|
||||
Text(text = showGroupItem.desc ?: "")
|
||||
}
|
||||
},
|
||||
confirmButton = {
|
||||
Row {
|
||||
|
|
Loading…
Reference in New Issue
Block a user