Browse Source

[BREAKING] Support RN 0.55 (#3342)

* Support RN 0.55.4

This commit adds support for RN 0.55.4 by introducing version specific build flavors - reactNative51

* Update scripts after introducing build flavors

* Update Android installation instruction on specifying build flavor
Guy Carmeli 6 years ago
parent
commit
13b4bc7218
No account linked to committer's email address

+ 12
- 1
docs/docs/Installing.md View File

94
 	    defaultConfig {
94
 	    defaultConfig {
95
 	        minSdkVersion 19
95
 	        minSdkVersion 19
96
 	        targetSdkVersion 25
96
 	        targetSdkVersion 25
97
+	        missingDimensionStrategy "RNN.reactNativeVersion", "reactNative51" // <- See note below for further instruction regarding compatibility with other React Native versions
97
 		...
98
 		...
98
 	    }
99
 	    }
99
 	
100
 	
111
 	    implementation project(':react-native-navigation')
112
 	    implementation project(':react-native-navigation')
112
 	}
113
 	}
113
 	```
114
 	```
114
-	
115
+	> react-native-navigation supports multiple React Native versions. Target the React Native version required by your project by specifying the RNN build flavor you require.
116
+><br><br>Available options:
117
+>
118
+>* `reactNative51`: Support for React Native 0.51-0.54
119
+>* `reactNative55`: Support for React Native 0.55 and above
120
+>
121
+><br>For example, To target React Native 0.55, replace the following line:<br>
122
+>`missingDimensionStrategy "RNN.reactNativeVersion", "reactNative51"`
123
+><br>with:<br>
124
+>`missingDimensionStrategy "RNN.reactNativeVersion", "reactNative55"`
125
+
115
 4. Make sure you're using the new gradle plugin, edit `android/gradle/wrapper/gradle-wrapper.properties`
126
 4. Make sure you're using the new gradle plugin, edit `android/gradle/wrapper/gradle-wrapper.properties`
116
 
127
 
117
 	```diff
128
 	```diff

+ 9
- 2
lib/android/app/build.gradle View File

46
         sourceCompatibility JavaVersion.VERSION_1_8
46
         sourceCompatibility JavaVersion.VERSION_1_8
47
         targetCompatibility JavaVersion.VERSION_1_8
47
         targetCompatibility JavaVersion.VERSION_1_8
48
     }
48
     }
49
+    flavorDimensions "RNN.reactNativeVersion"
50
+    productFlavors {
51
+        reactNative51 {
52
+            dimension "RNN.reactNativeVersion"
53
+        }
54
+        reactNative55 {
55
+            dimension "RNN.reactNativeVersion"
56
+        }
57
+    }
49
 }
58
 }
50
 
59
 
