6.6.2 - Alpha5 - 优化 UiObject 实例的信息打印格式
This commit is contained in:
@@ -436,56 +436,75 @@ open class UiObject(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun summary() = listOf("{").asSequence().plus(
|
fun summary(): String {
|
||||||
/* Common */ arrayOf(
|
val separatorLv0 = "\n"
|
||||||
"packageName='${packageName()}'",
|
val separatorLv1 = "$separatorLv0 "
|
||||||
"parent='${parent?.className}'",
|
val separatorLv2 = "$separatorLv1 "
|
||||||
"id='${id()}'",
|
|
||||||
"fullId='${fullId()}'",
|
|
||||||
"idHex='${idHex()}'",
|
|
||||||
"desc='${desc()}'",
|
|
||||||
"text='${text()}'",
|
|
||||||
"bounds='${bounds()}'",
|
|
||||||
"center='${center()}'",
|
|
||||||
"className='${className()}'",
|
|
||||||
"clickable=${clickable()}",
|
|
||||||
"longClickable=${longClickable()}",
|
|
||||||
"scrollable=${scrollable()}",
|
|
||||||
"indexInParent=${indexInParent()}",
|
|
||||||
"childCount=${childCount()}",
|
|
||||||
"depth=${depth()}"
|
|
||||||
).joinToString("\n")
|
|
||||||
).plus(
|
|
||||||
/* Regular */ arrayOf(
|
|
||||||
"checked=${checked()}",
|
|
||||||
"enabled=${enabled()}",
|
|
||||||
"editable=${editable()}",
|
|
||||||
"focusable=${focusable()}",
|
|
||||||
"checkable=${checkable()}",
|
|
||||||
"selected=${selected()}",
|
|
||||||
"dismissable=$isDismissable",
|
|
||||||
"visibleToUser=${visibleToUser()}"
|
|
||||||
).joinToString("\n")
|
|
||||||
).plus(
|
|
||||||
/* Rare */ arrayOf(
|
|
||||||
"contextClickable=$isContextClickable",
|
|
||||||
"focused=${focused()}",
|
|
||||||
"accessibilityFocused=${isAccessibilityFocused}",
|
|
||||||
"rowCount=${rowCount()}",
|
|
||||||
"columnCount=${columnCount()}",
|
|
||||||
"row=${row()}",
|
|
||||||
"column=${column()}",
|
|
||||||
"rowSpan=${rowSpan()}",
|
|
||||||
"columnSpan=${columnSpan()}",
|
|
||||||
"drawingOrder=$drawingOrder"
|
|
||||||
).joinToString("\n")
|
|
||||||
).plus(
|
|
||||||
/* Arrays */ arrayOf(
|
|
||||||
"actions=${actionNames()}"
|
|
||||||
).joinToString("\n")
|
|
||||||
).plus("}").joinToString("\n")
|
|
||||||
|
|
||||||
override fun toString() = "[${UiObject::class.java.simpleName}] $className ${summary()}"
|
val dataList = listOf<Pair<String, () -> Any?>>(
|
||||||
|
|
||||||
|
/* Common */
|
||||||
|
|
||||||
|
"packageName" to { packageName() },
|
||||||
|
"parent" to { parent?.className },
|
||||||
|
"id" to { id() },
|
||||||
|
"fullId" to { fullId() },
|
||||||
|
"idHex" to { idHex() },
|
||||||
|
"desc" to { desc() },
|
||||||
|
"text" to { text() },
|
||||||
|
"bounds" to { bounds() },
|
||||||
|
"center" to { center() },
|
||||||
|
"className" to { className() },
|
||||||
|
"clickable" to { clickable() },
|
||||||
|
"longClickable" to { longClickable() },
|
||||||
|
"scrollable" to { scrollable() },
|
||||||
|
"indexInParent" to { indexInParent() },
|
||||||
|
"childCount" to { childCount() },
|
||||||
|
"depth" to { depth() },
|
||||||
|
|
||||||
|
/* Regular */
|
||||||
|
|
||||||
|
"checked" to { checked() },
|
||||||
|
"enabled" to { enabled() },
|
||||||
|
"editable" to { editable() },
|
||||||
|
"focusable" to { focusable() },
|
||||||
|
"checkable" to { checkable() },
|
||||||
|
"selected" to { selected() },
|
||||||
|
"dismissable" to { isDismissable },
|
||||||
|
"visibleToUser" to { visibleToUser() },
|
||||||
|
|
||||||
|
/* Rare */
|
||||||
|
|
||||||
|
"contextClickable" to { isContextClickable },
|
||||||
|
"focused" to { focused() },
|
||||||
|
"accessibilityFocused" to { isAccessibilityFocused },
|
||||||
|
"rowCount" to { rowCount() },
|
||||||
|
"columnCount" to { columnCount() },
|
||||||
|
"row" to { row() },
|
||||||
|
"column" to { column() },
|
||||||
|
"rowSpan" to { rowSpan() },
|
||||||
|
"columnSpan" to { columnSpan() },
|
||||||
|
"drawingOrder" to { drawingOrder },
|
||||||
|
|
||||||
|
/* List */
|
||||||
|
|
||||||
|
"actions" to { actionNames() },
|
||||||
|
)
|
||||||
|
return dataList.joinToString(prefix = "{$separatorLv1", separator = separatorLv1, postfix = "$separatorLv0}") { (name, action) ->
|
||||||
|
val value = when (val actionResult = action()) {
|
||||||
|
is CharSequence -> "\"$actionResult\""
|
||||||
|
is Iterable<*> -> actionResult.joinToString(prefix = "[$separatorLv2", separator = separatorLv2, postfix = "$separatorLv1]")
|
||||||
|
is Array<*> -> actionResult.joinToString(prefix = "[$separatorLv2", separator = separatorLv2, postfix = "$separatorLv1]")
|
||||||
|
else -> actionResult
|
||||||
|
}
|
||||||
|
"$name=$value"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun toString(): String {
|
||||||
|
val simpledClassName = "$className".substringAfterLast(".")
|
||||||
|
return "[${UiObject::class.java.simpleName}] $simpledClassName ${summary()}"
|
||||||
|
}
|
||||||
|
|
||||||
override fun hashCode() = listOf(
|
override fun hashCode() = listOf(
|
||||||
"${packageName()}",
|
"${packageName()}",
|
||||||
|
|||||||
Reference in New Issue
Block a user