@situm/cordova 3.5.2 → 3.5.4
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/package.json +1 -1
- package/plugin.xml +2 -1
- package/src/android/app/build.gradle +1 -1
- package/src/android/app/src/main/java/es/situm/plugin/JsonUtils.java +52 -0
- package/src/android/app/src/main/java/es/situm/plugin/PluginHelper.java +46 -0
- package/src/android/app/src/main/java/es/situm/plugin/SitumPlugin.java +2 -0
- package/src/android/situm.gradle +1 -1
- package/www/Interfaces.js +16 -0
- package/www/map-view-controller.js +76 -0
- package/www/map-view.js +11 -5
- package/www/situm.js +11 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@situm/cordova",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.4",
|
|
4
4
|
"description": "Situm Wayfinding for Capacitor and Cordova. Integrate plug&play indoor navigation experience with floorplans, POIs, routes and turn-by-turn directions in no time. With the power of Situm.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"repository": "https://github.com/situmtech/cordova",
|
package/plugin.xml
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
|
4
4
|
id="@situm/cordova"
|
|
5
|
-
version="3.5.
|
|
5
|
+
version="3.5.4">
|
|
6
6
|
<name>Situm Cordova plugin Official</name>
|
|
7
7
|
<description>This is the stable branch.</description>
|
|
8
8
|
<license>MIT</license>
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
</config-file>
|
|
47
47
|
|
|
48
48
|
<source-file src="src/android/app/src/main/java/es/situm/plugin/SitumPlugin.java" target-dir="src/es/situm/plugin" />
|
|
49
|
+
<source-file src="src/android/app/src/main/java/es/situm/plugin/JsonUtils.java" target-dir="src/es/situm/plugin" />
|
|
49
50
|
<source-file src="src/android/app/src/main/java/es/situm/plugin/PluginHelper.java" target-dir="src/es/situm/plugin" />
|
|
50
51
|
<source-file src="src/android/app/src/main/java/es/situm/plugin/SitumMapper.java" target-dir="src/es/situm/plugin" />
|
|
51
52
|
<source-file src="src/android/app/src/main/java/es/situm/plugin/DateUtils.java" target-dir="src/es/situm/plugin" />
|
|
@@ -44,7 +44,7 @@ dependencies {
|
|
|
44
44
|
implementation ('com.googlecode.json-simple:json-simple:1.1.1'){
|
|
45
45
|
exclude group: 'junit', module:'junit'
|
|
46
46
|
}
|
|
47
|
-
implementation ('es.situm:situm-sdk:3.
|
|
47
|
+
implementation ('es.situm:situm-sdk:3.13.0@aar') {
|
|
48
48
|
transitive = true
|
|
49
49
|
}
|
|
50
50
|
implementation 'org.apache.cordova:framework:10.1.1'
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
package es.situm.plugin;
|
|
2
|
+
|
|
3
|
+
import org.json.JSONArray;
|
|
4
|
+
import org.json.JSONException;
|
|
5
|
+
import org.json.JSONObject;
|
|
6
|
+
|
|
7
|
+
import java.util.ArrayList;
|
|
8
|
+
import java.util.HashMap;
|
|
9
|
+
import java.util.Iterator;
|
|
10
|
+
import java.util.List;
|
|
11
|
+
import java.util.Map;
|
|
12
|
+
import java.util.Stack;
|
|
13
|
+
|
|
14
|
+
public class JsonUtils {
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
public static Map<String, Object> toMap(JSONObject jsonObject) {
|
|
18
|
+
if (jsonObject == null) {
|
|
19
|
+
return new HashMap<>();
|
|
20
|
+
}
|
|
21
|
+
Map<String, Object> finalMap = new HashMap<>();
|
|
22
|
+
Stack<Object> stack = new Stack<>();
|
|
23
|
+
Stack<Map<String, Object>> mapsStack = new Stack<>();
|
|
24
|
+
stack.push(jsonObject);
|
|
25
|
+
mapsStack.push(finalMap);
|
|
26
|
+
while (!stack.isEmpty()) {
|
|
27
|
+
Object item = stack.pop();
|
|
28
|
+
Map<String, Object> map = mapsStack.pop();
|
|
29
|
+
if (item instanceof JSONObject) {
|
|
30
|
+
Iterator<String> keys = ((JSONObject) item).keys();
|
|
31
|
+
while (keys.hasNext()) {
|
|
32
|
+
String key = keys.next();
|
|
33
|
+
Object value = null;
|
|
34
|
+
try {
|
|
35
|
+
value = ((JSONObject) item).get(key);
|
|
36
|
+
} catch (JSONException e) {
|
|
37
|
+
|
|
38
|
+
}
|
|
39
|
+
if (value instanceof JSONObject) {
|
|
40
|
+
stack.push(value);
|
|
41
|
+
Map<String, Object> newMap = new HashMap<>();
|
|
42
|
+
mapsStack.push(newMap);
|
|
43
|
+
map.put(key, newMap);
|
|
44
|
+
} else {
|
|
45
|
+
map.put(key, value);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return finalMap;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -19,6 +19,7 @@ import org.json.JSONObject;
|
|
|
19
19
|
import java.util.Collection;
|
|
20
20
|
import java.util.HashMap;
|
|
21
21
|
import java.util.List;
|
|
22
|
+
import java.util.Map;
|
|
22
23
|
|
|
23
24
|
import es.situm.sdk.SitumSdk;
|
|
24
25
|
import es.situm.sdk.communication.CommunicationManager;
|
|
@@ -38,6 +39,7 @@ import es.situm.sdk.model.directions.Route;
|
|
|
38
39
|
import es.situm.sdk.model.location.Location;
|
|
39
40
|
import es.situm.sdk.model.navigation.NavigationProgress;
|
|
40
41
|
import es.situm.sdk.model.realtime.RealTimeData;
|
|
42
|
+
import es.situm.sdk.navigation.ExternalNavigation;
|
|
41
43
|
import es.situm.sdk.navigation.NavigationListener;
|
|
42
44
|
import es.situm.sdk.navigation.NavigationManager;
|
|
43
45
|
import es.situm.sdk.navigation.NavigationRequest;
|
|
@@ -650,6 +652,50 @@ public class PluginHelper {
|
|
|
650
652
|
callbackContext.sendPluginResult(new PluginResult(Status.OK, "Cache invalidated"));
|
|
651
653
|
}
|
|
652
654
|
|
|
655
|
+
public void updateNavigationState(final CordovaInterface cordova,
|
|
656
|
+
CordovaWebView webView,
|
|
657
|
+
JSONArray args,
|
|
658
|
+
final CallbackContext callbackContext) {
|
|
659
|
+
ExternalNavigation externalNavigation = null;
|
|
660
|
+
try {
|
|
661
|
+
JSONObject jsonObject = args.getJSONObject(0);
|
|
662
|
+
String type = jsonObject.getString("messageType");
|
|
663
|
+
ExternalNavigation.MessageType messageType;
|
|
664
|
+
switch (type) {
|
|
665
|
+
case "NavigationStarted":
|
|
666
|
+
messageType = ExternalNavigation.MessageType.NAVIGATION_STARTED;
|
|
667
|
+
break;
|
|
668
|
+
case "NavigationUpdated":
|
|
669
|
+
messageType = ExternalNavigation.MessageType.NAVIGATION_UPDATED;
|
|
670
|
+
break;
|
|
671
|
+
case "DestinationReached":
|
|
672
|
+
messageType = ExternalNavigation.MessageType.DESTINATION_REACHED;
|
|
673
|
+
break;
|
|
674
|
+
case "OutsideRoute":
|
|
675
|
+
messageType = ExternalNavigation.MessageType.OUTSIDE_ROUTE;
|
|
676
|
+
break;
|
|
677
|
+
case "NavigationCancelled":
|
|
678
|
+
messageType = ExternalNavigation.MessageType.NAVIGATION_CANCELLED;
|
|
679
|
+
break;
|
|
680
|
+
default:
|
|
681
|
+
callbackContext.sendPluginResult(new PluginResult(Status.ERROR, "MessageType invalid"));
|
|
682
|
+
return;
|
|
683
|
+
}
|
|
684
|
+
Map<String, Object> payload;
|
|
685
|
+
if (jsonObject.has("payload")) {
|
|
686
|
+
payload = JsonUtils.toMap(jsonObject.getJSONObject("payload"));
|
|
687
|
+
} else {
|
|
688
|
+
payload = new HashMap<>();
|
|
689
|
+
}
|
|
690
|
+
externalNavigation = new ExternalNavigation(messageType,payload);
|
|
691
|
+
} catch (JSONException e) {
|
|
692
|
+
callbackContext.sendPluginResult(new PluginResult(Status.ERROR, "Error parsing the external navigation json" + e.getMessage()));
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
getNavigationManagerInstance().updateNavigationState(externalNavigation);
|
|
696
|
+
callbackContext.sendPluginResult(new PluginResult(Status.OK, "Navigation state changed"));
|
|
697
|
+
}
|
|
698
|
+
|
|
653
699
|
public void requestNavigationUpdates(final CordovaInterface cordova,
|
|
654
700
|
CordovaWebView webView,
|
|
655
701
|
JSONArray args,
|
|
@@ -102,6 +102,8 @@ public class SitumPlugin extends CordovaPlugin {
|
|
|
102
102
|
getPluginInstance().requestRealTimeUpdates(cordova, webView, args, callbackContext);
|
|
103
103
|
} else if(action.equalsIgnoreCase("removeRealTimeUpdates")) {
|
|
104
104
|
getPluginInstance().removeRealTimeUpdates(cordova, webView, args, callbackContext);
|
|
105
|
+
} else if(action.equalsIgnoreCase("updateNavigationState")) {
|
|
106
|
+
getPluginInstance().updateNavigationState(cordova, webView, args, callbackContext);
|
|
105
107
|
} else {
|
|
106
108
|
getPluginInstance().returnDefaultResponse(callbackContext);
|
|
107
109
|
}
|
package/src/android/situm.gradle
CHANGED
package/www/Interfaces.js
CHANGED
|
@@ -650,6 +650,22 @@ var DirectionsRequest = {
|
|
|
650
650
|
|
|
651
651
|
module.exports = DirectionsRequest;
|
|
652
652
|
|
|
653
|
+
|
|
654
|
+
/**
|
|
655
|
+
* @name
|
|
656
|
+
* ExternalNavigation
|
|
657
|
+
* @description
|
|
658
|
+
* For internal use only.
|
|
659
|
+
* @property {String} messageType
|
|
660
|
+
* @property {Map} payload
|
|
661
|
+
*/
|
|
662
|
+
var ExternalNavigation = {
|
|
663
|
+
messageType,
|
|
664
|
+
payload
|
|
665
|
+
};
|
|
666
|
+
|
|
667
|
+
module.exports = ExternalNavigation;
|
|
668
|
+
|
|
653
669
|
/**
|
|
654
670
|
* @name
|
|
655
671
|
* DirectionsOptions
|
|
@@ -52,6 +52,7 @@ class MapViewControllerImpl {
|
|
|
52
52
|
_buildings = undefined;
|
|
53
53
|
_mapView = undefined;
|
|
54
54
|
_isNavigating = false;
|
|
55
|
+
_navigationType = "";
|
|
55
56
|
|
|
56
57
|
constructor() {
|
|
57
58
|
Situm.internalSetEventDelegate(this._handleSdkNativeEvents.bind(this));
|
|
@@ -59,6 +60,23 @@ class MapViewControllerImpl {
|
|
|
59
60
|
|
|
60
61
|
_prepare(mapView) {
|
|
61
62
|
this._mapView = mapView;
|
|
63
|
+
let useViewerNavigation = mapView.getAttribute('use-viewer-navigation')
|
|
64
|
+
? mapView.getAttribute('use-viewer-navigation')
|
|
65
|
+
: null;
|
|
66
|
+
if (useViewerNavigation != null) {
|
|
67
|
+
this._setNavigationType(useViewerNavigation);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
_setNavigationType(useViewerNavigation) {
|
|
72
|
+
if (useViewerNavigation) {
|
|
73
|
+
if (useViewerNavigation === "true") {
|
|
74
|
+
this._navigationType = 'webAssembly';
|
|
75
|
+
} else {
|
|
76
|
+
this._navigationType = 'sdk';
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
62
80
|
}
|
|
63
81
|
|
|
64
82
|
_setOnLoadCallback(callback) {
|
|
@@ -141,6 +159,9 @@ class MapViewControllerImpl {
|
|
|
141
159
|
this._onLoadCallback(this);
|
|
142
160
|
console.debug('Map is ready!');
|
|
143
161
|
}
|
|
162
|
+
if (this._navigationType) {
|
|
163
|
+
this._sendNavigationConfig(this._navigationType);
|
|
164
|
+
}
|
|
144
165
|
break;
|
|
145
166
|
case 'cartography.poi_selected':
|
|
146
167
|
console.debug(`poi (${m.payload.identifier}) was selected`);
|
|
@@ -170,6 +191,15 @@ class MapViewControllerImpl {
|
|
|
170
191
|
case 'navigation.stopped':
|
|
171
192
|
this._onNavigationCancel();
|
|
172
193
|
break;
|
|
194
|
+
case 'viewer.navigation.started':
|
|
195
|
+
this._onViewerNavigationStarted(m.payload);
|
|
196
|
+
break;
|
|
197
|
+
case 'viewer.navigation.updated':
|
|
198
|
+
this._onViewerNavigationUpdated(m.payload);
|
|
199
|
+
break;
|
|
200
|
+
case 'viewer.navigation.stopped':
|
|
201
|
+
this._onViewerNavigationStopped(m.payload);
|
|
202
|
+
break;
|
|
173
203
|
default:
|
|
174
204
|
console.debug('Got unmanaged message: ', m);
|
|
175
205
|
break;
|
|
@@ -317,6 +347,45 @@ class MapViewControllerImpl {
|
|
|
317
347
|
);
|
|
318
348
|
}
|
|
319
349
|
|
|
350
|
+
_onViewerNavigationStarted(webPayload) {
|
|
351
|
+
if (this._isNavigating) {
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
this._isNavigating = true;
|
|
355
|
+
let externalNavigation = { messageType: "NavigationStarted", payload: webPayload};
|
|
356
|
+
Situm.updateNavigationState(externalNavigation, () => {}, () => {});
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
_onViewerNavigationUpdated(webPayload) {
|
|
360
|
+
if (!this._isNavigating) {
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
if (webPayload.type == "PROGRESS") {
|
|
364
|
+
let externalNavigation = { messageType: "NavigationUpdated", payload: webPayload};
|
|
365
|
+
Situm.updateNavigationState(externalNavigation, () => {}, () => {});
|
|
366
|
+
} else if (webPayload.type == "DESTINATION_REACHED") {
|
|
367
|
+
let externalNavigation = { messageType: "DestinationReached", payload: webPayload};
|
|
368
|
+
Situm.updateNavigationState(externalNavigation, () => {}, () => {});
|
|
369
|
+
this._isNavigating = false;
|
|
370
|
+
} else if (webPayload.type == "OUT_OF_ROUTE") {
|
|
371
|
+
let externalNavigation = { messageType: "OutsideRoute", payload: webPayload};
|
|
372
|
+
Situm.updateNavigationState(externalNavigation, () => {}, () => {});
|
|
373
|
+
this._isNavigating = false;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
_onViewerNavigationStopped(webPayload) {
|
|
379
|
+
if (!this._isNavigating) {
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
this._isNavigating = false;
|
|
383
|
+
let externalNavigation = { messageType: "NavigationCancelled", payload: webPayload};
|
|
384
|
+
Situm.updateNavigationState(externalNavigation, () => {}, () => {});
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
|
|
320
389
|
// ==================================================
|
|
321
390
|
// ACTIONS
|
|
322
391
|
// ==================================================
|
|
@@ -335,6 +404,13 @@ class MapViewControllerImpl {
|
|
|
335
404
|
});
|
|
336
405
|
}
|
|
337
406
|
|
|
407
|
+
_sendNavigationConfig(navigationType) {
|
|
408
|
+
if (window.cordova.platformId !== 'android') {
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
this._sendMessageToViewer('app.set_config_item', [{key:'internal.navigationLibrary',value:navigationType}]);
|
|
412
|
+
}
|
|
413
|
+
|
|
338
414
|
/**
|
|
339
415
|
* Allows you to navigate to a {@link POI} programmatically in your venue. This will cause the {@link MapView} to start navigation mode displaying the route between the user's location and the POI specified by parameters.
|
|
340
416
|
*
|
package/www/map-view.js
CHANGED
|
@@ -12,10 +12,10 @@ const MapViewController = require('./map-view-controller');
|
|
|
12
12
|
* remote-identifier="YOUR_REMOTE_IDENTIFIER"
|
|
13
13
|
* />
|
|
14
14
|
* </pre>
|
|
15
|
-
*
|
|
15
|
+
*
|
|
16
16
|
* <button id="copySnippetButton">Copy</button>
|
|
17
17
|
* </div>
|
|
18
|
-
*
|
|
18
|
+
*
|
|
19
19
|
* <script>
|
|
20
20
|
document.getElementById("copySnippetButton").addEventListener("click", function() {
|
|
21
21
|
var textToCopy = document.getElementById("textToCopy");
|
|
@@ -87,9 +87,15 @@ class MapView extends HTMLElement {
|
|
|
87
87
|
let viewerDomain = this._formatValidDomain(
|
|
88
88
|
this.getAttribute('viewer-domain')
|
|
89
89
|
);
|
|
90
|
-
let situmApiKey = this.getAttribute('situm-api-key')
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
let situmApiKey = this.getAttribute('situm-api-key')
|
|
91
|
+
? this.getAttribute('situm-api-key')
|
|
92
|
+
: '';
|
|
93
|
+
let buildingIdentifier = this.getAttribute('building-identifier')
|
|
94
|
+
? this.getAttribute('building-identifier')
|
|
95
|
+
: '';
|
|
96
|
+
let language = this.getAttribute('language')
|
|
97
|
+
? this.getAttribute('language')
|
|
98
|
+
: '';
|
|
93
99
|
|
|
94
100
|
let situmApiKeyQP = situmApiKey.length > 0 ? `apikey=${situmApiKey}` : '';
|
|
95
101
|
let buildingIdentifierQP =
|
package/www/situm.js
CHANGED
|
@@ -409,6 +409,17 @@ var Situm = {
|
|
|
409
409
|
updateNavigationWithLocation: function (location, cb, error) {
|
|
410
410
|
exec(cb, error, PLUGIN_NAME, 'updateNavigationWithLocation', [location]);
|
|
411
411
|
},
|
|
412
|
+
/**
|
|
413
|
+
* For internal use only
|
|
414
|
+
* @description Informs NavigationManager object the change of the user's location.
|
|
415
|
+
* @param {ExternalNavigation} externalNavigation Navigation info.
|
|
416
|
+
* @param {function} cb Cordova native callback to recive data.
|
|
417
|
+
* @param {function} error Cordova native callback to recive errors.
|
|
418
|
+
* @return {boolean} success True if there is a listener to which notify progress update. False if there isn't, so this method do nothing.
|
|
419
|
+
*/
|
|
420
|
+
updateNavigationState: function (externalNavigation, cb, error) {
|
|
421
|
+
exec(cb, error, PLUGIN_NAME, 'updateNavigationState', [externalNavigation]);
|
|
422
|
+
},
|
|
412
423
|
/**
|
|
413
424
|
* Removes all location updates.
|
|
414
425
|
* @description Removes all location updates. This removes the internal state of the manager, including the listener provided in requestNavigationUpdates(NavigationRequest, NavigationListener), so it won't receive more progress updates.
|