mirror of
https://github.com/gkd-kit/gkd.git
synced 2024-11-16 11:42:22 +08:00
feat: vid
This commit is contained in:
parent
606dafe4c1
commit
cd70a02221
|
@ -7,6 +7,7 @@ import kotlinx.serialization.Serializable
|
||||||
@Serializable
|
@Serializable
|
||||||
data class AttrInfo(
|
data class AttrInfo(
|
||||||
val id: String?,
|
val id: String?,
|
||||||
|
val vid: String?,
|
||||||
val name: String?,
|
val name: String?,
|
||||||
val text: String?,
|
val text: String?,
|
||||||
val desc: String?,
|
val desc: String?,
|
||||||
|
@ -42,8 +43,18 @@ data class AttrInfo(
|
||||||
depth: Int,
|
depth: Int,
|
||||||
): AttrInfo {
|
): AttrInfo {
|
||||||
node.getBoundsInScreen(rect)
|
node.getBoundsInScreen(rect)
|
||||||
|
val appId = node.packageName?.toString() ?: ""
|
||||||
|
val id: String? = node.viewIdResourceName
|
||||||
|
val idPrefix = "$appId:id/"
|
||||||
|
val vid = if (id != null && id.startsWith(idPrefix)) {
|
||||||
|
id.substring(idPrefix.length)
|
||||||
|
} else {
|
||||||
|
// 此处不使用 id 是因为某些节点的 id 没有 appId:id/ 前缀
|
||||||
|
null
|
||||||
|
}
|
||||||
return AttrInfo(
|
return AttrInfo(
|
||||||
id = node.viewIdResourceName,
|
id = id,
|
||||||
|
vid = vid,
|
||||||
name = node.className?.toString(),
|
name = node.className?.toString(),
|
||||||
text = node.text?.toString(),
|
text = node.text?.toString(),
|
||||||
desc = node.contentDescription?.toString(),
|
desc = node.contentDescription?.toString(),
|
||||||
|
@ -66,7 +77,7 @@ data class AttrInfo(
|
||||||
childCount = node.childCount,
|
childCount = node.childCount,
|
||||||
|
|
||||||
index = index,
|
index = index,
|
||||||
depth = depth, //
|
depth = depth,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user