react-native-pointr 9.2.0 → 9.3.1
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/API_REFERENCE.md +887 -0
- package/CHANGELOG.md +35 -0
- package/EXTENDING.md +419 -0
- package/README.md +221 -117
- package/WAYFINDING_EVENTS.md +243 -0
- package/android/build.gradle +3 -4
- package/android/src/main/java/com/pointr/PTRCoreExtensions.kt +126 -0
- package/android/src/main/java/com/pointr/PTRMapWidgetCommandType.kt +2 -1
- package/android/src/main/java/com/pointr/PTRMapWidgetManager.kt +73 -11
- package/android/src/main/java/com/pointr/PointrModule.kt +106 -3
- package/example/pointr_rn_demo/.bundle/config +2 -0
- package/example/pointr_rn_demo/.eslintrc.js +4 -0
- package/example/pointr_rn_demo/.prettierrc.js +5 -0
- package/example/pointr_rn_demo/.watchmanconfig +1 -0
- package/example/pointr_rn_demo/App.tsx +323 -0
- package/example/pointr_rn_demo/Gemfile +16 -0
- package/example/pointr_rn_demo/Gemfile.lock +111 -0
- package/example/pointr_rn_demo/README.md +188 -0
- package/example/pointr_rn_demo/__tests__/App.test.tsx +13 -0
- package/example/pointr_rn_demo/android/app/build.gradle +119 -0
- package/example/pointr_rn_demo/android/app/debug.keystore +0 -0
- package/example/pointr_rn_demo/android/app/proguard-rules.pro +10 -0
- package/example/pointr_rn_demo/android/app/src/main/AndroidManifest.xml +27 -0
- package/example/pointr_rn_demo/android/app/src/main/java/com/pointr_rn_demo/MainActivity.kt +22 -0
- package/example/pointr_rn_demo/android/app/src/main/java/com/pointr_rn_demo/MainApplication.kt +27 -0
- package/example/pointr_rn_demo/android/app/src/main/res/drawable/rn_edit_text_material.xml +37 -0
- package/example/pointr_rn_demo/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/example/pointr_rn_demo/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/example/pointr_rn_demo/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/example/pointr_rn_demo/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/example/pointr_rn_demo/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/example/pointr_rn_demo/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/example/pointr_rn_demo/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/example/pointr_rn_demo/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/example/pointr_rn_demo/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/example/pointr_rn_demo/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/example/pointr_rn_demo/android/app/src/main/res/values/strings.xml +3 -0
- package/example/pointr_rn_demo/android/app/src/main/res/values/styles.xml +9 -0
- package/example/pointr_rn_demo/android/build.gradle +32 -0
- package/example/pointr_rn_demo/android/gradle.properties +44 -0
- package/example/pointr_rn_demo/android/settings.gradle +6 -0
- package/example/pointr_rn_demo/app.json +4 -0
- package/example/pointr_rn_demo/babel.config.js +3 -0
- package/example/pointr_rn_demo/index.js +16 -0
- package/example/pointr_rn_demo/ios/.xcode.env +11 -0
- package/example/pointr_rn_demo/ios/Podfile +40 -0
- package/example/pointr_rn_demo/ios/Podfile.lock +2767 -0
- package/example/pointr_rn_demo/ios/pointr_rn_demo/AppDelegate.swift +48 -0
- package/example/pointr_rn_demo/ios/pointr_rn_demo/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
- package/example/pointr_rn_demo/ios/pointr_rn_demo/Images.xcassets/Contents.json +6 -0
- package/example/pointr_rn_demo/ios/pointr_rn_demo/Info.plist +63 -0
- package/example/pointr_rn_demo/ios/pointr_rn_demo/LaunchScreen.storyboard +47 -0
- package/example/pointr_rn_demo/ios/pointr_rn_demo/PrivacyInfo.xcprivacy +37 -0
- package/example/pointr_rn_demo/ios/pointr_rn_demo.xcodeproj/project.pbxproj +496 -0
- package/example/pointr_rn_demo/ios/pointr_rn_demo.xcodeproj/xcshareddata/xcschemes/pointr_rn_demo.xcscheme +88 -0
- package/example/pointr_rn_demo/ios/pointr_rn_demo.xcworkspace/contents.xcworkspacedata +10 -0
- package/example/pointr_rn_demo/jest.config.js +3 -0
- package/example/pointr_rn_demo/metro.config.js +22 -0
- package/example/pointr_rn_demo/package-lock.json +11747 -0
- package/example/pointr_rn_demo/package.json +46 -0
- package/example/pointr_rn_demo/prepare-demo-distribution.sh +103 -0
- package/example/pointr_rn_demo/tsconfig.json +5 -0
- package/ios/PTRMapWidgetContainerView.swift +56 -5
- package/ios/PTRMapWidgetManager-Bridging.m +7 -0
- package/ios/PTRMapWidgetManager.swift +28 -0
- package/ios/PTRNativeLibrary-Bridging.m +4 -0
- package/ios/PTRNativeLibrary.swift +208 -2
- package/package.json +16 -2
- package/prepare-distribution.sh +84 -0
- package/react-native-pointr.podspec +1 -1
- package/src/PTRCommand.ts +13 -0
- package/src/PTRMapWidgetUtils.ts +10 -1
- package/src/PTRPoiManager.ts +20 -0
- package/src/index.tsx +40 -1
- package/src/types/PTRGeometry.ts +70 -0
- package/src/types/PTRPoi.ts +49 -0
- package/src/types/PTRPosition.ts +22 -0
- package/src/types/PTRWayfindingEvent.ts +18 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
package com.pointr
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Arguments
|
|
4
|
+
import com.facebook.react.bridge.ReadableMap
|
|
5
|
+
import com.pointrlabs.core.geojson.PTRFeature
|
|
6
|
+
import com.pointrlabs.core.geometry.GeoMultiPoint
|
|
7
|
+
import com.pointrlabs.core.geometry.GeoMultiPolygon
|
|
8
|
+
import com.pointrlabs.core.geometry.GeoPoint
|
|
9
|
+
import com.pointrlabs.core.geometry.GeoPolygon
|
|
10
|
+
import com.pointrlabs.core.geometry.Geometry
|
|
11
|
+
import com.pointrlabs.core.positioning.model.Position
|
|
12
|
+
|
|
13
|
+
val Position.map
|
|
14
|
+
get() = Arguments.createMap().apply {
|
|
15
|
+
putDouble("lat", lat)
|
|
16
|
+
putDouble("lon", lon)
|
|
17
|
+
putBoolean("isValid", isValid())
|
|
18
|
+
putString("sid", siteIdentifier)
|
|
19
|
+
putString("bid", buildingIdentifier)
|
|
20
|
+
putInt("lvl", levelIndex)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
private fun getAttributes(attributes: Map<*, *>): ReadableMap {
|
|
24
|
+
return Arguments.createMap().apply {
|
|
25
|
+
attributes.forEach { (key, value) ->
|
|
26
|
+
when (value) {
|
|
27
|
+
is Long -> putLong(key.toString(), value)
|
|
28
|
+
|
|
29
|
+
is Int -> putInt(key.toString(), value)
|
|
30
|
+
|
|
31
|
+
is Boolean -> putBoolean(key.toString(), value)
|
|
32
|
+
|
|
33
|
+
is String -> putString(key.toString(), value)
|
|
34
|
+
|
|
35
|
+
is Double -> putDouble(key.toString(), value)
|
|
36
|
+
|
|
37
|
+
is List<*> -> {
|
|
38
|
+
putArray(key.toString(), Arguments.createArray().apply {
|
|
39
|
+
value.forEach { v ->
|
|
40
|
+
when (v) {
|
|
41
|
+
is Int -> pushInt(v)
|
|
42
|
+
is Double -> pushDouble(v)
|
|
43
|
+
is Long -> pushLong(v)
|
|
44
|
+
is Boolean -> pushBoolean(v)
|
|
45
|
+
is String -> pushString(v)
|
|
46
|
+
else -> pushNull()
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
is Map<*, *> -> putMap(key.toString(), getAttributes(value))
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
val PTRFeature.map
|
|
59
|
+
get() = Arguments.createMap().apply {
|
|
60
|
+
putString("identifier", identifier)
|
|
61
|
+
putString("externalIdentifier", externalIdentifier)
|
|
62
|
+
putString("typeCode", typeCode)
|
|
63
|
+
putMap("geometry", geometry.map)
|
|
64
|
+
putMap("attributes", getAttributes(attributes))
|
|
65
|
+
putString("name", name)
|
|
66
|
+
putMap("position", position.map)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
val GeoPoint.map
|
|
70
|
+
get() = Arguments.createMap().apply {
|
|
71
|
+
putString("type", type.name)
|
|
72
|
+
putDouble("lat", lat)
|
|
73
|
+
putDouble("lon", lon)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
val GeoPolygon.map
|
|
77
|
+
get() = Arguments.createMap().apply {
|
|
78
|
+
putString("type", type.name)
|
|
79
|
+
putArray("outer", Arguments.createArray().apply {
|
|
80
|
+
outer.forEach { point ->
|
|
81
|
+
pushMap(point.map)
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
if (inners.isNotEmpty()) {
|
|
85
|
+
putArray("inners", Arguments.createArray().apply {
|
|
86
|
+
inners.forEach { inner ->
|
|
87
|
+
Arguments.createArray().apply {
|
|
88
|
+
inner.forEach { point ->
|
|
89
|
+
pushMap(point.map)
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
})
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
val GeoMultiPoint.map
|
|
98
|
+
get() = Arguments.createMap().apply {
|
|
99
|
+
putString("type", type.name)
|
|
100
|
+
putArray("points", Arguments.createArray().apply {
|
|
101
|
+
points.forEach { point ->
|
|
102
|
+
pushMap(point.map)
|
|
103
|
+
}
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
val GeoMultiPolygon.map
|
|
108
|
+
get() = Arguments.createMap().apply {
|
|
109
|
+
putString("type", type.name)
|
|
110
|
+
putArray("polygons", Arguments.createArray().apply {
|
|
111
|
+
polygons.forEach { polygon ->
|
|
112
|
+
pushMap(polygon.map)
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
val Geometry.map
|
|
118
|
+
get() = when (this) {
|
|
119
|
+
is GeoPoint -> this.map
|
|
120
|
+
is GeoPolygon -> this.map
|
|
121
|
+
is GeoMultiPoint -> this.map
|
|
122
|
+
is GeoMultiPolygon -> this.map
|
|
123
|
+
else -> Arguments.createMap().apply {
|
|
124
|
+
putString("type", type.name)
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -2,7 +2,7 @@ package com.pointr
|
|
|
2
2
|
|
|
3
3
|
import androidx.annotation.StringDef
|
|
4
4
|
|
|
5
|
-
@StringDef(value = [PTRMapWidgetCommandType.SITE, PTRMapWidgetCommandType.BUILDING, PTRMapWidgetCommandType.LEVEL, PTRMapWidgetCommandType.POI, PTRMapWidgetCommandType.PATH, PTRMapWidgetCommandType.STATIC_PATH, PTRMapWidgetCommandType.START_AND_FOCUS])
|
|
5
|
+
@StringDef(value = [PTRMapWidgetCommandType.SITE, PTRMapWidgetCommandType.BUILDING, PTRMapWidgetCommandType.LEVEL, PTRMapWidgetCommandType.POI, PTRMapWidgetCommandType.PATH, PTRMapWidgetCommandType.STATIC_PATH, PTRMapWidgetCommandType.STATIC_WAYFINDING, PTRMapWidgetCommandType.START_AND_FOCUS])
|
|
6
6
|
annotation class PTRMapWidgetCommandType {
|
|
7
7
|
companion object {
|
|
8
8
|
const val SITE = "site"
|
|
@@ -11,6 +11,7 @@ annotation class PTRMapWidgetCommandType {
|
|
|
11
11
|
const val POI = "poi"
|
|
12
12
|
const val PATH = "path"
|
|
13
13
|
const val STATIC_PATH = "staticPath"
|
|
14
|
+
const val STATIC_WAYFINDING = "staticWayfinding"
|
|
14
15
|
const val MARK_MY_CAR_LEVEL = "markMyCarForLevel"
|
|
15
16
|
const val MARK_MY_CAR_SITE = "markMyCarForSite"
|
|
16
17
|
const val SHOW_MY_CAR_SITE = "showMyCarForSite"
|
|
@@ -27,15 +27,20 @@ import com.pointrlabs.core.management.models.deeplink.PTRMapWidgetMarkMyCarActio
|
|
|
27
27
|
import com.pointrlabs.core.management.models.deeplink.PTRMapWidgetPoiLocation
|
|
28
28
|
import com.pointrlabs.core.management.models.deeplink.PTRMapWidgetShowMyCarAction
|
|
29
29
|
import com.pointrlabs.core.management.models.deeplink.PTRMapWidgetSiteLocation
|
|
30
|
+
import com.pointrlabs.core.management.models.deeplink.PTRMapWidgetStaticWayfindingAction
|
|
30
31
|
import com.pointrlabs.core.management.models.deeplink.PTRMapWidgetWayfindingAction
|
|
31
32
|
import com.pointrlabs.core.nativecore.wrappers.Plog
|
|
33
|
+
import com.pointrlabs.core.poi.models.Poi
|
|
32
34
|
import com.pointrlabs.core.site.SiteManager
|
|
33
35
|
import com.pointrlabs.core.util.models.error.PTRError
|
|
34
36
|
import com.pointrlabs.core.wayfinding.WayfindingManager
|
|
37
|
+
import com.pointrlabs.core.wayfinding.session.RouteSession
|
|
38
|
+
import com.pointrlabs.core.wayfinding.session.RouteSessionState
|
|
35
39
|
import com.pointrlabs.ui.map.models.PTRMapSymbolLayer
|
|
36
40
|
import com.pointrlabs.ui.map.models.events_listeners.MapEventsListener
|
|
37
41
|
import com.pointrlabs.ui.map.models.events_listeners.MarkMyCarDetailsEvent
|
|
38
42
|
import com.pointrlabs.ui.map.models.events_listeners.MarkMyCarDetailsEventsListener
|
|
43
|
+
import com.pointrlabs.ui.map.models.events_listeners.WayfindingEventsListener
|
|
39
44
|
import com.pointrlabs.ui.map.views.PTRMapFragment
|
|
40
45
|
import com.pointrlabs.ui.map.views.PTRMapWidgetFragment
|
|
41
46
|
import com.pointrlabs.ui.map.views.wayfinding.MarkMyCarBottomSheet
|
|
@@ -44,24 +49,28 @@ import java.util.concurrent.Semaphore
|
|
|
44
49
|
|
|
45
50
|
@SuppressLint("LogNotTimber")
|
|
46
51
|
class PTRMapWidgetManager(private val reactContext: ReactApplicationContext) :
|
|
47
|
-
ViewGroupManager<FrameLayout>(), MapEventsListener, MarkMyCarDetailsEventsListener {
|
|
52
|
+
ViewGroupManager<FrameLayout>(), MapEventsListener, MarkMyCarDetailsEventsListener, WayfindingEventsListener {
|
|
48
53
|
|
|
49
54
|
override fun getName() = REACT_CLASS
|
|
50
55
|
|
|
51
56
|
private lateinit var frameLayout: FrameLayout
|
|
52
57
|
|
|
58
|
+
private var ptrMapWidgetFragment: PTRMapWidgetFragment? = null
|
|
59
|
+
|
|
53
60
|
private fun getMapWidgetFragment(action: PTRMapWidgetAction): PTRMapWidgetFragment {
|
|
54
|
-
Log.i(
|
|
61
|
+
Log.i(name, "Creating map widget fragment with action: $action")
|
|
55
62
|
waitForPointrToRun()
|
|
56
|
-
|
|
63
|
+
ptrMapWidgetFragment?.removeListener(this)
|
|
64
|
+
ptrMapWidgetFragment = PTRMapWidgetFragment.newInstance(
|
|
57
65
|
(reactContext.currentActivity as FragmentActivity).supportFragmentManager,
|
|
58
66
|
frameLayout.id,
|
|
59
67
|
PointrModule.mapWidgetConfiguration,
|
|
60
68
|
action
|
|
61
69
|
)
|
|
62
70
|
Choreographer.getInstance().postFrameCallback(frameCallback)
|
|
63
|
-
|
|
64
|
-
|
|
71
|
+
Log.v(name, "Adding itself as listener to map widget")
|
|
72
|
+
ptrMapWidgetFragment?.addListener(this)
|
|
73
|
+
return ptrMapWidgetFragment!!
|
|
65
74
|
}
|
|
66
75
|
|
|
67
76
|
/**
|
|
@@ -145,7 +154,7 @@ class PTRMapWidgetManager(private val reactContext: ReactApplicationContext) :
|
|
|
145
154
|
)
|
|
146
155
|
return@onComplete
|
|
147
156
|
}
|
|
148
|
-
|
|
157
|
+
Log.i(name, "Focus action completed, showing static path")
|
|
149
158
|
|
|
150
159
|
showStaticPath(
|
|
151
160
|
ptrMapWidgetFragment,
|
|
@@ -157,6 +166,15 @@ class PTRMapWidgetManager(private val reactContext: ReactApplicationContext) :
|
|
|
157
166
|
return
|
|
158
167
|
}
|
|
159
168
|
|
|
169
|
+
PTRMapWidgetCommandType.STATIC_WAYFINDING -> {
|
|
170
|
+
val siteId = args.getString(0).orEmpty()
|
|
171
|
+
val sourcePoiId = args.getString(1).orEmpty()
|
|
172
|
+
val destinationPoiId = args.getString(2).orEmpty()
|
|
173
|
+
val sourceLocation = PTRMapWidgetPoiLocation(siteId, sourcePoiId, isExternalIdentifier = true)
|
|
174
|
+
val destinationLocation = PTRMapWidgetPoiLocation(siteId, destinationPoiId, isExternalIdentifier = true)
|
|
175
|
+
PTRMapWidgetStaticWayfindingAction(sourceLocation, destinationLocation)
|
|
176
|
+
}
|
|
177
|
+
|
|
160
178
|
PTRMapWidgetCommandType.MARK_MY_CAR_SITE -> {
|
|
161
179
|
val siteId = args.getString(0).orEmpty()
|
|
162
180
|
val location = PTRMapWidgetSiteLocation(siteId, isExternalIdentifier = true)
|
|
@@ -287,6 +305,13 @@ class PTRMapWidgetManager(private val reactContext: ReactApplicationContext) :
|
|
|
287
305
|
event.putString("error", args[3] as String)
|
|
288
306
|
}
|
|
289
307
|
|
|
308
|
+
PTRMapWidgetCommandType.STATIC_WAYFINDING -> {
|
|
309
|
+
event.putString("siteExternalIdentifier", args[0] as String)
|
|
310
|
+
event.putString("sourcePoiExternalIdentifier", args[1] as String)
|
|
311
|
+
event.putString("destinationPoiExternalIdentifier", args[2] as String)
|
|
312
|
+
event.putString("error", args[3] as String)
|
|
313
|
+
}
|
|
314
|
+
|
|
290
315
|
PTRMapWidgetCommandType.MARK_MY_CAR_SITE -> {
|
|
291
316
|
event.putString("siteExternalIdentifier", args[0] as String)
|
|
292
317
|
event.putBoolean("shouldShowPopup", args[1] as Boolean)
|
|
@@ -351,6 +376,7 @@ class PTRMapWidgetManager(private val reactContext: ReactApplicationContext) :
|
|
|
351
376
|
return
|
|
352
377
|
}
|
|
353
378
|
}
|
|
379
|
+
Log.v(name, "sending onMapWidgetDidEndLoading with event: $event")
|
|
354
380
|
reactContext.getJSModule(RCTEventEmitter::class.java).receiveEvent(
|
|
355
381
|
frameLayout.id,
|
|
356
382
|
"onMapWidgetDidEndLoading",
|
|
@@ -358,12 +384,29 @@ class PTRMapWidgetManager(private val reactContext: ReactApplicationContext) :
|
|
|
358
384
|
)
|
|
359
385
|
}
|
|
360
386
|
|
|
387
|
+
private fun onWayfindingEvent(type: Int, poi: Poi?) {
|
|
388
|
+
val event: WritableMap = WritableNativeMap()
|
|
389
|
+
event.putInt("type" , type)
|
|
390
|
+
event.putMap("poi", poi?.map)
|
|
391
|
+
Log.v(name, "Sending event for wayfinding: $event")
|
|
392
|
+
reactContext.getJSModule(RCTEventEmitter::class.java).receiveEvent(
|
|
393
|
+
frameLayout.id,
|
|
394
|
+
"onWayfindingEvent",
|
|
395
|
+
event
|
|
396
|
+
)
|
|
397
|
+
}
|
|
398
|
+
|
|
361
399
|
override fun getExportedCustomBubblingEventTypeConstants(): Map<String, Any> {
|
|
362
400
|
return mapOf(
|
|
363
401
|
"onMapWidgetDidEndLoading" to mapOf(
|
|
364
402
|
"phasedRegistrationNames" to mapOf(
|
|
365
403
|
"bubbled" to "onMapWidgetDidEndLoading"
|
|
366
404
|
)
|
|
405
|
+
),
|
|
406
|
+
"onWayfindingEvent" to mapOf(
|
|
407
|
+
"phasedRegistrationNames" to mapOf(
|
|
408
|
+
"bubbled" to "onWayfindingEvent"
|
|
409
|
+
)
|
|
367
410
|
)
|
|
368
411
|
)
|
|
369
412
|
}
|
|
@@ -461,7 +504,7 @@ class PTRMapWidgetManager(private val reactContext: ReactApplicationContext) :
|
|
|
461
504
|
)
|
|
462
505
|
return@addLayer
|
|
463
506
|
}
|
|
464
|
-
Log.i(
|
|
507
|
+
Log.i(name, "Static path layer added successfully")
|
|
465
508
|
|
|
466
509
|
ptrMapWidgetFragment.mapFragment?.addFeatures(
|
|
467
510
|
listOf(source, target),
|
|
@@ -477,7 +520,7 @@ class PTRMapWidgetManager(private val reactContext: ReactApplicationContext) :
|
|
|
477
520
|
)
|
|
478
521
|
return@addFeatures
|
|
479
522
|
}
|
|
480
|
-
Log.i(
|
|
523
|
+
Log.i(name, "POI features added successfully")
|
|
481
524
|
ptrMapWidgetFragment.mapFragment?.currentRoute = route
|
|
482
525
|
mapWidgetDidEndLoading(
|
|
483
526
|
PTRMapWidgetCommandType.STATIC_PATH,
|
|
@@ -607,12 +650,12 @@ class PTRMapWidgetManager(private val reactContext: ReactApplicationContext) :
|
|
|
607
650
|
|
|
608
651
|
override fun mapDidEndLoading(mapFragment: PTRMapFragment) {
|
|
609
652
|
super.mapDidEndLoading(mapFragment)
|
|
610
|
-
Log.i(
|
|
653
|
+
Log.i(name, "Map loaded")
|
|
611
654
|
}
|
|
612
655
|
|
|
613
656
|
override fun mapDidFailToLoad(mapFragment: PTRMapFragment, ptrError: PTRError) {
|
|
614
657
|
super.mapDidFailToLoad(mapFragment, ptrError)
|
|
615
|
-
Log.e(
|
|
658
|
+
Log.e(name, "Map failed to load: $ptrError")
|
|
616
659
|
}
|
|
617
660
|
|
|
618
661
|
override fun onMarkMyCarDetailsEvent(
|
|
@@ -620,7 +663,7 @@ class PTRMapWidgetManager(private val reactContext: ReactApplicationContext) :
|
|
|
620
663
|
markMyCarDetailsEvent: MarkMyCarDetailsEvent
|
|
621
664
|
) {
|
|
622
665
|
super.onMarkMyCarDetailsEvent(markMyCarSheet, markMyCarDetailsEvent)
|
|
623
|
-
|
|
666
|
+
Log.i(name, "Mark my car details event: $markMyCarDetailsEvent")
|
|
624
667
|
}
|
|
625
668
|
|
|
626
669
|
private val frameCallback = object : Choreographer.FrameCallback {
|
|
@@ -640,6 +683,25 @@ class PTRMapWidgetManager(private val reactContext: ReactApplicationContext) :
|
|
|
640
683
|
}
|
|
641
684
|
}
|
|
642
685
|
|
|
686
|
+
override fun wayfindingDidShown() {
|
|
687
|
+
Log.v(name, "Wayfinding did shown")
|
|
688
|
+
val destination = (ptrMapWidgetFragment?.mapFragment?.currentRouteSession?.destination as? Poi)
|
|
689
|
+
onWayfindingEvent(0, destination)
|
|
690
|
+
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
override fun wayfindingDidTapClose() {
|
|
694
|
+
Log.v(name, "Wayfinding cancelled")
|
|
695
|
+
val destination = (ptrMapWidgetFragment?.mapFragment?.currentRouteSession?.destination as? Poi)
|
|
696
|
+
onWayfindingEvent(-1, destination)
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
override fun wayfindingDone() {
|
|
700
|
+
Log.v(name, "Wayfinding done")
|
|
701
|
+
val destination = (ptrMapWidgetFragment?.mapFragment?.currentRouteSession?.destination as? Poi)
|
|
702
|
+
onWayfindingEvent(1, destination)
|
|
703
|
+
}
|
|
704
|
+
|
|
643
705
|
companion object {
|
|
644
706
|
const val REACT_CLASS = "PTRMapWidget"
|
|
645
707
|
const val LAYER_STATIC_PATH = "sym-static-path"
|
|
@@ -8,11 +8,16 @@ import android.os.Parcelable
|
|
|
8
8
|
import android.util.Log
|
|
9
9
|
import com.facebook.react.bridge.Arguments
|
|
10
10
|
import com.facebook.react.bridge.Callback
|
|
11
|
+
import com.facebook.react.bridge.Promise
|
|
11
12
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
12
13
|
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
13
14
|
import com.facebook.react.bridge.ReactMethod
|
|
14
15
|
import com.facebook.react.bridge.WritableMap
|
|
15
16
|
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
17
|
+
import com.pointrlabs.core.geofence.GeofenceEvent
|
|
18
|
+
import com.pointrlabs.core.geofence.GeofenceEventType
|
|
19
|
+
import com.pointrlabs.core.geofence.GeofenceType
|
|
20
|
+
import com.pointrlabs.core.management.GeofenceManager
|
|
16
21
|
import com.pointrlabs.core.management.Pointr
|
|
17
22
|
import com.pointrlabs.core.management.PositioningManager
|
|
18
23
|
import com.pointrlabs.core.management.interfaces.PointrListener
|
|
@@ -20,6 +25,7 @@ import com.pointrlabs.core.management.models.Building
|
|
|
20
25
|
import com.pointrlabs.core.management.models.PTRParams
|
|
21
26
|
import com.pointrlabs.core.management.models.Site
|
|
22
27
|
import com.pointrlabs.core.nativecore.wrappers.Plog
|
|
28
|
+
import com.pointrlabs.core.poi.models.Poi
|
|
23
29
|
import com.pointrlabs.core.positioning.model.CalculatedPosition
|
|
24
30
|
import com.pointrlabs.core.positioning.model.PositioningTypes
|
|
25
31
|
import com.pointrlabs.core.util.models.error.PTRError
|
|
@@ -36,6 +42,7 @@ class PointrModule(reactContext: ReactApplicationContext) :
|
|
|
36
42
|
ReactContextBaseJavaModule(reactContext) {
|
|
37
43
|
|
|
38
44
|
private val positionManagerListener: PositioningManager.Listener
|
|
45
|
+
private val geofenceListener : GeofenceManager.Listener
|
|
39
46
|
private var listenerCount = 0
|
|
40
47
|
|
|
41
48
|
init {
|
|
@@ -45,6 +52,12 @@ class PointrModule(reactContext: ReactApplicationContext) :
|
|
|
45
52
|
sendEventToJs(reactContext, OnPositionManagerCalculatedLocation, params)
|
|
46
53
|
}
|
|
47
54
|
}
|
|
55
|
+
geofenceListener = object : GeofenceManager.Listener {
|
|
56
|
+
override fun onGeofenceManagerGeofenceEvent(geofenceEvent: GeofenceEvent) {
|
|
57
|
+
val params = buildParamsForGeofenceEvent(geofenceEvent)
|
|
58
|
+
sendEventToJs(reactContext, OnGeofenceEvent, params)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
48
61
|
setPointrListeners()
|
|
49
62
|
}
|
|
50
63
|
|
|
@@ -70,7 +83,7 @@ class PointrModule(reactContext: ReactApplicationContext) :
|
|
|
70
83
|
Log.e("Pointr", "Permission manager is not ready")
|
|
71
84
|
return
|
|
72
85
|
}
|
|
73
|
-
val activity = currentActivity ?: run {
|
|
86
|
+
val activity = reactApplicationContext.currentActivity ?: run {
|
|
74
87
|
Log.e("Pointr", "Could not get current activity")
|
|
75
88
|
return
|
|
76
89
|
}
|
|
@@ -111,7 +124,7 @@ class PointrModule(reactContext: ReactApplicationContext) :
|
|
|
111
124
|
clientId: String,
|
|
112
125
|
licenceKey: String,
|
|
113
126
|
baseUrl: String,
|
|
114
|
-
logLevel: Int
|
|
127
|
+
logLevel: Int = 0
|
|
115
128
|
) {
|
|
116
129
|
initialize(
|
|
117
130
|
reactApplicationContext,
|
|
@@ -171,6 +184,40 @@ class PointrModule(reactContext: ReactApplicationContext) :
|
|
|
171
184
|
}
|
|
172
185
|
}
|
|
173
186
|
|
|
187
|
+
@ReactMethod
|
|
188
|
+
fun getPois(siteId: String, promise: Promise) {
|
|
189
|
+
try {
|
|
190
|
+
Log.v(name, "get pois called $siteId")
|
|
191
|
+
// Ensure Pointr SDK is initialized
|
|
192
|
+
val site = Pointr.getPointr()?.siteManager?.getSiteByExternalIdentifier(siteId)
|
|
193
|
+
|
|
194
|
+
if (site == null) {
|
|
195
|
+
Log.e(name, "Site is null")
|
|
196
|
+
promise.reject("ERROR", "Site not found: $siteId")
|
|
197
|
+
return
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
Log.v(name, "getting pois")
|
|
201
|
+
|
|
202
|
+
// Get all POIs for the site
|
|
203
|
+
val pois = Pointr.getPointr()?.poiManager?.getPois(site)?.poiList ?: emptyList()
|
|
204
|
+
|
|
205
|
+
Log.v(name, "found ${pois.size} pois")
|
|
206
|
+
|
|
207
|
+
// Convert POIs to WritableArray
|
|
208
|
+
val poisArray = Arguments.createArray()
|
|
209
|
+
|
|
210
|
+
pois.forEach { poi ->
|
|
211
|
+
poisArray.pushMap(poi.map)
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
promise.resolve(poisArray)
|
|
215
|
+
|
|
216
|
+
} catch (e: Exception) {
|
|
217
|
+
promise.reject("ERROR", "Failed to get POIs: ${e.message}", e)
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
174
221
|
companion object {
|
|
175
222
|
const val NAME = "PTRNativePointrLibrary"
|
|
176
223
|
val mapWidgetConfiguration = PTRMapWidgetConfiguration.defaultConfiguration()
|
|
@@ -189,6 +236,8 @@ class PointrModule(reactContext: ReactApplicationContext) :
|
|
|
189
236
|
const val OnBuildingClicked = "OnBuildingClicked"
|
|
190
237
|
const val OnSiteClicked = "OnSiteClicked"
|
|
191
238
|
|
|
239
|
+
const val OnGeofenceEvent = "OnGeofenceEvent"
|
|
240
|
+
|
|
192
241
|
var shouldRequestPermissionsAtStartup = true
|
|
193
242
|
|
|
194
243
|
fun sendEventToJs(
|
|
@@ -305,6 +354,9 @@ class PointrModule(reactContext: ReactApplicationContext) :
|
|
|
305
354
|
dialog.setCanceledOnTouchOutside(false)
|
|
306
355
|
dialog.show()
|
|
307
356
|
}
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
|
|
308
360
|
// endregion [com.pointrlabs.core.map.models.events_listeners.CustomMapEventsListener]
|
|
309
361
|
}
|
|
310
362
|
|
|
@@ -343,7 +395,7 @@ class PointrModule(reactContext: ReactApplicationContext) :
|
|
|
343
395
|
clientId: String,
|
|
344
396
|
licenceKey: String,
|
|
345
397
|
baseUrl: String,
|
|
346
|
-
logLevel: Int
|
|
398
|
+
logLevel: Int = 0
|
|
347
399
|
) {
|
|
348
400
|
val ptrParams = PTRParams(clientId, licenceKey, baseUrl)
|
|
349
401
|
try {
|
|
@@ -355,6 +407,55 @@ class PointrModule(reactContext: ReactApplicationContext) :
|
|
|
355
407
|
Pointr.with(reactContext, ptrParams)
|
|
356
408
|
}
|
|
357
409
|
|
|
410
|
+
private fun buildParamsForGeofenceEvent(geofenceEvent: GeofenceEvent): WritableMap {
|
|
411
|
+
val params: WritableMap = Arguments.createMap()
|
|
412
|
+
|
|
413
|
+
//TODO: Add PTRGeofenceEvent's timestamp
|
|
414
|
+
|
|
415
|
+
// Event type (enter, exit)
|
|
416
|
+
val eventType = when (geofenceEvent.type) {
|
|
417
|
+
GeofenceEventType.Enter -> "enter"
|
|
418
|
+
else -> "exit"
|
|
419
|
+
}
|
|
420
|
+
params.putString("eventType", eventType)
|
|
421
|
+
|
|
422
|
+
// Geofence information
|
|
423
|
+
val geofence = geofenceEvent.geofence
|
|
424
|
+
val geofenceMap = Arguments.createMap().apply {
|
|
425
|
+
putString("id", geofence.identifier)
|
|
426
|
+
putString("externalId", geofence.externalIdentifier)
|
|
427
|
+
putString("name", geofence.name)
|
|
428
|
+
|
|
429
|
+
val geofenceType = when (geofence.type) {
|
|
430
|
+
GeofenceType.GPS -> "gps"
|
|
431
|
+
else -> "beacon"
|
|
432
|
+
}
|
|
433
|
+
params.putString("geofenceType", geofenceType)
|
|
434
|
+
|
|
435
|
+
// Position information
|
|
436
|
+
val position = geofence.position
|
|
437
|
+
val positionMap = Arguments.createMap().apply {
|
|
438
|
+
putDouble("latitude", position.lat)
|
|
439
|
+
putDouble("longitude", position.lon)
|
|
440
|
+
}
|
|
441
|
+
putMap("position", positionMap)
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
params.putMap("geofence", geofenceMap)
|
|
445
|
+
|
|
446
|
+
// Geofence notification information if available
|
|
447
|
+
geofenceEvent.geofenceNotification?.let { notification ->
|
|
448
|
+
val notificationMap = Arguments.createMap().apply {
|
|
449
|
+
putString("id", notification.id)
|
|
450
|
+
putString("message", notification.message)
|
|
451
|
+
putLong("timestamp", notification.timeStamp)
|
|
452
|
+
}
|
|
453
|
+
params.putMap("geofenceNotification", notificationMap)
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
return params
|
|
457
|
+
}
|
|
458
|
+
|
|
358
459
|
private fun onPointrStartEnded(action: (String) -> Unit) {
|
|
359
460
|
val pointr = Pointr.getPointr() ?: return
|
|
360
461
|
pointr.addListener(object : PointrListener {
|
|
@@ -373,12 +474,14 @@ class PointrModule(reactContext: ReactApplicationContext) :
|
|
|
373
474
|
val pointr = Pointr.getPointr() ?: return
|
|
374
475
|
if (pointr.state != Pointr.State.RUNNING) return
|
|
375
476
|
pointr.positioningManager?.removeListener(positionManagerListener)
|
|
477
|
+
pointr.geofenceManager?.removeListener(geofenceListener)
|
|
376
478
|
}
|
|
377
479
|
|
|
378
480
|
private fun setPointrListeners() {
|
|
379
481
|
val pointr = Pointr.getPointr() ?: return
|
|
380
482
|
if (pointr.state != Pointr.State.RUNNING) return
|
|
381
483
|
pointr.positioningManager?.addListener(positionManagerListener)
|
|
484
|
+
pointr.geofenceManager?.addListener(geofenceListener)
|
|
382
485
|
if (shouldRequestPermissionsAtStartup) {
|
|
383
486
|
requestPermissions()
|
|
384
487
|
} else {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|