react-native-external-keyboard 0.8.5 → 0.9.1

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 (159) hide show
  1. package/README.md +149 -67
  2. package/android/src/main/java/com/externalkeyboard/delegates/FocusOrderDelegate.java +81 -75
  3. package/android/src/main/java/com/externalkeyboard/delegates/FocusOrderDelegateHost.java +14 -0
  4. package/android/src/main/java/com/externalkeyboard/helper/Linking/A11yOrderLinking.java +5 -0
  5. package/android/src/main/java/com/externalkeyboard/modules/ExternalKeyboardModule.java +10 -10
  6. package/android/src/main/java/com/externalkeyboard/services/FocusLinkObserver/FocusLinkObserver.java +26 -35
  7. package/android/src/main/java/com/externalkeyboard/views/ExternalKeyboardLockView/ExternalKeyboardLockView.java +5 -0
  8. package/android/src/main/java/com/externalkeyboard/views/ExternalKeyboardLockView/ExternalKeyboardLockViewManager.java +6 -0
  9. package/android/src/main/java/com/externalkeyboard/views/ExternalKeyboardView/ExternalKeyboardView.java +8 -307
  10. package/android/src/main/java/com/externalkeyboard/views/ExternalKeyboardView/ExternalKeyboardViewManager.java +11 -18
  11. package/android/src/main/java/com/externalkeyboard/views/TextInputFocusWrapper/TextInputFocusWrapper.java +208 -101
  12. package/android/src/main/java/com/externalkeyboard/views/TextInputFocusWrapper/TextInputFocusWrapperManager.java +123 -34
  13. package/android/src/main/java/com/externalkeyboard/views/base/FocusHighlightBase.java +38 -0
  14. package/android/src/main/java/com/externalkeyboard/views/base/ViewGroupBase.java +19 -0
  15. package/android/src/main/java/com/externalkeyboard/views/base/ViewOrderGroupBase.java +190 -0
  16. package/android/src/main/java/com/externalkeyboard/views/base/keyboard/ViewFocusChangeBase.java +39 -0
  17. package/android/src/main/java/com/externalkeyboard/views/base/keyboard/ViewFocusRequestBase.java +125 -0
  18. package/android/src/main/java/com/externalkeyboard/views/base/keyboard/ViewKeyHandlerBase.java +40 -0
  19. package/android/src/newarch/TextInputFocusWrapperManagerSpec.java +2 -8
  20. package/android/src/oldarch/ExternalKeyboardLockViewManagerSpec.java +1 -0
  21. package/android/src/oldarch/TextInputFocusWrapperManagerSpec.java +32 -2
  22. package/ios/Delegates/RNCEKVFocusLinkDelegate/RNCEKVFocusLinkDelegate.h +35 -0
  23. package/ios/Delegates/RNCEKVFocusLinkDelegate/RNCEKVFocusLinkDelegate.mm +195 -0
  24. package/ios/Delegates/RNCEKVFocusOrderDelegate/RNCEKVFocusOrderProtocol.h +6 -8
  25. package/ios/Delegates/RNCEKVFocusSequenceDelegate/RNCEKVFocusSequenceDelegate.h +25 -0
  26. package/ios/Delegates/RNCEKVFocusSequenceDelegate/RNCEKVFocusSequenceDelegate.mm +163 -0
  27. package/ios/Delegates/RNCEKVGroupIdentifierDelegate/RNCEKVGroupIdentifierDelegate.h +2 -6
  28. package/ios/Delegates/RNCEKVGroupIdentifierDelegate/RNCEKVGroupIdentifierDelegate.mm +6 -78
  29. package/ios/Delegates/RNCEKVHaloDelegate/RNCEKVHaloDelegate.h +3 -4
  30. package/ios/Delegates/RNCEKVHaloDelegate/RNCEKVHaloDelegate.mm +32 -101
  31. package/ios/Delegates/RNCEKVHaloDelegate/RNCEKVHaloProtocol.h +1 -1
  32. package/ios/Extensions/RCTEnhancedScrollView+RNCEKVExternalKeyboard.mm +1 -1
  33. package/ios/Extensions/RCTTextInputComponentView+RNCEKVExternalKeyboard.mm +15 -0
  34. package/ios/Extensions/RCTViewComponentView+RNCEKVExternalKeyboard.h +9 -6
  35. package/ios/Extensions/RCTViewComponentView+RNCEKVExternalKeyboard.mm +16 -29
  36. package/ios/Extensions/UIViewController+RNCEKVExternalKeyboard.h +1 -0
  37. package/ios/Extensions/UIViewController+RNCEKVExternalKeyboard.mm +8 -0
  38. package/ios/Helpers/RNCEKVNativeProps/RNCEKVNativeProps.h +123 -0
  39. package/ios/Protocols/RNCEKVCustomFocusEffectProtocol.h +15 -0
  40. package/ios/Protocols/RNCEKVCustomGroudIdProtocol.h +15 -0
  41. package/ios/Protocols/RNCEKVKeyboardFocusableProtocol.h +15 -0
  42. package/ios/Services/RNCEKVFocusLinkObserver.mm +2 -3
  43. package/ios/Services/RNCEKVKeyboardOrderManager/RNCEKVOrderRelationship/RNCEKVOrderRelationship.mm +15 -28
  44. package/ios/Services/RNCEKVOrderLinking.mm +43 -51
  45. package/ios/Views/Base/ContextMenu/RNCEKVViewContextMenuBase.h +33 -0
  46. package/ios/Views/Base/ContextMenu/RNCEKVViewContextMenuBase.mm +84 -0
  47. package/ios/Views/Base/FocusChange/RNCEKVViewFocusChangeBase.h +37 -0
  48. package/ios/Views/Base/FocusChange/RNCEKVViewFocusChangeBase.mm +89 -0
  49. package/ios/Views/Base/FocusOrderGroup/RNCEKVViewOrderGroupBase.h +49 -0
  50. package/ios/Views/Base/FocusOrderGroup/RNCEKVViewOrderGroupBase.mm +245 -0
  51. package/ios/Views/Base/FocusRequest/RNCEKVViewFocusRequestBase.h +34 -0
  52. package/ios/Views/Base/FocusRequest/RNCEKVViewFocusRequestBase.mm +112 -0
  53. package/ios/Views/Base/GroupIdentifier/RNCEKVViewGroupIdentifierBase.h +27 -0
  54. package/ios/Views/Base/GroupIdentifier/RNCEKVViewGroupIdentifierBase.mm +69 -0
  55. package/ios/Views/Base/KeyPress/RNCEKVViewKeyPress.h +30 -0
  56. package/ios/Views/Base/KeyPress/RNCEKVViewKeyPress.mm +75 -0
  57. package/ios/Views/Base/KeyboardHallo/RNCEKVExternalKeyboardHalloBase.h +33 -0
  58. package/ios/Views/Base/KeyboardHallo/RNCEKVExternalKeyboardHalloBase.mm +92 -0
  59. package/ios/Views/Base/ViewGroup/RNCEKVViewGroupBase.h +36 -0
  60. package/ios/Views/Base/ViewGroup/RNCEKVViewGroupBase.mm +63 -0
  61. package/ios/Views/RNCEKVExternalKeyboardLockView/RNCEKVExternalKeyboardLockView.h +8 -0
  62. package/ios/Views/RNCEKVExternalKeyboardLockView/RNCEKVExternalKeyboardLockView.mm +105 -2
  63. package/ios/Views/RNCEKVExternalKeyboardLockView/RNCEKVExternalKeyboardLockViewManager.mm +11 -0
  64. package/ios/Views/RNCEKVExternalKeyboardView/RNCEKVExternalKeyboardView.h +7 -82
  65. package/ios/Views/RNCEKVExternalKeyboardView/RNCEKVExternalKeyboardView.mm +23 -493
  66. package/ios/Views/RNCEKVExternalKeyboardView/RNCEKVExternalKeyboardViewManager.mm +5 -7
  67. package/ios/Views/RNCEKVKeyboardFocusGroupView/RNCEKVKeyboardFocusGroup.mm +20 -17
  68. package/ios/Views/RNCEKVTextInputFocusWrapper/RNCEKVTextInputFocusWrapper.h +10 -39
  69. package/ios/Views/RNCEKVTextInputFocusWrapper/RNCEKVTextInputFocusWrapper.mm +40 -73
  70. package/ios/Views/RNCEKVTextInputFocusWrapper/RNCEKVTextInputFocusWrapperManager.mm +76 -8
  71. package/lib/commonjs/components/BaseKeyboardView/BaseKeyboardView.js +35 -7
  72. package/lib/commonjs/components/BaseKeyboardView/BaseKeyboardView.js.map +1 -1
  73. package/lib/commonjs/components/KeyboardExtendedInput/KeyboardExtendedInput.js +79 -1
  74. package/lib/commonjs/components/KeyboardExtendedInput/KeyboardExtendedInput.js.map +1 -1
  75. package/lib/commonjs/components/KeyboardFocusLock/FocusTrap/FocusTrap.js +18 -4
  76. package/lib/commonjs/components/KeyboardFocusLock/FocusTrap/FocusTrap.js.map +1 -1
  77. package/lib/commonjs/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.js +17 -2
  78. package/lib/commonjs/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.js.map +1 -1
  79. package/lib/commonjs/components/KeyboardFocusView/KeyboardFocusView.js +2 -0
  80. package/lib/commonjs/components/KeyboardFocusView/KeyboardFocusView.js.map +1 -1
  81. package/lib/commonjs/nativeSpec/ExternalKeyboardLockViewNativeComponent.ts +1 -0
  82. package/lib/commonjs/nativeSpec/TextInputFocusWrapperNativeComponent.ts +16 -0
  83. package/lib/commonjs/utils/useFocusStyle.js +3 -9
  84. package/lib/commonjs/utils/useFocusStyle.js.map +1 -1
  85. package/lib/commonjs/utils/withKeyboardFocus.js +32 -15
  86. package/lib/commonjs/utils/withKeyboardFocus.js.map +1 -1
  87. package/lib/commonjs/utils/wrapOrderPrefix.js +17 -0
  88. package/lib/commonjs/utils/wrapOrderPrefix.js.map +1 -0
  89. package/lib/module/components/BaseKeyboardView/BaseKeyboardView.js +35 -7
  90. package/lib/module/components/BaseKeyboardView/BaseKeyboardView.js.map +1 -1
  91. package/lib/module/components/KeyboardExtendedInput/KeyboardExtendedInput.js +80 -2
  92. package/lib/module/components/KeyboardExtendedInput/KeyboardExtendedInput.js.map +1 -1
  93. package/lib/module/components/KeyboardFocusLock/FocusTrap/FocusTrap.js +18 -4
  94. package/lib/module/components/KeyboardFocusLock/FocusTrap/FocusTrap.js.map +1 -1
  95. package/lib/module/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.js +16 -2
  96. package/lib/module/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.js.map +1 -1
  97. package/lib/module/components/KeyboardFocusView/KeyboardFocusView.js +2 -0
  98. package/lib/module/components/KeyboardFocusView/KeyboardFocusView.js.map +1 -1
  99. package/lib/module/nativeSpec/ExternalKeyboardLockViewNativeComponent.ts +1 -0
  100. package/lib/module/nativeSpec/TextInputFocusWrapperNativeComponent.ts +16 -0
  101. package/lib/module/utils/useFocusStyle.js +4 -10
  102. package/lib/module/utils/useFocusStyle.js.map +1 -1
  103. package/lib/module/utils/withKeyboardFocus.js +32 -15
  104. package/lib/module/utils/withKeyboardFocus.js.map +1 -1
  105. package/lib/module/utils/wrapOrderPrefix.js +12 -0
  106. package/lib/module/utils/wrapOrderPrefix.js.map +1 -0
  107. package/lib/typescript/src/components/BaseKeyboardView/BaseKeyboardView.d.ts.map +1 -1
  108. package/lib/typescript/src/components/KeyboardExtendedInput/KeyboardExtendedInput.d.ts.map +1 -1
  109. package/lib/typescript/src/components/KeyboardExtendedInput/KeyboardExtendedInput.types.d.ts +15 -0
  110. package/lib/typescript/src/components/KeyboardExtendedInput/KeyboardExtendedInput.types.d.ts.map +1 -1
  111. package/lib/typescript/src/components/KeyboardFocusLock/FocusTrap/FocusTrap.d.ts +1 -1
  112. package/lib/typescript/src/components/KeyboardFocusLock/FocusTrap/FocusTrap.d.ts.map +1 -1
  113. package/lib/typescript/src/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.d.ts +2 -1
  114. package/lib/typescript/src/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.d.ts.map +1 -1
  115. package/lib/typescript/src/components/KeyboardFocusView/KeyboardFocusView.d.ts.map +1 -1
  116. package/lib/typescript/src/index.d.ts +1 -1
  117. package/lib/typescript/src/nativeSpec/ExternalKeyboardLockViewNativeComponent.d.ts +1 -0
  118. package/lib/typescript/src/nativeSpec/ExternalKeyboardLockViewNativeComponent.d.ts.map +1 -1
  119. package/lib/typescript/src/nativeSpec/TextInputFocusWrapperNativeComponent.d.ts +16 -1
  120. package/lib/typescript/src/nativeSpec/TextInputFocusWrapperNativeComponent.d.ts.map +1 -1
  121. package/lib/typescript/src/types/BaseKeyboardView.d.ts +2 -0
  122. package/lib/typescript/src/types/BaseKeyboardView.d.ts.map +1 -1
  123. package/lib/typescript/src/types/KeyboardFocusLock.types.d.ts +1 -0
  124. package/lib/typescript/src/types/KeyboardFocusLock.types.d.ts.map +1 -1
  125. package/lib/typescript/src/types/WithKeyboardFocus.d.ts +11 -2
  126. package/lib/typescript/src/types/WithKeyboardFocus.d.ts.map +1 -1
  127. package/lib/typescript/src/utils/useFocusStyle.d.ts +1 -0
  128. package/lib/typescript/src/utils/useFocusStyle.d.ts.map +1 -1
  129. package/lib/typescript/src/utils/withKeyboardFocus.d.ts.map +1 -1
  130. package/lib/typescript/src/utils/wrapOrderPrefix.d.ts +9 -0
  131. package/lib/typescript/src/utils/wrapOrderPrefix.d.ts.map +1 -0
  132. package/package.json +6 -2
  133. package/src/components/BaseKeyboardView/BaseKeyboardView.tsx +88 -10
  134. package/src/components/KeyboardExtendedInput/KeyboardExtendedInput.tsx +138 -2
  135. package/src/components/KeyboardExtendedInput/KeyboardExtendedInput.types.ts +15 -0
  136. package/src/components/KeyboardFocusLock/FocusTrap/FocusTrap.tsx +21 -4
  137. package/src/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.tsx +20 -3
  138. package/src/components/KeyboardFocusView/KeyboardFocusView.tsx +2 -0
  139. package/src/nativeSpec/ExternalKeyboardLockViewNativeComponent.ts +1 -0
  140. package/src/nativeSpec/TextInputFocusWrapperNativeComponent.ts +16 -0
  141. package/src/types/BaseKeyboardView.ts +2 -0
  142. package/src/types/KeyboardFocusLock.types.ts +1 -0
  143. package/src/types/WithKeyboardFocus.ts +19 -2
  144. package/src/utils/useFocusStyle.tsx +5 -15
  145. package/src/utils/withKeyboardFocus.tsx +44 -15
  146. package/src/utils/wrapOrderPrefix.ts +16 -0
  147. package/ios/Delegates/RNCEKVFocusOrderDelegate/RNCEKVFocusGuideDelegate/RNCEKVFocusGuideDelegate.h +0 -36
  148. package/ios/Delegates/RNCEKVFocusOrderDelegate/RNCEKVFocusGuideDelegate/RNCEKVFocusGuideDelegate.mm +0 -150
  149. package/ios/Delegates/RNCEKVFocusOrderDelegate/RNCEKVFocusOrderDelegate.h +0 -47
  150. package/ios/Delegates/RNCEKVFocusOrderDelegate/RNCEKVFocusOrderDelegate.mm +0 -326
  151. package/ios/Services/RNCEKVKeyboardOrderManager/RNCEKVKeyboardOrderManager.h +0 -17
  152. package/ios/Services/RNCEKVKeyboardOrderManager/RNCEKVKeyboardOrderManager.mm +0 -15
  153. package/lib/commonjs/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.android.js +0 -22
  154. package/lib/commonjs/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.android.js.map +0 -1
  155. package/lib/module/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.android.js +0 -17
  156. package/lib/module/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.android.js.map +0 -1
  157. package/lib/typescript/src/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.android.d.ts +0 -4
  158. package/lib/typescript/src/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.android.d.ts.map +0 -1
  159. package/src/components/KeyboardFocusLock/KeyboardFocusLockBase/KeyboardFocusLockBase.android.tsx +0 -16
