hybrid-navigation 2.13.18 → 2.14.0-rc.0

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 (45) hide show
  1. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  2. package/android/.gradle/7.4/dependencies-accessors/dependencies-accessors.lock +0 -0
  3. package/android/.gradle/7.4/dependencies-accessors/gc.properties +0 -0
  4. package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
  5. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  6. package/android/.gradle/7.4/gc.properties +0 -0
  7. package/android/.gradle/vcs-1/gc.properties +0 -0
  8. package/android/.idea/gradle.xml +14 -0
  9. package/android/.idea/misc.xml +10 -0
  10. package/android/.idea/vcs.xml +6 -0
  11. package/android/build.gradle +1 -1
  12. package/android/src/main/java/com/reactnative/hybridnavigation/GardenModule.java +4 -2
  13. package/android/src/main/java/com/reactnative/hybridnavigation/HybridNavigationPackage.java +6 -3
  14. package/android/src/main/java/com/reactnative/hybridnavigation/KeyboardInsetsCallback.java +142 -0
  15. package/android/src/main/java/com/reactnative/hybridnavigation/KeyboardInsetsChangeEvent.java +34 -0
  16. package/android/src/main/java/com/reactnative/hybridnavigation/KeyboardInsetsModule.java +52 -0
  17. package/android/src/main/java/com/reactnative/hybridnavigation/KeyboardInsetsView.java +33 -0
  18. package/android/src/main/java/com/reactnative/hybridnavigation/KeyboardInsetsViewManager.java +53 -0
  19. package/android/src/main/java/com/reactnative/hybridnavigation/ReactAppCompatActivity.java +31 -20
  20. package/android/src/main/java/com/reactnative/hybridnavigation/ReactAppCompatActivityDelegate.java +17 -8
  21. package/ios/HybridNavigation/Keyboard/HBDKeyboardInsetsModule.h +9 -0
  22. package/ios/HybridNavigation/Keyboard/HBDKeyboardInsetsModule.m +34 -0
  23. package/ios/HybridNavigation/Keyboard/HBDKeyboardInsetsView.h +17 -0
  24. package/ios/HybridNavigation/Keyboard/HBDKeyboardInsetsView.m +203 -0
  25. package/ios/HybridNavigation/Keyboard/HBDKeyboardInsetsViewManager.h +9 -0
  26. package/ios/HybridNavigation/Keyboard/HBDKeyboardInsetsViewManager.m +18 -0
  27. package/lib/DeepLink.js +1 -0
  28. package/lib/Garden.d.ts +1 -1
  29. package/lib/Keyboard.d.ts +17 -0
  30. package/lib/Keyboard.js +57 -0
  31. package/lib/Navigation.d.ts +5 -5
  32. package/lib/NavigationComponentWrap.d.ts +1 -1
  33. package/lib/Options.d.ts +12 -12
  34. package/lib/Route.d.ts +5 -5
  35. package/lib/handler/BarButtonEventHandler.d.ts +1 -1
  36. package/lib/handler/DispatchCommandHandler.d.ts +1 -1
  37. package/lib/handler/ResultEventHandler.d.ts +2 -2
  38. package/lib/handler/VisibilityEventHandler.d.ts +2 -2
  39. package/lib/index.d.ts +1 -0
  40. package/lib/index.js +1 -0
  41. package/package.json +12 -12
  42. package/src/DeepLink.ts +1 -0
  43. package/src/Keyboard.tsx +128 -0
  44. package/src/Navigation.ts +1 -1
  45. package/src/index.ts +1 -0
File without changes
File without changes
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="GradleMigrationSettings" migrationVersion="1" />
4
+ <component name="GradleSettings">
5
+ <option name="linkedExternalProjectsSettings">
6
+ <GradleProjectSettings>
7
+ <option name="testRunner" value="GRADLE" />
8
+ <option name="distributionType" value="DEFAULT_WRAPPED" />
9
+ <option name="externalProjectPath" value="$PROJECT_DIR$" />
10
+ <option name="gradleJvm" value="Embedded JDK" />
11
+ </GradleProjectSettings>
12
+ </option>
13
+ </component>
14
+ </project>
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ExternalStorageConfigurationManager" enabled="true" />
4
+ <component name="ProjectRootManager" version="2" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK">
5
+ <output url="file://$PROJECT_DIR$/build/classes" />
6
+ </component>
7
+ <component name="ProjectType">
8
+ <option name="id" value="Android" />
9
+ </component>
10
+ </project>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$/.." vcs="Git" />
5
+ </component>
6
+ </project>
@@ -33,5 +33,5 @@ dependencies {
33
33
  implementation fileTree(dir: 'libs', include: ['*.jar'])
34
34
  implementation 'com.facebook.react:react-native:+'
35
35
  // api project(':navigation')
36
- api 'io.github.listenzz:AndroidNavigation:12.5.13'
36
+ api 'io.github.listenzz:AndroidNavigation:13.0.0'
37
37
  }
@@ -8,6 +8,7 @@ import static com.reactnative.hybridnavigation.Parameters.toBundle;
8
8
  import static com.reactnative.hybridnavigation.Parameters.toList;
9
9
 
10
10
  import android.app.Activity;
11
+ import android.content.res.Resources;
11
12
  import android.os.Bundle;
12
13
 
13
14
  import androidx.annotation.NonNull;
@@ -29,7 +30,6 @@ import com.facebook.react.uimanager.PixelUtil;
29
30
  import com.navigation.androidx.AwesomeFragment;
30
31
  import com.navigation.androidx.DrawerFragment;
31
32
  import com.navigation.androidx.FragmentHelper;
32
- import com.navigation.androidx.SystemUI;
33
33
  import com.navigation.androidx.TabBarFragment;
34
34
 
35
35
  import java.util.HashMap;
@@ -56,7 +56,9 @@ public class GardenModule extends ReactContextBaseJavaModule {
56
56
  public Map<String, Object> getConstants() {
57
57
  final Map<String, Object> constants = new HashMap<>();
58
58
  constants.put("TOOLBAR_HEIGHT", 56);
59
- float statusBarHeight = PixelUtil.toDIPFromPixel(SystemUI.getStatusBarHeight(getReactApplicationContext()));
59
+ Resources resources = getReactApplicationContextIfActiveOrWarn().getResources();
60
+ int resourceId = resources.getIdentifier("status_bar_height", "dimen", "android");
61
+ float statusBarHeight = PixelUtil.toDIPFromPixel(resources.getDimensionPixelSize(resourceId));
60
62
  constants.put("STATUSBAR_HEIGHT", statusBarHeight);
61
63
  return constants;
62
64
  }
@@ -8,7 +8,6 @@ import com.facebook.react.bridge.ReactApplicationContext;
8
8
  import com.facebook.react.uimanager.ViewManager;
9
9
 
10
10
  import java.util.Arrays;
11
- import java.util.Collections;
12
11
  import java.util.List;
13
12
 
14
13
  public class HybridNavigationPackage implements ReactPackage {
@@ -19,14 +18,18 @@ public class HybridNavigationPackage implements ReactPackage {
19
18
  return Arrays.<NativeModule>asList(
20
19
  new NavigationModule(reactContext, ReactBridgeManager.get()),
21
20
  new GardenModule(reactContext, ReactBridgeManager.get()),
22
- new HBDEventEmitter(reactContext)
21
+ new HBDEventEmitter(reactContext),
22
+ new KeyboardInsetsModule(reactContext)
23
23
  );
24
24
  }
25
25
 
26
26
  @NonNull
27
27
  @Override
28
28
  public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
29
- return Collections.emptyList();
29
+ // return Collections.emptyList();
30
+ return Arrays.asList(
31
+ new KeyboardInsetsViewManager()
32
+ );
30
33
  }
31
34
 
32
35
  }
