react-native-pointr 8.16.0 → 9.1.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/CHANGELOG.md +8 -0
- package/android/build.gradle +20 -11
- package/android/gradle.properties +3 -3
- package/android/src/main/AndroidManifestNew.xml +2 -9
- package/android/src/main/java/com/pointr/PTRMapWidgetCommandType.kt +1 -3
- package/android/src/main/java/com/pointr/PTRMapWidgetManager.kt +178 -394
- package/android/src/main/java/com/pointr/PointrModule.kt +36 -177
- package/ios/PTRMapWidgetContainerView.swift +247 -0
- package/ios/PTRMapWidgetManager-Bridging.m +59 -0
- package/ios/PTRMapWidgetManager.swift +242 -0
- package/ios/PTRNativeLibrary-Bridging.m +34 -0
- package/ios/PTRNativeLibrary.swift +337 -0
- package/ios/react-native-pointr-Bridging-Header.h +5 -0
- package/package.json +1 -1
- package/react-native-pointr.podspec +1 -1
- package/src/PTRCommand.ts +5 -4
- package/src/PTRMapWidgetUtils.ts +13 -13
- package/android/.settings/org.eclipse.buildship.core.prefs +0 -2
- package/android/src/main/AndroidManifest.xml +0 -12
- package/android/src/main/java/com/pointr/PointrMapWidgetActivity.kt +0 -485
- package/android/src/main/res/layout/pointr_map_widget_activity_layout.xml +0 -16
- package/ios/PTRMapWidgetContainerView.h +0 -19
- package/ios/PTRMapWidgetContainerView.m +0 -281
- package/ios/PTRMapWidgetManager.m +0 -256
- package/ios/PTRNativeLibrary.h +0 -11
- package/ios/PTRNativeLibrary.m +0 -159
- package/ios/PointrApp.swift +0 -636
package/src/PTRMapWidgetUtils.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { UIManager } from 'react-native';
|
|
2
|
-
import { PTRSiteCommand, PTRBuildingCommand, PTRLevelCommand, PTRPoiCommand, PTRPathCommand, PTRStaticPathCommand, PTRCommand, PTRCommandType, PTRMarkMyCarLevelCommand, PTRMarkMyCarSiteCommand,
|
|
2
|
+
import { PTRSiteCommand, PTRBuildingCommand, PTRLevelCommand, PTRPoiCommand, PTRPathCommand, PTRStaticPathCommand, PTRCommand, PTRCommandType, PTRMarkMyCarLevelCommand, PTRMarkMyCarSiteCommand, PTRShowMyCarSiteCommand } from 'react-native-pointr/src/PTRCommand';
|
|
3
3
|
/**
|
|
4
4
|
* Show the map widget with the given command
|
|
5
5
|
* @param reactTag view tag of the map widget
|
|
6
6
|
* @param ptrCommand command to show the map widget
|
|
7
7
|
*/
|
|
8
8
|
export const showMapWidget = (reactTag: number, ptrCommand: PTRCommand) => {
|
|
9
|
-
console.log(`Showing map widget with command: ${ptrCommand.type}`);
|
|
9
|
+
console.log(`Showing map widget with command: ${ptrCommand.type} and reactTag: ${reactTag}`);
|
|
10
10
|
switch (ptrCommand.type) {
|
|
11
11
|
case PTRCommandType.SITE: {
|
|
12
12
|
const siteCommand = ptrCommand as PTRSiteCommand;
|
|
13
13
|
UIManager.dispatchViewManagerCommand(
|
|
14
14
|
reactTag,
|
|
15
|
-
|
|
15
|
+
'site',
|
|
16
16
|
[siteCommand.site],
|
|
17
17
|
);
|
|
18
18
|
break;
|
|
@@ -21,7 +21,7 @@ export const showMapWidget = (reactTag: number, ptrCommand: PTRCommand) => {
|
|
|
21
21
|
const buildingCommand = ptrCommand as PTRBuildingCommand;
|
|
22
22
|
UIManager.dispatchViewManagerCommand(
|
|
23
23
|
reactTag,
|
|
24
|
-
|
|
24
|
+
'building',
|
|
25
25
|
[buildingCommand.site, buildingCommand.building],
|
|
26
26
|
);
|
|
27
27
|
break;
|
|
@@ -30,7 +30,7 @@ export const showMapWidget = (reactTag: number, ptrCommand: PTRCommand) => {
|
|
|
30
30
|
const levelCommand = ptrCommand as PTRLevelCommand;
|
|
31
31
|
UIManager.dispatchViewManagerCommand(
|
|
32
32
|
reactTag,
|
|
33
|
-
|
|
33
|
+
'level',
|
|
34
34
|
[levelCommand.site, levelCommand.building, levelCommand.level],
|
|
35
35
|
);
|
|
36
36
|
break;
|
|
@@ -39,7 +39,7 @@ export const showMapWidget = (reactTag: number, ptrCommand: PTRCommand) => {
|
|
|
39
39
|
const poiCommand = ptrCommand as PTRPoiCommand;
|
|
40
40
|
UIManager.dispatchViewManagerCommand(
|
|
41
41
|
reactTag,
|
|
42
|
-
|
|
42
|
+
'poi',
|
|
43
43
|
[poiCommand.site, poiCommand.poi],
|
|
44
44
|
);
|
|
45
45
|
break;
|
|
@@ -48,7 +48,7 @@ export const showMapWidget = (reactTag: number, ptrCommand: PTRCommand) => {
|
|
|
48
48
|
const pathCommand = ptrCommand as PTRPathCommand;
|
|
49
49
|
UIManager.dispatchViewManagerCommand(
|
|
50
50
|
reactTag,
|
|
51
|
-
|
|
51
|
+
'path',
|
|
52
52
|
[pathCommand.site, pathCommand.poi],
|
|
53
53
|
);
|
|
54
54
|
break;
|
|
@@ -57,7 +57,7 @@ export const showMapWidget = (reactTag: number, ptrCommand: PTRCommand) => {
|
|
|
57
57
|
const staticPathCommand = ptrCommand as PTRStaticPathCommand;
|
|
58
58
|
UIManager.dispatchViewManagerCommand(
|
|
59
59
|
reactTag,
|
|
60
|
-
|
|
60
|
+
'staticPath',
|
|
61
61
|
[staticPathCommand.site, staticPathCommand.fromPoi, staticPathCommand.toPoi],
|
|
62
62
|
);
|
|
63
63
|
break;
|
|
@@ -66,7 +66,7 @@ export const showMapWidget = (reactTag: number, ptrCommand: PTRCommand) => {
|
|
|
66
66
|
const markMyCarCommand = ptrCommand as PTRMarkMyCarLevelCommand;
|
|
67
67
|
UIManager.dispatchViewManagerCommand(
|
|
68
68
|
reactTag,
|
|
69
|
-
|
|
69
|
+
'markMyCarForLevel',
|
|
70
70
|
[markMyCarCommand.site, markMyCarCommand.building, markMyCarCommand.level, markMyCarCommand.shouldShowPopup, markMyCarCommand.animationType],
|
|
71
71
|
);
|
|
72
72
|
break;
|
|
@@ -75,16 +75,16 @@ export const showMapWidget = (reactTag: number, ptrCommand: PTRCommand) => {
|
|
|
75
75
|
const markMyCarCommand = ptrCommand as PTRMarkMyCarSiteCommand;
|
|
76
76
|
UIManager.dispatchViewManagerCommand(
|
|
77
77
|
reactTag,
|
|
78
|
-
|
|
78
|
+
'markMyCarForSite',
|
|
79
79
|
[markMyCarCommand.site, markMyCarCommand.shouldShowPopup, markMyCarCommand.animationType],
|
|
80
80
|
);
|
|
81
81
|
break;
|
|
82
82
|
}
|
|
83
|
-
case PTRCommandType.
|
|
84
|
-
const myCarCommand = ptrCommand as
|
|
83
|
+
case PTRCommandType.SHOW_MY_CAR_SITE: {
|
|
84
|
+
const myCarCommand = ptrCommand as PTRShowMyCarSiteCommand;
|
|
85
85
|
UIManager.dispatchViewManagerCommand(
|
|
86
86
|
reactTag,
|
|
87
|
-
|
|
87
|
+
'myCarForSite',
|
|
88
88
|
[myCarCommand.site, myCarCommand.animationType],
|
|
89
89
|
);
|
|
90
90
|
break;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
3
|
-
package="com.pointr">
|
|
4
|
-
<application>
|
|
5
|
-
<activity
|
|
6
|
-
android:name="com.pointr.PointrMapWidgetActivity"
|
|
7
|
-
android:exported="true"
|
|
8
|
-
android:launchMode="singleTask"
|
|
9
|
-
android:screenOrientation="portrait">
|
|
10
|
-
</activity>
|
|
11
|
-
</application>
|
|
12
|
-
</manifest>
|
|
@@ -1,485 +0,0 @@
|
|
|
1
|
-
package com.pointr
|
|
2
|
-
|
|
3
|
-
import android.Manifest
|
|
4
|
-
import android.annotation.SuppressLint
|
|
5
|
-
import android.content.Intent
|
|
6
|
-
import android.os.Build
|
|
7
|
-
import android.os.Bundle
|
|
8
|
-
import android.os.Handler
|
|
9
|
-
import android.util.Log
|
|
10
|
-
import android.view.WindowManager
|
|
11
|
-
import android.widget.TextView
|
|
12
|
-
import android.widget.Toast
|
|
13
|
-
import androidx.annotation.WorkerThread
|
|
14
|
-
import androidx.appcompat.app.AppCompatActivity
|
|
15
|
-
import androidx.constraintlayout.widget.ConstraintLayout
|
|
16
|
-
import com.pointrlabs.core.management.Pointr
|
|
17
|
-
import com.pointrlabs.core.management.interfaces.PointrListener
|
|
18
|
-
import com.pointrlabs.core.map.viewmodels.PTRMapWidgetConfiguration
|
|
19
|
-
import com.pointrlabs.core.map.views.PTRMapAnimationType
|
|
20
|
-
import com.pointrlabs.core.map.views.PTRMapWidgetFragment
|
|
21
|
-
import com.pointrlabs.core.nativecore.wrappers.Plog
|
|
22
|
-
import com.pointrlabs.core.positioning.model.PositioningTypes.INVALID_INTEGER
|
|
23
|
-
import com.facebook.react.bridge.Callback
|
|
24
|
-
import com.pointr.PointrModule.Companion.mapEventsListenerKey
|
|
25
|
-
import com.pointrlabs.core.geometry.GeoPoint
|
|
26
|
-
import com.pointrlabs.core.management.DataManager
|
|
27
|
-
import com.pointrlabs.core.management.models.ErrorMessage
|
|
28
|
-
import com.pointrlabs.core.management.models.Site
|
|
29
|
-
import com.pointrlabs.core.map.handlers.ExitButtonEventsHandler
|
|
30
|
-
import com.pointrlabs.core.map.models.PTRMapSymbolLayer
|
|
31
|
-
import com.pointrlabs.core.map.models.events_listeners.MapEventsListener
|
|
32
|
-
import com.pointrlabs.core.site.SiteManager
|
|
33
|
-
import java.lang.IllegalArgumentException
|
|
34
|
-
import java.util.concurrent.Semaphore
|
|
35
|
-
import java.util.concurrent.TimeUnit
|
|
36
|
-
import kotlin.random.Random
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* This activity is the activity where the Pointr Map is served to the user.
|
|
41
|
-
* Any UI related operation can be performed here
|
|
42
|
-
*/
|
|
43
|
-
@SuppressLint("LogNotTimber")
|
|
44
|
-
class PointrMapWidgetActivity : AppCompatActivity() {
|
|
45
|
-
|
|
46
|
-
companion object {
|
|
47
|
-
const val destinationPoiExternalIdentifierKey = "destinationPoiExternalIdentifier"
|
|
48
|
-
const val sourcePoiExternalIdentifierKey = "sourcePoiExternalIdentifier"
|
|
49
|
-
const val SHOW_PATHFINDING_BETWEEN_POIS = "showPathBetweenPOIs"
|
|
50
|
-
const val SHOW_SITE = "showSite"
|
|
51
|
-
const val SHOW_BUILDING = "showBuilding"
|
|
52
|
-
const val SHOW_LEVEL = "showLevel"
|
|
53
|
-
const val SHOW_PATHFINDING_TO_POI = "showPathfindingToPoi"
|
|
54
|
-
const val SHOW_POI_DETAILS = "showPoiDetails"
|
|
55
|
-
const val animationTypeKey = "animationType"
|
|
56
|
-
const val siteExternalIdentifierKey = "siteExternalId"
|
|
57
|
-
const val buildingExternalIdentifierKey = "buildingExternalId"
|
|
58
|
-
const val levelIndexKey = "levelIndex"
|
|
59
|
-
const val poiExternalIdentifierKey = "poiExternalId"
|
|
60
|
-
var callback: Callback? = null
|
|
61
|
-
val mapWidgetConfiguration = PTRMapWidgetConfiguration.defaultConfiguration()
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
var pendingAction: () -> Unit = {}
|
|
65
|
-
|
|
66
|
-
private val timeoutInSeconds = 15L
|
|
67
|
-
|
|
68
|
-
private var ptrMapWidgetFragment: PTRMapWidgetFragment? = null
|
|
69
|
-
|
|
70
|
-
private var mapEventsListener: MapEventsListener? = null
|
|
71
|
-
|
|
72
|
-
val pointr: Pointr?
|
|
73
|
-
get() {
|
|
74
|
-
return Pointr.getPointr()
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
private val pointrListener = object : PointrListener {
|
|
78
|
-
override fun onStateUpdated(p0: Pointr.State?) {
|
|
79
|
-
val state = p0 ?: return
|
|
80
|
-
Plog.v("Pointr state updated: ${state.name}")
|
|
81
|
-
if (state == Pointr.State.RUNNING) {
|
|
82
|
-
Plog.v("Pointr is Running")
|
|
83
|
-
pointr?.removeListener(this)
|
|
84
|
-
if (PointrModule.shouldRequestPermissionsAtStartup) {
|
|
85
|
-
requestPermissions()
|
|
86
|
-
} else {
|
|
87
|
-
pointr?.permissionManager?.shouldRequestLocationPermissionForWhileInUse = false
|
|
88
|
-
pointr?.permissionManager?.shouldRequestBluetoothPermission = false
|
|
89
|
-
pointr?.permissionManager?.shouldRequestLocationPermissionForAlways = false
|
|
90
|
-
}
|
|
91
|
-
runOnUiThread {
|
|
92
|
-
pendingAction.invoke()
|
|
93
|
-
pendingAction = {}
|
|
94
|
-
}
|
|
95
|
-
} else if (state.`val` <= Pointr.State.OFF.`val`) {
|
|
96
|
-
Plog.e("Pointr could not start. Current state: ${state.name}")
|
|
97
|
-
callback?.invoke("Starting Pointr resulted in ${state.name}")
|
|
98
|
-
callback = null
|
|
99
|
-
pointr?.removeListener(this)
|
|
100
|
-
runOnUiThread {
|
|
101
|
-
Toast.makeText(applicationContext, "Could not start maps.", Toast.LENGTH_LONG)
|
|
102
|
-
.show()
|
|
103
|
-
finish()
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
private fun requestPermissions() {
|
|
111
|
-
val permissionManager = Pointr.getPointr()?.permissionManager ?: run {
|
|
112
|
-
Log.e("Pointr", "Permission manager is not ready")
|
|
113
|
-
return
|
|
114
|
-
}
|
|
115
|
-
val permissionList = arrayListOf<String>()
|
|
116
|
-
if (!permissionManager.hasLocationPermissionAlwaysOrWhileInUse)
|
|
117
|
-
permissionList.add(Manifest.permission.ACCESS_FINE_LOCATION)
|
|
118
|
-
|
|
119
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && !permissionManager.hasBluetoothPermission) {
|
|
120
|
-
permissionList.add(Manifest.permission.BLUETOOTH_SCAN)
|
|
121
|
-
permissionList.add(Manifest.permission.BLUETOOTH_CONNECT)
|
|
122
|
-
}
|
|
123
|
-
if (permissionList.isEmpty()) return
|
|
124
|
-
requestPermissions(permissionList.toTypedArray(), Random.nextInt(1024, 65_536))
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
override fun onCreate(savedInstanceState: Bundle?) {
|
|
128
|
-
super.onCreate(savedInstanceState)
|
|
129
|
-
setContentView(R.layout.pointr_map_widget_activity_layout)
|
|
130
|
-
val attrib = window.attributes
|
|
131
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
|
132
|
-
attrib.layoutInDisplayCutoutMode =
|
|
133
|
-
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
|
|
134
|
-
findViewById<ConstraintLayout>(R.id.pointr_map_widget_activity_layout).setOnApplyWindowInsetsListener { _, windowInsets ->
|
|
135
|
-
val inset = windowInsets.displayCutout
|
|
136
|
-
Log.d("Tag", "Inset: $inset")
|
|
137
|
-
windowInsets
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
if (pointr == null) {
|
|
141
|
-
Plog.e("CRITICAL!! Pointr is null. Did you call Pointr.with before?")
|
|
142
|
-
return
|
|
143
|
-
}
|
|
144
|
-
pointr?.addListener(pointrListener)
|
|
145
|
-
pendingAction = { showMapWidgetBasedOnAction() }
|
|
146
|
-
if (pointr?.state == Pointr.State.RUNNING) {
|
|
147
|
-
Plog.v("Pointr already running - will invoke the action.")
|
|
148
|
-
pendingAction.invoke()
|
|
149
|
-
pendingAction = {}
|
|
150
|
-
pointr?.removeListener(pointrListener)
|
|
151
|
-
} else {
|
|
152
|
-
Plog.v("Starting Pointr...")
|
|
153
|
-
Thread {
|
|
154
|
-
pointr?.start()
|
|
155
|
-
}.start()
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
override fun onDestroy() {
|
|
160
|
-
pointr?.removeListener(pointrListener)
|
|
161
|
-
mapEventsListener?.let { ptrMapWidgetFragment?.removeListener(it) }
|
|
162
|
-
ptrMapWidgetFragment?.let {
|
|
163
|
-
supportFragmentManager.beginTransaction().remove(it).commitAllowingStateLoss()
|
|
164
|
-
}
|
|
165
|
-
callback = null
|
|
166
|
-
pendingAction = {}
|
|
167
|
-
super.onDestroy()
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
private fun showMapWidgetBasedOnAction() {
|
|
171
|
-
|
|
172
|
-
PTRMapWidgetFragment.newInstance(configuration = mapWidgetConfiguration) { widget->
|
|
173
|
-
ptrMapWidgetFragment = widget.show(supportFragmentManager, R.id.fragment_container)
|
|
174
|
-
ptrMapWidgetFragment?.exitButtonEventsHandler = object : ExitButtonEventsHandler() {
|
|
175
|
-
override fun onExitClicked(mapWidget: PTRMapWidgetFragment, exitButton: TextView) {
|
|
176
|
-
this@PointrMapWidgetActivity.finish()
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
mapEventsListener = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
|
180
|
-
intent.getParcelableExtra(
|
|
181
|
-
mapEventsListenerKey,
|
|
182
|
-
PointrModule.CustomMapEventsListener::class.java
|
|
183
|
-
)
|
|
184
|
-
} else {
|
|
185
|
-
@Suppress("DEPRECATION")
|
|
186
|
-
intent.getParcelableExtra(mapEventsListenerKey)
|
|
187
|
-
}
|
|
188
|
-
mapEventsListener?.let { ptrMapWidgetFragment?.addListener(it) }
|
|
189
|
-
when (intent.action) {
|
|
190
|
-
SHOW_SITE -> {
|
|
191
|
-
val siteExternalId = intent.getStringExtra(siteExternalIdentifierKey)
|
|
192
|
-
if (siteExternalId != null) {
|
|
193
|
-
val animationTypeInt = intent.getIntExtra(animationTypeKey, 0)
|
|
194
|
-
val animationType = try {
|
|
195
|
-
PTRMapAnimationType.values()[animationTypeInt]
|
|
196
|
-
} catch (ex: IllegalArgumentException) {
|
|
197
|
-
PTRMapAnimationType.flyOver
|
|
198
|
-
}
|
|
199
|
-
ptrMapWidgetFragment?.showSite(siteExternalId, animationType) {
|
|
200
|
-
callback?.invoke(it)
|
|
201
|
-
callback = null
|
|
202
|
-
}
|
|
203
|
-
} else {
|
|
204
|
-
Plog.e("Site External Id not provided")
|
|
205
|
-
callback?.invoke("Site External Id not provided")
|
|
206
|
-
callback = null
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
SHOW_BUILDING -> {
|
|
211
|
-
val siteExternalId = intent.getStringExtra(siteExternalIdentifierKey)
|
|
212
|
-
val buildingExternalId = intent.getStringExtra(buildingExternalIdentifierKey)
|
|
213
|
-
if (siteExternalId != null && buildingExternalId != null) {
|
|
214
|
-
val animationTypeInt = intent.getIntExtra(animationTypeKey, 0)
|
|
215
|
-
val animationType = try {
|
|
216
|
-
PTRMapAnimationType.values()[animationTypeInt]
|
|
217
|
-
} catch (ex: IllegalArgumentException) {
|
|
218
|
-
PTRMapAnimationType.flyOver
|
|
219
|
-
}
|
|
220
|
-
ptrMapWidgetFragment?.showBuilding(
|
|
221
|
-
siteExternalId,
|
|
222
|
-
buildingExternalId,
|
|
223
|
-
animationType
|
|
224
|
-
) {
|
|
225
|
-
callback?.invoke(it)
|
|
226
|
-
callback = null
|
|
227
|
-
}
|
|
228
|
-
} else {
|
|
229
|
-
Plog.e("Site or Building Id not provided")
|
|
230
|
-
callback?.invoke("Site or Building Id not provided")
|
|
231
|
-
callback = null
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
SHOW_LEVEL -> {
|
|
236
|
-
val siteExternalId = intent.getStringExtra(siteExternalIdentifierKey)
|
|
237
|
-
val buildingExternalId = intent.getStringExtra(buildingExternalIdentifierKey)
|
|
238
|
-
val levelIndex = intent.getIntExtra(levelIndexKey, INVALID_INTEGER)
|
|
239
|
-
if (siteExternalId != null && buildingExternalId != null && levelIndex != INVALID_INTEGER) {
|
|
240
|
-
val animationTypeInt = intent.getIntExtra(animationTypeKey, 0)
|
|
241
|
-
val animationType = try {
|
|
242
|
-
PTRMapAnimationType.values()[animationTypeInt]
|
|
243
|
-
} catch (ex: IllegalArgumentException) {
|
|
244
|
-
PTRMapAnimationType.flyOver
|
|
245
|
-
}
|
|
246
|
-
ptrMapWidgetFragment?.showLevel(
|
|
247
|
-
siteExternalId,
|
|
248
|
-
buildingExternalId,
|
|
249
|
-
levelIndex,
|
|
250
|
-
animationType
|
|
251
|
-
) {
|
|
252
|
-
callback?.invoke(it)
|
|
253
|
-
callback = null
|
|
254
|
-
}
|
|
255
|
-
} else {
|
|
256
|
-
Plog.e("Site or Building Id not provided")
|
|
257
|
-
callback?.invoke("Site or Building Id not provided")
|
|
258
|
-
callback = null
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
SHOW_POI_DETAILS -> {
|
|
263
|
-
val siteExternalId = intent.getStringExtra(siteExternalIdentifierKey)
|
|
264
|
-
val poiExternalId = intent.getStringExtra(poiExternalIdentifierKey)
|
|
265
|
-
if (siteExternalId != null && poiExternalId != null) {
|
|
266
|
-
val animationTypeInt = intent.getIntExtra(animationTypeKey, 0)
|
|
267
|
-
val animationType = try {
|
|
268
|
-
PTRMapAnimationType.values()[animationTypeInt]
|
|
269
|
-
} catch (ex: IllegalArgumentException) {
|
|
270
|
-
PTRMapAnimationType.flyOver
|
|
271
|
-
}
|
|
272
|
-
ptrMapWidgetFragment?.showPoiDetails(
|
|
273
|
-
siteExternalId,
|
|
274
|
-
poiExternalId,
|
|
275
|
-
animationType
|
|
276
|
-
) {
|
|
277
|
-
callback?.invoke(it)
|
|
278
|
-
callback = null
|
|
279
|
-
}
|
|
280
|
-
} else {
|
|
281
|
-
Plog.e("Site or Poi Id not provided")
|
|
282
|
-
callback?.invoke("Site or Poi Id not provided")
|
|
283
|
-
callback = null
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
SHOW_PATHFINDING_TO_POI -> {
|
|
288
|
-
val siteExternalId = intent.getStringExtra(siteExternalIdentifierKey)
|
|
289
|
-
val poiExternalId = intent.getStringExtra(poiExternalIdentifierKey)
|
|
290
|
-
if (siteExternalId != null && poiExternalId != null) {
|
|
291
|
-
val animationTypeInt = intent.getIntExtra(animationTypeKey, 0)
|
|
292
|
-
val animationType = try {
|
|
293
|
-
PTRMapAnimationType.values()[animationTypeInt]
|
|
294
|
-
} catch (ex: IllegalArgumentException) {
|
|
295
|
-
PTRMapAnimationType.flyOver
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
ptrMapWidgetFragment?.showPathFinding(
|
|
299
|
-
siteExternalId,
|
|
300
|
-
poiExternalId,
|
|
301
|
-
animationType
|
|
302
|
-
) {
|
|
303
|
-
callback?.invoke(it)
|
|
304
|
-
callback = null
|
|
305
|
-
}
|
|
306
|
-
} else {
|
|
307
|
-
Plog.e("Site or Poi Id not provided")
|
|
308
|
-
callback?.invoke("Site or Poi Id not provided")
|
|
309
|
-
callback = null
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
SHOW_PATHFINDING_BETWEEN_POIS -> {
|
|
314
|
-
internalShowPathFindingBetweenPois(intent)
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
private fun internalShowPathFindingBetweenPois(intent: Intent) {
|
|
321
|
-
val siteExternalId = intent.getStringExtra(siteExternalIdentifierKey) ?: run {
|
|
322
|
-
this@PointrMapWidgetActivity.finish()
|
|
323
|
-
callback?.invoke("Site is not provided")
|
|
324
|
-
callback = null
|
|
325
|
-
return
|
|
326
|
-
}
|
|
327
|
-
val sourcePoiExternalId = intent.getStringExtra(sourcePoiExternalIdentifierKey) ?: run {
|
|
328
|
-
this@PointrMapWidgetActivity.finish()
|
|
329
|
-
callback?.invoke("Source poi is not provided")
|
|
330
|
-
callback = null
|
|
331
|
-
return
|
|
332
|
-
}
|
|
333
|
-
val destinationPoiExternalId =
|
|
334
|
-
intent.getStringExtra(destinationPoiExternalIdentifierKey) ?: run {
|
|
335
|
-
this@PointrMapWidgetActivity.finish()
|
|
336
|
-
callback?.invoke("Destination poi is not provided")
|
|
337
|
-
callback = null
|
|
338
|
-
return
|
|
339
|
-
}
|
|
340
|
-
val animationTypeInt = intent.getIntExtra(animationTypeKey, 0)
|
|
341
|
-
val animationType = try {
|
|
342
|
-
PTRMapAnimationType.values()[animationTypeInt]
|
|
343
|
-
} catch (ex: IllegalArgumentException) {
|
|
344
|
-
PTRMapAnimationType.flyOver
|
|
345
|
-
}
|
|
346
|
-
val dataManager = pointr?.dataManager ?: run {
|
|
347
|
-
this@PointrMapWidgetActivity.finish()
|
|
348
|
-
callback?.invoke("Data Manager is not ready")
|
|
349
|
-
callback = null
|
|
350
|
-
return
|
|
351
|
-
}
|
|
352
|
-
val poiManager = pointr?.poiManager ?: run {
|
|
353
|
-
this@PointrMapWidgetActivity.finish()
|
|
354
|
-
callback?.invoke("Poi Manager is not ready")
|
|
355
|
-
callback = null
|
|
356
|
-
return
|
|
357
|
-
}
|
|
358
|
-
val pathManager = pointr?.pathManager ?: run {
|
|
359
|
-
this@PointrMapWidgetActivity.finish()
|
|
360
|
-
callback?.invoke("Path Manager is not ready")
|
|
361
|
-
callback = null
|
|
362
|
-
return
|
|
363
|
-
}
|
|
364
|
-
val theSite = getSite(siteExternalId) ?: run {
|
|
365
|
-
this@PointrMapWidgetActivity.finish()
|
|
366
|
-
callback?.invoke("Site `$siteExternalId` does not exist.")
|
|
367
|
-
callback = null
|
|
368
|
-
return
|
|
369
|
-
}
|
|
370
|
-
val dataManagementSemaphore = Semaphore(0)
|
|
371
|
-
val dataManagerListener = object : DataManager.Listener {
|
|
372
|
-
override fun onDataManagerCompleteAllForSite(
|
|
373
|
-
site: Site,
|
|
374
|
-
isSuccessful: Boolean,
|
|
375
|
-
isOnlineData: Boolean,
|
|
376
|
-
errors: List<ErrorMessage?>?
|
|
377
|
-
) {
|
|
378
|
-
if (theSite == site && isOnlineData) {
|
|
379
|
-
dataManagementSemaphore.release()
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
dataManager.addListener(dataManagerListener)
|
|
384
|
-
if (!dataManager.isSiteContentReady(theSite)) {
|
|
385
|
-
Plog.i("Data for site: ${theSite.title} is not ready. Will start and wait for completion")
|
|
386
|
-
dataManager.loadDataForSite(theSite)
|
|
387
|
-
val didAcquire = dataManagementSemaphore.tryAcquire(timeoutInSeconds, TimeUnit.SECONDS)
|
|
388
|
-
if (!didAcquire) {
|
|
389
|
-
Plog.e("Data management for site: ${theSite.title} did not complete in time")
|
|
390
|
-
dataManager.removeListener(dataManagerListener)
|
|
391
|
-
dataManagementSemaphore.release()
|
|
392
|
-
this@PointrMapWidgetActivity.finish()
|
|
393
|
-
callback?.invoke("Data management for site: ${theSite.title} did not complete in time")
|
|
394
|
-
callback = null
|
|
395
|
-
return
|
|
396
|
-
}
|
|
397
|
-
} else {
|
|
398
|
-
Plog.v("Data for site: ${theSite.title} is ready. Moving on.")
|
|
399
|
-
dataManager.removeListener(dataManagerListener)
|
|
400
|
-
}
|
|
401
|
-
val sourcePoi = poiManager.getPoiByExternalIdentifier(theSite, sourcePoiExternalId) ?: run {
|
|
402
|
-
this@PointrMapWidgetActivity.finish()
|
|
403
|
-
callback?.invoke("Source poi `$sourcePoiExternalId` does not exist within site `${theSite.title}`.")
|
|
404
|
-
callback = null
|
|
405
|
-
return
|
|
406
|
-
}
|
|
407
|
-
val destinationPoi =
|
|
408
|
-
poiManager.getPoiByExternalIdentifier(theSite, destinationPoiExternalId) ?: run {
|
|
409
|
-
this@PointrMapWidgetActivity.finish()
|
|
410
|
-
callback?.invoke("Destination poi `$destinationPoiExternalId` does not exist within site ${theSite.title}.")
|
|
411
|
-
callback = null
|
|
412
|
-
return
|
|
413
|
-
}
|
|
414
|
-
val path = pathManager.calculatePath(sourcePoi, listOf(destinationPoi)) ?: run {
|
|
415
|
-
this@PointrMapWidgetActivity.finish()
|
|
416
|
-
callback?.invoke("Unable to calculate path")
|
|
417
|
-
callback = null
|
|
418
|
-
return
|
|
419
|
-
}
|
|
420
|
-
ptrMapWidgetFragment?.showLevel(sourcePoi.level!!, animationType, true) { error ->
|
|
421
|
-
error?.let {
|
|
422
|
-
this@PointrMapWidgetActivity.finish()
|
|
423
|
-
callback?.invoke(it)
|
|
424
|
-
callback = null
|
|
425
|
-
return@showLevel
|
|
426
|
-
}
|
|
427
|
-
val handler = Handler(mainLooper)
|
|
428
|
-
handler.post {
|
|
429
|
-
val mapFragment = ptrMapWidgetFragment?.mapFragment ?: run {
|
|
430
|
-
this@PointrMapWidgetActivity.finish()
|
|
431
|
-
callback?.invoke("Map is not ready")
|
|
432
|
-
callback = null
|
|
433
|
-
return@post
|
|
434
|
-
}
|
|
435
|
-
val layer = PTRMapSymbolLayer()
|
|
436
|
-
mapFragment.addLayer(layer) { b1, e1 ->
|
|
437
|
-
if (!b1) {
|
|
438
|
-
this@PointrMapWidgetActivity.finish()
|
|
439
|
-
callback?.invoke(e1)
|
|
440
|
-
callback = null
|
|
441
|
-
return@addLayer
|
|
442
|
-
}
|
|
443
|
-
mapFragment.addFeatures(
|
|
444
|
-
listOf(sourcePoi, destinationPoi),
|
|
445
|
-
layer.identifier
|
|
446
|
-
) { b2, e2 ->
|
|
447
|
-
if (!b2) {
|
|
448
|
-
this@PointrMapWidgetActivity.finish()
|
|
449
|
-
callback?.invoke(e2)
|
|
450
|
-
callback = null
|
|
451
|
-
return@addFeatures
|
|
452
|
-
}
|
|
453
|
-
mapFragment.zoomToLocation(
|
|
454
|
-
GeoPoint(
|
|
455
|
-
sourcePoi.location.lat,
|
|
456
|
-
sourcePoi.location.lon
|
|
457
|
-
)
|
|
458
|
-
)
|
|
459
|
-
mapFragment.currentPath = path
|
|
460
|
-
callback?.invoke(null)
|
|
461
|
-
callback = null
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
@WorkerThread
|
|
469
|
-
private fun getSite(siteExternalId: String): Site? {
|
|
470
|
-
val siteManager = pointr?.siteManager ?: return null
|
|
471
|
-
if (siteManager.getSites().isEmpty()) {
|
|
472
|
-
val semaphore = Semaphore(0)
|
|
473
|
-
val listener = object : SiteManager.Listener {
|
|
474
|
-
override fun onSiteManagerDataChanged() {
|
|
475
|
-
semaphore.release()
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
siteManager.addListener(listener)
|
|
479
|
-
semaphore.tryAcquire(timeoutInSeconds, TimeUnit.SECONDS)
|
|
480
|
-
siteManager.removeListener(listener)
|
|
481
|
-
semaphore.release()
|
|
482
|
-
}
|
|
483
|
-
return siteManager.getSite(siteExternalId)
|
|
484
|
-
}
|
|
485
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
-
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
3
|
-
android:layout_width="match_parent"
|
|
4
|
-
android:layout_height="match_parent"
|
|
5
|
-
android:id="@+id/pointr_map_widget_activity_layout"
|
|
6
|
-
xmlns:app="http://schemas.android.com/apk/res-auto">
|
|
7
|
-
|
|
8
|
-
<FrameLayout
|
|
9
|
-
android:id="@+id/fragment_container"
|
|
10
|
-
android:layout_width="0dp"
|
|
11
|
-
android:layout_height="0dp"
|
|
12
|
-
app:layout_constraintBottom_toBottomOf="parent"
|
|
13
|
-
app:layout_constraintEnd_toEndOf="parent"
|
|
14
|
-
app:layout_constraintStart_toStartOf="parent"
|
|
15
|
-
app:layout_constraintTop_toTopOf="parent"/>
|
|
16
|
-
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
#import <React/RCTComponent.h>
|
|
2
|
-
#import <PointrKit/PointrKit.h>
|
|
3
|
-
|
|
4
|
-
extern NSString * const kLayerStaticPath;
|
|
5
|
-
|
|
6
|
-
@interface PTRMapWidgetContainerView: UIView<PTRConfigurationManagerDelegate, PTRSiteManagerDelegate, PTRDataManagerDelegate, PTRPathManagerDelegate>
|
|
7
|
-
|
|
8
|
-
@property (nonatomic, copy) RCTBubblingEventBlock onMapWidgetDidEndLoading;
|
|
9
|
-
@property(readonly, atomic, strong) PTRMapWidgetViewController *mapWidget;
|
|
10
|
-
@property (nonatomic, strong) dispatch_semaphore_t semaphore;
|
|
11
|
-
@property (nonatomic, strong) PTRSite *site;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
- (void)ptrMapWidgetDidEndLoadingWithParameters:(NSDictionary *)parameters;
|
|
15
|
-
-(PTRMapWidgetViewController *) getMapWidget;
|
|
16
|
-
-(void) present:(PTRMapWidgetViewController *) mapWidget;
|
|
17
|
-
-(void) showStaticPath:(NSString *) siteExternalIdentifier fromPoiExternalIdentifier:(NSString *) fromPoiExternalIdentifier toPoiExternalIdentifier:(NSString *) toPoiExternalIdentifier;
|
|
18
|
-
|
|
19
|
-
@end
|