From 4d71b1525d357a61a1740d6de5c1b97b6527f986 Mon Sep 17 00:00:00 2001 From: Krzysztof Ciombor Date: Mon, 24 Sep 2018 00:32:47 -0700 Subject: [PATCH] Fix event handlers for DPad arrows on Android TV (#21143) Summary: Fixes #20924 DPad arrow events were missing from `KEY_EVENTS_ACTIONS` which meant that they were not broadcasted by `TVEventHandler`. Pull Request resolved: https://github.com/facebook/react-native/pull/21143 Differential Revision: D10007851 Pulled By: mdvacca fbshipit-source-id: 9a03cad249a4a1917975d1de10b6112e69d32a72 --- .../ReactAndroidHWInputDeviceHelper.java | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactAndroidHWInputDeviceHelper.java b/ReactAndroid/src/main/java/com/facebook/react/ReactAndroidHWInputDeviceHelper.java index e5127d3841d0d0..35bbf17ed012ab 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactAndroidHWInputDeviceHelper.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactAndroidHWInputDeviceHelper.java @@ -25,20 +25,18 @@ public class ReactAndroidHWInputDeviceHelper { * Contains a mapping between handled KeyEvents and the corresponding navigation event * that should be fired when the KeyEvent is received. */ - private static final Map KEY_EVENTS_ACTIONS = MapBuilder.of( - KeyEvent.KEYCODE_DPAD_CENTER, - "select", - KeyEvent.KEYCODE_ENTER, - "select", - KeyEvent.KEYCODE_SPACE, - "select", - KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE, - "playPause", - KeyEvent.KEYCODE_MEDIA_REWIND, - "rewind", - KeyEvent.KEYCODE_MEDIA_FAST_FORWARD, - "fastForward" - ); + private static final Map KEY_EVENTS_ACTIONS = MapBuilder.builder() + .put(KeyEvent.KEYCODE_DPAD_CENTER, "select") + .put(KeyEvent.KEYCODE_ENTER, "select") + .put(KeyEvent.KEYCODE_SPACE, "select") + .put(KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE, "playPause") + .put(KeyEvent.KEYCODE_MEDIA_REWIND, "rewind") + .put(KeyEvent.KEYCODE_MEDIA_FAST_FORWARD, "fastForward") + .put(KeyEvent.KEYCODE_DPAD_UP, "up") + .put(KeyEvent.KEYCODE_DPAD_RIGHT, "right") + .put(KeyEvent.KEYCODE_DPAD_DOWN, "down") + .put(KeyEvent.KEYCODE_DPAD_LEFT, "left") + .build(); /** * We keep a reference to the last focused view id