51
 allprojects { p ->
60
 allprojects { p ->
63
     implementation 'com.aurelhubert:ahbottomnavigation:2.1.0'
72
     implementation 'com.aurelhubert:ahbottomnavigation:2.1.0'
64
     implementation 'com.github.clans:fab:1.6.4'
73
     implementation 'com.github.clans:fab:1.6.4'
65
 
74
 
66
-
67
-    // node_modules
68
     //noinspection GradleDynamicVersion
75
     //noinspection GradleDynamicVersion
69
     implementation 'com.facebook.react:react-native:+'
76
     implementation 'com.facebook.react:react-native:+'
70
 
77
 

lib/android/app/src/main/java/com/reactnativenavigation/react/SyncUiImplementation.java → lib/android/app/src/reactNative51/java/com/reactnativenavigation/react/SyncUiImplementation.java View File


+ 83
- 0
lib/android/app/src/reactNative55/java/com/reactnativenavigation/react/SyncUiImplementation.java View File

1
+package com.reactnativenavigation.react;
2
+
3
+import android.support.annotation.Nullable;
4
+
5
+import com.facebook.react.bridge.ReactApplicationContext;
6
+import com.facebook.react.bridge.ReadableArray;
7
+import com.facebook.react.bridge.ReadableMap;
8
+import com.facebook.react.uimanager.ThemedReactContext;
9
+import com.facebook.react.uimanager.UIImplementation;
10
+import com.facebook.react.uimanager.UIImplementationProvider;
11
+import com.facebook.react.uimanager.UIManagerModule;
12
+import com.facebook.react.uimanager.ViewManager;
13
+import com.facebook.react.uimanager.common.MeasureSpecProvider;
14
+import com.facebook.react.uimanager.common.SizeMonitoringFrameLayout;
15
+import com.facebook.react.uimanager.events.EventDispatcher;
16
+
17
+import java.util.List;
18
+
19
+@SuppressWarnings("WeakerAccess")
20
+public class SyncUiImplementation extends UIImplementation {
21
+    private static final Object lock = new Object();
22
+
23
+    public static class Provider extends UIImplementationProvider {
24
+        @Override
25
+        public UIImplementation createUIImplementation(ReactApplicationContext reactContext, List<ViewManager> viewManagerList, EventDispatcher eventDispatcher, int minTimeLeftInFrameForNonBatchedOperationMs) {
26
+            return new SyncUiImplementation(reactContext, viewManagerList, eventDispatcher, minTimeLeftInFrameForNonBatchedOperationMs);
27
+        }
28
+
29
+        @Override
30
+        public UIImplementation createUIImplementation(ReactApplicationContext reactContext, UIManagerModule.ViewManagerResolver viewManagerResolver, EventDispatcher eventDispatcher, int minTimeLeftInFrameForNonBatchedOperationMs) {
31
+            return new SyncUiImplementation(reactContext, viewManagerResolver, eventDispatcher, minTimeLeftInFrameForNonBatchedOperationMs);
32
+        }
33
+    }
34
+
35
+    public SyncUiImplementation(ReactApplicationContext reactContext, List<ViewManager> viewManagerList, EventDispatcher eventDispatcher, int minTimeLeftInFrameForNonBatchedOperationMs) {
36
+        super(reactContext, viewManagerList, eventDispatcher, minTimeLeftInFrameForNonBatchedOperationMs);
37
+    }
38
+
39
+    public SyncUiImplementation(ReactApplicationContext reactContext, UIManagerModule.ViewManagerResolver viewManagerResolver, EventDispatcher eventDispatcher, int minTimeLeftInFrameForNonBatchedOperationMs) {
40
+        super(reactContext, viewManagerResolver, eventDispatcher, minTimeLeftInFrameForNonBatchedOperationMs);
41
+    }
42
+
43
+    @Override
44
+    public void manageChildren(
45
+            int viewTag,
46
+            @Nullable ReadableArray moveFrom,
47
+            @Nullable ReadableArray moveTo,
48
+            @Nullable ReadableArray addChildTags,
49
+            @Nullable ReadableArray addAtIndices,
50
+            @Nullable ReadableArray removeFrom) {
51
+        synchronized (lock) {
52
+            super.manageChildren(viewTag, moveFrom, moveTo, addChildTags, addAtIndices, removeFrom);
53
+        }
54
+    }
55
+
56
+    @Override
57
+    public void setChildren(int viewTag, ReadableArray childrenTags) {
58
+        synchronized (lock) {
59
+            super.setChildren(viewTag, childrenTags);
60
+        }
61
+    }
62
+
63
+    @Override
64
+    public void createView(int tag, String className, int rootViewTag, ReadableMap props) {
65
+        synchronized (lock) {
66
+            super.createView(tag, className, rootViewTag, props);
67
+        }
68
+    }
69
+
70
+    @Override
71
+    public void removeRootShadowNode(int rootViewTag) {
72
+        synchronized (lock) {
73
+            super.removeRootShadowNode(rootViewTag);
74
+        }
75
+    }
76
+
77
+    @Override
78
+    public <T extends SizeMonitoringFrameLayout & MeasureSpecProvider> void registerRootView(T rootView, int tag, ThemedReactContext context) {
79
+        synchronized (lock) {
80
+            super.registerRootView(rootView, tag, context);
81
+        }
82
+    }
83
+}

+ 2
- 2
package.json View File

134
       },
134
       },