@@ -0,0 +1,190 @@
1
+ package com.externalkeyboard.views.base;
2
+
3
+ import android.content.Context;
4
+ import android.view.FocusFinder;
5
+ import android.view.KeyEvent;
6
+ import android.view.View;
7
+ import android.view.ViewGroup;
8
+
9
+ import com.externalkeyboard.delegates.FocusOrderDelegate;
10
+ import com.externalkeyboard.delegates.FocusOrderDelegateHost;
11
+ import com.externalkeyboard.helper.FocusHelper;
12
+ import com.externalkeyboard.helper.ReactNativeVersionChecker;
13
+
14
+ public class ViewOrderGroupBase extends ViewGroupBase implements FocusOrderDelegateHost {
15
+ public int lockFocus = 0;
16
+
17
+ private View firstChild;
18
+
19
+ private Integer orderIndex;
20
+ private String orderGroup;
21
+
22
+ public String orderId;
23
+ private String orderUp;
24
+ private String orderDown;
25
+ private String orderLeft;
26
+ private String orderRight;
27
+ public String orderForward;
28
+ public String orderBackward;
29
+
30
+ protected FocusOrderDelegate focusOrderDelegate;
31
+
32
+
33
+ public String getOrderRight() {
34
+ return orderRight;
35
+ }
36
+
37
+ public void setOrderRight(String orderRight) {
38
+ focusOrderDelegate.refreshRight(this.orderRight, orderRight);
39
+ this.orderRight = orderRight;
40
+ }
41
+
42
+ public String getOrderLeft() {
43
+ return orderLeft;
44
+ }
45
+
46
+ public void setOrderLeft(String orderLeft) {
47
+ focusOrderDelegate.refreshLeft(this.orderLeft, orderLeft);
48
+ this.orderLeft = orderLeft;
49
+ }
50
+
51
+ public String getOrderDown() {
52
+ return orderDown;
53
+ }
54
+
55
+ public void setOrderDown(String orderDown) {
56
+ focusOrderDelegate.refreshDown(this.orderDown, orderDown);
57
+ this.orderDown = orderDown;
58
+ }
59
+
60
+ public String getOrderUp() {
61
+ return orderUp;
62
+ }
63
+
64
+ public void setOrderUp(String orderUp) {
65
+ focusOrderDelegate.refreshUp(this.orderUp, orderUp);
66
+ this.orderUp = orderUp;
67
+ }
68
+
69
+ public String getOrderGroup() {
70
+ return this.orderGroup;
71
+ }
72
+
73
+ public String getOrderId() {
74
+ return this.orderId;
75
+ }
76
+
77
+ public void setOrderGroup(String orderGroup) {
78
+ focusOrderDelegate.updateOrderGroup(this.orderGroup, orderGroup);
79
+ this.orderGroup = orderGroup;
80
+ }
81
+
82
+ public Integer getOrderIndex() {
83
+ return this.orderIndex;
84
+ }
85
+
86
+
87
+ public void setOrderIndex(int orderIndex) {
88
+ if(orderIndex == -1) {
89
+ this.orderIndex = null;
90
+ return;
91
+ }
92
+ boolean wasSet = this.orderIndex != null;
93
+ this.orderIndex = orderIndex;
94
+ if (wasSet) {
95
+ focusOrderDelegate.refreshOrder();
96
+ }
97
+ }
98
+
99
+ public View getFirstChild() {
100
+ return this.firstChild;
101
+ }
102
+
103
+ public ViewOrderGroupBase(Context context) {
104
+ super(context);
105
+ this.focusOrderDelegate = new FocusOrderDelegate(this);
106
+ }
107
+
108
+ @Override
109
+ public void onViewAdded(View child) {
110
+ super.onViewAdded(child);
111
+ linkAddView(child);
112
+ }
113
+
114
+ @Override
115
+ public void onViewRemoved(View child) {
116
+ super.onViewRemoved(child);
117
+ linkRemoveView(child);
118
+ }
119
+
120
+ public void linkAddView(View child) {
121
+ if (firstChild == null) {
122
+ firstChild = child;
123
+ focusOrderDelegate.link();
124
+ }
125
+ }
126
+
127
+ public void linkRemoveView(View view) {
128
+ if (view == firstChild) {
129
+ focusOrderDelegate.unlink();
130
+ firstChild = null;
131
+ }
132
+ }
133
+
134
+
135
+ @Override
136
+ public View focusSearch(View focused, int direction) {
137
+ if (lockFocus == 0 && orderGroup == null && orderIndex == null && orderForward == null && orderBackward == null) {
138
+ return super.focusSearch(focused, direction);
139
+ }
140
+
141
+ boolean isLocked = FocusHelper.isLocked(direction, lockFocus);
142
+ if (isLocked) {
143
+ return this;
144
+ }
145
+
146
+ if (direction == FOCUS_FORWARD && orderForward != null) {
147
+ View nextView = this.focusOrderDelegate.getLink(orderForward);
148
+ if (isValidLinkedFocusTarget(nextView)) {
149
+ return nextView;
150
+ }
151
+ }
152
+
153
+ if (direction == FOCUS_BACKWARD && orderBackward != null) {
154
+ View prevView = this.focusOrderDelegate.getLink(orderBackward);
155
+ if (isValidLinkedFocusTarget(prevView)) {
156
+ return prevView;
157
+ }
158
+ }
159
+
160
+ if (ReactNativeVersionChecker.isReactNative80OrLater()) {
161
+ if (orderGroup != null && orderIndex != null && (direction == FOCUS_FORWARD || direction == FOCUS_BACKWARD)) {
162
+ return FocusFinder.getInstance().findNextFocus((ViewGroup) this.getParent(), focused, direction);
163
+ }
164
+ }
165
+
166
+ return super.focusSearch(focused, direction);
167
+ }
168
+
169
+ protected boolean isFocusLocked(KeyEvent keyEvent) {
170
+ if (lockFocus != 0) {
171
+ int keyCode = keyEvent.getKeyCode();
172
+ return FocusHelper.isKeyLocked(keyCode, lockFocus);
173
+ }
174
+
175
+ return false;
176
+ }
177
+
178
+
179
+ private boolean isValidLinkedFocusTarget(View target) {
180
+ if (target == null || !target.isAttachedToWindow() || !this.isAttachedToWindow()) {
181
+ return false;
182
+ }
183
+
184
+ return target.getWindowToken() == this.getWindowToken();
185
+ }
186
+
187
+ public void onDropViewInstance() {
188
+ focusOrderDelegate.cleanByOrderId(orderId);
189
+ }
190
+ }
@@ -0,0 +1,39 @@
1
+ package com.externalkeyboard.views.base.keyboard;
2
+
3
+ import android.content.Context;
4
+ import android.view.View;
5
+
6
+ import com.externalkeyboard.events.EventHelper;
7
+ import com.externalkeyboard.views.base.FocusHighlightBase;
8
+ import com.facebook.react.bridge.ReactContext;
9
+
10
+ public class ViewFocusChangeBase extends FocusHighlightBase {
11
+ private View listeningView;
12
+ private final Context context;
13
+
14
+ public ViewFocusChangeBase(Context context) {
15
+ super(context);
16
+ this.context = context;
17
+ }
18
+
19
+
20
+ @Override
21
+ protected void onAttachedToWindow() {
22
+ super.onAttachedToWindow();
23
+
24
+ this.listeningView = getFocusingView();
25
+ setFocusable(this.listeningView == this);
26
+
27
+ this.listeningView.setOnFocusChangeListener((focusedView, hasFocus) -> {
28
+ EventHelper.focusChanged((ReactContext) context, this.getId(), hasFocus);
29
+ });
30
+ }
31
+
32
+ @Override
33
+ protected void onDetachedFromWindow() {
34
+ super.onDetachedFromWindow();
35
+ if (this.listeningView != null) {
36
+ this.listeningView.setOnFocusChangeListener(null);
37
+ }
38
+ }
39
+ }
@@ -0,0 +1,125 @@
1
+ package com.externalkeyboard.views.base.keyboard;
2
+
3
+ import android.content.Context;
4
+ import android.view.View;
5
+ import android.view.ViewTreeObserver;
6
+ import android.view.accessibility.AccessibilityEvent;
7
+
8
+ import com.facebook.react.bridge.ReactContext;
9
+ import com.facebook.react.uimanager.UIManagerHelper;
10
+ import com.facebook.react.uimanager.common.ViewUtil;
11
+ import com.facebook.react.uimanager.events.Event;
12
+ import com.facebook.react.uimanager.events.EventDispatcher;
13
+ import com.facebook.react.uimanager.events.EventDispatcherListener;
14
+
15
+
16
+ public class ViewFocusRequestBase extends ViewFocusChangeBase {
17
+ public boolean autoFocus = false;
18
+ public boolean enableA11yFocus = false;
19
+ public boolean hasBeenFocused = false;
20
+ public boolean hasBeenA11yFocused = false;
21
+
22
+ public boolean screenAutoA11yFocus = false;
23
+
24
+ public int screenAutoA11yFocusDelay = 500;
25
+
26
+ private EventDispatcher a11yViewAppearDispatcher = null;
27
+ private EventDispatcherListener eventA11yViewAppearListener = null;
28
+ private final Context context;
29
+
30
+ public ViewFocusRequestBase(Context context) {
31
+ super(context);
32
+ this.context = context;
33
+ }
34
+
35
+ private void onRnScreenViewAppear() {
36
+ boolean a11yAutoFocus = autoFocus && enableA11yFocus && !hasBeenA11yFocused && screenAutoA11yFocus;
37
+ if (!a11yAutoFocus) return;
38
+
39
+ try {
40
+ int reactTag = this.getId();
41
+ int uiManagerType = ViewUtil.getUIManagerType(reactTag);
42
+ a11yViewAppearDispatcher = UIManagerHelper.getEventDispatcher((ReactContext) context, uiManagerType);
43
+ if (a11yViewAppearDispatcher == null) return;
44
+ View focusingView = this.getFocusingView();
45
+
46
+
47
+ eventA11yViewAppearListener = new EventDispatcherListener() {
48
+ @Override
49
+ public void onEventDispatch(Event event) {
50
+ if ("topClick".equals(event.getEventName())) {
51
+ a11yViewAppearDispatcher.removeListener(this);
52
+ eventA11yViewAppearListener = null;
53
+ hasBeenA11yFocused = true;
54
+ }
55
+ if ("topFinishTransitioning".equals(event.getEventName()) || "topShow".equals(event.getEventName())) {
56
+ if (hasBeenA11yFocused) return;
57
+ hasBeenA11yFocused = true;
58
+
59
+ focusingView.postDelayed(() -> {
60
+ focus(false, true);
61
+ a11yViewAppearDispatcher.removeListener(this);
62
+ eventA11yViewAppearListener = null;
63
+ }, screenAutoA11yFocusDelay);
64
+ }
65
+ }
66
+ };
67
+ a11yViewAppearDispatcher.addListener(eventA11yViewAppearListener);
68
+ } catch (Exception ignored) {
69
+ }
70
+ }
71
+
72
+ @Override
73
+ protected void onAttachedToWindow() {
74
+ super.onAttachedToWindow();
75
+
76
+ if (autoFocus && !hasBeenFocused) {
77
+ this.autoFocusOnDraw();
78
+ hasBeenFocused = true;
79
+ }
80
+ }
81
+
82
+ @Override
83
+ protected void onDetachedFromWindow() {
84
+ super.onDetachedFromWindow();
85
+ if (this.a11yViewAppearDispatcher != null && this.eventA11yViewAppearListener != null) {
86
+ this.a11yViewAppearDispatcher.removeListener(this.eventA11yViewAppearListener);
87
+ a11yViewAppearDispatcher = null;
88
+ eventA11yViewAppearListener = null;
89
+ }
90
+ }
91
+
92
+ private void autoFocusOnDraw() {
93
+ getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
94
+ @Override
95
+ public boolean onPreDraw() {
96
+ onRnScreenViewAppear();
97
+ getViewTreeObserver().removeOnPreDrawListener(this);
98
+ focus();
99
+
100
+ return true;
101
+ }
102
+ });
103
+ }
104
+
105
+ private void a11yFocus(View view) {
106
+ if (!enableA11yFocus) return;
107
+ view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
108
+ }
109
+
110
+ public void focus(boolean keyboard, boolean a11y) {
111
+ View focusingView = this.getFocusingView();
112
+ if (keyboard) {
113
+ focusingView.requestFocus();
114
+ }
115
+ if (a11y) {
116
+ a11yFocus(focusingView);
117
+ }
118
+ }
119
+
120
+
121
+ public void focus() {
122
+ this.focus(true, true);
123
+ }
124
+
125
+ }
@@ -0,0 +1,40 @@
1
+ package com.externalkeyboard.views.base.keyboard;
2
+
3
+ import android.content.Context;
4
+ import android.view.KeyEvent;
5
+
6
+ import com.externalkeyboard.events.EventHelper;
7
+ import com.externalkeyboard.services.KeyboardKeyPressHandler;
8
+ import com.facebook.react.bridge.ReactContext;
9
+
10
+ public class ViewKeyHandlerBase extends ViewFocusRequestBase {
11
+ public boolean hasKeyDownListener = false;
12
+ public boolean hasKeyUpListener = false;
13
+ private final Context context;
14
+
15
+ private final KeyboardKeyPressHandler keyboardKeyPressHandler;
16
+
17
+ public ViewKeyHandlerBase(Context context) {
18
+ super(context);
19
+ this.context = context;
20
+
21
+ this.keyboardKeyPressHandler = new KeyboardKeyPressHandler();
22
+ }
23
+
24
+ protected boolean hasKeyListener() {
25
+ return this.hasKeyUpListener || this.hasKeyDownListener;
26
+ }
27
+
28
+ protected void handleKeyPress(KeyEvent keyEvent) {
29
+ int keyCode = keyEvent.getKeyCode();
30
+ KeyboardKeyPressHandler.PressInfo pressInfo = keyboardKeyPressHandler.getEventsFromKeyPress(keyCode, keyEvent);
31
+
32
+ if (pressInfo.firePressDownEvent && this.hasKeyDownListener) {
33
+ EventHelper.pressDown((ReactContext) context, this.getId(), keyCode, keyEvent);
34
+ }
35
+
36
+ if (pressInfo.firePressUpEvent && this.hasKeyUpListener) {
37
+ EventHelper.pressUp((ReactContext) context, this.getId(), keyCode, keyEvent, pressInfo.isLongPress);
38
+ }
39
+ }
40
+ }
@@ -4,21 +4,15 @@ import android.view.ViewGroup;
4
4
 
