Skip to content

Commit 3f2a95b

Browse files
committed
chore(android): remove old architecture code
Since @rnmapbox/maps 10.3.0 only supports React Native's new architecture, this removes all old architecture related code from Android: - Delete android/src/main/old-arch directory with generated specs - Remove isNewArchitectureEnabled() checks from build.gradle - Remove IS_NEW_ARCHITECTURE_ENABLED BuildConfig field - Always apply com.facebook.react plugin (required for new arch) - Simplify ViewTagResolver to always use FABRIC UIManager - Remove old arch event emission fallback in RNMBXLocationModule - Update RNMBXPackage to always use isTurboModule=true for TurboModules - Delete unused EventEmitter.java (was only used for old arch events) - Delete scripts/codegen-old-arch.js and remove from autogenerate.mjs - Update CONTRIBUTING.md to remove old-arch references The new architecture codegen by React Native's Gradle plugin now generates the required specs during build.
1 parent 934b096 commit 3f2a95b

File tree

87 files changed

+13
-3363
lines changed

Some content is hidden

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

87 files changed

+13
-3363
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,8 @@ We use the following code generators, but check yarn generate for more:
6363
```
6464
are generated. So instead of editing the code between the comments you need to edit the `codepart-*` file and run
6565
`yarn generate` again
66-
- `android/src/main/old-arch/` is java code generated by react-native codegen from `src/specs`
6766
68-
Also new architecture `codegen` by `react-native` generates a bunch of code from `src/specs`
67+
React Native's new architecture `codegen` generates code from `src/specs`
6968
7069
### Documentation generation
7170

android/build.gradle

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@ def safeExtGet(prop, fallback) {
1414
}
1515

1616

17-
def isNewArchitectureEnabled() {
18-
// To opt-in for the New Architecture, you can either:
19-
// - Set `newArchEnabled` to true inside the `gradle.properties` file
20-
// - Invoke gradle with `-newArchEnabled=true`
21-
// - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
22-
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
23-
}
2417

2518
def getCoroutinesVersion(kotlinVersion) {
2619
return kotlinVersion >= '1.9' ? '1.8.0' : '1.6.4'
@@ -50,9 +43,7 @@ buildscript {
5043
}
5144
}
5245

53-
if (isNewArchitectureEnabled()) {
54-
apply plugin: 'com.facebook.react'
55-
}
46+
apply plugin: 'com.facebook.react'
5647
apply plugin: 'com.android.library'
5748

5849
if (safeExtGet("RNMapboxMapsImpl", defaultMapboxMapsImpl) == "mapbox") {
@@ -236,15 +227,6 @@ Please upgrade to Mapbox v11.x or use @rnmapbox/maps 10.2.x
236227
throw new GradleException(msg)
237228
}
238229

239-
if (!isNewArchitectureEnabled()) {
240-
def msg = """
241-
❌ ERROR: Old React Native Architecture is no longer supported as of @rnmapbox/maps 10.3.0
242-
Please enable New Architecture (newArchEnabled=true) or use @rnmapbox/maps 10.2.x
243-
"""
244-
logger.error(msg)
245-
throw new GradleException(msg)
246-
}
247-
248230
compileSdkVersion safeExtGet("compileSdkVersion", 28)
249231
buildToolsVersion safeExtGet("buildToolsVersion", '28.0.3')
250232

@@ -253,7 +235,6 @@ Please enable New Architecture (newArchEnabled=true) or use @rnmapbox/maps 10.2.
253235
targetSdkVersion safeExtGet('targetSdkVersion', 26)
254236
versionCode 1
255237
versionName "1.0"
256-
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
257238
}
258239

259240
compileOptions {

android/src/main/java/com/rnmapbox/rnmbx/RNMBXPackage.kt

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ class RNMBXPackage : TurboReactPackage() {
177177
resetViewTagResolver()
178178
return ReactModuleInfoProvider {
179179
val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
180-
val isTurboModule = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
181180
moduleInfos[RNMBXModule.REACT_CLASS] = ReactModuleInfo(
182181
RNMBXModule.REACT_CLASS,
183182
RNMBXModule.REACT_CLASS,
@@ -194,7 +193,7 @@ class RNMBXPackage : TurboReactPackage() {
194193
false, // needsEagerInit
195194
true, // hasConstants
196195
false, // isCxxModule
197-
isTurboModule // isTurboModule
196+
true // isTurboModule
198197
)
199198
moduleInfos[RNMBXOfflineModule.REACT_CLASS] = ReactModuleInfo(
200199
RNMBXOfflineModule.REACT_CLASS,
@@ -248,7 +247,7 @@ class RNMBXPackage : TurboReactPackage() {
248247
false, // needsEagerInit
249248
false, // hasConstants
250249
false, // isCxxModule
251-
isTurboModule // isTurboModule
250+
true // isTurboModule
252251
)
253252
moduleInfos[RNMBXViewportModule.NAME] = ReactModuleInfo(
254253
RNMBXViewportModule.NAME,
@@ -257,7 +256,7 @@ class RNMBXPackage : TurboReactPackage() {
257256
false, // needsEagerInit
258257
false, // hasConstants
259258
false, // isCxxModule
260-
isTurboModule // isTurboModule
259+
true // isTurboModule
261260
)
262261
moduleInfos[RNMBXCameraModule.NAME] = ReactModuleInfo(
263262
RNMBXCameraModule.NAME,
@@ -266,7 +265,7 @@ class RNMBXPackage : TurboReactPackage() {
266265
false, // needsEagerInit
267266
false, // hasConstants
268267
false, // isCxxModule
269-
isTurboModule // isTurboModule
268+
true // isTurboModule
270269
)
271270
moduleInfos[RNMBXShapeSourceModule.NAME] = ReactModuleInfo(
272271
RNMBXShapeSourceModule.NAME,
@@ -275,7 +274,7 @@ class RNMBXPackage : TurboReactPackage() {
275274
false, // needsEagerInit
276275
false, // hasConstants
277276
false, // isCxxModule
278-
isTurboModule // isTurboModule
277+
true // isTurboModule
279278
)
280279
moduleInfos[RNMBXImageModule.NAME] = ReactModuleInfo(
281280
RNMBXImageModule.NAME,
@@ -284,7 +283,7 @@ class RNMBXPackage : TurboReactPackage() {
284283
false, // needsEagerInit
285284
false, // hasConstants
286285
false, // isCxxModule
287-
isTurboModule // isTurboModule
286+
true // isTurboModule
288287
)
289288
moduleInfos[RNMBXPointAnnotationModule.NAME] = ReactModuleInfo(
290289
RNMBXPointAnnotationModule.NAME,
@@ -293,7 +292,7 @@ class RNMBXPackage : TurboReactPackage() {
293292
false, // needsEagerInit
294293
false, // hasConstants
295294
false, // isCxxModule
296-
isTurboModule // isTurboModule
295+
true // isTurboModule
297296
)
298297
moduleInfos[RNMBXMovePointShapeAnimatorModule.NAME] = ReactModuleInfo(
299298
RNMBXMovePointShapeAnimatorModule.NAME,
@@ -302,7 +301,7 @@ class RNMBXPackage : TurboReactPackage() {
302301
false,
303302
false,
304303
false,
305-
isTurboModule
304+
true // isTurboModule
306305
)
307306
moduleInfos[RNMBXChangeLineOffsetsShapeAnimatorModule.NAME] = ReactModuleInfo(
308307
RNMBXChangeLineOffsetsShapeAnimatorModule.NAME,
@@ -311,7 +310,7 @@ class RNMBXPackage : TurboReactPackage() {
311310
false,
312311
false,
313312
false,
314-
isTurboModule
313+
true // isTurboModule
315314
)
316315
moduleInfos
317316
}

android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXShapeSourceModule.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@ import com.facebook.react.bridge.Promise
44
import com.facebook.react.bridge.ReactApplicationContext
55
import com.facebook.react.bridge.ReactMethod
66
import com.facebook.react.module.annotations.ReactModule
7-
import com.facebook.react.uimanager.UIManagerHelper
8-
import com.facebook.react.uimanager.common.UIManagerType
9-
import com.rnmapbox.rnmbx.BuildConfig
107
import com.rnmapbox.rnmbx.NativeRNMBXShapeSourceModuleSpec
11-
import com.rnmapbox.rnmbx.components.mapview.RNMBXMapView
128
import com.rnmapbox.rnmbx.utils.ViewRefTag
139
import com.rnmapbox.rnmbx.utils.ViewTagResolver
1410

android/src/main/java/com/rnmapbox/rnmbx/events/EventEmitter.java

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

android/src/main/java/com/rnmapbox/rnmbx/modules/RNMBXLocationModule.kt

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import com.facebook.react.module.annotations.ReactModule
66
import com.rnmapbox.rnmbx.NativeRNMBXLocationModuleSpec
77
import com.rnmapbox.rnmbx.location.LocationManager.OnUserLocationChange
88
import com.rnmapbox.rnmbx.events.LocationEvent
9-
import com.rnmapbox.rnmbx.events.EventEmitter
109
import com.rnmapbox.rnmbx.location.LocationManager.Companion.getInstance
1110
import java.lang.Exception
1211

@@ -58,14 +57,7 @@ class RNMBXLocationModule(reactContext: ReactApplicationContext) :
5857
mLastLocation = location
5958
if (changed && (location != null) && shouldSendLocationEvent()) {
6059
val locationEvent = LocationEvent(location)
61-
62-
if(mEventEmitterCallback != null){
63-
emitOnLocationUpdate(locationEvent.toJSON())
64-
}else {
65-
// Emmit event for old architecture
66-
val emitter = EventEmitter.getModuleEmitter(reactApplicationContext)
67-
emitter?.emit(LOCATION_UPDATE, locationEvent.payload)
68-
}
60+
emitOnLocationUpdate(locationEvent.toJSON())
6961
}
7062
}
7163
}

android/src/main/java/com/rnmapbox/rnmbx/utils/ViewTagResolver.kt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import com.facebook.react.bridge.UIManager
77
import com.facebook.react.uimanager.IllegalViewOperationException
88
import com.facebook.react.uimanager.UIManagerHelper
99
import com.facebook.react.uimanager.common.UIManagerType
10-
import com.rnmapbox.rnmbx.BuildConfig
1110

1211
data class ViewTagWaiter<V>(
1312
val fn: (V) -> Unit,
@@ -59,12 +58,7 @@ open class ViewTagResolver(val context: ReactApplicationContext) {
5958
}
6059

6160
private val manager : UIManager
62-
get() =
63-
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
64-
UIManagerHelper.getUIManager(context, UIManagerType.FABRIC)!!
65-
} else {
66-
UIManagerHelper.getUIManager(context, UIManagerType.DEFAULT)!!
67-
}
61+
get() = UIManagerHelper.getUIManager(context, UIManagerType.FABRIC)!!
6862

6963
// calls on UiQueueThread with resolved view
7064
fun <V>withViewResolved(viewTag: Int, reject: Promise? = null, fn: (V) -> Unit) {

android/src/main/old-arch/com/facebook/react/viewmanagers/RNMBXAtmosphereManagerDelegate.java

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

android/src/main/old-arch/com/facebook/react/viewmanagers/RNMBXAtmosphereManagerInterface.java

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

android/src/main/old-arch/com/facebook/react/viewmanagers/RNMBXBackgroundLayerManagerDelegate.java

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

0 commit comments

Comments
 (0)