react-native-external-keyboard 0.7.0 → 0.7.2

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.
package/README.md CHANGED
@@ -22,7 +22,7 @@ iOS | Android
22
22
 
23
23
  | iOS | Android |
24
24
  | :-- | :-- |
25
- | <img src="/.github/images/rnek-focus-lock-ios.gif" height="500" /> | <img src="/.github/images/rnek-focus-lock-ios.gif" height="500" /> |
25
+ | <img src="/.github/images/rnek-focus-lock-ios.gif" height="500" /> | <img src="/.github/images/rnek-focus-lock-android.gif" height="500" /> |
26
26
 
27
27
  > A new type of focus lock functionality has been introduced, featuring two new components: `Focus.Frame` and `Focus.Trap`. These components help manage and lock focus within specific areas of the screen.
28
28
 
@@ -154,20 +154,20 @@ public class ExternalKeyboardView extends ReactViewGroup {
154
154
 
155
155
  if (direction == FOCUS_FORWARD && orderForward != null) {
156
156
  View nextView = this.focusOrderDelegate.getLink(orderForward);
157
- if (nextView != null) {
157
+ if (isValidLinkedFocusTarget(nextView)) {
158
158
  return nextView;
159
159
  }
160
160
  }
161
161
 
162
162
  if (direction == FOCUS_BACKWARD && orderBackward != null) {
163
163
  View prevView = this.focusOrderDelegate.getLink(orderBackward);
164
- if (prevView != null) {
164
+ if (isValidLinkedFocusTarget(prevView)) {
165
165
  return prevView;
166
166
  }
167
167
  }
168
168
 
169
- if(ReactNativeVersionChecker.isReactNative80OrLater()) {
170
- if(orderGroup != null && orderIndex != null && (direction == FOCUS_FORWARD || direction == FOCUS_BACKWARD)){
169
+ if (ReactNativeVersionChecker.isReactNative80OrLater()) {
170
+ if (orderGroup != null && orderIndex != null && (direction == FOCUS_FORWARD || direction == FOCUS_BACKWARD)) {
171
171
  return FocusFinder.getInstance().findNextFocus((ViewGroup) this.getParent(), focused, direction);
172
172
  }
173
173
  }
@@ -292,6 +292,22 @@ public class ExternalKeyboardView extends ReactViewGroup {
292
292
  return focusableView != null ? focusableView : this;
293
293
  }
294
294
 
295
+ private boolean isValidLinkedFocusTarget(View target) {
296
+ if (target == null || !target.isAttachedToWindow() || !this.isAttachedToWindow()) {
297
+ return false;
298
+ }
299
+
300
+ if (target.getWindowToken() == null || this.getWindowToken() == null) {
301
+ return false;
302
+ }
303
+
304
+ if (target.getWindowToken() != this.getWindowToken()) {
305
+ return false;
306
+ }
307
+
308
+ return target.getRootView() == this.getRootView();
309
+ }
310
+
295
311
  public void setCanBeFocused(boolean canBeFocused) {
296
312
  int descendantFocusability = canBeFocused ? ViewGroup.FOCUS_BEFORE_DESCENDANTS : ViewGroup.FOCUS_BLOCK_DESCENDANTS;
297
313
  this.setDescendantFocusability(descendantFocusability);
@@ -21,7 +21,8 @@ using namespace facebook::react;
21
21
  + (void)onKeyDownPressEventEmmiter:(NSDictionary*) dictionary withEmitter:(facebook::react::SharedViewEventEmitter) _eventEmitter {
22
22
  if (_eventEmitter) {
23
23
  auto viewEventEmitter = std::static_pointer_cast<ExternalKeyboardViewEventEmitter const>(_eventEmitter);
24
-
24
+
25
+ NSString* unicodeChar = [dictionary valueForKey:@"unicodeChar"];
25
26
  facebook::react::ExternalKeyboardViewEventEmitter::OnKeyDownPress data = {
26
27
  .keyCode = [[dictionary valueForKey:@"keyCode"] intValue],
27
28
  .isLongPress = [[dictionary valueForKey:@"isLongPress"] boolValue],
@@ -31,7 +32,7 @@ using namespace facebook::react;
31
32
  .isCapsLockOn = [[dictionary valueForKey:@"isCapsLockOn"] boolValue],
32
33
  .hasNoModifiers = [[dictionary valueForKey:@"hasNoModifiers"] boolValue],
33
34
  .unicode = [[dictionary valueForKey:@"unicode"] intValue],
34
- .unicodeChar = [[[dictionary valueForKey:@"unicodeChar"] stringValue] UTF8String],
35
+ .unicodeChar = [unicodeChar UTF8String],
35
36
  };
36
37
  viewEventEmitter->onKeyDownPress(data);
37
38
  };
@@ -40,7 +41,8 @@ using namespace facebook::react;
40
41
  + (void)onKeyUpPressEventEmmiter:(NSDictionary*) dictionary withEmitter:(facebook::react::SharedViewEventEmitter) _eventEmitter {
41
42
  if (_eventEmitter) {
42
43
  auto viewEventEmitter = std::static_pointer_cast<ExternalKeyboardViewEventEmitter const>(_eventEmitter);
43
-
44
+
45
+ NSString* unicodeChar = [dictionary valueForKey:@"unicodeChar"];
44
46
  facebook::react::ExternalKeyboardViewEventEmitter::OnKeyUpPress data = {
45
47
  .keyCode = [[dictionary valueForKey:@"keyCode"] intValue],
46
48
  .isLongPress = [[dictionary valueForKey:@"isLongPress"] boolValue],
@@ -50,7 +52,7 @@ using namespace facebook::react;
50
52
  .isCapsLockOn = [[dictionary valueForKey:@"isCapsLockOn"] boolValue],
51
53
  .hasNoModifiers = [[dictionary valueForKey:@"hasNoModifiers"] boolValue],
52
54
  .unicode = [[dictionary valueForKey:@"unicode"] intValue],
53
- .unicodeChar = [[[dictionary valueForKey:@"unicodeChar"] stringValue] UTF8String],
55
+ .unicodeChar = [unicodeChar UTF8String],
54
56
  };
55
57
  viewEventEmitter->onKeyUpPress(data);
56
58
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-external-keyboard",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "description": "Toolkit for improving physical keyboard support in React Native",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",