135
       "android.emu.debug": {
135
       "android.emu.debug": {
136
         "binaryPath": "playground/android/app/build/outputs/apk/debug/app-debug.apk",
136
         "binaryPath": "playground/android/app/build/outputs/apk/debug/app-debug.apk",
137
-        "build": "cd playground/android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug",
137
+        "build": "cd playground/android && ./gradlew app:assembleDebug app:assembleAndroidTest -DtestBuildType=debug",
138
         "type": "android.emulator",
138
         "type": "android.emulator",
139
         "name": "Pixel_2_API_26"
139
         "name": "Pixel_2_API_26"
140
       },
140
       },
141
       "android.emu.release": {
141
       "android.emu.release": {
142
         "binaryPath": "playground/android/app/build/outputs/apk/release/app-release.apk",
142
         "binaryPath": "playground/android/app/build/outputs/apk/release/app-release.apk",
143
-        "build": "cd playground/android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release",
143
+        "build": "cd playground/android && ./gradlew app:assembleRelease app:assembleAndroidTest -DtestBuildType=release",
144
         "type": "android.emulator",
144
         "type": "android.emulator",
145
         "name": "Pixel_2_API_26"
145
         "name": "Pixel_2_API_26"
146
       }
146
       }

+ 6
- 3
playground/android/app/build.gradle View File

27
         }
27
         }
28
 
28
 
29
         testBuildType System.getProperty('testBuildType', 'debug')  //this will later be used to control the test apk build type
29
         testBuildType System.getProperty('testBuildType', 'debug')  //this will later be used to control the test apk build type
30
-        missingDimensionStrategy "minReactNative", "minReactNative46" //read note
30
+        missingDimensionStrategy "minReactNative", "minReactNative46"
31
+        missingDimensionStrategy "RNN.reactNativeVersion", "reactNative51"
31
         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
32
         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
32
     }
33
     }
33
     signingConfigs {
34
     signingConfigs {
47
 
48
 
48
 dependencies {
49
 dependencies {
49
     implementation fileTree(dir: 'libs', include: ['*.jar'])
50
     implementation fileTree(dir: 'libs', include: ['*.jar'])
50
-    implementation ('com.facebook.react:react-native:0.51.1') { force = true }
51
     implementation 'com.android.support:design:25.4.0'
51
     implementation 'com.android.support:design:25.4.0'
52
     implementation "com.android.support:appcompat-v7:25.4.0"
52
     implementation "com.android.support:appcompat-v7:25.4.0"
53
+
54
+    //noinspection GradleDynamicVersion
55
+    implementation 'com.facebook.react:react-native:+'
53
     implementation project(':react-native-navigation')
56
     implementation project(':react-native-navigation')
54
 
57
 
55
-    androidTestImplementation(project(path: ":detox"))
58
+    androidTestImplementation(project(':detox'))
56
     androidTestImplementation 'junit:junit:4.12'
59
     androidTestImplementation 'junit:junit:4.12'
57
     androidTestImplementation 'com.android.support.test:runner:1.0.1'
60
     androidTestImplementation 'com.android.support.test:runner:1.0.1'
58
     androidTestImplementation 'com.android.support.test:rules:1.0.1'
61
     androidTestImplementation 'com.android.support.test:rules:1.0.1'

+ 1
- 1
playground/android/build.gradle View File

8
         jcenter()
8
         jcenter()
9
     }
9
     }
10
     dependencies {
10
     dependencies {
11
-        classpath 'com.android.tools.build:gradle:3.0.1'
11
+        classpath 'com.android.tools.build:gradle:3.1.3'
12
 
12
 
13
         // NOTE: Do not place your application dependencies here; they belong
13
         // NOTE: Do not place your application dependencies here; they belong
14
         // in the individual module build.gradle files
14
         // in the individual module build.gradle files

+ 1
- 1
scripts/test-unit.js View File

13
 }
13
 }
14
 
14
 
15
 function runAndroidUnitTests() {
15
 function runAndroidUnitTests() {
16
-  const conf = release ? 'testReleaseUnitTest' : 'testDebugUnitTest';
16
+  const conf = release ? 'testReactNative51ReleaseUnitTest' : 'testReactNative51DebugUnitTest';
17
 
17
 
18
   exec.execSync(`cd lib/android && ./gradlew ${conf}`);
18
   exec.execSync(`cd lib/android && ./gradlew ${conf}`);
19
 }
19
 }