Skip to content

Commit 4d91361

Browse files
Merge pull request #15 from rn-bridge/newarch_support
Support New Architecture
2 parents 703210f + ecdc8d6 commit 4d91361

Some content is hidden

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

63 files changed

+5174
-3345
lines changed

Diff for: README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
# @rn-bridge/react-native-geofencing
44

5-
Native module to determine if a location is within defined geographical boundaries. Geofencing combines awareness of the user's current location with awareness of the user's proximity to locations that may be of interest. To mark a location of interest, you specify its latitude and longitude. To adjust the proximity for the location, you add a radius. The latitude, longitude, and radius define a geofence, creating a circular area, or fence, around the location of interest.
5+
React native module to determine if a location is within defined geographical boundaries. Geofencing combines awareness of the user's current location with awareness of the user's proximity to locations that may be of interest. To mark a location of interest, you specify its latitude and longitude. To adjust the proximity for the location, you add a radius. The latitude, longitude, and radius define a geofence, creating a circular area, or fence, around the location of interest.
66

7-
Fully compatible with TypeScript.
7+
Fully compatible with TypeScript & Turbomodules.
88

99
## Supported platforms
1010

Diff for: android/build.gradle

+14-3
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,18 @@ static def supportsNamespace() {
5252
android {
5353
if (supportsNamespace()) {
5454
namespace "com.rnbridge.geofencing"
55+
}
5556

56-
sourceSets {
57-
main {
57+
sourceSets {
58+
main {
59+
if (supportsNamespace()) {
5860
manifest.srcFile "src/main/AndroidManifestNew.xml"
5961
}
62+
if (isNewArchitectureEnabled()) {
63+
java.srcDirs += ['src/newarch']
64+
} else {
65+
java.srcDirs += ['src/oldarch']
66+
}
6067
}
6168
}
6269

@@ -65,7 +72,7 @@ android {
6572
defaultConfig {
6673
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
6774
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
68-
75+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
6976
}
7077

7178
buildTypes {
@@ -77,6 +84,10 @@ android {
7784
lintOptions {
7885
disable "GradleCompatible"
7986
}
87+
88+
buildFeatures {
89+
buildConfig true
90+
}
8091
}
8192

8293
repositories {

Diff for: android/gradle.properties

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
1212
# org.gradle.parallel=true
1313
#Fri Aug 16 11:45:03 IST 2024
14-
ReactNativeGeofencing_compileSdkVersion=33
15-
ReactNativeGeofencing_kotlinVersion=1.9.24
16-
ReactNativeGeofencing_minSdkVersion=21
17-
ReactNativeGeofencing_ndkversion=26.1.10909125
18-
ReactNativeGeofencing_targetSdkVersion=33
14+
ReactNativeGeofencing_compileSdkVersion=35
15+
ReactNativeGeofencing_kotlinVersion=2.0.21
16+
ReactNativeGeofencing_minSdkVersion=24
17+
ReactNativeGeofencing_ndkversion=27.1.12297006
18+
ReactNativeGeofencing_targetSdkVersion=34
1919
android.useAndroidX=true

Diff for: android/gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

Diff for: android/src/main/java/com/rnbridge/geofencing/GeofencingPackage.kt

-16
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.rnbridge.geofencing
2+
3+
import com.facebook.react.BaseReactPackage
4+
import com.facebook.react.bridge.NativeModule
5+
import com.facebook.react.bridge.ReactApplicationContext
6+
import com.facebook.react.module.model.ReactModuleInfo
7+
import com.facebook.react.module.model.ReactModuleInfoProvider
8+
import com.facebook.react.uimanager.ViewManager
9+
10+
class RNGeofencingPackage : BaseReactPackage() {
11+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
12+
return listOf(RNGeofencingModule(reactContext))
13+
}
14+
15+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
16+
return emptyList()
17+
}
18+
19+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
20+
return when (name) {
21+
"RNGeofencing" -> RNGeofencingModule(reactContext)
22+
else -> null
23+
}
24+
}
25+
26+
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
27+
return ReactModuleInfoProvider {
28+
val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
29+
val isTurboModule: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
30+
moduleInfos["RNGeofencing"] = ReactModuleInfo(
31+
"RNGeofencing",
32+
"RNGeofencing",
33+
false,
34+
false,
35+
false,
36+
isTurboModule
37+
)
38+
moduleInfos
39+
}
40+
}
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package com.rnbridge.geofencing
2+
3+
import android.location.Location
4+
import com.facebook.react.bridge.Callback
5+
import com.facebook.react.bridge.Promise
6+
import com.facebook.react.bridge.ReactApplicationContext
7+
import com.facebook.react.bridge.ReadableMap
8+
9+
class RNGeofencingModule(reactContext: ReactApplicationContext) :
10+
NativeGeofencingSpec(reactContext) {
11+
12+
private val geofenceManager = GeofenceManager(reactApplicationContext)
13+
14+
override fun getName(): String {
15+
return NAME
16+
}
17+
18+
override fun getCurrentLocation(promise: Promise) {
19+
geofenceManager.getCurrentLocation(promise)
20+
}
21+
22+
override fun getRegisteredGeofences(promise: Promise) {
23+
geofenceManager.getRegisteredGeofences(promise)
24+
}
25+
26+
override fun addGeofence(params: ReadableMap, promise: Promise) {
27+
val id = params.getString("id") as String
28+
val latitude = params.getDouble("latitude")
29+
val longitude = params.getDouble("longitude")
30+
val radius = params.getDouble("radius")
31+
32+
val location = Location("").apply {
33+
this.latitude = latitude
34+
this.longitude = longitude
35+
}
36+
37+
geofenceManager.addGeofence(id, location, radius.toFloat(), promise)
38+
}
39+
40+
override fun removeGeofence(id: String, promise: Promise) {
41+
geofenceManager.removeGeofence(id, promise)
42+
}
43+
44+
override fun removeAllGeofence(promise: Promise) {
45+
geofenceManager.removeAllGeofence(promise)
46+
}
47+
48+
override fun requestLocation(params: ReadableMap, response: Callback) {}
49+
50+
override fun getLocationAuthorizationStatus(promise: Promise) {}
51+
52+
companion object {
53+
const val NAME = "RNGeofencing"
54+
}
55+
}

Diff for: android/src/main/java/com/rnbridge/geofencing/GeofencingModule.kt renamed to android/src/oldarch/com/rnbridge/geofencing/RNGeofencingModule.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule
77
import com.facebook.react.bridge.ReactMethod
88
import com.facebook.react.bridge.ReadableMap
99

10-
class GeofencingModule(reactContext: ReactApplicationContext) :
10+
class RNGeofencingModule(reactContext: ReactApplicationContext) :
1111
ReactContextBaseJavaModule(reactContext) {
1212

1313
private val geofenceManager = GeofenceManager(reactApplicationContext)
@@ -52,6 +52,6 @@ class GeofencingModule(reactContext: ReactApplicationContext) :
5252
}
5353

5454
companion object {
55-
const val NAME = "Geofencing"
55+
const val NAME = "RNGeofencing"
5656
}
5757
}

Diff for: example/Gemfile

+2
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ ruby ">= 2.6.10"
66
# Exclude problematic versions of cocoapods and activesupport that causes build failures.
77
gem 'cocoapods', '>= 1.13', '!= 1.15.0', '!= 1.15.1'
88
gem 'activesupport', '>= 6.1.7.5', '!= 7.1.0'
9+
gem 'xcodeproj', '< 1.26.0'
10+
gem 'concurrent-ruby', '< 1.3.4'

Diff for: example/Gemfile.lock

+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
CFPropertyList (3.0.7)
5+
base64
6+
nkf
7+
rexml
8+
activesupport (7.2.2.1)
9+
base64
10+
benchmark (>= 0.3)
11+
bigdecimal
12+
concurrent-ruby (~> 1.0, >= 1.3.1)
13+
connection_pool (>= 2.2.5)
14+
drb
15+
i18n (>= 1.6, < 2)
16+
logger (>= 1.4.2)
17+
minitest (>= 5.1)
18+
securerandom (>= 0.3)
19+
tzinfo (~> 2.0, >= 2.0.5)
20+
addressable (2.8.7)
21+
public_suffix (>= 2.0.2, < 7.0)
22+
algoliasearch (1.27.5)
23+
httpclient (~> 2.8, >= 2.8.3)
24+
json (>= 1.5.1)
25+
atomos (0.1.3)
26+
base64 (0.2.0)
27+
benchmark (0.4.0)
28+
bigdecimal (3.1.9)
29+
claide (1.1.0)
30+
cocoapods (1.15.2)
31+
addressable (~> 2.8)
32+
claide (>= 1.0.2, < 2.0)
33+
cocoapods-core (= 1.15.2)
34+
cocoapods-deintegrate (>= 1.0.3, < 2.0)
35+
cocoapods-downloader (>= 2.1, < 3.0)
36+
cocoapods-plugins (>= 1.0.0, < 2.0)
37+
cocoapods-search (>= 1.0.0, < 2.0)
38+
cocoapods-trunk (>= 1.6.0, < 2.0)
39+
cocoapods-try (>= 1.1.0, < 2.0)
40+
colored2 (~> 3.1)
41+
escape (~> 0.0.4)
42+
fourflusher (>= 2.3.0, < 3.0)
43+
gh_inspector (~> 1.0)
44+
molinillo (~> 0.8.0)
45+
nap (~> 1.0)
46+
ruby-macho (>= 2.3.0, < 3.0)
47+
xcodeproj (>= 1.23.0, < 2.0)
48+
cocoapods-core (1.15.2)
49+
activesupport (>= 5.0, < 8)
50+
addressable (~> 2.8)
51+
algoliasearch (~> 1.0)
52+
concurrent-ruby (~> 1.1)
53+
fuzzy_match (~> 2.0.4)
54+
nap (~> 1.0)
55+
netrc (~> 0.11)
56+
public_suffix (~> 4.0)
57+
typhoeus (~> 1.0)
58+
cocoapods-deintegrate (1.0.5)
59+
cocoapods-downloader (2.1)
60+
cocoapods-plugins (1.0.0)
61+
nap
62+
cocoapods-search (1.0.1)
63+
cocoapods-trunk (1.6.0)
64+
nap (>= 0.8, < 2.0)
65+
netrc (~> 0.11)
66+
cocoapods-try (1.2.0)
67+
colored2 (3.1.2)
68+
concurrent-ruby (1.3.3)
69+
connection_pool (2.5.0)
70+
drb (2.2.1)
71+
escape (0.0.4)
72+
ethon (0.16.0)
73+
ffi (>= 1.15.0)
74+
ffi (1.17.1)
75+
fourflusher (2.3.1)
76+
fuzzy_match (2.0.4)
77+
gh_inspector (1.1.3)
78+
httpclient (2.8.3)
79+
i18n (1.14.7)
80+
concurrent-ruby (~> 1.0)
81+
json (2.10.1)
82+
logger (1.6.6)
83+
minitest (5.25.4)
84+
molinillo (0.8.0)
85+
nanaimo (0.3.0)
86+
nap (1.1.0)
87+
netrc (0.11.0)
88+
nkf (0.2.0)
89+
public_suffix (4.0.7)
90+
rexml (3.4.0)
91+
ruby-macho (2.5.1)
92+
securerandom (0.4.1)
93+
typhoeus (1.4.1)
94+
ethon (>= 0.9.0)
95+
tzinfo (2.0.6)
96+
concurrent-ruby (~> 1.0)
97+
xcodeproj (1.25.1)
98+
CFPropertyList (>= 2.3.3, < 4.0)
99+
atomos (~> 0.1.3)
100+
claide (>= 1.0.2, < 2.0)
101+
colored2 (~> 3.1)
102+
nanaimo (~> 0.3.0)
103+
rexml (>= 3.3.6, < 4.0)
104+
105+
PLATFORMS
106+
ruby
107+
108+
DEPENDENCIES
109+
activesupport (>= 6.1.7.5, != 7.1.0)
110+
cocoapods (>= 1.13, != 1.15.1, != 1.15.0)
111+
concurrent-ruby (< 1.3.4)
112+
xcodeproj (< 1.26.0)
113+
114+
RUBY VERSION
115+
ruby 3.2.2p53
116+
117+
BUNDLED WITH
118+
2.6.3

Diff for: example/android/app/src/main/java/rnbridge/reactnativegeofencing/example/MainApplication.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import com.facebook.react.ReactPackage
99
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
1010
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
1111
import com.facebook.react.defaults.DefaultReactNativeHost
12+
import com.facebook.react.soloader.OpenSourceMergedSoMapping
1213
import com.facebook.soloader.SoLoader
1314

1415
class MainApplication : Application(), ReactApplication {
@@ -34,7 +35,7 @@ class MainApplication : Application(), ReactApplication {
3435

3536
override fun onCreate() {
3637
super.onCreate()
37-
SoLoader.init(this, false)
38+
SoLoader.init(this, OpenSourceMergedSoMapping)
3839
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
3940
// If you opted-in for the New Architecture, we load the native entry point for this app.
4041
load()

Diff for: example/android/build.gradle

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
buildscript {
22
ext {
3-
buildToolsVersion = "34.0.0"
4-
minSdkVersion = 23
5-
compileSdkVersion = 34
3+
buildToolsVersion = "35.0.0"
4+
minSdkVersion = 24
5+
compileSdkVersion = 35
66
targetSdkVersion = 34
7-
ndkVersion = "26.1.10909125"
8-
kotlinVersion = "1.9.24"
7+
ndkVersion = "27.1.12297006"
8+
kotlinVersion = "2.0.21"
99
}
1010
repositories {
1111
google()

Diff for: example/android/gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
3232
# your application. You should enable this flag either if you want
3333
# to write custom TurboModules/Fabric components OR use libraries that
3434
# are providing them.
35-
newArchEnabled=false
35+
newArchEnabled=true
3636

3737
# Use this property to enable or disable the Hermes JS engine.
3838
# If set to false, you will be using JSC instead.

Diff for: example/android/gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

0 commit comments

Comments
 (0)