Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 12 additions & 124 deletions lib/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,24 @@ def safeExtGet(prop, fallback) {
}

def safeExtGetFallbackLowerBound(prop, fallback) {
Math.max(safeExtGet(prop,fallback),fallback)
Math.max(safeExtGet(prop, fallback), fallback)
}

def DEFAULT_COMPILE_SDK_VERSION = 33
def DEFAULT_MIN_SDK_VERSION = 21
def DEFAULT_TARGET_SDK_VERSION = 33
def DEFAULT_COMPILE_SDK_VERSION = 35
def DEFAULT_MIN_SDK_VERSION = 24
def DEFAULT_TARGET_SDK_VERSION = 35
def DEFAULT_KOTLIN_VERSION = "1.5.31"
def DEFAULT_KOTLIN_STDLIB = 'kotlin-stdlib-jdk8'
def DEFAULT_BUILD_TOOLS_VERSION = "35.0.0"
def kotlinVersion = safeExtGet("RNNKotlinVersion", DEFAULT_KOTLIN_VERSION)
def kotlinStdlib = safeExtGet('RNNKotlinStdlib',DEFAULT_KOTLIN_STDLIB )
def kotlinStdlib = safeExtGet('RNNKotlinStdlib', DEFAULT_KOTLIN_STDLIB)
def kotlinCoroutinesCore = safeExtGet('RNNKotlinCoroutinesCore', '1.5.2')
def _buildToolsVersion = safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)

