Skip to content

Commit 4d71b15

Browse files
Krzysztof Ciomborfacebook-github-bot
Krzysztof Ciombor
authored andcommitted
Fix event handlers for DPad arrows on Android TV (#21143)
Summary: <!-- Thank you for sending the PR! We appreciate you spending the time to work on these changes. Help us understand your motivation by explaining why you decided to make this change. If this PR fixes an issue, type "Fixes #issueNumber" to automatically close the issue when the PR is merged. --> Fixes #20924 DPad arrow events were missing from `KEY_EVENTS_ACTIONS` which meant that they were not broadcasted by `TVEventHandler`. Pull Request resolved: #21143 Differential Revision: D10007851 Pulled By: mdvacca fbshipit-source-id: 9a03cad249a4a1917975d1de10b6112e69d32a72
1 parent 421667c commit 4d71b15

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

ReactAndroid/src/main/java/com/facebook/react/ReactAndroidHWInputDeviceHelper.java

+12-14
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,18 @@ public class ReactAndroidHWInputDeviceHelper {
2525
* Contains a mapping between handled KeyEvents and the corresponding navigation event
2626
* that should be fired when the KeyEvent is received.
2727
*/
28-
private static final Map<Integer, String> KEY_EVENTS_ACTIONS = MapBuilder.of(
29-
KeyEvent.KEYCODE_DPAD_CENTER,
30-
"select",
31-
KeyEvent.KEYCODE_ENTER,
32-
"select",
33-
KeyEvent.KEYCODE_SPACE,
34-
"select",
35-
KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE,
36-
"playPause",
37-
KeyEvent.KEYCODE_MEDIA_REWIND,
38-
"rewind",
39-
KeyEvent.KEYCODE_MEDIA_FAST_FORWARD,
40-
"fastForward"
41-
);
28+
private static final Map<Integer, String> KEY_EVENTS_ACTIONS = MapBuilder.<Integer, String>builder()
29+
.put(KeyEvent.KEYCODE_DPAD_CENTER, "select")
30+
.put(KeyEvent.KEYCODE_ENTER, "select")
31+
.put(KeyEvent.KEYCODE_SPACE, "select")
32+
.put(KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE, "playPause")
33+
.put(KeyEvent.KEYCODE_MEDIA_REWIND, "rewind")
34+
.put(KeyEvent.KEYCODE_MEDIA_FAST_FORWARD, "fastForward")
35+
.put(KeyEvent.KEYCODE_DPAD_UP, "up")
36+
.put(KeyEvent.KEYCODE_DPAD_RIGHT, "right")
37+
.put(KeyEvent.KEYCODE_DPAD_DOWN, "down")
38+
.put(KeyEvent.KEYCODE_DPAD_LEFT, "left")
39+
.build();
4240

4341
/**
4442
* We keep a reference to the last focused view id

0 commit comments

Comments
 (0)