Skip to content

Commit

Permalink
feat: vid
Browse files Browse the repository at this point in the history
  • Loading branch information
lisonge committed Dec 14, 2023
1 parent 606dafe commit cd70a02
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions app/src/main/kotlin/li/songe/gkd/data/AttrInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import kotlinx.serialization.Serializable
@Serializable
data class AttrInfo(
val id: String?,
val vid: String?,
val name: String?,
val text: String?,
val desc: String?,
Expand Down Expand Up @@ -42,8 +43,18 @@ data class AttrInfo(
depth: Int,
): AttrInfo {
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(
id = node.viewIdResourceName,
id = id,
vid = vid,
name = node.className?.toString(),
text = node.text?.toString(),
desc = node.contentDescription?.toString(),
Expand All @@ -66,7 +77,7 @@ data class AttrInfo(
childCount = node.childCount,

index = index,
depth = depth, //
depth = depth,
)
}
}
Expand Down

0 comments on commit cd70a02

Please sign in to comment.