android {
namespace 'com.reactnativenavigation'
compileSdkVersion safeExtGetFallbackLowerBound('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
buildToolsVersion = "34.0.0"
buildToolsVersion = _buildToolsVersion
defaultConfig {
minSdkVersion safeExtGetFallbackLowerBound('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
targetSdkVersion safeExtGetFallbackLowerBound('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
Expand Down Expand Up @@ -73,126 +75,12 @@ android {
}
}
compileOptions {
if (reactNativeMinorVersion() >= 73) {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
} else {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
if (reactNativeMinorVersion() >= 73) {
jvmTarget = JavaVersion.VERSION_17
} else {
jvmTarget = JavaVersion.VERSION_11
}
jvmTarget = JavaVersion.VERSION_17
}

flavorDimensions "RNN.reactNativeVersion"
productFlavors {
reactNative51 {
dimension "RNN.reactNativeVersion"
buildConfigField("int", "REACT_NATVE_VERSION_MINOR", "51")
}
reactNative55 {
dimension "RNN.reactNativeVersion"
buildConfigField("int", "REACT_NATVE_VERSION_MINOR", "55")
}
reactNative56 {
dimension "RNN.reactNativeVersion"
buildConfigField("int", "REACT_NATVE_VERSION_MINOR", "56")
}
reactNative57 {
dimension "RNN.reactNativeVersion"
buildConfigField("int", "REACT_NATVE_VERSION_MINOR", "57")
}
reactNative57_5 {
dimension "RNN.reactNativeVersion"
buildConfigField("int", "REACT_NATVE_VERSION_MINOR", "57")
}
reactNative60 {
dimension "RNN.reactNativeVersion"
buildConfigField("int", "REACT_NATVE_VERSION_MINOR", "60")
}
reactNative62 {
dimension "RNN.reactNativeVersion"
buildConfigField("int", "REACT_NATVE_VERSION_MINOR", "62")
}
reactNative63 {
dimension "RNN.reactNativeVersion"
buildConfigField("int", "REACT_NATVE_VERSION_MINOR", "63")
}
reactNative68 {
dimension "RNN.reactNativeVersion"
buildConfigField("int", "REACT_NATVE_VERSION_MINOR", "68")
}
reactNative71 {
dimension "RNN.reactNativeVersion"
buildConfigField("int", "REACT_NATVE_VERSION_MINOR", "71")
}
}

def flavor = resolveFlavor()
variantFilter { variant ->
def names = variant.flavors*.name
if (!names.contains(flavor)) {
setIgnore(true)
}
}
}

int reactNativeMinorVersion() {
List reactNativeVersionComponents = reactNativeVersionComponents(findReactNativePackageJson())
reactNativeVersionComponents[1].toInteger()
}

String resolveFlavor() {
List reactNativeVersionComponents = reactNativeVersionComponents(findReactNativePackageJson())
Integer reactNativeMinorComponent = reactNativeVersionComponents[1].toInteger()
Integer reactNativePatchComponent = reactNativeVersionComponents[2].toInteger()

if (reactNativeMinorComponent >= 71) {
return "reactNative71"
} else if (reactNativeMinorComponent >= 68) {
return "reactNative68"
} else if (reactNativeMinorComponent >= 63) {
return "reactNative63"
} else if (reactNativeMinorComponent >= 62) {
return "reactNative62"
} else if (reactNativeMinorComponent >= 60) {
return "reactNative60"
} else if (reactNativeMinorComponent >= 57 && reactNativePatchComponent >= 5) {
return "reactNative57_5"
} else if (reactNativeMinorComponent >= 57) {
return "reactNative57"
} else if (reactNativeMinorComponent >= 56) {
return "reactNative56"
} else if (reactNativeMinorComponent >= 55) {
return "reactNative55"
} else if (reactNativeMinorComponent >= 51) {
return "reactNative51"
}
}


Object findReactNativePackageJson() {
def searchPath = 'node_modules/react-native/package.json'
def projectDir = project.projectDir.toString() + '/'
def rnPackageJsonFile = new File(projectDir + searchPath)
while (!rnPackageJsonFile.exists()) {
searchPath = '../' + searchPath
rnPackageJsonFile = new File(projectDir + searchPath)
}
return rnPackageJsonFile
}

List reactNativeVersionComponents(rnPackageJsonFile) {
def packageSlurper = new JsonSlurper()
def reactNativePackageJson = packageSlurper.parseText(rnPackageJsonFile.text)
def reactNativeVersion = reactNativePackageJson.version

return reactNativeVersion.tokenize('-')[0].tokenize('.')
}

dependencies {
Expand All @@ -214,7 +102,7 @@ dependencies {
//noinspection GradleDynamicVersion
implementation 'com.facebook.react:react-native:+'

if("Playground".toLowerCase() == rootProject.name.toLowerCase()){
if ("Playground".toLowerCase() == rootProject.name.toLowerCase()) {
// tests only for our playground
testImplementation 'junit:junit:4.13.2'
testImplementation "org.robolectric:robolectric:4.7.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void onCreate() {
* @return a singleton {@link ReactGateway}
*/
protected ReactGateway createReactGateway() {
return new ReactGateway(getReactHost(), getReactNativeHost());
return new ReactGateway(getReactHost());
}

public ReactGateway getReactGateway() {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@
public class NavigationReactInitializer implements ReactInstanceManager.ReactInstanceEventListener {

private final ReactHost reactHost;
private final DevPermissionRequest devPermissionRequest;
private boolean waitingForAppLaunchEvent = true;
private boolean isActivityReadyForUi = false;

NavigationReactInitializer(ReactHost reactHost, boolean isDebug) {
NavigationReactInitializer(ReactHost reactHost) {
this.reactHost = reactHost;
this.devPermissionRequest = new DevPermissionRequest(isDebug);
}

void onActivityCreated() {
Expand All @@ -26,13 +24,10 @@ void onActivityCreated() {
}

void onActivityResumed(NavigationActivity activity) {
if (devPermissionRequest.shouldAskPermission(activity)) {
devPermissionRequest.askPermission(activity);
} else {

reactHost.onHostResume(activity, activity);
isActivityReadyForUi = true;
prepareReactApp();
}
}

void onActivityPaused(NavigationActivity activity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public class ReactGateway {
private final NavigationReactInitializer initializer;
private final JsDevReloadHandler jsDevReloadHandler;

public ReactGateway(ReactHost host, ReactNativeHost reactNativeHost) {
public ReactGateway(ReactHost host) {
this.host = host;
initializer = new NavigationReactInitializer(host, reactNativeHost.getUseDeveloperSupport());
initializer = new NavigationReactInitializer(host);
jsDevReloadHandler = new JsDevReloadHandler(host.getDevSupportManager());
if (host instanceof BundleDownloadListenerProvider) {
((BundleDownloadListenerProvider) host).setBundleLoaderListener(jsDevReloadHandler);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,9 @@ import com.reactnativenavigation.BuildConfig
val hitRect = Rect()

fun MotionEvent.coordinatesInsideView(view: View?): Boolean {
if (BuildConfig.REACT_NATVE_VERSION_MINOR < 71) {
view ?: return false
view.getHitRect(hitRect)
return hitRect.contains(x.toInt(), y.toInt())
} else {
val viewGroup = (view as? ViewGroup)?.getChildAt(0) as? ViewGroup ?: view
val viewGroup = (view as? ViewGroup)?.getChildAt(0) as? ViewGroup ?: view

viewGroup?.getHitRect(hitRect)
return hitRect.contains(x.toInt(), y.toInt())

viewGroup?.getHitRect(hitRect)
return hitRect.contains(x.toInt(), y.toInt())
}
}

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading