mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-06-23 09:30:53 +00:00
A11Y: Add some null checks to avoid crashes when running with accessibility turned on
Signed-off-by: Peter Vágner <pvdeejay@gmail.com>
This commit is contained in:
parent
dc46c14f9c
commit
f7c6178bec
2 changed files with 8 additions and 8 deletions
|
@ -112,7 +112,7 @@ open class KeyboardAccessibilityDelegate<KV : KeyboardView?>(protected val mKeyb
|
|||
* @param event The hover event.
|
||||
* @return key The key that the `event` is on.
|
||||
*/
|
||||
protected fun getHoverKeyOf(event: MotionEvent): Key {
|
||||
protected fun getHoverKeyOf(event: MotionEvent): Key? {
|
||||
val actionIndex = event.actionIndex
|
||||
val x = event.getX(actionIndex).toInt()
|
||||
val y = event.getY(actionIndex).toInt()
|
||||
|
@ -145,7 +145,7 @@ open class KeyboardAccessibilityDelegate<KV : KeyboardView?>(protected val mKeyb
|
|||
if (DEBUG_HOVER) {
|
||||
Log.d(TAG, "onHoverEnter: key=$key")
|
||||
}
|
||||
key.let { onHoverEnterTo(it) }
|
||||
key?.let { onHoverEnterTo(it) }
|
||||
mLastHoverKey = key
|
||||
}
|
||||
|
||||
|
@ -159,9 +159,9 @@ open class KeyboardAccessibilityDelegate<KV : KeyboardView?>(protected val mKeyb
|
|||
val key = getHoverKeyOf(event)
|
||||
if (key !== lastKey) {
|
||||
lastKey?.let { onHoverExitFrom(it) }
|
||||
key.let { onHoverEnterTo(it) }
|
||||
key?.let { onHoverEnterTo(it) }
|
||||
}
|
||||
key.let { onHoverMoveWithin(it) }
|
||||
key?.let { onHoverMoveWithin(it) }
|
||||
mLastHoverKey = key
|
||||
}
|
||||
|
||||
|
@ -179,8 +179,8 @@ open class KeyboardAccessibilityDelegate<KV : KeyboardView?>(protected val mKeyb
|
|||
val key = getHoverKeyOf(event)
|
||||
// Make sure we're not getting an EXIT event because the user slid
|
||||
// off the keyboard area, then force a key press.
|
||||
performClickOn(key)
|
||||
onHoverExitFrom(key)
|
||||
key?.let { performClickOn(it)
|
||||
onHoverExitFrom(it) }
|
||||
mLastHoverKey = null
|
||||
}
|
||||
|
||||
|
|
|
@ -209,7 +209,7 @@ class KeyboardAccessibilityNodeProvider<KV : KeyboardView?>(keyboardView: KV,
|
|||
}
|
||||
|
||||
override fun performAction(virtualViewId: Int, action: Int,
|
||||
arguments: Bundle): Boolean {
|
||||
arguments: Bundle?): Boolean {
|
||||
val key = getKeyOf(virtualViewId) ?: return false
|
||||
return performActionForKey(key, action)
|
||||
}
|
||||
|
@ -300,4 +300,4 @@ class KeyboardAccessibilityNodeProvider<KV : KeyboardView?>(keyboardView: KV,
|
|||
// call to setKeyboard() and therefore need to call it now.
|
||||
setKeyboard(keyboardView!!.keyboard)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue