Skip to content

Commit ad2075f

Browse files
authored
Feat/8009 rn77 na android remove old unsupported flavors in the project (#8028)
* Removed old flavors * Removed legacy code * Updated default android kotlin version and build versions * Fixed unit test
1 parent c915e02 commit ad2075f

File tree

113 files changed

+33
-4324
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+33
-4324
lines changed

lib/android/app/build.gradle

Lines changed: 12 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,24 @@ def safeExtGet(prop, fallback) {
1818
}
1919

2020
def safeExtGetFallbackLowerBound(prop, fallback) {
21-
Math.max(safeExtGet(prop,fallback),fallback)
21+
Math.max(safeExtGet(prop, fallback), fallback)
2222
}
2323

24-
def DEFAULT_COMPILE_SDK_VERSION = 33
25-
def DEFAULT_MIN_SDK_VERSION = 21
26-
def DEFAULT_TARGET_SDK_VERSION = 33
24+
def DEFAULT_COMPILE_SDK_VERSION = 35
25+
def DEFAULT_MIN_SDK_VERSION = 24
26+
def DEFAULT_TARGET_SDK_VERSION = 35
2727
def DEFAULT_KOTLIN_VERSION = "1.5.31"
2828
def DEFAULT_KOTLIN_STDLIB = 'kotlin-stdlib-jdk8'
29+
def DEFAULT_BUILD_TOOLS_VERSION = "35.0.0"
2930
def kotlinVersion = safeExtGet("RNNKotlinVersion", DEFAULT_KOTLIN_VERSION)
30-
def kotlinStdlib = safeExtGet('RNNKotlinStdlib',DEFAULT_KOTLIN_STDLIB )
31+
def kotlinStdlib = safeExtGet('RNNKotlinStdlib', DEFAULT_KOTLIN_STDLIB)
3132
def kotlinCoroutinesCore = safeExtGet('RNNKotlinCoroutinesCore', '1.5.2')
33+
def _buildToolsVersion = safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
3234

3335
android {
3436
namespace 'com.reactnativenavigation'
3537
compileSdkVersion safeExtGetFallbackLowerBound('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
36-
buildToolsVersion = "34.0.0"
38+
buildToolsVersion = _buildToolsVersion
3739
defaultConfig {
3840
minSdkVersion safeExtGetFallbackLowerBound('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
3941
targetSdkVersion safeExtGetFallbackLowerBound('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
@@ -73,126 +75,12 @@ android {
7375
}
7476
}
7577
compileOptions {
76-
if (reactNativeMinorVersion() >= 73) {
77-
sourceCompatibility JavaVersion.VERSION_17
78-
targetCompatibility JavaVersion.VERSION_17
79-
} else {
80-
sourceCompatibility JavaVersion.VERSION_1_8
81-
targetCompatibility JavaVersion.VERSION_1_8
82-
}
78+
sourceCompatibility JavaVersion.VERSION_17
79+
targetCompatibility JavaVersion.VERSION_17
8380
}
8481
kotlinOptions {
85-
if (reactNativeMinorVersion() >= 73) {
86-
jvmTarget = JavaVersion.VERSION_17
87-
} else {
88-
jvmTarget = JavaVersion.VERSION_11
89-
}
82+
jvmTarget = JavaVersion.VERSION_17
9083
}
91-
92-
flavorDimensions "RNN.reactNativeVersion"
93-
productFlavors {
94-
reactNative51 {
95-
dimension "RNN.reactNativeVersion"
96-
buildConfigField("int", "REACT_NATVE_VERSION_MINOR", "51")
97-
}
98-
reactNative55 {
99-
dimension "RNN.reactNativeVersion"
100-
buildConfigField("int", "REACT_NATVE_VERSION_MINOR", "55")
101-
}
102-
reactNative56 {
103-
dimension "RNN.reactNativeVersion"
104-
buildConfigField("int", "REACT_NATVE_VERSION_MINOR", "56")
105-
}
106-
reactNative57 {
107-
dimension "RNN.reactNativeVersion"
108-
buildConfigField("int", "REACT_NATVE_VERSION_MINOR", "57")
109-
}
110-
reactNative57_5 {
111-
dimension "RNN.reactNativeVersion"
112-
buildConfigField("int", "REACT_NATVE_VERSION_MINOR", "57")
113-
}
114-
reactNative60 {
115-
dimension "RNN.reactNativeVersion"
116-
buildConfigField("int", "REACT_NATVE_VERSION_MINOR", "60")
117-
}
118-
reactNative62 {
119-
dimension "RNN.reactNativeVersion"
120-
buildConfigField("int", "REACT_NATVE_VERSION_MINOR", "62")
121-
}
122-
reactNative63 {
123-
dimension "RNN.reactNativeVersion"
124-
buildConfigField("int", "REACT_NATVE_VERSION_MINOR", "63")
125-
}
126-
reactNative68 {
127-
dimension "RNN.reactNativeVersion"
128-
buildConfigField("int", "REACT_NATVE_VERSION_MINOR", "68")
129-
}
130-
reactNative71 {
131-
dimension "RNN.reactNativeVersion"
132-
buildConfigField("int", "REACT_NATVE_VERSION_MINOR", "71")
133-
}
134-
}
135-
136-
def flavor = resolveFlavor()
137-
variantFilter { variant ->
138-
def names = variant.flavors*.name
139-
if (!names.contains(flavor)) {
140-
setIgnore(true)
141-
}
142-
}
143-
}
144-
145-
int reactNativeMinorVersion() {
146-
List reactNativeVersionComponents = reactNativeVersionComponents(findReactNativePackageJson())
147-
reactNativeVersionComponents[1].toInteger()
148-
}
149-
150-
String resolveFlavor() {
151-
List reactNativeVersionComponents = reactNativeVersionComponents(findReactNativePackageJson())
152-
Integer reactNativeMinorComponent = reactNativeVersionComponents[1].toInteger()
153-
Integer reactNativePatchComponent = reactNativeVersionComponents[2].toInteger()
154-
155-
if (reactNativeMinorComponent >= 71) {
156-
return "reactNative71"
157-
} else if (reactNativeMinorComponent >= 68) {
158-
return "reactNative68"
159-
} else if (reactNativeMinorComponent >= 63) {
160-
return "reactNative63"
161-
} else if (reactNativeMinorComponent >= 62) {
162-
return "reactNative62"
163-
} else if (reactNativeMinorComponent >= 60) {
164-
return "reactNative60"
165-
} else if (reactNativeMinorComponent >= 57 && reactNativePatchComponent >= 5) {
166-
return "reactNative57_5"
167-
} else if (reactNativeMinorComponent >= 57) {
168-
return "reactNative57"
169-
} else if (reactNativeMinorComponent >= 56) {
170-
return "reactNative56"
171-
} else if (reactNativeMinorComponent >= 55) {
172-
return "reactNative55"
173-
} else if (reactNativeMinorComponent >= 51) {
174-
return "reactNative51"
175-
}
176-
}
177-
178-
179-
Object findReactNativePackageJson() {
180-
def searchPath = 'node_modules/react-native/package.json'
181-
def projectDir = project.projectDir.toString() + '/'
182-
def rnPackageJsonFile = new File(projectDir + searchPath)
183-
while (!rnPackageJsonFile.exists()) {
184-
searchPath = '../' + searchPath
185-
rnPackageJsonFile = new File(projectDir + searchPath)
186-
}
187-
return rnPackageJsonFile
188-
}
189-
190-
List reactNativeVersionComponents(rnPackageJsonFile) {
191-
def packageSlurper = new JsonSlurper()
192-
def reactNativePackageJson = packageSlurper.parseText(rnPackageJsonFile.text)
193-
def reactNativeVersion = reactNativePackageJson.version
194-
195-
return reactNativeVersion.tokenize('-')[0].tokenize('.')
19684
}
19785

19886
dependencies {
@@ -214,7 +102,7 @@ dependencies {
214102
//noinspection GradleDynamicVersion
215103
implementation 'com.facebook.react:react-native:+'
216104

217-
if("Playground".toLowerCase() == rootProject.name.toLowerCase()){
105+
if ("Playground".toLowerCase() == rootProject.name.toLowerCase()) {
218106
// tests only for our playground
219107
testImplementation 'junit:junit:4.13.2'
220108
testImplementation "org.robolectric:robolectric:4.7.2"

lib/android/app/src/main/java/com/reactnativenavigation/NavigationApplication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public void onCreate() {
5353
* @return a singleton {@link ReactGateway}
5454
*/
5555
protected ReactGateway createReactGateway() {
56-
return new ReactGateway(getReactHost(), getReactNativeHost());
56+
return new ReactGateway(getReactHost());
5757
}
5858

5959
public ReactGateway getReactGateway() {

lib/android/app/src/reactNative63/java/com/reactnativenavigation/options/parsers/ColorParser.kt renamed to lib/android/app/src/main/java/com/reactnativenavigation/options/parsers/ColorParser.kt

File renamed without changes.

lib/android/app/src/reactNative62/java/com/reactnativenavigation/react/DevBundleDownloadListenerAdapter.java renamed to lib/android/app/src/main/java/com/reactnativenavigation/react/DevBundleDownloadListenerAdapter.java

File renamed without changes.

lib/android/app/src/main/java/com/reactnativenavigation/react/DevPermissionRequest.java

Lines changed: 0 additions & 42 deletions
This file was deleted.

lib/android/app/src/reactNative62/java/com/reactnativenavigation/react/JsDevReloadHandlerFacade.java renamed to lib/android/app/src/main/java/com/reactnativenavigation/react/JsDevReloadHandlerFacade.java

File renamed without changes.

lib/android/app/src/main/java/com/reactnativenavigation/react/NavigationReactInitializer.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@
1111
public class NavigationReactInitializer implements ReactInstanceManager.ReactInstanceEventListener {
1212

1313
private final ReactHost reactHost;
14-
private final DevPermissionRequest devPermissionRequest;
1514
private boolean waitingForAppLaunchEvent = true;
1615
private boolean isActivityReadyForUi = false;
1716

18-
NavigationReactInitializer(ReactHost reactHost, boolean isDebug) {
17+
NavigationReactInitializer(ReactHost reactHost) {
1918
this.reactHost = reactHost;
20-
this.devPermissionRequest = new DevPermissionRequest(isDebug);
2119
}
2220

2321
void onActivityCreated() {
@@ -26,13 +24,10 @@ void onActivityCreated() {
2624
}
2725

2826
void onActivityResumed(NavigationActivity activity) {
29-
if (devPermissionRequest.shouldAskPermission(activity)) {
30-
devPermissionRequest.askPermission(activity);
31-
} else {
27+
3228
reactHost.onHostResume(activity, activity);
3329
isActivityReadyForUi = true;
3430
prepareReactApp();
35-
}
3631
}
3732

3833
void onActivityPaused(NavigationActivity activity) {

lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/NavigationReactNativeHost.java renamed to lib/android/app/src/main/java/com/reactnativenavigation/react/NavigationReactNativeHost.java

File renamed without changes.

lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/ReactGateway.java renamed to lib/android/app/src/main/java/com/reactnativenavigation/react/ReactGateway.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ public class ReactGateway {
1616
private final NavigationReactInitializer initializer;
1717
private final JsDevReloadHandler jsDevReloadHandler;
1818

19-
public ReactGateway(ReactHost host, ReactNativeHost reactNativeHost) {
19+
public ReactGateway(ReactHost host) {
2020
this.host = host;
21-
initializer = new NavigationReactInitializer(host, reactNativeHost.getUseDeveloperSupport());
21+
initializer = new NavigationReactInitializer(host);
2222
jsDevReloadHandler = new JsDevReloadHandler(host.getDevSupportManager());
2323
if (host instanceof BundleDownloadListenerProvider) {
2424
((BundleDownloadListenerProvider) host).setBundleLoaderListener(jsDevReloadHandler);

lib/android/app/src/reactNative51/java/com/reactnativenavigation/react/ReloadHandlerFacade.java renamed to lib/android/app/src/main/java/com/reactnativenavigation/react/ReloadHandlerFacade.java

File renamed without changes.

0 commit comments

Comments
 (0)