react-native-tvos 0.64.2-1 → 0.64.2-5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/Libraries/Components/AppleTV/TVFocusGuideView.js +24 -1
  2. package/Libraries/Components/Pressable/Pressable.js +4 -4
  3. package/Libraries/Components/StatusBar/NativeStatusBarManagerIOS.js +14 -8
  4. package/Libraries/Components/Touchable/TouchableHighlight.js +1 -1
  5. package/Libraries/NewAppScreen/components/HermesBadge.js +39 -12
  6. package/README.md +8 -2
  7. package/React/Base/RCTRootView.m +5 -35
  8. package/React/Base/RCTTVRemoteHandler.h +5 -2
  9. package/React/Base/RCTTVRemoteHandler.m +173 -70
  10. package/React/Modules/RCTTVMenuBridge.m +3 -0
  11. package/React/Views/RCTModalHostView.m +6 -9
  12. package/React/Views/RCTTVFocusGuideView.m +1 -1
  13. package/ReactAndroid/gradle.properties +1 -1
  14. package/ReactAndroid/src/androidTest/assets/AndroidTestBundle.js +47 -24
  15. package/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java +10 -9
  16. package/ReactAndroid/src/main/java/com/facebook/react/modules/core/ReactAndroidHWInputDeviceHelper.java +133 -0
  17. package/ReactAndroid/src/main/java/com/facebook/react/views/modal/BUCK +1 -0
  18. package/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.java +21 -0
  19. package/ReactCommon/hermes/inspector/tools/msggen/yarn.lock +3 -3
  20. package/ReactCommon/react/renderer/components/rncore/ComponentDescriptors.h +32 -0
  21. package/ReactCommon/react/renderer/components/rncore/ComponentDescriptors.h.bak +32 -0
  22. package/ReactCommon/react/renderer/components/rncore/EventEmitters.cpp +149 -0
  23. package/ReactCommon/react/renderer/components/rncore/EventEmitters.cpp.bak +149 -0
  24. package/ReactCommon/react/renderer/components/rncore/EventEmitters.h +237 -0
  25. package/ReactCommon/react/renderer/components/rncore/EventEmitters.h.bak +237 -0
  26. package/ReactCommon/react/renderer/components/rncore/Props.cpp +218 -0
  27. package/ReactCommon/react/renderer/components/rncore/Props.cpp.bak +218 -0
  28. package/ReactCommon/react/renderer/components/rncore/Props.h +576 -0
  29. package/ReactCommon/react/renderer/components/rncore/Props.h.bak +576 -0
  30. package/ReactCommon/react/renderer/components/rncore/RCTComponentViewHelpers.h +273 -0
  31. package/ReactCommon/react/renderer/components/rncore/RCTComponentViewHelpers.h.bak +273 -0
  32. package/ReactCommon/react/renderer/components/rncore/ShadowNodes.cpp +29 -0
  33. package/ReactCommon/react/renderer/components/rncore/ShadowNodes.cpp.bak +29 -0
  34. package/ReactCommon/react/renderer/components/rncore/ShadowNodes.h +126 -0
  35. package/ReactCommon/react/renderer/components/rncore/ShadowNodes.h.bak +126 -0
  36. package/android/com/facebook/react/react-native/{0.64.2-1/react-native-0.64.2-1-sources.jar → 0.64.2-5/react-native-0.64.2-5-sources.jar} +0 -0
  37. package/android/com/facebook/react/react-native/0.64.2-5/react-native-0.64.2-5-sources.jar.md5 +1 -0
  38. package/android/com/facebook/react/react-native/0.64.2-5/react-native-0.64.2-5-sources.jar.sha1 +1 -0
  39. package/android/com/facebook/react/react-native/0.64.2-5/react-native-0.64.2-5.aar +0 -0
  40. package/android/com/facebook/react/react-native/0.64.2-5/react-native-0.64.2-5.aar.md5 +1 -0
  41. package/android/com/facebook/react/react-native/0.64.2-5/react-native-0.64.2-5.aar.sha1 +1 -0
  42. package/android/com/facebook/react/react-native/{0.64.2-1/react-native-0.64.2-1.pom → 0.64.2-5/react-native-0.64.2-5.pom} +1 -1
  43. package/android/com/facebook/react/react-native/0.64.2-5/react-native-0.64.2-5.pom.md5 +1 -0
  44. package/android/com/facebook/react/react-native/0.64.2-5/react-native-0.64.2-5.pom.sha1 +1 -0
  45. package/android/com/facebook/react/react-native/maven-metadata.xml +3 -3
  46. package/android/com/facebook/react/react-native/maven-metadata.xml.md5 +1 -1
  47. package/android/com/facebook/react/react-native/maven-metadata.xml.sha1 +1 -1
  48. package/local-cli/cli.js +0 -0
  49. package/package.json +1 -1
  50. package/template/App.js +1 -2
  51. package/template/ios/HelloWorld.xcodeproj/project.pbxproj.rej +1034 -0
  52. package/template/package.json +1 -1
  53. package/Libraries/.npmignore +0 -1
  54. package/ReactAndroid/.npmignore +0 -3
  55. package/ReactAndroid/build.gradle.orig +0 -479
  56. package/ReactAndroid/src/main/java/com/facebook/react/ReactAndroidHWInputDeviceHelper.java +0 -98
  57. package/ReactAndroid/src/main/jni/first-party/fbjni/.gitignore +0 -2
  58. package/ReactCommon/hermes/inspector/tools/msggen/.gitignore +0 -3
  59. package/android/com/facebook/react/react-native/0.64.2-1/react-native-0.64.2-1-sources.jar.md5 +0 -1
  60. package/android/com/facebook/react/react-native/0.64.2-1/react-native-0.64.2-1-sources.jar.sha1 +0 -1
  61. package/android/com/facebook/react/react-native/0.64.2-1/react-native-0.64.2-1.aar +0 -0
  62. package/android/com/facebook/react/react-native/0.64.2-1/react-native-0.64.2-1.aar.md5 +0 -1
  63. package/android/com/facebook/react/react-native/0.64.2-1/react-native-0.64.2-1.aar.sha1 +0 -1
  64. package/android/com/facebook/react/react-native/0.64.2-1/react-native-0.64.2-1.pom.md5 +0 -1
  65. package/android/com/facebook/react/react-native/0.64.2-1/react-native-0.64.2-1.pom.sha1 +0 -1
  66. package/third-party-podspecs/hermes-engine.podspec +0 -45
