-
-
Save ataulm/169e80f429eceab9bc03b1ca86648cc1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ViewDumpAccessibilityService : AccessibilityService() { | |
... | |
override fun onAccessibilityEvent(event: AccessibilityEvent) { | |
Log.d("!!!", "...") | |
printLeaves(event.source) | |
Log.d("!!!", "...") | |
} | |
private fun printLeaves(info: AccessibilityNodeInfo?) { | |
if (childCount(info) == 0 && info?.text != null) { | |
Log.d("!!!", info.text.toString()) | |
} else { | |
printLeavesForEachChildIn(info) | |
} | |
} | |
private fun printLeavesForEachChildIn(info: AccessibilityNodeInfo?) { | |
for (i in 0 until childCount(info)) { | |
printLeaves(info?.getChild(i)) | |
} | |
} | |
private fun childCount(info: AccessibilityNodeInfo?) = info?.childCount ?: 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment