hybrid-navigation 2.13.17 → 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.
- package/android/.gradle/7.4/checksums/checksums.lock +0 -0
- package/android/.gradle/7.4/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.4/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.4/gc.properties +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.idea/gradle.xml +14 -0
- package/android/.idea/misc.xml +10 -0
- package/android/.idea/vcs.xml +6 -0
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/GardenModule.java +4 -2
- package/android/src/main/java/com/reactnative/hybridnavigation/HybridNavigationPackage.java +6 -3
- package/android/src/main/java/com/reactnative/hybridnavigation/KeyboardInsetsCallback.java +142 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/KeyboardInsetsChangeEvent.java +34 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/KeyboardInsetsModule.java +52 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/KeyboardInsetsView.java +33 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/KeyboardInsetsViewManager.java +53 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactAppCompatActivity.java +34 -20
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactAppCompatActivityDelegate.java +17 -8
- package/ios/HybridNavigation/Keyboard/HBDKeyboardInsetsModule.h +9 -0
- package/ios/HybridNavigation/Keyboard/HBDKeyboardInsetsModule.m +34 -0
- package/ios/HybridNavigation/Keyboard/HBDKeyboardInsetsView.h +17 -0
- package/ios/HybridNavigation/Keyboard/HBDKeyboardInsetsView.m +203 -0
- package/ios/HybridNavigation/Keyboard/HBDKeyboardInsetsViewManager.h +9 -0
- package/ios/HybridNavigation/Keyboard/HBDKeyboardInsetsViewManager.m +18 -0
- package/lib/DeepLink.js +1 -0
- package/lib/Garden.d.ts +1 -1
- package/lib/Keyboard.d.ts +17 -0
- package/lib/Keyboard.js +57 -0
- package/lib/Navigation.d.ts +5 -5
- package/lib/NavigationComponentWrap.d.ts +1 -1
- package/lib/Options.d.ts +12 -12
- package/lib/Route.d.ts +5 -5
- package/lib/handler/BarButtonEventHandler.d.ts +1 -1
- package/lib/handler/DispatchCommandHandler.d.ts +1 -1
- package/lib/handler/ResultEventHandler.d.ts +2 -2
- package/lib/handler/VisibilityEventHandler.d.ts +2 -2
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/package.json +12 -12
- package/src/DeepLink.ts +1 -0
- package/src/Keyboard.tsx +128 -0
- package/src/Navigation.ts +1 -1
- package/src/index.ts +1 -0
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
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>
|
package/android/build.gradle
CHANGED
|
@@ -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:
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
30
|
+
private final ReactAppCompatActivityDelegate mDelegate;
|
|
30
31
|
|
|
31
32
|
protected ReactAppCompatActivity() {
|
|
32
|
-
|
|
33
|
+
mDelegate = createReactActivityDelegate();
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
protected ReactAppCompatActivityDelegate createReactActivityDelegate() {
|
|
@@ -39,15 +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
|
-
|
|
43
|
+
mDelegate.onCreate(savedInstanceState);
|
|
43
44
|
ReactBridgeManager bridgeManager = getReactBridgeManager();
|
|
44
45
|
bridgeManager.addReactModuleRegisterListener(this);
|
|
45
|
-
|
|
46
|
+
|
|
47
|
+
if (savedInstanceState != null) {
|
|
48
|
+
FLog.i(TAG, "ReactAppCompatActivity#re-create");
|
|
49
|
+
}
|
|
50
|
+
|
|
46
51
|
if (isReactModuleRegisterCompleted()) {
|
|
47
52
|
onReactModuleRegisterCompleted();
|
|
48
53
|
}
|
|
49
54
|
}
|
|
50
|
-
|
|
55
|
+
|
|
51
56
|
public void inflateStyle() {
|
|
52
57
|
Style style = getStyle();
|
|
53
58
|
GlobalStyle globalStyle = Garden.getGlobalStyle();
|
|
@@ -61,7 +66,7 @@ public class ReactAppCompatActivity extends AwesomeActivity implements DefaultHa
|
|
|
61
66
|
protected void onDestroy() {
|
|
62
67
|
getReactBridgeManager().removeReactModuleRegisterListener(this);
|
|
63
68
|
super.onDestroy();
|
|
64
|
-
|
|
69
|
+
mDelegate.onDestroy();
|
|
65
70
|
}
|
|
66
71
|
|
|
67
72
|
@Override
|
|
@@ -69,10 +74,9 @@ public class ReactAppCompatActivity extends AwesomeActivity implements DefaultHa
|
|
|
69
74
|
FLog.i(TAG, "ReactAppCompatActivity#onReactModuleRegisterCompleted");
|
|
70
75
|
ReactContext reactContext = Assertions.assertNotNull(getCurrentReactContext());
|
|
71
76
|
if (isResumed && reactContext.getCurrentActivity() == null) {
|
|
72
|
-
|
|
77
|
+
mDelegate.onResume();
|
|
73
78
|
}
|
|
74
79
|
inflateStyle();
|
|
75
|
-
// 部分手机,如三星,Activity 销毁后重建,不会重建 Fragment。
|
|
76
80
|
Fragment fragment = getSupportFragmentManager().findFragmentById(android.R.id.content);
|
|
77
81
|
if (fragment == null) {
|
|
78
82
|
createMainComponent();
|
|
@@ -148,7 +152,7 @@ public class ReactAppCompatActivity extends AwesomeActivity implements DefaultHa
|
|
|
148
152
|
super.onResume();
|
|
149
153
|
isResumed = true;
|
|
150
154
|
if (getCurrentReactContext() != null) {
|
|
151
|
-
|
|
155
|
+
mDelegate.onResume();
|
|
152
156
|
}
|
|
153
157
|
|
|
154
158
|
ReactBridgeManager bridgeManager = getReactBridgeManager();
|
|
@@ -162,35 +166,35 @@ public class ReactAppCompatActivity extends AwesomeActivity implements DefaultHa
|
|
|
162
166
|
protected void onPause() {
|
|
163
167
|
isResumed = false;
|
|
164
168
|
if (getCurrentReactContext() != null) {
|
|
165
|
-
|
|
169
|
+
mDelegate.onPause();
|
|
166
170
|
}
|
|
167
171
|
super.onPause();
|
|
168
172
|
}
|
|
169
173
|
|
|
170
174
|
@Override
|
|
171
175
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
172
|
-
|
|
176
|
+
mDelegate.onActivityResult(requestCode, resultCode, data);
|
|
173
177
|
super.onActivityResult(requestCode, resultCode, data);
|
|
174
178
|
}
|
|
175
179
|
|
|
176
180
|
@Override
|
|
177
181
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
178
|
-
return
|
|
182
|
+
return mDelegate.onKeyDown(keyCode, event) || super.onKeyDown(keyCode, event);
|
|
179
183
|
}
|
|
180
184
|
|
|
181
185
|
@Override
|
|
182
186
|
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
|
183
|
-
return
|
|
187
|
+
return mDelegate.onKeyUp(keyCode, event) || super.onKeyUp(keyCode, event);
|
|
184
188
|
}
|
|
185
189
|
|
|
186
190
|
@Override
|
|
187
191
|
public boolean onKeyLongPress(int keyCode, KeyEvent event) {
|
|
188
|
-
return
|
|
192
|
+
return mDelegate.onKeyLongPress(keyCode, event) || super.onKeyLongPress(keyCode, event);
|
|
189
193
|
}
|
|
190
194
|
|
|
191
195
|
@Override
|
|
192
196
|
public void onBackPressed() {
|
|
193
|
-
if (!
|
|
197
|
+
if (!mDelegate.onBackPressed()) {
|
|
194
198
|
super.onBackPressed();
|
|
195
199
|
}
|
|
196
200
|
}
|
|
@@ -202,24 +206,34 @@ public class ReactAppCompatActivity extends AwesomeActivity implements DefaultHa
|
|
|
202
206
|
|
|
203
207
|
@Override
|
|
204
208
|
public void onNewIntent(Intent intent) {
|
|
205
|
-
if (!
|
|
209
|
+
if (!mDelegate.onNewIntent(intent)) {
|
|
206
210
|
super.onNewIntent(intent);
|
|
207
211
|
}
|
|
208
212
|
}
|
|
209
213
|
|
|
210
214
|
@Override
|
|
211
215
|
public void requestPermissions(String[] permissions, int requestCode, PermissionListener listener) {
|
|
212
|
-
|
|
216
|
+
mDelegate.requestPermissions(permissions, requestCode, listener);
|
|
213
217
|
}
|
|
214
218
|
|
|
215
219
|
@Override
|
|
216
220
|
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
|
217
|
-
|
|
221
|
+
mDelegate.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
|
218
222
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
|
219
223
|
}
|
|
220
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
|
+
|
|
221
235
|
protected final ReactNativeHost getReactNativeHost() {
|
|
222
|
-
return
|
|
236
|
+
return mDelegate.getReactNativeHost();
|
|
223
237
|
}
|
|
224
238
|
|
|
225
239
|
protected final ReactInstanceManager getReactInstanceManager() {
|
|
@@ -232,7 +246,7 @@ public class ReactAppCompatActivity extends AwesomeActivity implements DefaultHa
|
|
|
232
246
|
|
|
233
247
|
@NonNull
|
|
234
248
|
protected ReactBridgeManager getReactBridgeManager() {
|
|
235
|
-
return
|
|
249
|
+
return mDelegate.getReactBridgeManager();
|
|
236
250
|
}
|
|
237
251
|
|
|
238
252
|
protected boolean isReactModuleRegisterCompleted() {
|
package/android/src/main/java/com/reactnative/hybridnavigation/ReactAppCompatActivityDelegate.java
CHANGED
|
@@ -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
|
-
|
|
148
|
-
|
|
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;
|