5
5
  import androidx.annotation.Nullable;
6
6
 
7
- import com.facebook.react.uimanager.ViewGroupManager;
7
+ import com.facebook.react.views.view.ReactViewManager;
8
8
  import com.facebook.react.uimanager.ViewManagerDelegate;
9
9
  import com.facebook.react.viewmanagers.TextInputFocusWrapperManagerDelegate;
10
10
  import com.facebook.react.viewmanagers.TextInputFocusWrapperManagerInterface;
11
11
 
12
- public abstract class TextInputFocusWrapperManagerSpec<T extends ViewGroup> extends ViewGroupManager<T> implements TextInputFocusWrapperManagerInterface<T> {
12
+ public abstract class TextInputFocusWrapperManagerSpec<T extends ViewGroup> extends ReactViewManager implements TextInputFocusWrapperManagerInterface<T> {
13
13
  private final ViewManagerDelegate<T> mDelegate;
14
14
 
15
15
  public TextInputFocusWrapperManagerSpec() {
16
16
  mDelegate = new TextInputFocusWrapperManagerDelegate(this);
17
17
  }
18
-
19
- @Nullable
20
- @Override
21
- protected ViewManagerDelegate<T> getDelegate() {
22
- return mDelegate;
23
- }
24
18
  }
@@ -8,5 +8,6 @@ import com.facebook.react.views.view.ReactViewManager;
8
8
  public abstract class ExternalKeyboardLockViewManagerSpec<T extends ExternalKeyboardLockView> extends ReactViewManager {
9
9
  public abstract void setComponentType(T view, int value);
10
10
  public abstract void setLockDisabled(T view, boolean value);
11
+ public abstract void setForceLock(T view, boolean value);
11
12
  }
12
13
 
@@ -5,9 +5,9 @@ import android.view.ViewGroup;
5
5
  import androidx.annotation.Nullable;
6
6
 
7
7
  import com.externalkeyboard.views.TextInputFocusWrapper.TextInputFocusWrapper;
8
- import com.facebook.react.uimanager.ViewGroupManager;
8
+ import com.facebook.react.views.view.ReactViewManager;
9
9
 
10
- public abstract class TextInputFocusWrapperManagerSpec<T extends ViewGroup> extends ViewGroupManager<T> {
10
+ public abstract class TextInputFocusWrapperManagerSpec<T extends ViewGroup> extends ReactViewManager {
11
11
  public abstract void setCanBeFocused(T wrapper, boolean canBeFocused);
12
12
 
13
13
  public abstract void setFocusType(T wrapper, int focusType);
@@ -23,4 +23,34 @@ public abstract class TextInputFocusWrapperManagerSpec<T extends ViewGroup> exte
23
23
  public abstract void setMultiline(TextInputFocusWrapper view, boolean value);
24
24
 
25
25
  public abstract void setGroupIdentifier(TextInputFocusWrapper view, @Nullable String value);
26
+
27
+ public abstract void setOrderGroup(TextInputFocusWrapper view, @Nullable String value);
28
+
29
+ public abstract void setOrderIndex(TextInputFocusWrapper view, int value);
30
+
31
+ public abstract void setOrderId(TextInputFocusWrapper view, @Nullable String value);
32
+
33
+ public abstract void setOrderLeft(TextInputFocusWrapper view, @Nullable String value);
34
+
35
+ public abstract void setOrderRight(TextInputFocusWrapper view, @Nullable String value);
36
+
37
+ public abstract void setOrderUp(TextInputFocusWrapper view, @Nullable String value);
38
+
39
+ public abstract void setOrderDown(TextInputFocusWrapper view, @Nullable String value);
40
+
41
+ public abstract void setOrderForward(TextInputFocusWrapper view, @Nullable String value);
42
+
43
+ public abstract void setOrderBackward(TextInputFocusWrapper view, @Nullable String value);
44
+
45
+ public abstract void setLockFocus(TextInputFocusWrapper view, int value);
46
+
47
+ public abstract void setOrderFirst(TextInputFocusWrapper view, @Nullable String value);
48
+
49
+ public abstract void setOrderLast(TextInputFocusWrapper view, @Nullable String value);
50
+
51
+ public abstract void setHaloExpendY(TextInputFocusWrapper view, float value);
52
+
53
+ public abstract void setHaloExpendX(TextInputFocusWrapper view, float value);
54
+
55
+ public abstract void setHaloCornerRadius(TextInputFocusWrapper view, float value);
26
56
  }
@@ -0,0 +1,35 @@
1
+ //
2
+ // RNCEKVFocusLinkDelegate.h
3
+ // react-native-external-keyboard
4
+ //
5
+
6
+ #ifndef RNCEKVFocusLinkDelegate_h
7
+ #define RNCEKVFocusLinkDelegate_h
8
+
9
+ #import <Foundation/Foundation.h>
10
+ #import "RNCEKVFocusOrderProtocol.h"
11
+ #import "RNCEKVFocusGuideHelper.h"
12
+
13
+ @interface RNCEKVFocusLinkDelegate : NSObject
14
+
15
+ - (instancetype _Nonnull)initWithView:(UIView<RNCEKVFocusOrderProtocol> *_Nonnull)view;
16
+
17
+ - (NSNumber *_Nullable)shouldUpdateFocusInContext:(UIFocusUpdateContext *_Nonnull)context;
18
+
19
+ - (void)link;
20
+ - (void)unlink;
21
+
22
+ - (void)linkId;
23
+ - (void)refreshId:(NSString *_Nullable)prev next:(NSString *_Nullable)next;
24
+ - (void)setIsFocused:(BOOL)value;
25
+
26
+ - (void)refreshLeft:(NSString *_Nullable)next;
27
+ - (void)refreshRight:(NSString *_Nullable)next;
28
+ - (void)refreshUp:(NSString *_Nullable)next;
29
+ - (void)refreshDown:(NSString *_Nullable)next;
30
+
31
+ - (void)clear;
32
+
33
+ @end
34
+
35
+ #endif /* RNCEKVFocusLinkDelegate_h */