@@ -44,7 +44,7 @@
44
44
  - (void)addFocusGuide:(NSArray*)destinations {
45
45
 
46
46
  UIView *origin = [self reactSuperview];
47
- if (self.focusGuide == nil) {
47
+ if (self.focusGuide == nil && origin != nil) {
48
48
  self.focusGuide = [UIFocusGuide new];
49
49
  [self addLayoutGuide:self.focusGuide];
50
50
 
@@ -1,4 +1,4 @@
1
- VERSION_NAME=0.64.2-1
1
+ VERSION_NAME=0.64.2-5
2
2
  GROUP=com.facebook.react
3
3
 
4
4
  POM_NAME=ReactNative
@@ -54733,17 +54733,19 @@ __d(function (global, _$$_REQUIRE, _$$_IMPORT_DEFAULT, _$$_IMPORT_ALL, module, e
54733
54733
 
54734
54734
  var React = _$$_REQUIRE(_dependencyMap[5], "react");
54735
54735
 
54736
- var StyleSheet = _$$_REQUIRE(_dependencyMap[6], "../../StyleSheet/StyleSheet");
54736
+ var ReactNative = _$$_REQUIRE(_dependencyMap[6], "../../Renderer/shims/ReactNative");
54737
54737
 
54738
- var TVEventHandler = _$$_REQUIRE(_dependencyMap[7], "../AppleTV/TVEventHandler");
54738
+ var StyleSheet = _$$_REQUIRE(_dependencyMap[7], "../../StyleSheet/StyleSheet");
54739
54739
 
54740
- var UIManager = _$$_REQUIRE(_dependencyMap[8], "../../ReactNative/UIManager");
54740
+ var TVEventHandler = _$$_REQUIRE(_dependencyMap[8], "../AppleTV/TVEventHandler");
54741
54741
 
54742
- var View = _$$_REQUIRE(_dependencyMap[9], "../View/View");
54742
+ var UIManager = _$$_REQUIRE(_dependencyMap[9], "../../ReactNative/UIManager");
54743
54743
 
54744
- var SoundManager = _$$_REQUIRE(_dependencyMap[10], "../Sound/SoundManager");
54744
+ var View = _$$_REQUIRE(_dependencyMap[10], "../View/View");
54745
54745
 
54746
- var normalizeColor = _$$_REQUIRE(_dependencyMap[11], "../../StyleSheet/normalizeColor");
54746
+ var SoundManager = _$$_REQUIRE(_dependencyMap[11], "../Sound/SoundManager");
54747
+
54748
+ var normalizeColor = _$$_REQUIRE(_dependencyMap[12], "../../StyleSheet/normalizeColor");
54747
54749
 
54748
54750
  var extractSingleTouch = function extractSingleTouch(nativeEvent) {
54749
54751
  var touches = nativeEvent.touches;
@@ -55227,7 +55229,7 @@ __d(function (global, _$$_REQUIRE, _$$_IMPORT_DEFAULT, _$$_IMPORT_ALL, module, e
55227
55229
  __self: _this2,
55228
55230
  __source: {
55229
55231
  fileName: _jsxFileName,
55230
- lineNumber: 956,
55232
+ lineNumber: 957,
55231
55233
  columnNumber: 7
55232
55234
  }
55233
55235
  });
@@ -55241,7 +55243,7 @@ __d(function (global, _$$_REQUIRE, _$$_IMPORT_DEFAULT, _$$_IMPORT_ALL, module, e
55241
55243
  }
55242
55244
  });
55243
55245
  module.exports = Touchable;
55244
- },266,[52,10,267,3,269,54,58,270,45,88,272,65],"Libraries/Components/Touchable/Touchable.js");
55246
+ },266,[52,10,267,3,269,54,91,58,270,45,88,272,65],"Libraries/Components/Touchable/Touchable.js");
55245
55247
  __d(function (global, _$$_REQUIRE, _$$_IMPORT_DEFAULT, _$$_IMPORT_ALL, module, exports, _dependencyMap) {
55246
55248
  'use strict';
55247
55249
 
@@ -68340,38 +68342,45 @@ __d(function (global, _$$_REQUIRE, _$$_IMPORT_DEFAULT, _$$_IMPORT_ALL, module, e
68340
68342
 
68341
68343
  var TurboModuleRegistry = _interopRequireWildcard(_$$_REQUIRE(_dependencyMap[1], "../../TurboModule/TurboModuleRegistry"));
68342
68344
 
68343
- var NativeModule = TurboModuleRegistry.getEnforcing('StatusBarManager');
68345
+ var Platform = _$$_REQUIRE(_dependencyMap[2], "../../Utilities/Platform");
68346
+
68347
+ var NativeModule = Platform.isTVOS ? null : TurboModuleRegistry.getEnforcing('StatusBarManager');
68344
68348
  var constants = null;
68345
68349
  var NativeStatusBarManager = {
68346
68350
  getConstants: function getConstants() {
68347
68351
  if (constants == null) {
68348
- constants = NativeModule.getConstants();
68352
+ constants = NativeModule ? NativeModule.getConstants() : {
68353
+ HEIGHT: 0,
68354
+ DEFAULT_BACKGROUND_COLOR: 0
68355
+ };
68349
68356
  }
68350
68357
 
68351
68358
  return constants;
68352
68359
  },
68353
68360
  getHeight: function getHeight(callback) {
68354
- NativeModule.getHeight(callback);
68361
+ NativeModule ? NativeModule.getHeight(callback) : callback({
68362
+ height: 0
68363
+ });
68355
68364
  },
68356
68365
  setNetworkActivityIndicatorVisible: function setNetworkActivityIndicatorVisible(visible) {
68357
- NativeModule.setNetworkActivityIndicatorVisible(visible);
68366
+ NativeModule && NativeModule.setNetworkActivityIndicatorVisible(visible);
68358
68367
  },
68359
68368
  addListener: function addListener(eventType) {
68360
- NativeModule.addListener(eventType);
68369
+ NativeModule && NativeModule.addListener(eventType);
68361
68370
  },
68362
68371
  removeListeners: function removeListeners(count) {
68363
- NativeModule.removeListeners(count);
68372
+ NativeModule && NativeModule.removeListeners(count);
68364
68373
  },
68365
68374
  setStyle: function setStyle(statusBarStyle, animated) {
68366
- NativeModule.setStyle(statusBarStyle, animated);
68375
+ NativeModule && NativeModule.setStyle(statusBarStyle, animated);
68367
68376
  },
68368
68377
  setHidden: function setHidden(hidden, withAnimation) {
68369
- NativeModule.setHidden(hidden, withAnimation);
68378
+ NativeModule && NativeModule.setHidden(hidden, withAnimation);
68370
68379
  }
68371
68380
  };
68372
68381
  var _default = NativeStatusBarManager;
68373
68382
  exports.default = _default;
68374
- },364,[5,7],"Libraries/Components/StatusBar/NativeStatusBarManagerIOS.js");
68383
+ },364,[5,7,3],"Libraries/Components/StatusBar/NativeStatusBarManagerIOS.js");
68375
68384
  __d(function (global, _$$_REQUIRE, _$$_IMPORT_DEFAULT, _$$_IMPORT_ALL, module, exports, _dependencyMap) {
68376
68385
  'use strict';
68377
68386
 
@@ -74134,6 +74143,7 @@ __d(function (global, _$$_REQUIRE, _$$_IMPORT_DEFAULT, _$$_IMPORT_ALL, module, e
74134
74143
  var restPropsWithDefaults = (0, _extends2.default)({}, restProps, android_rippleConfig == null ? void 0 : android_rippleConfig.viewProps, {
74135
74144
  accessible: accessible !== false,
74136
74145
  focusable: focusable !== false,
74146
+ isTVSelectable: isTVSelectable !== false && accessible !== false,
74137
74147
  hitSlop: hitSlop
74138
74148
  });
74139
74149
  var config = (0, React.useMemo)(function () {
@@ -74177,7 +74187,7 @@ __d(function (global, _$$_REQUIRE, _$$_IMPORT_DEFAULT, _$$_IMPORT_ALL, module, e
74177
74187
 
74178
74188
  var pressableTVEventHandler = function pressableTVEventHandler(evt) {
74179
74189
  if (props.isTVSelectable !== false || props.focusable !== false) {
74180
- if (viewRef.current._nativeTag === evt.target) {
74190
+ if (viewRef.current && viewRef.current._nativeTag === evt.target) {
74181
74191
  if ((evt == null ? void 0 : evt.eventType) === 'focus') {
74182
74192
  setFocused(true);
74183
74193
  onFocus && onFocus(evt);
@@ -74202,19 +74212,20 @@ __d(function (global, _$$_REQUIRE, _$$_IMPORT_DEFAULT, _$$_IMPORT_ALL, module, e
74202
74212
  (0, _useTVEventHandler.default)(pressableTVEventHandler);
74203
74213
  return React.createElement(_View.default, (0, _extends2.default)({}, restPropsWithDefaults, eventHandlers, {
74204
74214
  ref: viewRef,
74205
- isTVSelectable: isTVSelectable !== false && accessible !== false,
74206
74215
  style: typeof style === 'function' ? style({
74207
- pressed: pressed
74216
+ pressed: pressed,
74217
+ focused: focused
74208
74218
  }) : style,
74209
74219
  collapsable: false,
74210
74220
  __self: this,
74211
74221
  __source: {
74212
74222
  fileName: _jsxFileName,
74213
- lineNumber: 284,
74223
+ lineNumber: 285,
74214
74224
  columnNumber: 5
74215
74225
  }
74216
74226
  }), typeof children === 'function' ? children({
74217
- pressed: pressed
74227
+ pressed: pressed,
74228
+ focused: focused
74218
74229
  }) : children, __DEV__ ? React.createElement(_PressabilityDebug.PressabilityDebugView, {
74219
74230
  color: "red",
74220
74231
  hitSlop: hitSlop,
@@ -101565,7 +101576,7 @@ __d(function (global, _$$_REQUIRE, _$$_IMPORT_DEFAULT, _$$_IMPORT_ALL, module, e
101565
101576
  columnNumber: 7
101566
101577
  }
101567
101578
  }, Platform.isTVOS ? React.createElement(RNFocusGuide, {
101568
- style: this.props.style,
101579
+ style: [this.props.style, styles.focusGuideLayout],
101569
101580
  ref: function ref(_ref) {
101570
101581
  return _this._focusGuideRef = _ref;
101571
101582
  },
@@ -101573,7 +101584,7 @@ __d(function (global, _$$_REQUIRE, _$$_IMPORT_DEFAULT, _$$_IMPORT_ALL, module, e
101573
101584
  __self: this,
101574
101585
  __source: {
101575
101586
  fileName: _jsxFileName,
101576
- lineNumber: 46,
101587
+ lineNumber: 56,
101577
101588
  columnNumber: 11
101578
101589
  }
101579
101590
  }, this.props.children) : this.props.children);
@@ -101583,6 +101594,18 @@ __d(function (global, _$$_REQUIRE, _$$_IMPORT_DEFAULT, _$$_IMPORT_ALL, module, e
101583
101594
  return TVFocusGuideView;
101584
101595
  }(React.Component);
101585
101596
 
101597
+ var styles = ReactNative.StyleSheet.create({
101598
+ focusGuideLayout: {
101599
+ left: 0,
101600
+ top: 0,
101601
+ right: 0,
101602
+ bottom: 0,
101603
+ marginLeft: 0,
101604
+ marginTop: 0,
101605
+ marginRight: 0,
101606
+ marginBottom: 0
101607
+ }
101608
+ });
101586
101609
  var RNFocusGuide = requireNativeComponent('RCTTVFocusGuideView');
101587
101610
  module.exports = TVFocusGuideView;
101588
101611
  },487,[23,24,36,38,35,229,54,1,3],"Libraries/Components/AppleTV/TVFocusGuideView.js");
@@ -43,7 +43,6 @@ import com.facebook.react.bridge.WritableNativeMap;
43
43
  import com.facebook.react.common.annotations.VisibleForTesting;
44
44
  import com.facebook.react.config.ReactFeatureFlags;
45
45
  import com.facebook.react.modules.appregistry.AppRegistry;
46
- import com.facebook.react.modules.core.DeviceEventManagerModule;
47
46
  import com.facebook.react.modules.deviceinfo.DeviceInfoModule;
48
47
  import com.facebook.react.surface.ReactStage;
49
48
  import com.facebook.react.uimanager.DisplayMetricsHolder;
@@ -56,6 +55,7 @@ import com.facebook.react.uimanager.UIManagerHelper;
56
55
  import com.facebook.react.uimanager.UIManagerModule;
57
56
  import com.facebook.react.uimanager.common.UIManagerType;
58
57
  import com.facebook.react.uimanager.events.EventDispatcher;
58
+ import com.facebook.react.modules.core.ReactAndroidHWInputDeviceHelper;
59
59
  import com.facebook.systrace.Systrace;
60
60
 
61
61
  /**
@@ -90,7 +90,7 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
90
90
  private boolean mShouldLogContentAppeared;
91
91
  private @Nullable JSTouchDispatcher mJSTouchDispatcher;
92
92
  private final ReactAndroidHWInputDeviceHelper mAndroidHWInputDeviceHelper =
93
- new ReactAndroidHWInputDeviceHelper(this);
93
+ new ReactAndroidHWInputDeviceHelper();
94
94
  private boolean mWasMeasured = false;
95
95
  private int mWidthMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
96
96
  private int mHeightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
@@ -230,7 +230,7 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
230
230
  FLog.w(TAG, "Unable to handle key event as the catalyst instance has not been attached");
231
231
  return super.dispatchKeyEvent(ev);
232
232
  }
233
- mAndroidHWInputDeviceHelper.handleKeyEvent(ev);
233
+ mAndroidHWInputDeviceHelper.handleKeyEvent(ev, mReactInstanceManager.getCurrentReactContext());
234
234
  return super.dispatchKeyEvent(ev);
235
235
  }
236
236
 
@@ -245,7 +245,7 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
245
245
  super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
246
246
  return;
247
247
  }
248
- mAndroidHWInputDeviceHelper.clearFocus();
248
+ mAndroidHWInputDeviceHelper.clearFocus(mReactInstanceManager.getCurrentReactContext());
249
249
  super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
250
250
  }
251
251
 
@@ -260,7 +260,7 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
260
260
  super.requestChildFocus(child, focused);
261
261
  return;
262
262
  }
263
- mAndroidHWInputDeviceHelper.onFocusChanged(focused);
263
+ mAndroidHWInputDeviceHelper.onFocusChanged(focused, mReactInstanceManager.getCurrentReactContext());
264
264
  super.requestChildFocus(child, focused);
265
265
  }
266
266
 
@@ -683,10 +683,11 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
683
683
 
684
684
  /* package */ void sendEvent(String eventName, @Nullable WritableMap params) {
685
685
  if (mReactInstanceManager != null) {
686
- mReactInstanceManager
687
- .getCurrentReactContext()
688
- .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
689
- .emit(eventName, params);
686
+ mAndroidHWInputDeviceHelper.emitNamedEvent(
687
+ eventName,
688
+ params,
689
+ mReactInstanceManager.getCurrentReactContext()
690
+ );
690
691
  }
691
692
  }
692
693
 
@@ -0,0 +1,133 @@
1
+ /*
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ package com.facebook.react.modules.core;
9
+
10
+ import android.view.KeyEvent;
11
+ import android.view.View;
12
+
13
+ import com.facebook.react.bridge.ReactContext;
14
+ import com.facebook.react.bridge.WritableMap;
15
+ import com.facebook.react.bridge.WritableNativeMap;
16
+ import com.facebook.react.common.MapBuilder;
17
+ import com.facebook.react.common.SystemClock;
18
+
19
+ import java.util.Map;
20
+
21
+ /** Responsible for dispatching events specific for hardware inputs. */
22
+ public class ReactAndroidHWInputDeviceHelper {
23
+
24
+ /**
25
+ * Contains a mapping between handled KeyEvents and the corresponding navigation event that should
26
+ * be fired when the KeyEvent is received.
27
+ */
28
+ private static final Map<Integer, String> KEY_EVENTS_ACTIONS =
29
+ MapBuilder.<Integer, String>builder()
30
+ .put(KeyEvent.KEYCODE_DPAD_CENTER, "select")
31
+ .put(KeyEvent.KEYCODE_ENTER, "select")
32
+ .put(KeyEvent.KEYCODE_NUMPAD_ENTER, "select")
33
+ .put(KeyEvent.KEYCODE_BUTTON_SELECT, "select")
34
+ .put(KeyEvent.KEYCODE_SPACE, "select")
35
+ .put(KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE, "playPause")
36
+ .put(KeyEvent.KEYCODE_MEDIA_PLAY, "play")
37
+ .put(KeyEvent.KEYCODE_MEDIA_PAUSE, "pause")
38
+ .put(KeyEvent.KEYCODE_MEDIA_NEXT, "next")
39
+ .put(KeyEvent.KEYCODE_MEDIA_PREVIOUS, "previous")
40
+ .put(KeyEvent.KEYCODE_MEDIA_REWIND, "rewind")
41
+ .put(KeyEvent.KEYCODE_MEDIA_FAST_FORWARD, "fastForward")
42
+ .put(KeyEvent.KEYCODE_DPAD_UP, "up")
43
+ .put(KeyEvent.KEYCODE_DPAD_RIGHT, "right")
44
+ .put(KeyEvent.KEYCODE_DPAD_DOWN, "down")
45
+ .put(KeyEvent.KEYCODE_DPAD_LEFT, "left")
46
+ .build();
47
+
48
+ /**
49
+ * We keep a reference to the last focused view id so that we can send it as a target for key
50
+ * events and be able to send a blur event when focus changes.
51
+ */
52
+ private int mLastFocusedViewId = View.NO_ID;
53
+
54
+ private long mLastKeyDownTime = 0;
55
+ private long mPressedDelta = 1000;
56
+
57
+ public ReactAndroidHWInputDeviceHelper() {}
58
+
59
+ private boolean isSelectEvent(int eventKeyCode) {
60
+ return eventKeyCode == KeyEvent.KEYCODE_DPAD_CENTER ||
61
+ eventKeyCode == KeyEvent.KEYCODE_BUTTON_SELECT ||
62
+ eventKeyCode == KeyEvent.KEYCODE_NUMPAD_ENTER ||
63
+ eventKeyCode == KeyEvent.KEYCODE_ENTER;
64
+ }
65
+
66
+ /** Called from {@link com.facebook.react.ReactRootView}. This is the main place the key events are handled. */
67
+ public void handleKeyEvent(KeyEvent ev, ReactContext context) {
68
+ int eventKeyCode = ev.getKeyCode();
69
+ int eventKeyAction = ev.getAction();
70
+ long time = SystemClock.uptimeMillis();
71
+
72
+ // Simple implementation of long press detection
73
+ if ((eventKeyAction == KeyEvent.ACTION_DOWN)
74
+ && isSelectEvent(eventKeyCode) && mLastKeyDownTime == 0) {
75
+ mLastKeyDownTime = time;
76
+ }
77
+ // We only need the up event for Android TV
78
+ // if ((eventKeyAction == KeyEvent.ACTION_UP || eventKeyAction == KeyEvent.ACTION_DOWN)
79
+ if ((eventKeyAction == KeyEvent.ACTION_UP)
80
+ && KEY_EVENTS_ACTIONS.containsKey(eventKeyCode)) {
81
+ long delta = time - mLastKeyDownTime;
82
+ if (isSelectEvent(eventKeyCode) && (delta > mPressedDelta)) {
83
+ dispatchEvent("longSelect", mLastFocusedViewId, eventKeyAction, context);
84
+ } else {
85
+ dispatchEvent(KEY_EVENTS_ACTIONS.get(eventKeyCode), mLastFocusedViewId, eventKeyAction, context);
86
+ }
87
+ mLastKeyDownTime = 0;
88
+ }
89
+ }
90
+
91
+ /** Called from {@link com.facebook.react.ReactRootView} when focused view changes. */
92
+ public void onFocusChanged(View newFocusedView, ReactContext context) {
93
+ if (mLastFocusedViewId == newFocusedView.getId()) {
94
+ return;
95
+ }
96
+ if (mLastFocusedViewId != View.NO_ID) {
97
+ dispatchEvent("blur", mLastFocusedViewId, context);
98
+ }
99
+ mLastFocusedViewId = newFocusedView.getId();
100
+ dispatchEvent("focus", newFocusedView.getId(), context);
101
+ }
102
+
103
+ /** Called from {@link com.facebook.react.ReactRootView} when the whole view hierarchy looses focus. */
104
+ public void clearFocus(ReactContext context) {
105
+ if (mLastFocusedViewId != View.NO_ID) {
106
+ dispatchEvent("blur", mLastFocusedViewId, context);
107
+ }
108
+ mLastFocusedViewId = View.NO_ID;
109
+ }
110
+
111
+ private void dispatchEvent(String eventType, int targetViewId, ReactContext context) {
112
+ dispatchEvent(eventType, targetViewId, -1, context);
113
+ }
114
+
115
+ private void dispatchEvent(String eventType, int targetViewId, int eventKeyAction, ReactContext context) {
116
+ WritableMap event = new WritableNativeMap();
117
+ event.putString("eventType", eventType);
118
+ event.putInt("eventKeyAction", eventKeyAction);
119
+ if (targetViewId != View.NO_ID) {
120
+ event.putInt("tag", targetViewId);
121
+ event.putInt("target", targetViewId);
122
+ }
123
+ emitNamedEvent("onHWKeyEvent", event, context);
124
+ }
125
+
126
+ public void emitNamedEvent(String eventName, WritableMap event, ReactContext context) {
127
+ if (context != null) {
128
+ context.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
129
+ .emit(eventName, event);
130
+ }
131
+ }
132
+
133
+ }
@@ -19,6 +19,7 @@ rn_android_library(
19
19
  react_native_target("java/com/facebook/react/bridge:bridge"),
20
20
  react_native_target("java/com/facebook/react/common:common"),
21
21
  react_native_target("java/com/facebook/react/module/annotations:annotations"),
22
+ react_native_target("java/com/facebook/react/modules/core:core"),
22
23
  react_native_target("java/com/facebook/react/touch:touch"),
23
24
  react_native_target("java/com/facebook/react/uimanager:uimanager"),
24
25
  react_native_target("java/com/facebook/react/uimanager/annotations:annotations"),
@@ -12,6 +12,7 @@ import android.app.Activity;
12
12
  import android.app.Dialog;
13
13
  import android.content.Context;
14
14
  import android.content.DialogInterface;
15
+ import android.graphics.Rect;
15
16
  import android.view.KeyEvent;
16
17
  import android.view.MotionEvent;
17
18
  import android.view.View;
@@ -23,8 +24,10 @@ import android.view.accessibility.AccessibilityEvent;
23
24
  import android.widget.FrameLayout;
24
25
  import androidx.annotation.Nullable;
25
26
  import androidx.annotation.UiThread;
27
+
26
28
  import com.facebook.infer.annotation.Assertions;
27
29
  import com.facebook.react.R;
30
+ import com.facebook.react.modules.core.ReactAndroidHWInputDeviceHelper;
28
31
  import com.facebook.react.bridge.GuardedRunnable;
29
32
  import com.facebook.react.bridge.LifecycleEventListener;
30
33
  import com.facebook.react.bridge.ReactContext;
@@ -398,8 +401,14 @@ public class ReactModalHostView extends ViewGroup
398
401
 
399
402
  private final JSTouchDispatcher mJSTouchDispatcher = new JSTouchDispatcher(this);
400
403
 
404
+ private final ReactAndroidHWInputDeviceHelper mAndroidHWInputDeviceHelper;
405
+
406
+ private final ReactContext mReactContext;
407
+
401
408
  public DialogRootViewGroup(Context context) {
402
409
  super(context);
410
+ mReactContext = (ReactContext)context;
411
+ mAndroidHWInputDeviceHelper = new ReactAndroidHWInputDeviceHelper();
403
412
  }
404
413
 
405
414
  @Override
@@ -410,6 +419,18 @@ public class ReactModalHostView extends ViewGroup
410
419
  updateFirstChildView();
411
420
  }
412
421
 
422
+ @Override
423
+ protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) {
424
+ mAndroidHWInputDeviceHelper.clearFocus(mReactContext);
425
+ super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
426
+ }
427
+
428
+ @Override
429
+ public void requestChildFocus(View child, View focused) {
430
+ mAndroidHWInputDeviceHelper.onFocusChanged(focused, mReactContext);
431
+ super.requestChildFocus(child, focused);
432
+ }
433
+
413
434
  private void updateFirstChildView() {
414
435
  if (getChildCount() > 0) {
415
436
  hasAdjustedSize = false;
@@ -3902,9 +3902,9 @@ path-key@^2.0.0, path-key@^2.0.1:
3902
3902
  integrity sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=
3903
3903
 
3904
3904
  path-parse@^1.0.6:
3905
- version "1.0.6"
3906
- resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c"
3907
- integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==
3905
+ version "1.0.7"
3906
+ resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735"
3907
+ integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==
3908
3908
 
3909
3909
  path-type@^3.0.0:
3910
3910
  version "3.0.0"
@@ -0,0 +1,32 @@
1
+
2
+ /**
3
+ * Copyright (c) Facebook, Inc. and its affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ *
8
+ * @generated by codegen project: GenerateComponentDescriptorH.js
9
+ */
10
+
11
+ #pragma once
12
+
13
+ #include <react/renderer/components/rncore/ShadowNodes.h>
14
+ #include <react/renderer/core/ConcreteComponentDescriptor.h>
15
+
16
+ namespace facebook {
17
+ namespace react {
18
+
19
+ using ActivityIndicatorViewComponentDescriptor = ConcreteComponentDescriptor<ActivityIndicatorViewShadowNode>;
20
+ using DatePickerComponentDescriptor = ConcreteComponentDescriptor<DatePickerShadowNode>;
21
+ using AndroidDrawerLayoutComponentDescriptor = ConcreteComponentDescriptor<AndroidDrawerLayoutShadowNode>;
22
+ using RCTMaskedViewComponentDescriptor = ConcreteComponentDescriptor<RCTMaskedViewShadowNode>;
23
+ using RCTProgressViewComponentDescriptor = ConcreteComponentDescriptor<RCTProgressViewShadowNode>;
24
+ using AndroidSwipeRefreshLayoutComponentDescriptor = ConcreteComponentDescriptor<AndroidSwipeRefreshLayoutShadowNode>;
25
+ using PullToRefreshViewComponentDescriptor = ConcreteComponentDescriptor<PullToRefreshViewShadowNode>;
26
+ using AndroidHorizontalScrollContentViewComponentDescriptor = ConcreteComponentDescriptor<AndroidHorizontalScrollContentViewShadowNode>;
27
+ using RCTSegmentedControlComponentDescriptor = ConcreteComponentDescriptor<RCTSegmentedControlShadowNode>;
28
+ using SwitchComponentDescriptor = ConcreteComponentDescriptor<SwitchShadowNode>;
29
+ using UnimplementedNativeViewComponentDescriptor = ConcreteComponentDescriptor<UnimplementedNativeViewShadowNode>;
30
+
31
+ } // namespace react
32
+ } // namespace facebook
@@ -0,0 +1,32 @@
1
+
2
+ /**
3
+ * Copyright (c) Facebook, Inc. and its affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ *
8
+ * @generated by codegen project: GenerateComponentDescriptorH.js
9
+ */
10
+
11
+ #pragma once
12
+
13
+ #include <react/renderer/components/FBReactNativeSpec/ShadowNodes.h>
14
+ #include <react/renderer/core/ConcreteComponentDescriptor.h>
15
+
16
+ namespace facebook {
17
+ namespace react {
18
+
19
+ using ActivityIndicatorViewComponentDescriptor = ConcreteComponentDescriptor<ActivityIndicatorViewShadowNode>;
20
+ using DatePickerComponentDescriptor = ConcreteComponentDescriptor<DatePickerShadowNode>;
21
+ using AndroidDrawerLayoutComponentDescriptor = ConcreteComponentDescriptor<AndroidDrawerLayoutShadowNode>;
22
+ using RCTMaskedViewComponentDescriptor = ConcreteComponentDescriptor<RCTMaskedViewShadowNode>;
23
+ using RCTProgressViewComponentDescriptor = ConcreteComponentDescriptor<RCTProgressViewShadowNode>;
24
+ using AndroidSwipeRefreshLayoutComponentDescriptor = ConcreteComponentDescriptor<AndroidSwipeRefreshLayoutShadowNode>;
25
+ using PullToRefreshViewComponentDescriptor = ConcreteComponentDescriptor<PullToRefreshViewShadowNode>;
26
+ using AndroidHorizontalScrollContentViewComponentDescriptor = ConcreteComponentDescriptor<AndroidHorizontalScrollContentViewShadowNode>;
27
+ using RCTSegmentedControlComponentDescriptor = ConcreteComponentDescriptor<RCTSegmentedControlShadowNode>;
28
+ using SwitchComponentDescriptor = ConcreteComponentDescriptor<SwitchShadowNode>;
29
+ using UnimplementedNativeViewComponentDescriptor = ConcreteComponentDescriptor<UnimplementedNativeViewShadowNode>;
30
+
31
+ } // namespace react
32
+ } // namespace facebook