@@ -0,0 +1,142 @@
1
+ package com.reactnative.hybridnavigation;
2
+
3
+ import android.util.Log;
4
+ import android.view.View;
5
+ import android.view.ViewParent;
6
+
7
+ import androidx.annotation.NonNull;
8
+ import androidx.core.graphics.Insets;
9
+ import androidx.core.view.OnApplyWindowInsetsListener;
10
+ import androidx.core.view.WindowInsetsAnimationCompat;
11
+ import androidx.core.view.WindowInsetsCompat;
12
+
13
+ import com.facebook.common.logging.FLog;
14
+ import com.facebook.react.bridge.Arguments;
15
+ import com.facebook.react.bridge.WritableMap;
16
+ import com.facebook.react.uimanager.PixelUtil;
17
+ import com.facebook.react.uimanager.ThemedReactContext;
18
+ import com.facebook.react.uimanager.UIManagerHelper;
19
+ import com.facebook.react.uimanager.events.EventDispatcher;
20
+ import com.facebook.react.uimanager.events.RCTEventEmitter;
21
+ import com.navigation.androidx.EdgeInsets;
22
+ import com.navigation.androidx.SystemUI;
23
+
24
+ import java.util.List;
25
+
26
+ public class KeyboardInsetsCallback extends WindowInsetsAnimationCompat.Callback implements OnApplyWindowInsetsListener {
27
+
28
+ private final KeyboardInsetsView view;
29
+ private final ThemedReactContext reactContext;
30
+
31
+ public KeyboardInsetsCallback(KeyboardInsetsView view, ThemedReactContext reactContext) {
32
+ super(WindowInsetsAnimationCompat.Callback.DISPATCH_MODE_CONTINUE_ON_SUBTREE);
33
+ this.view = view;
34
+ this.reactContext = reactContext;
35
+ }
36
+
37
+ private View focusView;
38
+ private boolean animating;
39
+
40
+ @Override
41
+ public void onPrepare(@NonNull WindowInsetsAnimationCompat animation) {
42
+ animating = true;
43
+ }
44
+
45
+ @NonNull
46
+ @Override
47
+ public WindowInsetsAnimationCompat.BoundsCompat onStart(@NonNull WindowInsetsAnimationCompat animation, @NonNull WindowInsetsAnimationCompat.BoundsCompat bounds) {
48
+ if (SystemUI.isImeVisible(view)) {
49
+ focusView = view.findFocus();
50
+ }
51
+
52
+ if (!shouldHandleKeyboardTransition(focusView)) {
53
+ return super.onStart(animation, bounds);
54
+ }
55
+
56
+ FLog.w("KeyboardInsets", "WindowInsetsAnimation.Callback onStart");
57
+
58
+ if (SystemUI.isImeVisible(view)) {
59
+ int keyboardHeight = SystemUI.imeHeight(view);
60
+ WritableMap map = Arguments.createMap();
61
+ map.putDouble("height", PixelUtil.toDIPFromPixel(keyboardHeight));
62
+ reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(
63
+ view.getId(),
64
+ "topKeyboardHeightChanged",
65
+ map);
66
+ }
67
+
68
+ return super.onStart(animation, bounds);
69
+ }
70
+
71
+ @Override
72
+ public void onEnd(@NonNull WindowInsetsAnimationCompat animation) {
73
+ super.onEnd(animation);
74
+ animating = false;
75
+
76
+ if (!shouldHandleKeyboardTransition(focusView)) {
77
+ return;
78
+ }
79
+
80
+ FLog.w("KeyboardInsets", "WindowInsetsAnimation.Callback onEnd");
81
+ if (!SystemUI.isImeVisible(view)) {
82
+ focusView = null;
83
+ }
84
+ }
85
+
86
+ @NonNull
87
+ @Override
88
+ public WindowInsetsCompat onProgress(@NonNull WindowInsetsCompat insets, @NonNull List<WindowInsetsAnimationCompat> runningAnimations) {
89
+ if (!shouldHandleKeyboardTransition(focusView)) {
90
+ return insets;
91
+ }
92
+
93
+ handleKeyboardTransition(insets);
94
+
95
+ return WindowInsetsCompat.CONSUMED;
96
+ }
97
+
98
+ @Override
99
+ public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
100
+ if (shouldHandleKeyboardTransition(focusView) && !animating) {
101
+ FLog.w("KeyboardInsets", "onApplyWindowInsets " + insets);
102
+ handleKeyboardTransition(insets);
103
+ }
104
+ return insets;
105
+ }
106
+
107
+ private void handleKeyboardTransition(WindowInsetsCompat insets) {
108
+ Insets imeInsets = insets.getInsets(WindowInsetsCompat.Type.ime());
109
+ if (view.isAutoMode()) {
110
+ EdgeInsets edgeInsets = SystemUI.getEdgeInsetsForView(focusView);
111
+ float extraHeight = PixelUtil.toPixelFromDIP(view.getExtraHeight());
112
+ Log.d("KeyboardInsets", "edgeInsets.bottom:" + edgeInsets.bottom + " imeInsets.bottom:" + imeInsets.bottom);
113
+ view.setTranslationY(-Math.max(imeInsets.bottom - edgeInsets.bottom + extraHeight, 0));
114
+
115
+ } else {
116
+ EventDispatcher eventDispatcher = UIManagerHelper.getEventDispatcherForReactTag(reactContext, view.getId());
117
+ eventDispatcher.dispatchEvent(new KeyboardInsetsChangeEvent(view.getId(), imeInsets));
118
+ }
119
+ }
120
+
121
+ private boolean shouldHandleKeyboardTransition(View focus) {
122
+ if (focus != null) {
123
+ KeyboardInsetsView insetsView = findClosestKeyboardInsetsView(focus);
124
+ return insetsView == view;
125
+ }
126
+ return false;
127
+ }
128
+
129
+ private static KeyboardInsetsView findClosestKeyboardInsetsView(View focus) {
130
+ ViewParent viewParent = focus.getParent();
131
+ if (viewParent instanceof KeyboardInsetsView) {
132
+ return (KeyboardInsetsView) viewParent;
133
+ }
134
+
135
+ if (viewParent instanceof View) {
136
+ return findClosestKeyboardInsetsView((View) viewParent);
137
+ }
138
+
139
+ return null;
140
+ }
141
+
142
+ }
@@ -0,0 +1,34 @@
1
+ package com.reactnative.hybridnavigation;
2
+
3
+ import androidx.core.graphics.Insets;
4
+
5
+ import com.facebook.react.bridge.Arguments;
6
+ import com.facebook.react.bridge.WritableMap;
7
+ import com.facebook.react.uimanager.PixelUtil;
8
+ import com.facebook.react.uimanager.events.Event;
9
+ import com.facebook.react.uimanager.events.RCTEventEmitter;
10
+
11
+ public class KeyboardInsetsChangeEvent extends Event<KeyboardInsetsChangeEvent> {
12
+
13
+ private final Insets insets;
14
+
15
+ public KeyboardInsetsChangeEvent(int viewId, Insets insets) {
16
+ super(viewId);
17
+ this.insets = insets;
18
+ }
19
+
20
+ @Override
21
+ public String getEventName() {
22
+ return "topInsetsChanged";
23
+ }
24
+
25
+ @Override
26
+ public void dispatch(RCTEventEmitter rctEventEmitter) {
27
+ WritableMap map = Arguments.createMap();
28
+ map.putDouble("top", PixelUtil.toDIPFromPixel(insets.top));
29
+ map.putDouble("left", PixelUtil.toDIPFromPixel(insets.left));
30
+ map.putDouble("right", PixelUtil.toDIPFromPixel(insets.right));
31
+ map.putDouble("bottom", PixelUtil.toDIPFromPixel(insets.bottom));
32
+ rctEventEmitter.receiveEvent(getViewTag(), getEventName(), map);
33
+ }
34
+ }
@@ -0,0 +1,52 @@
1
+ package com.reactnative.hybridnavigation;
2
+
3
+ import android.view.View;
4
+
5
+ import androidx.annotation.NonNull;
6
+
7
+ import com.facebook.react.bridge.Arguments;
8
+ import com.facebook.react.bridge.Callback;
9
+ import com.facebook.react.bridge.ReactApplicationContext;
10
+ import com.facebook.react.bridge.ReactContextBaseJavaModule;
11
+ import com.facebook.react.bridge.ReactMethod;
12
+ import com.facebook.react.bridge.UiThreadUtil;
13
+ import com.facebook.react.bridge.WritableMap;
14
+ import com.facebook.react.uimanager.PixelUtil;
15
+ import com.facebook.react.uimanager.UIManagerModule;
16
+ import com.navigation.androidx.EdgeInsets;
17
+ import com.navigation.androidx.SystemUI;
18
+
19
+ public class KeyboardInsetsModule extends ReactContextBaseJavaModule {
20
+
21
+ public KeyboardInsetsModule(ReactApplicationContext reactContext) {
22
+ super(reactContext);
23
+ }
24
+
25
+ @NonNull
26
+ @Override
27
+ public String getName() {
28
+ return "KeyboardInsetsModule";
29
+ }
30
+
31
+ @ReactMethod
32
+ public void getEdgeInsetsForView(int viewTag, Callback callback) {
33
+ UiThreadUtil.runOnUiThread(() -> {
34
+ UIManagerModule uiManagerModule = getReactApplicationContext().getNativeModule(UIManagerModule.class);
35
+ View view = uiManagerModule.resolveView(viewTag);
36
+ WritableMap map = Arguments.createMap();
37
+ map.putDouble("top", 0);
38
+ map.putDouble("left", 0);
39
+ map.putDouble("right", 0);
40
+ map.putDouble("bottom", 0);
41
+ if (view != null) {
42
+ EdgeInsets insets = SystemUI.getEdgeInsetsForView(view);
43
+ map.putDouble("top", PixelUtil.toDIPFromPixel(insets.top));
44
+ map.putDouble("left", PixelUtil.toDIPFromPixel(insets.left));
45
+ map.putDouble("right", PixelUtil.toDIPFromPixel(insets.right));
46
+ map.putDouble("bottom", PixelUtil.toDIPFromPixel(insets.bottom));
47
+ }
48
+ callback.invoke(map);
49
+ });
50
+ }
51
+
52
+ }
@@ -0,0 +1,33 @@
1
+ package com.reactnative.hybridnavigation;
2
+
3
+ import android.content.Context;
4
+
5
+ import com.facebook.react.views.view.ReactViewGroup;
6
+
7
+ public class KeyboardInsetsView extends ReactViewGroup {
8
+
9
+ private String mode = "auto";
10
+
11
+ private float extraHeight = 0.0f;
12
+
13
+ public KeyboardInsetsView(Context context) {
14
+ super(context);
15
+ }
16
+
17
+ public void setMode(String mode) {
18
+ this.mode = mode;
19
+ }
20
+
21
+ public boolean isAutoMode() {
22
+ return this.mode.equals("auto");
23
+ }
24
+
25
+ public void setExtraHeight(float extraHeight) {
26
+ this.extraHeight = extraHeight;
27
+ }
28
+
29
+ public float getExtraHeight() {
30
+ return this.extraHeight;
31
+ }
32
+
33
+ }
@@ -0,0 +1,53 @@
1
+ package com.reactnative.hybridnavigation;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import androidx.annotation.Nullable;
5
+ import androidx.core.view.ViewCompat;
6
+
7
+ import com.facebook.react.common.MapBuilder;
8
+ import com.facebook.react.uimanager.ThemedReactContext;
9
+ import com.facebook.react.uimanager.ViewGroupManager;
10
+ import com.facebook.react.uimanager.annotations.ReactProp;
11
+
12
+ import java.util.Map;
13
+
14
+ public class KeyboardInsetsViewManager extends ViewGroupManager<KeyboardInsetsView> {
15
+
16
+ public static final String REACT_CLASS = "KeyboardInsetsView";
17
+
18
+ @NonNull
19
+ @Override
20
+ public String getName() {
21
+ return REACT_CLASS;
22
+ }
23
+
24
+ @NonNull
25
+ @Override
26
+ protected KeyboardInsetsView createViewInstance(@NonNull ThemedReactContext themedReactContext) {
27
+ KeyboardInsetsView view = new KeyboardInsetsView(themedReactContext);
28
+ KeyboardInsetsCallback callback = new KeyboardInsetsCallback(view, themedReactContext);
29
+ ViewCompat.setWindowInsetsAnimationCallback(view, callback);
30
+ ViewCompat.setOnApplyWindowInsetsListener(view, callback);
31
+ return view;
32
+ }
33
+
34
+ @ReactProp(name = "mode")
35
+ public void setMode(KeyboardInsetsView view, String mode) {
36
+ view.setMode(mode);
37
+ }
38
+
39
+ @ReactProp(name = "extraHeight")
40
+ public void setExtraHeight(KeyboardInsetsView view, float extraHeight) {
41
+ view.setExtraHeight(extraHeight);
42
+ }
43
+
44
+ @Nullable
45
+ @Override
46
+ public Map<String, Object> getExportedCustomDirectEventTypeConstants() {
47
+ return MapBuilder.of(
48
+ "topInsetsChanged", MapBuilder.of("registrationName", "onInsetsChanged"),
49
+ "topKeyboardHeightChanged", MapBuilder.of("registrationName", "onKeyboardHeightChanged")
50
+ );
51
+ }
52
+
53
+ }
@@ -1,6 +1,7 @@
1
1
  package com.reactnative.hybridnavigation;
