Skip to content

Instantly share code, notes, and snippets.

@tpolecat
Created May 22, 2013 23:26
Show Gist options
  • Save tpolecat/5631755 to your computer and use it in GitHub Desktop.
Save tpolecat/5631755 to your computer and use it in GitHub Desktop.
object Marrrk {
trait AccessibilityNodeInfo {
def getChildCount: Int
def getChild(n: Int): AccessibilityNodeInfo
def getClassName: String
def performAction(a: Any): Boolean
}
object AccessibilityNodeInfo {
val ACTION_CLICK = 1
}
trait AccessibilityEvent {
def getSource: AccessibilityNodeInfo
}
def getNodeWithText(ani: AccessibilityNodeInfo, text: String): Option[AccessibilityNodeInfo] = ???
def findClickableParent(nodeInfo: AccessibilityNodeInfo): Option[AccessibilityNodeInfo] = ???
def selectAutoResponderKeyboard(event: AccessibilityEvent): Boolean = {
val parent = for {
node <- getNodeWithText(event.getSource, "Nyx")
parent <- findClickableParent(node)
} yield parent: AccessibilityNodeInfo
parent.fold(false)(p => p.performAction(AccessibilityNodeInfo.ACTION_CLICK))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment