@mapsindoors/react-native-maps-indoors-mapbox 2.6.2 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -9
- package/android/build.gradle +17 -70
- package/android/src/main/java/com/mapsindoorsrn/MapsIndoorsPackage.java +69 -18
- package/android/src/main/java/com/mapsindoorsrn/MapsIndoorsViewManager.java +135 -3
- package/android/src/main/java/com/mapsindoorsrn/core/DirectionsRendererModule.java +5 -1
- package/android/src/main/java/com/mapsindoorsrn/core/DirectionsServiceModule.java +5 -2
- package/android/src/main/java/com/mapsindoorsrn/core/MPDisplayRuleModule.java +5 -1
- package/android/src/main/java/com/mapsindoorsrn/core/MapControlModule.java +5 -1
- package/android/src/main/java/com/mapsindoorsrn/core/MapsIndoorsModule.java +4 -1
- package/android/src/main/java/com/mapsindoorsrn/core/UtilsModule.java +4 -1
- package/app.plugin.js +1 -1
- package/ios/core/DirectionsRendererBridge.m +5 -0
- package/ios/core/DirectionsRendererModule.swift +92 -72
- package/ios/core/DirectionsServiceBridge.m +1 -1
- package/ios/core/DirectionsServiceModule.swift +44 -51
- package/ios/core/IconStopUrl.swift +1 -1
- package/ios/core/MPDisplayRuleModule.swift +208 -210
- package/ios/core/MapControlModule.swift +284 -216
- package/ios/core/MapsIndoorsData.swift +48 -49
- package/ios/core/MapsIndoorsModule.swift +46 -52
- package/ios/core/RCMapView.swift +1 -1
- package/ios/core/ReactPositionProvider.swift +1 -2
- package/ios/core/RouteIcon.swift +6 -6
- package/ios/core/UtilsModule.swift +37 -42
- package/ios/core/helpers.swift +16 -11
- package/package.json +12 -8
- package/react-native-maps-indoors-mapbox.podspec +13 -4
- package/specs/MapsIndoorsViewNativeComponent.ts +10 -0
- package/specs/NativeDirectionsRendererModule.ts +23 -0
- package/specs/NativeDirectionsServiceModule.ts +22 -0
- package/specs/NativeMPDisplayRuleModule.ts +155 -0
- package/specs/NativeMapControlModule.ts +62 -0
- package/specs/NativeMapsIndoorsModule.ts +43 -0
- package/specs/NativeUtilsModule.ts +21 -0
- package/src/core/MPDirectionsRenderer.ts +15 -0
- package/src/core/MPDirectionsService.ts +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,34 @@
|
|
|
2
2
|
|
|
3
3
|
## Documentation
|
|
4
4
|
|
|
5
|
-
Visit [our reference document site](https://app.mapsindoors.com/mapsindoors/reference/react-native/mapbox/2.
|
|
5
|
+
Visit [our reference document site](https://app.mapsindoors.com/mapsindoors/reference/react-native/mapbox/2.8.0/index.html) to get an overview of what the MapsIndoors SDK offers.
|
|
6
|
+
|
|
7
|
+
## Changelog
|
|
8
|
+
|
|
9
|
+
### [2.8.0] - 2026-08-17
|
|
10
|
+
|
|
11
|
+
#### Changed
|
|
12
|
+
|
|
13
|
+
- **Breaking:** raised the minimum iOS deployment target to 16.0 (from 15.6), as required by the
|
|
14
|
+
MapsIndoors iOS SDK. Update your Podfile, and `expo-build-properties`' `deploymentTarget` if you
|
|
15
|
+
use Expo - see [iOS](#ios)
|
|
16
|
+
- **Breaking:** raised the minimum supported React Native version to 0.75.0
|
|
17
|
+
- Updated MapsIndoors Android SDK to 4.18.6
|
|
18
|
+
- Updated MapsIndoors iOS SDK to 4.19.1
|
|
19
|
+
|
|
20
|
+
#### Fixed
|
|
21
|
+
|
|
22
|
+
- The map turning black after navigating away from and back to the map screen when using
|
|
23
|
+
`react-native-screens`' native stack
|
|
24
|
+
- The map continuing to render in the background while the app was backgrounded, which wasted
|
|
25
|
+
battery
|
|
26
|
+
|
|
27
|
+
### 2.7.0
|
|
28
|
+
|
|
29
|
+
- Updated MapsIndoors Android SDK to 4.18.3
|
|
30
|
+
- Updated MapsIndoors iOS SDK to 4.17.2
|
|
31
|
+
- Added React Native New Architecture support (TurboModules / Fabric interop layer)
|
|
32
|
+
- Added `setPolylineColors` to `MPDirectionsRenderer` to allow customizing the foreground and background color of the displayed route
|
|
6
33
|
|
|
7
34
|
## Getting started
|
|
8
35
|
|
|
@@ -10,11 +37,12 @@ Visit [our reference document site](https://app.mapsindoors.com/mapsindoors/refe
|
|
|
10
37
|
|
|
11
38
|
### iOS
|
|
12
39
|
|
|
13
|
-
The MapsIndoors SDK requires iOS
|
|
14
|
-
Disable flipper and add
|
|
40
|
+
The MapsIndoors SDK requires iOS 16.0, so make sure that your podfile is configured for iOS 16.0.
|
|
41
|
+
Disable flipper and add `use_frameworks!` as well as adding config.build_settings to post install
|
|
42
|
+
script.
|
|
15
43
|
|
|
16
44
|
```pod
|
|
17
|
-
platform :ios, '
|
|
45
|
+
platform :ios, '16.0'
|
|
18
46
|
|
|
19
47
|
flipper_config = FlipperConfiguration.disabled
|
|
20
48
|
|
|
@@ -25,7 +53,7 @@ target 'MyApp' do
|
|
|
25
53
|
...
|
|
26
54
|
installer.pods_project.targets.each do |target|
|
|
27
55
|
target.build_configurations.each do |config|
|
|
28
|
-
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '
|
|
56
|
+
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '16.0'
|
|
29
57
|
end
|
|
30
58
|
end
|
|
31
59
|
end
|
|
@@ -95,8 +123,9 @@ allprojects {
|
|
|
95
123
|
|
|
96
124
|
This library implements native modules and can't be used with ExpoGO, developments build is required [Delopment Builds](https://docs.expo.dev/develop/development-builds/introduction/)
|
|
97
125
|
|
|
98
|
-
To build and run correctly, the native ios linkage required to
|
|
99
|
-
Project configuration can be done with the expo module
|
|
126
|
+
To build and run correctly, the native ios linkage is required to be set as dynamic
|
|
127
|
+
(`useFrameworks: "dynamic"`). Project configuration can be done with the expo module
|
|
128
|
+
expo-build-properties.
|
|
100
129
|
|
|
101
130
|
with npx :
|
|
102
131
|
`$ npx expo install expo-build-properties`
|
|
@@ -121,7 +150,8 @@ To enable it, you need to add the configuration in your expo configuration.
|
|
|
121
150
|
"expo-build-properties",
|
|
122
151
|
{
|
|
123
152
|
"ios": {
|
|
124
|
-
"deploymentTarget": "
|
|
153
|
+
"deploymentTarget": "16.0",
|
|
154
|
+
"useFrameworks": "dynamic"
|
|
125
155
|
}
|
|
126
156
|
}
|
|
127
157
|
],
|
|
@@ -130,7 +160,7 @@ To enable it, you need to add the configuration in your expo configuration.
|
|
|
130
160
|
{
|
|
131
161
|
"publicToken": "PUBLIC_TOKEN", // your map public token
|
|
132
162
|
"downloadToken": "DOWNLOAD_TOKEN", // your download token
|
|
133
|
-
"staticPods": true // OPTIONAL, add if your project
|
|
163
|
+
"staticPods": true // OPTIONAL, add if your project uses static linkage for pods (ex: "useFrameworks": "static" with expo-build-properties)
|
|
134
164
|
}
|
|
135
165
|
]
|
|
136
166
|
]
|
|
@@ -244,3 +274,5 @@ const changeTypePolygonColor = async (type: string, color: string) => {
|
|
|
244
274
|
typeDisplayRule?.setPolygonFillColor(color);
|
|
245
275
|
}
|
|
246
276
|
```
|
|
277
|
+
|
|
278
|
+
[2.8.0]: https://github.com/MapsPeople/react-native-mapsindoors-mapbox/compare/2.7.0...2.8.0
|
package/android/build.gradle
CHANGED
|
@@ -12,15 +12,23 @@
|
|
|
12
12
|
|
|
13
13
|
// These defaults should reflect the SDK versions used by
|
|
14
14
|
// the minimum React Native version supported.
|
|
15
|
-
def DEFAULT_COMPILE_SDK_VERSION =
|
|
16
|
-
def DEFAULT_BUILD_TOOLS_VERSION = '
|
|
15
|
+
def DEFAULT_COMPILE_SDK_VERSION = 34
|
|
16
|
+
def DEFAULT_BUILD_TOOLS_VERSION = '34.0.0'
|
|
17
17
|
def DEFAULT_MIN_SDK_VERSION = 21
|
|
18
|
-
def DEFAULT_TARGET_SDK_VERSION =
|
|
18
|
+
def DEFAULT_TARGET_SDK_VERSION = 34
|
|
19
19
|
|
|
20
20
|
def safeExtGet(prop, fallback) {
|
|
21
21
|
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
def isNewArchitectureEnabled() {
|
|
25
|
+
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (isNewArchitectureEnabled()) {
|
|
29
|
+
apply plugin: "com.facebook.react"
|
|
30
|
+
}
|
|
31
|
+
|
|
24
32
|
apply plugin: 'com.android.library'
|
|
25
33
|
|
|
26
34
|
buildscript {
|
|
@@ -48,11 +56,16 @@ buildscript {
|
|
|
48
56
|
|
|
49
57
|
android {
|
|
50
58
|
compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
|
|
59
|
+
namespace "com.mapsindoorsrn"
|
|
51
60
|
defaultConfig {
|
|
52
61
|
minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
|
|
53
62
|
targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
|
|
54
63
|
versionCode 1
|
|
55
64
|
versionName "1.0"
|
|
65
|
+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
66
|
+
}
|
|
67
|
+
buildFeatures {
|
|
68
|
+
buildConfig true
|
|
56
69
|
}
|
|
57
70
|
lintOptions {
|
|
58
71
|
abortOnError false
|
|
@@ -93,75 +106,9 @@ dependencies {
|
|
|
93
106
|
}
|
|
94
107
|
|
|
95
108
|
implementation 'com.mapbox.maps:android-ndk27:11.16.1'
|
|
96
|
-
implementation 'com.mapspeople.mapsindoors:mapbox-ndk27:4.
|
|
109
|
+
implementation 'com.mapspeople.mapsindoors:mapbox-ndk27:4.18.6'
|
|
97
110
|
implementation 'com.facebook.react:react-native:+' // From node_modules
|
|
98
111
|
implementation 'androidx.core:core-ktx:1.3.2'
|
|
99
112
|
implementation 'com.github.bumptech.glide:glide:4.16.0'
|
|
100
113
|
}
|
|
101
114
|
|
|
102
|
-
def configureReactNativePom(def pom) {
|
|
103
|
-
def packageJson = new groovy.json.JsonSlurper().parseText(file('../package.json').text)
|
|
104
|
-
|
|
105
|
-
pom.project {
|
|
106
|
-
name packageJson.title
|
|
107
|
-
artifactId packageJson.name
|
|
108
|
-
version = packageJson.version
|
|
109
|
-
group = "com.mapsindoorsrn"
|
|
110
|
-
description packageJson.description
|
|
111
|
-
url packageJson.repository.baseUrl
|
|
112
|
-
|
|
113
|
-
licenses {
|
|
114
|
-
license {
|
|
115
|
-
name packageJson.license
|
|
116
|
-
url packageJson.repository.baseUrl + '/blob/master/' + packageJson.licenseFilename
|
|
117
|
-
distribution 'repo'
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
developers {
|
|
122
|
-
developer {
|
|
123
|
-
id packageJson.author.username
|
|
124
|
-
name packageJson.author.name
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
afterEvaluate { project ->
|
|
131
|
-
// some Gradle build hooks ref:
|
|
132
|
-
// https://www.oreilly.com/library/view/gradle-beyond-the/9781449373801/ch03.html
|
|
133
|
-
task androidJavadoc(type: Javadoc) {
|
|
134
|
-
source = android.sourceSets.main.java.srcDirs
|
|
135
|
-
classpath += files(android.bootClasspath)
|
|
136
|
-
include '**/*.java'
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) {
|
|
140
|
-
archiveClassifier = 'javadoc'
|
|
141
|
-
from androidJavadoc.destinationDir
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
task androidSourcesJar(type: Jar) {
|
|
145
|
-
archiveClassifier = 'sources'
|
|
146
|
-
from android.sourceSets.main.java.srcDirs
|
|
147
|
-
include '**/*.java'
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
android.libraryVariants.all { variant ->
|
|
151
|
-
def name = variant.name.capitalize()
|
|
152
|
-
def javaCompileTask = variant.javaCompileProvider.get()
|
|
153
|
-
|
|
154
|
-
task "jar${name}"(type: Jar, dependsOn: javaCompileTask) {
|
|
155
|
-
from javaCompileTask.destinationDir
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
artifacts {
|
|
160
|
-
archives androidSourcesJar
|
|
161
|
-
archives androidJavadocJar
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
task installArchives(type: Upload) {
|
|
165
|
-
configuration = configurations.archives
|
|
166
|
-
}
|
|
167
|
-
}
|
|
@@ -3,13 +3,11 @@ package com.mapsindoorsrn;
|
|
|
3
3
|
import androidx.annotation.NonNull;
|
|
4
4
|
import androidx.annotation.Nullable;
|
|
5
5
|
|
|
6
|
-
import
|
|
7
|
-
import java.util.Collections;
|
|
8
|
-
import java.util.List;
|
|
9
|
-
|
|
10
|
-
import com.facebook.react.ReactPackage;
|
|
6
|
+
import com.facebook.react.TurboReactPackage;
|
|
11
7
|
import com.facebook.react.bridge.NativeModule;
|
|
12
8
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
9
|
+
import com.facebook.react.module.model.ReactModuleInfo;
|
|
10
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider;
|
|
13
11
|
import com.facebook.react.uimanager.ViewManager;
|
|
14
12
|
import com.mapsindoors.core.OnResultReadyListener;
|
|
15
13
|
import com.mapsindoors.core.errors.MIError;
|
|
@@ -20,34 +18,87 @@ import com.mapsindoorsrn.core.MapControlModule;
|
|
|
20
18
|
import com.mapsindoorsrn.core.MapsIndoorsModule;
|
|
21
19
|
import com.mapsindoorsrn.core.UtilsModule;
|
|
22
20
|
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
import java.util.Collections;
|
|
22
|
+
import java.util.HashMap;
|
|
23
|
+
import java.util.List;
|
|
24
|
+
import java.util.Map;
|
|
25
|
+
|
|
26
|
+
public class MapsIndoorsPackage extends TurboReactPackage implements OnResultReadyListener {
|
|
27
|
+
private volatile MapControlModule mapControlModule;
|
|
25
28
|
private MapsIndoorsViewManager viewManager;
|
|
26
29
|
private ReactApplicationContext mContext;
|
|
27
30
|
|
|
28
|
-
|
|
31
|
+
private MapControlModule getOrCreateMapControlModule(ReactApplicationContext context) {
|
|
32
|
+
if (mapControlModule == null) {
|
|
33
|
+
synchronized (this) {
|
|
34
|
+
if (mapControlModule == null) {
|
|
35
|
+
mapControlModule = new MapControlModule(context);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return mapControlModule;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@Nullable
|
|
29
43
|
@Override
|
|
30
|
-
public
|
|
44
|
+
public NativeModule getModule(@NonNull String name, @NonNull ReactApplicationContext reactContext) {
|
|
31
45
|
mContext = reactContext;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
new MapsIndoorsModule(reactContext)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
new
|
|
39
|
-
|
|
46
|
+
switch (name) {
|
|
47
|
+
case MapsIndoorsModule.NAME:
|
|
48
|
+
return new MapsIndoorsModule(reactContext);
|
|
49
|
+
case MapControlModule.NAME:
|
|
50
|
+
return getOrCreateMapControlModule(reactContext);
|
|
51
|
+
case DirectionsServiceModule.NAME:
|
|
52
|
+
return new DirectionsServiceModule(reactContext);
|
|
53
|
+
case DirectionsRendererModule.NAME:
|
|
54
|
+
return new DirectionsRendererModule(reactContext, getOrCreateMapControlModule(reactContext));
|
|
55
|
+
case MPDisplayRuleModule.NAME:
|
|
56
|
+
return new MPDisplayRuleModule(reactContext);
|
|
57
|
+
case UtilsModule.NAME:
|
|
58
|
+
return new UtilsModule(reactContext);
|
|
59
|
+
default:
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@Override
|
|
65
|
+
public ReactModuleInfoProvider getReactModuleInfoProvider() {
|
|
66
|
+
return () -> {
|
|
67
|
+
Map<String, ReactModuleInfo> map = new HashMap<>();
|
|
68
|
+
map.put(MapsIndoorsModule.NAME, new ReactModuleInfo(
|
|
69
|
+
MapsIndoorsModule.NAME, MapsIndoorsModule.class.getName(),
|
|
70
|
+
false, false, false, false));
|
|
71
|
+
map.put(MapControlModule.NAME, new ReactModuleInfo(
|
|
72
|
+
MapControlModule.NAME, MapControlModule.class.getName(),
|
|
73
|
+
false, false, false, false));
|
|
74
|
+
map.put(DirectionsServiceModule.NAME, new ReactModuleInfo(
|
|
75
|
+
DirectionsServiceModule.NAME, DirectionsServiceModule.class.getName(),
|
|
76
|
+
false, false, false, false));
|
|
77
|
+
map.put(DirectionsRendererModule.NAME, new ReactModuleInfo(
|
|
78
|
+
DirectionsRendererModule.NAME, DirectionsRendererModule.class.getName(),
|
|
79
|
+
false, false, false, false));
|
|
80
|
+
map.put(MPDisplayRuleModule.NAME, new ReactModuleInfo(
|
|
81
|
+
MPDisplayRuleModule.NAME, MPDisplayRuleModule.class.getName(),
|
|
82
|
+
false, false, false, false));
|
|
83
|
+
map.put(UtilsModule.NAME, new ReactModuleInfo(
|
|
84
|
+
UtilsModule.NAME, UtilsModule.class.getName(),
|
|
85
|
+
false, false, false, false));
|
|
86
|
+
return map;
|
|
87
|
+
};
|
|
40
88
|
}
|
|
41
89
|
|
|
42
90
|
@NonNull
|
|
43
91
|
@Override
|
|
44
92
|
public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
|
|
93
|
+
mContext = reactContext;
|
|
45
94
|
viewManager = new MapsIndoorsViewManager(reactContext, this);
|
|
46
95
|
return Collections.singletonList(viewManager);
|
|
47
96
|
}
|
|
48
97
|
|
|
49
98
|
@Override
|
|
50
99
|
public void onResultReady(@Nullable MIError miError) {
|
|
51
|
-
mapControlModule
|
|
100
|
+
if (mapControlModule != null && viewManager != null) {
|
|
101
|
+
mapControlModule.setView(new MapboxMapView(viewManager.getView(), mContext));
|
|
102
|
+
}
|
|
52
103
|
}
|
|
53
104
|
}
|
|
@@ -7,9 +7,15 @@ import android.widget.FrameLayout;
|
|
|
7
7
|
|
|
8
8
|
import androidx.annotation.NonNull;
|
|
9
9
|
import androidx.annotation.Nullable;
|
|
10
|
+
import androidx.lifecycle.Lifecycle;
|
|
11
|
+
import androidx.lifecycle.LifecycleOwner;
|
|
12
|
+
import androidx.lifecycle.LifecycleRegistry;
|
|
13
|
+
import androidx.lifecycle.ViewTreeLifecycleOwner;
|
|
10
14
|
|
|
15
|
+
import com.facebook.react.bridge.LifecycleEventListener;
|
|
11
16
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
12
17
|
import com.facebook.react.bridge.ReadableArray;
|
|
18
|
+
import com.facebook.react.common.LifecycleState;
|
|
13
19
|
import com.facebook.react.common.MapBuilder;
|
|
14
20
|
import com.facebook.react.uimanager.ThemedReactContext;
|
|
15
21
|
import com.facebook.react.uimanager.ViewGroupManager;
|
|
@@ -26,6 +32,7 @@ import com.mapbox.maps.plugin.compass.CompassUtils;
|
|
|
26
32
|
import com.mapsindoors.core.OnResultReadyListener;
|
|
27
33
|
import com.mapsindoorsrn.core.models.MPCameraPosition;
|
|
28
34
|
|
|
35
|
+
import java.util.HashMap;
|
|
29
36
|
import java.util.Map;
|
|
30
37
|
|
|
31
38
|
public class MapsIndoorsViewManager extends ViewGroupManager<MapView> {
|
|
@@ -38,6 +45,13 @@ public class MapsIndoorsViewManager extends ViewGroupManager<MapView> {
|
|
|
38
45
|
|
|
39
46
|
private MapView view;
|
|
40
47
|
|
|
48
|
+
// A ViewManager is shared across every instance of its view type, so the per-view lifecycle owners are
|
|
49
|
+
// tracked here keyed by MapView rather than as a single field. Cleanup is manual: entries are removed in
|
|
50
|
+
// onDropViewInstance (which React Native calls when the view is unmounted). A plain HashMap, not a
|
|
51
|
+
// WeakHashMap: Mapbox installs its lifecycle observer against the owner (the value), and that observer
|
|
52
|
+
// holds the MapView, so a weak key would be kept reachable by its own value and never clear.
|
|
53
|
+
private final Map<MapView, MapViewLifecycleOwner> lifecycleOwners = new HashMap<>();
|
|
54
|
+
|
|
41
55
|
ReactApplicationContext mReactContext;
|
|
42
56
|
OnResultReadyListener mOnMapReadyCallback;
|
|
43
57
|
|
|
@@ -45,6 +59,33 @@ public class MapsIndoorsViewManager extends ViewGroupManager<MapView> {
|
|
|
45
59
|
mReactContext = reactContext;
|
|
46
60
|
mOnMapReadyCallback = onMapReadyCallback;
|
|
47
61
|
gson = new Gson();
|
|
62
|
+
|
|
63
|
+
// SPEX-2030: also gate the map lifecycle on the host (Activity) foreground state. The view stays
|
|
64
|
+
// attached to the window when the app is merely backgrounded (home button / app switch), so the
|
|
65
|
+
// attach listener alone would leave the renderer RESUMED and burning GL/battery in the background.
|
|
66
|
+
// React Native's host lifecycle (onHostResume/onHostPause) gives us the Activity foreground signal.
|
|
67
|
+
mReactContext.addLifecycleEventListener(new LifecycleEventListener() {
|
|
68
|
+
@Override
|
|
69
|
+
public void onHostResume() {
|
|
70
|
+
setHostResumedOnAll(true);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@Override
|
|
74
|
+
public void onHostPause() {
|
|
75
|
+
setHostResumedOnAll(false);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@Override
|
|
79
|
+
public void onHostDestroy() {
|
|
80
|
+
setHostResumedOnAll(false);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
private void setHostResumedOnAll(boolean hostResumed) {
|
|
86
|
+
for (MapViewLifecycleOwner owner : lifecycleOwners.values()) {
|
|
87
|
+
owner.setHostResumed(hostResumed);
|
|
88
|
+
}
|
|
48
89
|
}
|
|
49
90
|
|
|
50
91
|
@NonNull
|
|
@@ -56,11 +97,102 @@ public class MapsIndoorsViewManager extends ViewGroupManager<MapView> {
|
|
|
56
97
|
@NonNull
|
|
57
98
|
@Override
|
|
58
99
|
protected MapView createViewInstance(@NonNull ThemedReactContext reactContext) {
|
|
100
|
+
// textureView = true (5th positional arg): a TextureView lives in the normal view hierarchy
|
|
101
|
+
// and is restored across detach/reattach, unlike the default SurfaceView whose surface is
|
|
102
|
+
// torn down when react-native-screens detaches the screen on navigation.
|
|
59
103
|
MapInitOptions options = new MapInitOptions(reactContext, MapInitOptions.Companion.getDefaultMapOptions(reactContext).toBuilder()
|
|
60
104
|
.glyphsRasterizationOptions(new GlyphsRasterizationOptions.Builder().rasterizationMode(GlyphsRasterizationMode.ALL_GLYPHS_RASTERIZED_LOCALLY).build()).build(),
|
|
61
|
-
MapInitOptions.Companion.getDefaultPluginList(), new CameraOptions.Builder().pitch(0.0).build()
|
|
62
|
-
|
|
63
|
-
|
|
105
|
+
MapInitOptions.Companion.getDefaultPluginList(), new CameraOptions.Builder().pitch(0.0).build(),
|
|
106
|
+
true);
|
|
107
|
+
final MapView mapView = new MapView(reactContext, options);
|
|
108
|
+
|
|
109
|
+
// Give the MapView an SDK-owned lifecycle and set it as the view's own ViewTreeLifecycleOwner.
|
|
110
|
+
// ViewTreeLifecycleOwner.get() checks the view itself before walking up the tree, so this wins
|
|
111
|
+
// over the per-screen LifecycleOwner that react-native-screens installs on the ancestor. That
|
|
112
|
+
// stops Mapbox v11 from binding its renderer to the screen lifecycle (which goes ON_STOP on
|
|
113
|
+
// navigate-away and is not reliably brought back to RESUMED on return -> black map).
|
|
114
|
+
// The owner is RESUMED only when the view is attached AND the host Activity is in the foreground;
|
|
115
|
+
// detaching (navigation) or backgrounding the app drives it to CREATED, which stops the renderer
|
|
116
|
+
// and releases the surface.
|
|
117
|
+
final MapViewLifecycleOwner lifecycleOwner = new MapViewLifecycleOwner();
|
|
118
|
+
lifecycleOwner.setHostResumed(mReactContext.getLifecycleState() == LifecycleState.RESUMED);
|
|
119
|
+
ViewTreeLifecycleOwner.set(mapView, lifecycleOwner);
|
|
120
|
+
lifecycleOwners.put(mapView, lifecycleOwner);
|
|
121
|
+
|
|
122
|
+
mapView.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
|
|
123
|
+
@Override
|
|
124
|
+
public void onViewAttachedToWindow(@NonNull View v) {
|
|
125
|
+
lifecycleOwner.setAttached(true); // -> RESUMED if host is foreground (restores renderer/surface)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
@Override
|
|
129
|
+
public void onViewDetachedFromWindow(@NonNull View v) {
|
|
130
|
+
lifecycleOwner.setAttached(false); // -> CREATED (stop rendering while off-screen)
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
view = mapView;
|
|
135
|
+
return mapView;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
@Override
|
|
139
|
+
public void onDropViewInstance(@NonNull MapView view) {
|
|
140
|
+
super.onDropViewInstance(view);
|
|
141
|
+
MapViewLifecycleOwner lifecycleOwner = lifecycleOwners.remove(view);
|
|
142
|
+
if (lifecycleOwner != null) {
|
|
143
|
+
// Driving the lifecycle to DESTROYED lets the MapView's lifecycle observer tear it down on
|
|
144
|
+
// ON_DESTROY in v11; this releases the renderer/surface and avoids leaking the MapView.
|
|
145
|
+
lifecycleOwner.destroy();
|
|
146
|
+
}
|
|
147
|
+
if (this.view == view) {
|
|
148
|
+
this.view = null;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* A self-contained {@link LifecycleOwner} for a single MapView, so the map's renderer follows the
|
|
154
|
+
* view's own attach + host-foreground state rather than the per-screen LifecycleOwner that
|
|
155
|
+
* react-native-screens installs. RESUMED only when the view is attached AND the host Activity is in
|
|
156
|
+
* the foreground; otherwise CREATED (renderer stopped, surface released). This both fixes the
|
|
157
|
+
* navigate-away/back black map and stops the renderer when the app is backgrounded.
|
|
158
|
+
*/
|
|
159
|
+
static class MapViewLifecycleOwner implements LifecycleOwner {
|
|
160
|
+
private final LifecycleRegistry registry = new LifecycleRegistry(this);
|
|
161
|
+
private boolean attached = false;
|
|
162
|
+
private boolean hostResumed = false;
|
|
163
|
+
private boolean destroyed = false;
|
|
164
|
+
|
|
165
|
+
MapViewLifecycleOwner() {
|
|
166
|
+
registry.setCurrentState(Lifecycle.State.INITIALIZED);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
void setAttached(boolean attached) {
|
|
170
|
+
this.attached = attached;
|
|
171
|
+
sync();
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
void setHostResumed(boolean hostResumed) {
|
|
175
|
+
this.hostResumed = hostResumed;
|
|
176
|
+
sync();
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
void destroy() {
|
|
180
|
+
destroyed = true;
|
|
181
|
+
registry.setCurrentState(Lifecycle.State.DESTROYED);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
private void sync() {
|
|
185
|
+
if (destroyed) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
registry.setCurrentState((attached && hostResumed) ? Lifecycle.State.RESUMED : Lifecycle.State.CREATED);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
@NonNull
|
|
192
|
+
@Override
|
|
193
|
+
public Lifecycle getLifecycle() {
|
|
194
|
+
return registry;
|
|
195
|
+
}
|
|
64
196
|
}
|
|
65
197
|
|
|
66
198
|
@Nullable
|
|
@@ -30,6 +30,7 @@ import com.mapsindoors.core.errors.MIError;
|
|
|
30
30
|
import com.mapsindoors.core.errors.MIErrorEnum;
|
|
31
31
|
import com.mapsindoors.core.errors.MapsIndoorsException;
|
|
32
32
|
import com.mapsindoorsrn.core.models.BitmapStopIconConfig;
|
|
33
|
+
import com.facebook.react.module.annotations.ReactModule;
|
|
33
34
|
import com.mapsindoorsrn.core.models.MPError;
|
|
34
35
|
import com.mapsindoorsrn.core.models.RouteStopIconConfigModel;
|
|
35
36
|
|
|
@@ -41,7 +42,10 @@ import java.util.regex.Matcher;
|
|
|
41
42
|
import java.util.regex.Pattern;
|
|
42
43
|
|
|
43
44
|
|
|
45
|
+
@ReactModule(name = DirectionsRendererModule.NAME)
|
|
44
46
|
public class DirectionsRendererModule extends ReactContextBaseJavaModule implements OnMapControlReadyListener {
|
|
47
|
+
public static final String NAME = "DirectionsRenderer";
|
|
48
|
+
|
|
45
49
|
private MapControl mMapControl;
|
|
46
50
|
private MPDirectionsRenderer mRenderer;
|
|
47
51
|
private final ReactApplicationContext mCtx;
|
|
@@ -57,7 +61,7 @@ public class DirectionsRendererModule extends ReactContextBaseJavaModule impleme
|
|
|
57
61
|
@NonNull
|
|
58
62
|
@Override
|
|
59
63
|
public String getName() {
|
|
60
|
-
return
|
|
64
|
+
return NAME;
|
|
61
65
|
}
|
|
62
66
|
|
|
63
67
|
private void rejectPromise(Promise promise) {
|
|
@@ -9,6 +9,7 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
|
9
9
|
import com.facebook.react.bridge.ReactMethod;
|
|
10
10
|
import com.facebook.react.bridge.WritableMap;
|
|
11
11
|
import com.facebook.react.bridge.ReadableArray;
|
|
12
|
+
import com.facebook.react.module.annotations.ReactModule;
|
|
12
13
|
import com.google.gson.Gson;
|
|
13
14
|
import com.mapsindoors.core.MPDirectionsService;
|
|
14
15
|
import com.mapsindoors.core.MPPoint;
|
|
@@ -20,7 +21,9 @@ import java.util.HashMap;
|
|
|
20
21
|
import java.util.List;
|
|
21
22
|
import java.util.UUID;
|
|
22
23
|
|
|
24
|
+
@ReactModule(name = DirectionsServiceModule.NAME)
|
|
23
25
|
public class DirectionsServiceModule extends ReactContextBaseJavaModule {
|
|
26
|
+
public static final String NAME = "DirectionsService";
|
|
24
27
|
|
|
25
28
|
private HashMap<String, MPDirectionsService> serviceMap = new HashMap<>();
|
|
26
29
|
private static final String NO_DS = "This DirectionsService is not available";
|
|
@@ -31,7 +34,7 @@ public class DirectionsServiceModule extends ReactContextBaseJavaModule {
|
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
@ReactMethod
|
|
34
|
-
public void
|
|
37
|
+
public void createService(final Promise promise) {
|
|
35
38
|
MPDirectionsService service = new MPDirectionsService();
|
|
36
39
|
String uuid = UUID.randomUUID().toString();
|
|
37
40
|
serviceMap.put(uuid, service);
|
|
@@ -161,6 +164,6 @@ public class DirectionsServiceModule extends ReactContextBaseJavaModule {
|
|
|
161
164
|
@NonNull
|
|
162
165
|
@Override
|
|
163
166
|
public String getName() {
|
|
164
|
-
return
|
|
167
|
+
return NAME;
|
|
165
168
|
}
|
|
166
169
|
}
|
|
@@ -6,6 +6,7 @@ import com.facebook.react.bridge.Promise;
|
|
|
6
6
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
7
7
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
8
8
|
import com.facebook.react.bridge.ReactMethod;
|
|
9
|
+
import com.facebook.react.module.annotations.ReactModule;
|
|
9
10
|
import com.google.gson.Gson;
|
|
10
11
|
import com.mapsindoors.core.MPBadgePosition;
|
|
11
12
|
import com.mapsindoors.core.MPDisplayRule;
|
|
@@ -20,7 +21,10 @@ import com.mapsindoors.core.errors.MIError;
|
|
|
20
21
|
import com.mapsindoors.core.errors.MIErrorEnum;
|
|
21
22
|
import com.mapsindoorsrn.core.models.MPError;
|
|
22
23
|
|
|
24
|
+
@ReactModule(name = MPDisplayRuleModule.NAME)
|
|
23
25
|
public class MPDisplayRuleModule extends ReactContextBaseJavaModule {
|
|
26
|
+
public static final String NAME = "DisplayRule";
|
|
27
|
+
|
|
24
28
|
private final Gson gson = new Gson();
|
|
25
29
|
|
|
26
30
|
public MPDisplayRuleModule(@NonNull ReactApplicationContext reactContext) {
|
|
@@ -30,7 +34,7 @@ public class MPDisplayRuleModule extends ReactContextBaseJavaModule {
|
|
|
30
34
|
@NonNull
|
|
31
35
|
@Override
|
|
32
36
|
public String getName() {
|
|
33
|
-
return
|
|
37
|
+
return NAME;
|
|
34
38
|
}
|
|
35
39
|
|
|
36
40
|
private void reject(Promise promise, String id) {
|
|
@@ -42,6 +42,7 @@ import com.mapsindoors.core.models.MPMapStyle;
|
|
|
42
42
|
import com.mapsindoorsrn.core.models.Filter;
|
|
43
43
|
import com.mapsindoorsrn.core.models.Location;
|
|
44
44
|
import com.mapsindoorsrn.core.models.MPCameraUpdate;
|
|
45
|
+
import com.facebook.react.module.annotations.ReactModule;
|
|
45
46
|
import com.mapsindoorsrn.core.models.MPError;
|
|
46
47
|
|
|
47
48
|
import java.util.ArrayList;
|
|
@@ -49,7 +50,10 @@ import java.util.HashMap;
|
|
|
49
50
|
import java.util.List;
|
|
50
51
|
import java.util.Map;
|
|
51
52
|
|
|
53
|
+
@ReactModule(name = MapControlModule.NAME)
|
|
52
54
|
public class MapControlModule extends ReactContextBaseJavaModule implements MPCameraEventListener, OnFloorUpdateListener, MPFloorSelectorInterface {
|
|
55
|
+
public static final String NAME = "MapControlModule";
|
|
56
|
+
|
|
53
57
|
private RCMapView mMapView;
|
|
54
58
|
private final Gson gson = new Gson();
|
|
55
59
|
private MapControl mMapControl;
|
|
@@ -64,7 +68,7 @@ public class MapControlModule extends ReactContextBaseJavaModule implements MPCa
|
|
|
64
68
|
@NonNull
|
|
65
69
|
@Override
|
|
66
70
|
public String getName() {
|
|
67
|
-
return
|
|
71
|
+
return NAME;
|
|
68
72
|
}
|
|
69
73
|
|
|
70
74
|
private void reject(Promise promise, MIError error) {
|
|
@@ -6,6 +6,7 @@ import com.facebook.react.bridge.ReactApplicationContext;
|
|
|
6
6
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
7
7
|
import com.facebook.react.bridge.ReactMethod;
|
|
8
8
|
import com.facebook.react.bridge.ReadableArray;
|
|
9
|
+
import com.facebook.react.module.annotations.ReactModule;
|
|
9
10
|
import com.google.gson.Gson;
|
|
10
11
|
import com.google.gson.reflect.TypeToken;
|
|
11
12
|
import com.mapsindoors.core.MPBuilding;
|
|
@@ -39,7 +40,9 @@ import java.util.ArrayList;
|
|
|
39
40
|
import java.util.Collections;
|
|
40
41
|
import java.util.List;
|
|
41
42
|
|
|
43
|
+
@ReactModule(name = MapsIndoorsModule.NAME)
|
|
42
44
|
public class MapsIndoorsModule extends ReactContextBaseJavaModule {
|
|
45
|
+
public static final String NAME = "MapsIndoorsModule";
|
|
43
46
|
|
|
44
47
|
private final ReactApplicationContext reactContext;
|
|
45
48
|
private final Gson gson = new Gson();
|
|
@@ -53,7 +56,7 @@ public class MapsIndoorsModule extends ReactContextBaseJavaModule {
|
|
|
53
56
|
|
|
54
57
|
@Override
|
|
55
58
|
public String getName() {
|
|
56
|
-
return
|
|
59
|
+
return NAME;
|
|
57
60
|
}
|
|
58
61
|
|
|
59
62
|
private void reject(Promise promise, MIError error) {
|