2
2
 
3
3
  import android.content.Intent;
4
+ import android.content.res.Configuration;
4
5
  import android.os.Bundle;
5
6
  import android.view.KeyEvent;
6
7
 
@@ -26,10 +27,10 @@ public class ReactAppCompatActivity extends AwesomeActivity implements DefaultHa
26
27
 
27
28
  protected static final String TAG = "Navigation";
28
29
 
29
- private final ReactAppCompatActivityDelegate activityDelegate;
30
+ private final ReactAppCompatActivityDelegate mDelegate;
30
31
 
31
32
  protected ReactAppCompatActivity() {
32
- activityDelegate = createReactActivityDelegate();
33
+ mDelegate = createReactActivityDelegate();
33
34
  }
34
35
 
35
36
  protected ReactAppCompatActivityDelegate createReactActivityDelegate() {
@@ -39,19 +40,19 @@ public class ReactAppCompatActivity extends AwesomeActivity implements DefaultHa
39
40
  @Override
40
41
  protected void onCreate(Bundle savedInstanceState) {
41
42
  super.onCreate(savedInstanceState);
42
- activityDelegate.onCreate(savedInstanceState);
43
+ mDelegate.onCreate(savedInstanceState);
43
44
  ReactBridgeManager bridgeManager = getReactBridgeManager();
44
45
  bridgeManager.addReactModuleRegisterListener(this);
45
-
46
+
46
47
  if (savedInstanceState != null) {
47
48
  FLog.i(TAG, "ReactAppCompatActivity#re-create");
48
49
  }
49
-
50
+
50
51
  if (isReactModuleRegisterCompleted()) {
51
52
  onReactModuleRegisterCompleted();
52
53
  }
53
54
  }
54
-
55
+
55
56
  public void inflateStyle() {
56
57
  Style style = getStyle();
57
58
  GlobalStyle globalStyle = Garden.getGlobalStyle();
@@ -65,7 +66,7 @@ public class ReactAppCompatActivity extends AwesomeActivity implements DefaultHa
65
66
  protected void onDestroy() {
66
67
  getReactBridgeManager().removeReactModuleRegisterListener(this);
67
68
  super.onDestroy();
68
- activityDelegate.onDestroy();
69
+ mDelegate.onDestroy();
69
70
  }
70
71
 
71
72
  @Override
@@ -73,7 +74,7 @@ public class ReactAppCompatActivity extends AwesomeActivity implements DefaultHa
73
74
  FLog.i(TAG, "ReactAppCompatActivity#onReactModuleRegisterCompleted");
74
75
  ReactContext reactContext = Assertions.assertNotNull(getCurrentReactContext());
75
76
  if (isResumed && reactContext.getCurrentActivity() == null) {
76
- activityDelegate.onResume();
77
+ mDelegate.onResume();
77
78
  }
78
79
  inflateStyle();
79
80
  Fragment fragment = getSupportFragmentManager().findFragmentById(android.R.id.content);
@@ -151,7 +152,7 @@ public class ReactAppCompatActivity extends AwesomeActivity implements DefaultHa
151
152
  super.onResume();
152
153
  isResumed = true;
153
154
  if (getCurrentReactContext() != null) {
154
- activityDelegate.onResume();
155
+ mDelegate.onResume();
155
156
  }
156
157
 
157
158
  ReactBridgeManager bridgeManager = getReactBridgeManager();
@@ -165,35 +166,35 @@ public class ReactAppCompatActivity extends AwesomeActivity implements DefaultHa
165
166
  protected void onPause() {
166
167
  isResumed = false;
167
168
  if (getCurrentReactContext() != null) {
168
- activityDelegate.onPause();
169
+ mDelegate.onPause();
169
170
  }
170
171
  super.onPause();
171
172
  }
172
173
 
173
174
  @Override
174
175
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
175
- activityDelegate.onActivityResult(requestCode, resultCode, data);
176
+ mDelegate.onActivityResult(requestCode, resultCode, data);
176
177
  super.onActivityResult(requestCode, resultCode, data);
177
178
  }
178
179
 
179
180
  @Override
180
181
  public boolean onKeyDown(int keyCode, KeyEvent event) {
181
- return activityDelegate.onKeyDown(keyCode, event) || super.onKeyDown(keyCode, event);
182
+ return mDelegate.onKeyDown(keyCode, event) || super.onKeyDown(keyCode, event);
182
183
  }
183
184
 
184
185
  @Override
185
186
  public boolean onKeyUp(int keyCode, KeyEvent event) {
186
- return activityDelegate.onKeyUp(keyCode, event) || super.onKeyUp(keyCode, event);
187
+ return mDelegate.onKeyUp(keyCode, event) || super.onKeyUp(keyCode, event);
187
188
  }
188
189
 
189
190
  @Override
190
191
  public boolean onKeyLongPress(int keyCode, KeyEvent event) {
191
- return activityDelegate.onKeyLongPress(keyCode, event) || super.onKeyLongPress(keyCode, event);
192
+ return mDelegate.onKeyLongPress(keyCode, event) || super.onKeyLongPress(keyCode, event);
192
193
  }
193
194
 
194
195
  @Override
195
196
  public void onBackPressed() {
196
- if (!activityDelegate.onBackPressed()) {
197
+ if (!mDelegate.onBackPressed()) {
197
198
  super.onBackPressed();
198
199
  }
199
200
  }
@@ -205,24 +206,34 @@ public class ReactAppCompatActivity extends AwesomeActivity implements DefaultHa
205
206
 
206
207
  @Override
207
208
  public void onNewIntent(Intent intent) {
208
- if (!activityDelegate.onNewIntent(intent)) {
209
+ if (!mDelegate.onNewIntent(intent)) {
209
210
  super.onNewIntent(intent);
210
211
  }
211
212
  }
212
213
 
213
214
  @Override
214
215
  public void requestPermissions(String[] permissions, int requestCode, PermissionListener listener) {
215
- activityDelegate.requestPermissions(permissions, requestCode, listener);
216
+ mDelegate.requestPermissions(permissions, requestCode, listener);
216
217
  }
217
218
 
218
219
  @Override
219
220
  public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
220
- activityDelegate.onRequestPermissionsResult(requestCode, permissions, grantResults);
221
+ mDelegate.onRequestPermissionsResult(requestCode, permissions, grantResults);
221
222
  super.onRequestPermissionsResult(requestCode, permissions, grantResults);
222
223
  }
223
224
 
225
+ public void onWindowFocusChanged(boolean hasFocus) {
226
+ super.onWindowFocusChanged(hasFocus);
227
+ this.mDelegate.onWindowFocusChanged(hasFocus);
228
+ }
229
+
230
+ public void onConfigurationChanged(@NonNull Configuration newConfig) {
231
+ super.onConfigurationChanged(newConfig);
232
+ this.mDelegate.onConfigurationChanged(newConfig);
233
+ }
234
+
224
235
  protected final ReactNativeHost getReactNativeHost() {
225
- return activityDelegate.getReactNativeHost();
236
+ return mDelegate.getReactNativeHost();
226
237
  }
227
238
 
228
239
  protected final ReactInstanceManager getReactInstanceManager() {
@@ -235,7 +246,7 @@ public class ReactAppCompatActivity extends AwesomeActivity implements DefaultHa
235
246
 
236
247
  @NonNull
237
248
  protected ReactBridgeManager getReactBridgeManager() {
238
- return activityDelegate.getReactBridgeManager();
249
+ return mDelegate.getReactBridgeManager();
239
250
  }
240
251
 
241
252
  protected boolean isReactModuleRegisterCompleted() {
@@ -4,6 +4,7 @@ import android.annotation.TargetApi;
4
4
  import android.app.Activity;
5
5
  import android.content.Context;
6
6
  import android.content.Intent;
7
+ import android.content.res.Configuration;
7
8
  import android.net.Uri;
8
9
  import android.os.Build;
9
10
  import android.os.Bundle;
@@ -129,9 +130,7 @@ public class ReactAppCompatActivityDelegate {
129
130
  }
130
131
 
131
132
  public boolean onKeyDown(int keyCode, KeyEvent event) {
132
- if (getReactNativeHost().hasInstance()
133
- && getReactNativeHost().getUseDeveloperSupport()
134
- && keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD) {
133
+ if (getReactNativeHost().hasInstance() && getReactNativeHost().getUseDeveloperSupport() && keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD) {
135
134
  event.startTracking();
136
135
  return true;
137
136
  }
@@ -144,8 +143,8 @@ public class ReactAppCompatActivityDelegate {
144
143
  getReactNativeHost().getReactInstanceManager().showDevOptionsDialog();
145
144
  return true;
146
145
  }
147
- boolean didDoubleTapR = Assertions.assertNotNull(mDoubleTapReloadRecognizer)
148
- .didDoubleTapR(keyCode, getPlainActivity().getCurrentFocus());
146
+
147
+ boolean didDoubleTapR = Assertions.assertNotNull(mDoubleTapReloadRecognizer).didDoubleTapR(keyCode, getPlainActivity().getCurrentFocus());
149
148
  if (didDoubleTapR) {
150
149
  getReactNativeHost().getReactInstanceManager().getDevSupportManager().handleReloadJS();
151
150
  return true;
@@ -155,9 +154,7 @@ public class ReactAppCompatActivityDelegate {
155
154
  }
156
155
 
157
156
  public boolean onKeyLongPress(int keyCode, KeyEvent event) {
158
- if (getReactNativeHost().hasInstance()
159
- && getReactNativeHost().getUseDeveloperSupport()
160
- && keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD) {
157
+ if (getReactNativeHost().hasInstance() && getReactNativeHost().getUseDeveloperSupport() && keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD) {
161
158
  getReactNativeHost().getReactInstanceManager().showDevOptionsDialog();
162
159
  return true;
163
160
  }
@@ -180,6 +177,18 @@ public class ReactAppCompatActivityDelegate {
180
177
  return false;
181
178
  }
182
179
 
180
+ public void onWindowFocusChanged(boolean hasFocus) {
181
+ if (this.getReactNativeHost().hasInstance()) {
182
+ this.getReactNativeHost().getReactInstanceManager().onWindowFocusChange(hasFocus);
183
+ }
184
+ }
185
+
186
+ public void onConfigurationChanged(Configuration newConfig) {
187
+ if (this.getReactNativeHost().hasInstance()) {
188
+ this.getReactInstanceManager().onConfigurationChanged(this.getContext(), newConfig);
189
+ }
190
+ }
191
+
183
192
  @TargetApi(Build.VERSION_CODES.M)
184
193
  public void requestPermissions(String[] permissions, int requestCode, PermissionListener listener) {
185
194
  mPermissionListener = listener;
@@ -0,0 +1,9 @@
1
+ #import <React/RCTBridgeModule.h>
2
+
3
+ NS_ASSUME_NONNULL_BEGIN
4
+
5
+ @interface HBDKeyboardInsetsModule : NSObject <RCTBridgeModule>
6
+
7
+ @end
8
+
9
+ NS_ASSUME_NONNULL_END