Created
April 6, 2020 02:05
-
-
Save miguelhincapie/560674f3528f6c3b547442ae86618fa1 to your computer and use it in GitHub Desktop.
Delegate implementation for general accessibility navigation using TalkBack.
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 GeneralKeyEventDelegate : BaseKeyEventDelegate() { | |
init { | |
keyEventActionMap.let { | |
it.put( | |
createKey( | |
R.id.accessibility_state, | |
KEYCODE_DPAD_DOWN, | |
ACTION_DOWN | |
), | |
this::consumeDownKeyOnTitle | |
) | |
it.put( | |
createKey( | |
R.id.button_turn_on, | |
KEYCODE_DPAD_DOWN, | |
ACTION_DOWN | |
), | |
this::consumeDownKeyOnTurnOnButton | |
) | |
it.put( | |
createKey( | |
R.id.button_turn_on, | |
KEYCODE_DPAD_UP, | |
ACTION_DOWN | |
), | |
this::consumeUpKeyOnTurnOnButton | |
) | |
it.put( | |
createKey( | |
R.id.button_turn_off, | |
KEYCODE_DPAD_UP, | |
ACTION_DOWN | |
), | |
this::consumeUpKeyOnTurnOffButton | |
) | |
} | |
} | |
private fun consumeDownKeyOnTitle(currentFocus: View): Boolean { | |
currentFocus.nextFocusDownId = R.id.gridRV | |
return false | |
} | |
private fun consumeDownKeyOnTurnOnButton(currentFocus: View): Boolean { | |
currentFocus.nextFocusDownId = R.id.button_turn_off | |
return false | |
} | |
private fun consumeUpKeyOnTurnOnButton(currentFocus: View): Boolean { | |
currentFocus.nextFocusUpId = R.id.carouselRV | |
return false | |
} | |
private fun consumeUpKeyOnTurnOffButton(currentFocus: View): Boolean { | |
currentFocus.nextFocusUpId = R.id.button_turn_on | |
return false | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment