@situm/cordova 3.0.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.
Files changed (313) hide show
  1. package/CHANGELOG.md +3 -0
  2. package/CHANGELOG_UNRELEASED.md +28 -0
  3. package/Jenkinsfile +84 -0
  4. package/LICENSE +21 -0
  5. package/README.md +472 -0
  6. package/azure/common-steps.yaml +5 -0
  7. package/azure-pipelines.yml +336 -0
  8. package/docs/JSDoc/MapView.html +300 -0
  9. package/docs/JSDoc/MapViewControllerImpl.html +299 -0
  10. package/docs/JSDoc/Situm.html +5257 -0
  11. package/docs/JSDoc/android_Interfaces.js.html +825 -0
  12. package/docs/JSDoc/android_situm.js.html +380 -0
  13. package/docs/JSDoc/fonts/glyphicons-halflings-regular.eot +0 -0
  14. package/docs/JSDoc/fonts/glyphicons-halflings-regular.svg +288 -0
  15. package/docs/JSDoc/fonts/glyphicons-halflings-regular.ttf +0 -0
  16. package/docs/JSDoc/fonts/glyphicons-halflings-regular.woff +0 -0
  17. package/docs/JSDoc/fonts/glyphicons-halflings-regular.woff2 +0 -0
  18. package/docs/JSDoc/global.html +7538 -0
  19. package/docs/JSDoc/img/toast-ui.png +0 -0
  20. package/docs/JSDoc/index.html +90 -0
  21. package/docs/JSDoc/map-view-controller.js.html +307 -0
  22. package/docs/JSDoc/map-view.js.html +172 -0
  23. package/docs/JSDoc/scripts/jquery.min.js +2 -0
  24. package/docs/JSDoc/scripts/linenumber.js +30 -0
  25. package/docs/JSDoc/scripts/prettify/Apache-License-2.0.txt +202 -0
  26. package/docs/JSDoc/scripts/prettify/lang-css.js +2 -0
  27. package/docs/JSDoc/scripts/prettify/prettify.js +28 -0
  28. package/docs/JSDoc/scripts/tui-doc.js +200 -0
  29. package/docs/JSDoc/styles/bootstrap.min.css +6 -0
  30. package/docs/JSDoc/styles/custom.css +23 -0
  31. package/docs/JSDoc/styles/prettify-jsdoc.css +111 -0
  32. package/docs/JSDoc/styles/prettify-tomorrow.css +132 -0
  33. package/docs/JSDoc/styles/tui-doc.css +485 -0
  34. package/docs/conf.json +28 -0
  35. package/docs/getting-started.md +298 -0
  36. package/docs/imagotype-SITUM-transparent-90.png +0 -0
  37. package/docs/static/styles/custom.css +23 -0
  38. package/package.json +60 -0
  39. package/plugin.xml +102 -0
  40. package/scripts/update_changelog.sh +22 -0
  41. package/src/android/app/build.gradle +51 -0
  42. package/src/android/app/proguard-rules.pro +21 -0
  43. package/src/android/app/src/main/AndroidManifest.xml +11 -0
  44. package/src/android/app/src/main/java/es/situm/plugin/DateUtils.java +15 -0
  45. package/src/android/app/src/main/java/es/situm/plugin/PluginHelper.java +919 -0
  46. package/src/android/app/src/main/java/es/situm/plugin/SitumMapper.java +968 -0
  47. package/src/android/app/src/main/java/es/situm/plugin/SitumPlugin.java +109 -0
  48. package/src/android/app/src/main/res/drawable/ic_launcher_background.xml +170 -0
  49. package/src/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml +34 -0
  50. package/src/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +5 -0
  51. package/src/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +5 -0
  52. package/src/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  53. package/src/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  54. package/src/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  55. package/src/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  56. package/src/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  57. package/src/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  58. package/src/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  59. package/src/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  60. package/src/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  61. package/src/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  62. package/src/android/app/src/main/res/values/colors.xml +6 -0
  63. package/src/android/app/src/main/res/values/strings.xml +3 -0
  64. package/src/android/app/src/main/res/values/styles.xml +11 -0
  65. package/src/android/app/src/test/java/es/situm/plugin/PluginHelperTest.java +27 -0
  66. package/src/android/app/src/test/java/es/situm/plugin/SitumMapperTest.java +1485 -0
  67. package/src/android/app/src/test/java/es/situm/plugin/angle/AngleCreator.java +46 -0
  68. package/src/android/app/src/test/java/es/situm/plugin/bounds/BoundsCreator.java +50 -0
  69. package/src/android/app/src/test/java/es/situm/plugin/building/BuildingCreator.java +76 -0
  70. package/src/android/app/src/test/java/es/situm/plugin/cartesianCoordinate/CartesianCoordinateCreator.java +31 -0
  71. package/src/android/app/src/test/java/es/situm/plugin/circle/CircleCreator.java +41 -0
  72. package/src/android/app/src/test/java/es/situm/plugin/coordinate/CoordinateCreator.java +32 -0
  73. package/src/android/app/src/test/java/es/situm/plugin/dimensions/DimensionsCreator.java +31 -0
  74. package/src/android/app/src/test/java/es/situm/plugin/directionsRequest/DirectionsRequestCreator.java +105 -0
  75. package/src/android/app/src/test/java/es/situm/plugin/event/EventCreator.java +108 -0
  76. package/src/android/app/src/test/java/es/situm/plugin/floor/FloorCreator.java +58 -0
  77. package/src/android/app/src/test/java/es/situm/plugin/indication/IndicationCreator.java +40 -0
  78. package/src/android/app/src/test/java/es/situm/plugin/location/LocationCreator.java +197 -0
  79. package/src/android/app/src/test/java/es/situm/plugin/locationRequest/LocationRequestCreator.java +45 -0
  80. package/src/android/app/src/test/java/es/situm/plugin/locationStatus/LocationStatusCreator.java +211 -0
  81. package/src/android/app/src/test/java/es/situm/plugin/navigationProgress/NavigationProgressCreator.java +154 -0
  82. package/src/android/app/src/test/java/es/situm/plugin/poi/PoiCreator.java +126 -0
  83. package/src/android/app/src/test/java/es/situm/plugin/poiCategory/PoiCategoryCreator.java +38 -0
  84. package/src/android/app/src/test/java/es/situm/plugin/point/PointCreator.java +200 -0
  85. package/src/android/app/src/test/java/es/situm/plugin/route/RouteCreator.java +142 -0
  86. package/src/android/app/src/test/java/es/situm/plugin/routeStep/RouteStepCreator.java +173 -0
  87. package/src/android/app/src/test/java/es/situm/plugin/situmConversionArea/SitumConversionAreaCreator.java +35 -0
  88. package/src/android/build.gradle +31 -0
  89. package/src/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  90. package/src/android/gradle/wrapper/gradle-wrapper.properties +6 -0
  91. package/src/android/gradle.properties +16 -0
  92. package/src/android/gradlew +172 -0
  93. package/src/android/gradlew.bat +84 -0
  94. package/src/android/settings.gradle +3 -0
  95. package/src/android/situm.gradle +19 -0
  96. package/src/ios/Classes/Private/CDVDebug.h +25 -0
  97. package/src/ios/Classes/Private/CDVJSON_private.h +31 -0
  98. package/src/ios/Classes/Private/CDVJSON_private.m +99 -0
  99. package/src/ios/Classes/Private/CDVPlugin+Private.h +24 -0
  100. package/src/ios/Classes/Private/CDVPlugins/CDVGestureHandler/CDVGestureHandler.h +26 -0
  101. package/src/ios/Classes/Private/CDVPlugins/CDVGestureHandler/CDVGestureHandler.m +70 -0
  102. package/src/ios/Classes/Private/CDVPlugins/CDVHandleOpenURL/CDVHandleOpenURL.h +27 -0
  103. package/src/ios/Classes/Private/CDVPlugins/CDVHandleOpenURL/CDVHandleOpenURL.m +86 -0
  104. package/src/ios/Classes/Private/CDVPlugins/CDVIntentAndNavigationFilter/CDVIntentAndNavigationFilter.h +34 -0
  105. package/src/ios/Classes/Private/CDVPlugins/CDVIntentAndNavigationFilter/CDVIntentAndNavigationFilter.m +153 -0
  106. package/src/ios/Classes/Private/CDVPlugins/CDVLocalStorage/CDVLocalStorage.h +50 -0
  107. package/src/ios/Classes/Private/CDVPlugins/CDVLocalStorage/CDVLocalStorage.m +487 -0
  108. package/src/ios/Classes/Private/CDVPlugins/CDVLogger/CDVLogger.h +26 -0
  109. package/src/ios/Classes/Private/CDVPlugins/CDVLogger/CDVLogger.m +37 -0
  110. package/src/ios/Classes/Private/CDVPlugins/CDVUIWebViewEngine/CDVUIWebViewDelegate.h +41 -0
  111. package/src/ios/Classes/Private/CDVPlugins/CDVUIWebViewEngine/CDVUIWebViewDelegate.m +399 -0
  112. package/src/ios/Classes/Private/CDVPlugins/CDVUIWebViewEngine/CDVUIWebViewEngine.h +27 -0
  113. package/src/ios/Classes/Private/CDVPlugins/CDVUIWebViewEngine/CDVUIWebViewEngine.m +202 -0
  114. package/src/ios/Classes/Private/CDVPlugins/CDVUIWebViewEngine/CDVUIWebViewNavigationDelegate.h +29 -0
  115. package/src/ios/Classes/Private/CDVPlugins/CDVUIWebViewEngine/CDVUIWebViewNavigationDelegate.m +153 -0
  116. package/src/ios/Classes/Public/CDV.h +32 -0
  117. package/src/ios/Classes/Public/CDVAppDelegate.h +28 -0
  118. package/src/ios/Classes/Public/CDVAppDelegate.m +118 -0
  119. package/src/ios/Classes/Public/CDVAvailability.h +111 -0
  120. package/src/ios/Classes/Public/CDVAvailabilityDeprecated.h +26 -0
  121. package/src/ios/Classes/Public/CDVCommandDelegate.h +51 -0
  122. package/src/ios/Classes/Public/CDVCommandDelegateImpl.h +36 -0
  123. package/src/ios/Classes/Public/CDVCommandDelegateImpl.m +186 -0
  124. package/src/ios/Classes/Public/CDVCommandQueue.h +39 -0
  125. package/src/ios/Classes/Public/CDVCommandQueue.m +194 -0
  126. package/src/ios/Classes/Public/CDVConfigParser.h +30 -0
  127. package/src/ios/Classes/Public/CDVConfigParser.m +81 -0
  128. package/src/ios/Classes/Public/CDVInvokedUrlCommand.h +52 -0
  129. package/src/ios/Classes/Public/CDVInvokedUrlCommand.m +116 -0
  130. package/src/ios/Classes/Public/CDVPlugin+Resources.h +39 -0
  131. package/src/ios/Classes/Public/CDVPlugin+Resources.m +38 -0
  132. package/src/ios/Classes/Public/CDVPlugin.h +85 -0
  133. package/src/ios/Classes/Public/CDVPlugin.m +202 -0
  134. package/src/ios/Classes/Public/CDVPluginResult.h +66 -0
  135. package/src/ios/Classes/Public/CDVPluginResult.m +186 -0
  136. package/src/ios/Classes/Public/CDVScreenOrientationDelegate.h +33 -0
  137. package/src/ios/Classes/Public/CDVTimer.h +27 -0
  138. package/src/ios/Classes/Public/CDVTimer.m +123 -0
  139. package/src/ios/Classes/Public/CDVURLProtocol.h +27 -0
  140. package/src/ios/Classes/Public/CDVURLProtocol.m +113 -0
  141. package/src/ios/Classes/Public/CDVUserAgentUtil.h +27 -0
  142. package/src/ios/Classes/Public/CDVUserAgentUtil.m +124 -0
  143. package/src/ios/Classes/Public/CDVViewController.h +92 -0
  144. package/src/ios/Classes/Public/CDVViewController.m +821 -0
  145. package/src/ios/Classes/Public/CDVWebViewEngineProtocol.h +42 -0
  146. package/src/ios/Classes/Public/CDVWhitelist.h +34 -0
  147. package/src/ios/Classes/Public/CDVWhitelist.m +285 -0
  148. package/src/ios/Classes/Public/NSDictionary+CordovaPreferences.h +35 -0
  149. package/src/ios/Classes/Public/NSDictionary+CordovaPreferences.m +63 -0
  150. package/src/ios/Classes/Public/NSMutableArray+QueueAdditions.h +29 -0
  151. package/src/ios/Classes/Public/NSMutableArray+QueueAdditions.m +58 -0
  152. package/src/ios/Cordova/Cordova.h +51 -0
  153. package/src/ios/Cordova/Info.plist +24 -0
  154. package/src/ios/Podfile +5 -0
  155. package/src/ios/SitumCordovaPlugin.xcodeproj/project.pbxproj +1324 -0
  156. package/src/ios/SitumCordovaPlugin.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  157. package/src/ios/SitumCordovaPlugin.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  158. package/src/ios/SitumCordovaPlugin.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +8 -0
  159. package/src/ios/SitumCordovaPlugin.xcodeproj/xcshareddata/xcschemes/CordovaLib.xcscheme +100 -0
  160. package/src/ios/SitumCordovaPlugin.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  161. package/src/ios/SitumCordovaPlugin_Prefix.pch +22 -0
  162. package/src/ios/VERSION +1 -0
  163. package/src/ios/cordova.js +2432 -0
  164. package/src/ios/situmcordovaplugin/AppDelegate.h +22 -0
  165. package/src/ios/situmcordovaplugin/AppDelegate.m +98 -0
  166. package/src/ios/situmcordovaplugin/Assets.xcassets/AppIcon.appiconset/Contents.json +98 -0
  167. package/src/ios/situmcordovaplugin/Base.lproj/LaunchScreen.storyboard +25 -0
  168. package/src/ios/situmcordovaplugin/Base.lproj/Main.storyboard +24 -0
  169. package/src/ios/situmcordovaplugin/Constants.h +14 -0
  170. package/src/ios/situmcordovaplugin/Constants.m +14 -0
  171. package/src/ios/situmcordovaplugin/Info.plist +45 -0
  172. package/src/ios/situmcordovaplugin/SITUtils.h +7 -0
  173. package/src/ios/situmcordovaplugin/SITUtils.m +13 -0
  174. package/src/ios/situmcordovaplugin/SitumLocationWrapper.h +109 -0
  175. package/src/ios/situmcordovaplugin/SitumLocationWrapper.m +983 -0
  176. package/src/ios/situmcordovaplugin/SitumPlugin.h +41 -0
  177. package/src/ios/situmcordovaplugin/SitumPlugin.m +752 -0
  178. package/src/ios/situmcordovaplugin/ViewController.h +15 -0
  179. package/src/ios/situmcordovaplugin/ViewController.m +29 -0
  180. package/src/ios/situmcordovaplugin/main.m +16 -0
  181. package/src/ios/situmcordovaplugin/situmcordovaplugin.xcdatamodeld/.xccurrentversion +8 -0
  182. package/src/ios/situmcordovaplugin/situmcordovaplugin.xcdatamodeld/situmcordovaplugin.xcdatamodel/contents +4 -0
  183. package/src/ios/situmcordovaplugintests/AngleTests.m +53 -0
  184. package/src/ios/situmcordovaplugintests/BoundTests.m +51 -0
  185. package/src/ios/situmcordovaplugintests/BuildingTests.m +41 -0
  186. package/src/ios/situmcordovaplugintests/CartesianCoordinateTests.m +42 -0
  187. package/src/ios/situmcordovaplugintests/ConversionAreaTests.m +43 -0
  188. package/src/ios/situmcordovaplugintests/CoordinateTests.m +42 -0
  189. package/src/ios/situmcordovaplugintests/DimensionTests.m +43 -0
  190. package/src/ios/situmcordovaplugintests/EventTests.m +42 -0
  191. package/src/ios/situmcordovaplugintests/FloorTests.m +52 -0
  192. package/src/ios/situmcordovaplugintests/Info.plist +38 -0
  193. package/src/ios/situmcordovaplugintests/InputTests/DirectionsRequestTest.m +108 -0
  194. package/src/ios/situmcordovaplugintests/InputTests/InputCartesianCoordinateTests.m +45 -0
  195. package/src/ios/situmcordovaplugintests/InputTests/InputCoordinateTests.m +45 -0
  196. package/src/ios/situmcordovaplugintests/InputTests/InputFloorTests.m +59 -0
  197. package/src/ios/situmcordovaplugintests/InputTests/InputIndicationTests.m +45 -0
  198. package/src/ios/situmcordovaplugintests/InputTests/InputLocationTests.m +163 -0
  199. package/src/ios/situmcordovaplugintests/InputTests/InputPoiCategoryTests.m +46 -0
  200. package/src/ios/situmcordovaplugintests/InputTests/InputPointTests.m +137 -0
  201. package/src/ios/situmcordovaplugintests/InputTests/LocationRequestTest.m +79 -0
  202. package/src/ios/situmcordovaplugintests/LocationStatusTests.m +60 -0
  203. package/src/ios/situmcordovaplugintests/LocationTests.m +114 -0
  204. package/src/ios/situmcordovaplugintests/NavigationProgressTests.m +50 -0
  205. package/src/ios/situmcordovaplugintests/PoiCategoryIconTests.m +43 -0
  206. package/src/ios/situmcordovaplugintests/PoiCategoryTests.m +42 -0
  207. package/src/ios/situmcordovaplugintests/PoiTests.m +83 -0
  208. package/src/ios/situmcordovaplugintests/PointTests.m +107 -0
  209. package/src/ios/situmcordovaplugintests/RouteStepTests.m +78 -0
  210. package/src/ios/situmcordovaplugintests/RouteTests.m +42 -0
  211. package/src/ios/situmcordovaplugintests/SitumCreatorTests.h +91 -0
  212. package/src/ios/situmcordovaplugintests/SitumCreatorTests.m +928 -0
  213. package/src/ios/situmcordovaplugintests/TestingHelper.h +48 -0
  214. package/src/ios/situmcordovaplugintests/TestingHelper.m +342 -0
  215. package/src/ios/situmcordovaplugintests/indicationTests.m +43 -0
  216. package/tests/common-resources/angle/angle1.json +6 -0
  217. package/tests/common-resources/angle/angle2.json +6 -0
  218. package/tests/common-resources/bounds/bounds1.json +18 -0
  219. package/tests/common-resources/bounds/bounds2.json +18 -0
  220. package/tests/common-resources/building/building1.json +64 -0
  221. package/tests/common-resources/cartesianCoordinate/cartesianCoordinate1.json +4 -0
  222. package/tests/common-resources/circle/circle1.json +17 -0
  223. package/tests/common-resources/coordinate/coordinate1.json +4 -0
  224. package/tests/common-resources/dimensions/dimensions1.json +4 -0
  225. package/tests/common-resources/directionsRequest/directionsRequest1.json +166 -0
  226. package/tests/common-resources/directionsRequest/directionsRequest2.json +167 -0
  227. package/tests/common-resources/directionsRequest/directionsRequest3.json +166 -0
  228. package/tests/common-resources/directionsRequest/directionsRequest4.json +166 -0
  229. package/tests/common-resources/directionsRequest/directionsRequest5.json +167 -0
  230. package/tests/common-resources/directionsRequest/directionsRequest6.json +153 -0
  231. package/tests/common-resources/events/event1.json +66 -0
  232. package/tests/common-resources/floor/floor1.json +13 -0
  233. package/tests/common-resources/floor/floor2.json +13 -0
  234. package/tests/common-resources/indication/indication1.json +10 -0
  235. package/tests/common-resources/location/location1.json +48 -0
  236. package/tests/common-resources/location/location10.json +48 -0
  237. package/tests/common-resources/location/location2.json +48 -0
  238. package/tests/common-resources/location/location3.json +48 -0
  239. package/tests/common-resources/location/location4.json +48 -0
  240. package/tests/common-resources/location/location5.json +48 -0
  241. package/tests/common-resources/location/location6.json +48 -0
  242. package/tests/common-resources/location/location7.json +48 -0
  243. package/tests/common-resources/location/location8.json +48 -0
  244. package/tests/common-resources/location/location9.json +48 -0
  245. package/tests/common-resources/locationRequest/locationRequest1.json +6 -0
  246. package/tests/common-resources/locationRequest/locationRequest2.json +32 -0
  247. package/tests/common-resources/locationRequest/locationRequest3.json +33 -0
  248. package/tests/common-resources/locationRequest/locationRequest4.json +31 -0
  249. package/tests/common-resources/locationStatus/locationStatus1.json +4 -0
  250. package/tests/common-resources/locationStatus/locationStatus10.json +4 -0
  251. package/tests/common-resources/locationStatus/locationStatus11.json +4 -0
  252. package/tests/common-resources/locationStatus/locationStatus12.json +4 -0
  253. package/tests/common-resources/locationStatus/locationStatus13.json +4 -0
  254. package/tests/common-resources/locationStatus/locationStatus2.json +4 -0
  255. package/tests/common-resources/locationStatus/locationStatus3.json +4 -0
  256. package/tests/common-resources/locationStatus/locationStatus4.json +4 -0
  257. package/tests/common-resources/locationStatus/locationStatus5.json +4 -0
  258. package/tests/common-resources/locationStatus/locationStatus6.json +4 -0
  259. package/tests/common-resources/locationStatus/locationStatus7.json +4 -0
  260. package/tests/common-resources/locationStatus/locationStatus8.json +4 -0
  261. package/tests/common-resources/locationStatus/locationStatus9.json +4 -0
  262. package/tests/common-resources/navigationProgress/navigationProgress1.json +77 -0
  263. package/tests/common-resources/navigationProgress/navigationProgress2.json +77 -0
  264. package/tests/common-resources/poi/poi1.json +35 -0
  265. package/tests/common-resources/poi/poi2.json +35 -0
  266. package/tests/common-resources/poi/poi3.json +35 -0
  267. package/tests/common-resources/poi/poi4.json +38 -0
  268. package/tests/common-resources/poi/poi5.json +35 -0
  269. package/tests/common-resources/poiCategory/poiCategory1.json +7 -0
  270. package/tests/common-resources/poiCategoryIcon/poiCategoryIcon1.json +1 -0
  271. package/tests/common-resources/poiCategoryIcon/poiCategoryIcon1.png +0 -0
  272. package/tests/common-resources/point/point1.json +14 -0
  273. package/tests/common-resources/point/point2.json +14 -0
  274. package/tests/common-resources/point/point3.json +14 -0
  275. package/tests/common-resources/point/point4.json +14 -0
  276. package/tests/common-resources/point/point5.json +14 -0
  277. package/tests/common-resources/point/point6.json +14 -0
  278. package/tests/common-resources/point/point7.json +14 -0
  279. package/tests/common-resources/point/point8.json +14 -0
  280. package/tests/common-resources/route/route1.json +530 -0
  281. package/tests/common-resources/routeStep/routeStep1.json +35 -0
  282. package/tests/common-resources/routeStep/routeStep2.json +35 -0
  283. package/tests/common-resources/routeStep/routeStep3.json +35 -0
  284. package/tests/common-resources/routeStep/routeStep4.json +35 -0
  285. package/tests/common-resources/routeStep/routeStep5.json +35 -0
  286. package/tests/common-resources/situmConversionArea/situmConversionArea1.json +19 -0
  287. package/tests/js/resources/fetchBuildings.json +176 -0
  288. package/tests/js/resources/fetchEventsFromBuilding.json +201 -0
  289. package/tests/js/resources/fetchFloorsFromBuilding.json +34 -0
  290. package/tests/js/resources/fetchIndoorPOIsFromBuilding.json +574 -0
  291. package/tests/js/resources/fetchMapFromFloor.json +3 -0
  292. package/tests/js/resources/fetchOutdoorPOIsFromBuilding.json +68 -0
  293. package/tests/js/resources/fetchPoiCategories.json +72 -0
  294. package/tests/js/resources/fetchPoiCategoryIconNormal.json +3 -0
  295. package/tests/js/resources/fetchPoiCategoryIconSelected.json +3 -0
  296. package/tests/js/resources/requestDirections.json +1167 -0
  297. package/tests/js/resources/startPositioning/0_starting.json +4 -0
  298. package/tests/js/resources/startPositioning/1_preparingPositioningModel.json +4 -0
  299. package/tests/js/resources/startPositioning/2_startingPositioning.json +4 -0
  300. package/tests/js/resources/startPositioning/3_calculating.json +4 -0
  301. package/tests/js/resources/startPositioning/4_position.json +48 -0
  302. package/tests/js/resources/startPositioning/5_position.json +48 -0
  303. package/tests/js/test.js +416 -0
  304. package/tests/scripts/clean_android_resources.sh +3 -0
  305. package/tests/scripts/clean_ios_resources.sh +3 -0
  306. package/tests/scripts/copy_android_resources.sh +3 -0
  307. package/tests/scripts/copy_ios_resources.sh +3 -0
  308. package/tests/scripts/self-destruct.sh +1 -0
  309. package/www/android/Interfaces.js +742 -0
  310. package/www/android/situm.js +296 -0
  311. package/www/ios/situm.js +99 -0
  312. package/www/map-view-controller.js +223 -0
  313. package/www/map-view.js +88 -0
@@ -0,0 +1,919 @@
1
+ package es.situm.plugin;
2
+
3
+ import android.content.Intent;
4
+ import android.graphics.Bitmap;
5
+ import android.util.Log;
6
+ import android.widget.Toast;
7
+
8
+ import androidx.core.app.ActivityCompat;
9
+
10
+ import org.apache.cordova.CallbackContext;
11
+ import org.apache.cordova.CordovaInterface;
12
+ import org.apache.cordova.CordovaWebView;
13
+ import org.apache.cordova.PluginResult;
14
+ import org.apache.cordova.PluginResult.Status;
15
+ import org.json.JSONArray;
16
+ import org.json.JSONException;
17
+ import org.json.JSONObject;
18
+
19
+ import java.util.Collection;
20
+ import java.util.HashMap;
21
+ import java.util.List;
22
+
23
+ import es.situm.sdk.SitumSdk;
24
+ import es.situm.sdk.communication.CommunicationManager;
25
+ import es.situm.sdk.directions.DirectionsRequest;
26
+ import es.situm.sdk.error.Error;
27
+ import es.situm.sdk.location.GeofenceListener;
28
+ import es.situm.sdk.location.LocationListener;
29
+ import es.situm.sdk.location.LocationRequest;
30
+ import es.situm.sdk.location.LocationStatus;
31
+ import es.situm.sdk.model.cartography.Building;
32
+ import es.situm.sdk.model.cartography.BuildingInfo;
33
+ import es.situm.sdk.model.cartography.Floor;
34
+ import es.situm.sdk.model.cartography.Geofence;
35
+ import es.situm.sdk.model.cartography.Poi;
36
+ import es.situm.sdk.model.cartography.PoiCategory;
37
+ import es.situm.sdk.model.directions.Route;
38
+ import es.situm.sdk.model.location.Location;
39
+ import es.situm.sdk.model.navigation.NavigationProgress;
40
+ import es.situm.sdk.model.realtime.RealTimeData;
41
+ import es.situm.sdk.navigation.NavigationListener;
42
+ import es.situm.sdk.navigation.NavigationManager;
43
+ import es.situm.sdk.navigation.NavigationRequest;
44
+ import es.situm.sdk.realtime.RealTimeListener;
45
+ import es.situm.sdk.realtime.RealTimeManager;
46
+ import es.situm.sdk.realtime.RealTimeRequest;
47
+ import es.situm.sdk.utils.Handler;
48
+ import es.situm.sdk.v1.SitumEvent;
49
+
50
+ public class PluginHelper {
51
+
52
+ private static final String TAG = "PluginHelper";
53
+
54
+ private LocationListener locationListener;
55
+ private LocationRequest locationRequest;
56
+ private NavigationListener navigationListener;
57
+ private NavigationRequest navigationRequest;
58
+
59
+ private volatile CommunicationManager cmInstance;
60
+
61
+ private volatile NavigationManager nmInstance;
62
+ private RealTimeListener realtimeListener;
63
+ private volatile RealTimeManager rmInstance;
64
+
65
+ private Route computedRoute;
66
+ private Location computedLocation;
67
+
68
+ private CallbackContext callbackEnterGeofences;
69
+ private CallbackContext callbackExitGeofences;
70
+
71
+ private CommunicationManager getCommunicationManagerInstance() {
72
+ if (cmInstance == null) { //Check for the first time
73
+ synchronized (CommunicationManager.class) { //Check for the second time.
74
+ //if there is no instance available... create new one
75
+ if (cmInstance == null) cmInstance = SitumSdk.communicationManager();
76
+ }
77
+ }
78
+ return cmInstance;
79
+ }
80
+
81
+ public void setCommunicationManager(CommunicationManager communicationManager) {
82
+ cmInstance = communicationManager;
83
+ }
84
+
85
+ private RealTimeManager getRealtimeManagerInstance() {
86
+ if (rmInstance == null) {
87
+ synchronized (RealTimeManager.class) { //Check for the second time.
88
+ //if there is no instance available... create new one
89
+ if (rmInstance == null) rmInstance = SitumSdk.realtimeManager();
90
+ }
91
+ }
92
+ return rmInstance;
93
+ }
94
+
95
+ private NavigationManager getNavigationManagerInstance() {
96
+ if (nmInstance == null) { //Check for the first time
97
+ synchronized (NavigationManager.class) { //Check for the second time.
98
+ //if there is no instance available... create new one
99
+ if (nmInstance == null) nmInstance = SitumSdk.navigationManager();
100
+ }
101
+ }
102
+ return nmInstance;
103
+ }
104
+
105
+ public void setNavigationManager(NavigationManager navigationManager) {
106
+ nmInstance = navigationManager;
107
+ }
108
+
109
+ public void fetchBuildings(CordovaInterface cordova, CordovaWebView webView, JSONArray args,
110
+ final CallbackContext callbackContext) {
111
+ try {
112
+ getCommunicationManagerInstance().fetchBuildings(new Handler<Collection<Building>>() {
113
+ public void onSuccess(Collection<Building> buildings) {
114
+ try {
115
+ Log.d(PluginHelper.TAG, "onSuccess: Buildings fetched successfully.");
116
+ JSONArray jsonaBuildings = new JSONArray();
117
+
118
+ for (Building building : buildings) {
119
+ Log.i(PluginHelper.TAG,
120
+ "onSuccess: " + building.getIdentifier() + " - " + building.getName());
121
+ JSONObject jsonoBuilding = SitumMapper.buildingToJsonObject(building);
122
+ jsonaBuildings.put(jsonoBuilding);
123
+ }
124
+ if (buildings.isEmpty()) {
125
+ Log.e(PluginHelper.TAG, "onSuccess: you have no buildings. Create one in the Dashboard");
126
+ }
127
+ callbackContext.sendPluginResult(new PluginResult(Status.OK, jsonaBuildings));
128
+ } catch (JSONException e) {
129
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, e.getMessage()));
130
+ }
131
+ }
132
+
133
+ public void onFailure(Error error) {
134
+ Log.e(PluginHelper.TAG, "onFailure:" + error);
135
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, error.getMessage()));
136
+ }
137
+ });
138
+ } catch (Exception e) {
139
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, e.getMessage()));
140
+ }
141
+ }
142
+
143
+ // building, floors, events, indoorPois, outdoorPois, ¿geofences? ¿Paths?
144
+ public void fetchBuildingInfo(CordovaInterface cordova, CordovaWebView webView, JSONArray args,
145
+ final CallbackContext callbackContext)
146
+ {
147
+ try {
148
+ JSONObject jsonoBuilding = args.getJSONObject(0);
149
+ Building building = SitumMapper.buildingJsonObjectToBuilding(jsonoBuilding);
150
+
151
+ getCommunicationManagerInstance().fetchBuildingInfo(building, new Handler<BuildingInfo>() {
152
+ @Override
153
+ public void onSuccess(BuildingInfo object) {
154
+ try {
155
+ Log.d(PluginHelper.TAG, "onSuccess: building info fetched successfully.");
156
+
157
+
158
+ JSONObject jsonObject = SitumMapper.buildingInfoToJsonObject(object); // Include geofences to parse ? This needs to be on sdk
159
+
160
+ callbackContext.sendPluginResult(new PluginResult(Status.OK, jsonObject));
161
+ } catch (JSONException e) {
162
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, e.getMessage()));
163
+ }
164
+ }
165
+
166
+ @Override
167
+ public void onFailure(Error error) {
168
+ Log.e(PluginHelper.TAG, "onFailure:" + error);
169
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, error.getMessage()));
170
+ }
171
+ });
172
+
173
+ } catch (Exception e) {
174
+ Log.e(TAG, "Unexpected error in building info response", e.getCause());
175
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, e.getMessage()));
176
+ }
177
+ }
178
+
179
+ public void fetchGeofencesFromBuilding(CordovaInterface cordova, CordovaWebView webView, JSONArray args,
180
+ final CallbackContext callbackContext)
181
+ {
182
+ try {
183
+ JSONObject jsonoBuilding = args.getJSONObject(0);
184
+ Building building = SitumMapper.buildingJsonObjectToBuilding(jsonoBuilding);
185
+
186
+ getCommunicationManagerInstance().fetchGeofencesFromBuilding(building, new Handler<List<Geofence>>() {
187
+ @Override
188
+ public void onSuccess(List<Geofence> geofences) {
189
+ try {
190
+ Log.d(PluginHelper.TAG, "onSuccess: Geofences fetched successfully.");
191
+ JSONArray jsonaGeofences = new JSONArray();
192
+
193
+ for (Geofence geofence : geofences) {
194
+ Log.i(PluginHelper.TAG, "onSuccess: " + geofence.getIdentifier());
195
+ JSONObject jsonoGeofence = SitumMapper.geofenceToJsonObject(geofence);
196
+ jsonaGeofences.put(jsonoGeofence);
197
+ }
198
+ if (geofences.isEmpty()) {
199
+ Log.e(PluginHelper.TAG, "onSuccess: you have no geofences defined for this building");
200
+ }
201
+ callbackContext.sendPluginResult(new PluginResult(Status.OK, jsonaGeofences));
202
+ } catch (JSONException e) {
203
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, e.getMessage()));
204
+ }
205
+ }
206
+
207
+ @Override
208
+ public void onFailure(Error error) {
209
+ Log.e(PluginHelper.TAG, "onFailure:" + error);
210
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, error.getMessage()));
211
+ }
212
+ });
213
+
214
+ } catch (Exception e) {
215
+ Log.e(TAG, "Unexpected error in building info response", e.getCause());
216
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, e.getMessage()));
217
+ }
218
+ }
219
+
220
+ public void fetchFloorsFromBuilding(CordovaInterface cordova, CordovaWebView webView, JSONArray args,
221
+ final CallbackContext callbackContext) {
222
+ try {
223
+ JSONObject jsonoBuilding = args.getJSONObject(0);
224
+ Building building = SitumMapper.buildingJsonObjectToBuilding(jsonoBuilding);
225
+ getCommunicationManagerInstance().fetchFloorsFromBuilding(building, new Handler<Collection<Floor>>() {
226
+ @Override
227
+ public void onSuccess(Collection<Floor> floors) {
228
+ try {
229
+ Log.d(PluginHelper.TAG, "onSuccess: Floors fetched successfully.");
230
+
231
+ // TODO 19/11/19: jo.put(FLOORS, arrayFromFloors(buildingInfo.getFloors()));
232
+ JSONArray jsonaFloors = new JSONArray();
233
+
234
+ for (Floor floor : floors) {
235
+ Log.i(PluginHelper.TAG, "onSuccess: " + floor.getIdentifier());
236
+ JSONObject jsonoFloor = SitumMapper.floorToJsonObject(floor);
237
+ jsonaFloors.put(jsonoFloor);
238
+ }
239
+ if (floors.isEmpty()) {
240
+ Log.e(PluginHelper.TAG, "onSuccess: you have no floors defined for this building");
241
+ }
242
+ callbackContext.sendPluginResult(new PluginResult(Status.OK, jsonaFloors));
243
+ } catch (JSONException e) {
244
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, e.getMessage()));
245
+ }
246
+ }
247
+
248
+ @Override
249
+ public void onFailure(Error error) {
250
+ Log.e(PluginHelper.TAG, "onFailure:" + error);
251
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, error.getMessage()));
252
+ }
253
+ });
254
+ } catch (Exception e) {
255
+ Log.e(TAG, "Unexpected error in floor response", e.getCause());
256
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, e.getMessage()));
257
+ }
258
+ }
259
+
260
+ public void fetchIndoorPOIsFromBuilding(CordovaInterface cordova, CordovaWebView webView, JSONArray args,
261
+ final CallbackContext callbackContext) {
262
+ try {
263
+ JSONObject jsonoBuilding = args.getJSONObject(0);
264
+ Building building = SitumMapper.buildingJsonObjectToBuilding(jsonoBuilding);
265
+ getCommunicationManagerInstance().fetchIndoorPOIsFromBuilding(building, new HashMap<String, Object>(),
266
+ new Handler<Collection<Poi>>() {
267
+ @Override
268
+ public void onSuccess(Collection<Poi> pois) {
269
+ try {
270
+ Log.d(PluginHelper.TAG, "onSuccess: Pois fetched successfully.");
271
+ JSONArray jsonaPois = new JSONArray();
272
+
273
+ for (Poi poi : pois) {
274
+ Log.i(PluginHelper.TAG,
275
+ "onSuccess: " + poi.getIdentifier() + " - " + poi.getName() + "-" + poi.getCustomFields());
276
+
277
+ Log.d(PluginHelper.TAG, "Some log that should appear");
278
+ JSONObject jsonoPoi = SitumMapper.poiToJsonObject(poi);
279
+ jsonaPois.put(jsonoPoi);
280
+ }
281
+ if (pois.isEmpty()) {
282
+ Log.e(PluginHelper.TAG,
283
+ "onSuccess: you have no indoor pois defined for this building");
284
+ }
285
+ callbackContext.sendPluginResult(new PluginResult(Status.OK, jsonaPois));
286
+ } catch (JSONException e) {
287
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, e.getMessage()));
288
+ }
289
+ }
290
+
291
+ @Override
292
+ public void onFailure(Error error) {
293
+ Log.e(PluginHelper.TAG, "onFailure:" + error);
294
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, error.getMessage()));
295
+ }
296
+ });
297
+ } catch (Exception e) {
298
+ Log.e(TAG, "Unexpected error in poi response", e.getCause());
299
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, e.getMessage()));
300
+ }
301
+ }
302
+
303
+ public void fetchOutdoorPOIsFromBuilding(CordovaInterface cordova, CordovaWebView webView, JSONArray args,
304
+ final CallbackContext callbackContext) {
305
+ try {
306
+ JSONObject jsonoBuilding = args.getJSONObject(0);
307
+ Building building = SitumMapper.buildingJsonObjectToBuilding(jsonoBuilding);
308
+ getCommunicationManagerInstance().fetchOutdoorPOIsFromBuilding(building, new HashMap<String, Object>(),
309
+ new Handler<Collection<Poi>>() {
310
+ @Override
311
+ public void onSuccess(Collection<Poi> pois) {
312
+ try {
313
+ Log.d(PluginHelper.TAG, "onSuccess: Floors fetched successfully.");
314
+ JSONArray jsonaPois = new JSONArray();
315
+
316
+ for (Poi poi : pois) {
317
+ Log.i(PluginHelper.TAG,
318
+ "onSuccess: " + poi.getIdentifier() + " - " + poi.getName());
319
+ JSONObject jsonoPoi = SitumMapper.poiToJsonObject(poi);
320
+ jsonaPois.put(jsonoPoi);
321
+ }
322
+ if (pois.isEmpty()) {
323
+ Log.e(PluginHelper.TAG,
324
+ "onSuccess: you have no outdoor pois defined for this building");
325
+ }
326
+ callbackContext.sendPluginResult(new PluginResult(Status.OK, jsonaPois));
327
+ } catch (JSONException e) {
328
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, e.getMessage()));
329
+ }
330
+ }
331
+
332
+ @Override
333
+ public void onFailure(Error error) {
334
+ Log.e(PluginHelper.TAG, "onFailure:" + error);
335
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, error.getMessage()));
336
+ }
337
+ });
338
+ } catch (Exception e) {
339
+ Log.e(TAG, "Unexpected error in poi response", e.getCause());
340
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, e.getMessage()));
341
+ }
342
+ }
343
+
344
+ public void fetchPoiCategories(CordovaInterface cordova, CordovaWebView webView, JSONArray args,
345
+ final CallbackContext callbackContext) {
346
+ getCommunicationManagerInstance().fetchPoiCategories(new Handler<Collection<PoiCategory>>() {
347
+ @Override
348
+ public void onSuccess(Collection<PoiCategory> poiCategories) {
349
+ try {
350
+ Log.d(PluginHelper.TAG, "onSuccess: POI Categories fetched successfully.");
351
+ JSONArray jsonaPoiCategories = new JSONArray();
352
+ for (PoiCategory poiCategory : poiCategories) {
353
+ Log.i(PluginHelper.TAG, "onSuccess: " + poiCategory.getCode() + " - " + poiCategory.getName());
354
+ JSONObject jsonoPoiCategory = SitumMapper.poiCategoryToJsonObject(poiCategory);
355
+ jsonaPoiCategories.put(jsonoPoiCategory);
356
+ }
357
+ if (poiCategories.isEmpty()) {
358
+ Log.e(PluginHelper.TAG, "onSuccess: you have no categories defined for POIs");
359
+ }
360
+ callbackContext.sendPluginResult(new PluginResult(Status.OK, jsonaPoiCategories));
361
+ } catch (JSONException e) {
362
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, e.getMessage()));
363
+ }
364
+ }
365
+
366
+ @Override
367
+ public void onFailure(Error error) {
368
+ Log.e(PluginHelper.TAG, "onFailure:" + error);
369
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, error.getMessage()));
370
+ }
371
+ });
372
+ }
373
+
374
+ public void fetchPoiCategoryIconNormal(CordovaInterface cordova, CordovaWebView webView, JSONArray args,
375
+ final CallbackContext callbackContext) {
376
+ try {
377
+ JSONObject jsonoCategory = args.getJSONObject(0);
378
+ PoiCategory category = SitumMapper.poiCategoryFromJsonObject(jsonoCategory);
379
+ getCommunicationManagerInstance().fetchPoiCategoryIconNormal(category, new Handler<Bitmap>() {
380
+ @Override
381
+ public void onSuccess(Bitmap bitmap) {
382
+ try {
383
+ Log.d(PluginHelper.TAG, "onSuccess: Poi icon fetched successfully");
384
+ JSONObject jsonoMap = SitumMapper.bitmapToString(bitmap);
385
+ callbackContext.sendPluginResult(new PluginResult(Status.OK, jsonoMap));
386
+ } catch (JSONException e) {
387
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, e.getMessage()));
388
+ }
389
+ }
390
+
391
+ @Override
392
+ public void onFailure(Error error) {
393
+ Log.e(PluginHelper.TAG, "onFailure: " + error);
394
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, error.getMessage()));
395
+ }
396
+ });
397
+ } catch (Exception e) {
398
+ Log.e(TAG, "Unexpected error in situm POI response", e.getCause());
399
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, e.getMessage()));
400
+ }
401
+ }
402
+
403
+ public void fetchPoiCategoryIconSelected(CordovaInterface cordova, CordovaWebView webView, JSONArray args,
404
+ final CallbackContext callbackContext) {
405
+ try {
406
+ JSONObject jsonoCategory = args.getJSONObject(0);
407
+ PoiCategory category = SitumMapper.poiCategoryFromJsonObject(jsonoCategory);
408
+ getCommunicationManagerInstance().fetchPoiCategoryIconSelected(category, new Handler<Bitmap>() {
409
+ @Override
410
+ public void onSuccess(Bitmap bitmap) {
411
+ try {
412
+ Log.d(PluginHelper.TAG, "onSuccess: Poi icon fetched successfully");
413
+ JSONObject jsonoMap = SitumMapper.bitmapToString(bitmap);
414
+ callbackContext.sendPluginResult(new PluginResult(Status.OK, jsonoMap));
415
+ } catch (JSONException e) {
416
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, e.getMessage()));
417
+ }
418
+ }
419
+
420
+ @Override
421
+ public void onFailure(Error error) {
422
+ Log.e(PluginHelper.TAG, "onFailure: " + error);
423
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, error.getMessage()));
424
+ }
425
+ });
426
+ } catch (Exception e) {
427
+ Log.e(TAG, "Unexpected error in situm POI response", e.getCause());
428
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, e.getMessage()));
429
+ }
430
+ }
431
+
432
+ public void fetchEventsFromBuilding(CordovaInterface cordova, CordovaWebView webView, JSONArray args,
433
+ final CallbackContext callbackContext) {
434
+ try {
435
+ JSONObject jsonoBuilding = args.getJSONObject(0);
436
+ Building building = SitumMapper.buildingJsonObjectToBuilding(jsonoBuilding);
437
+ getCommunicationManagerInstance().fetchEventsFromBuilding(building, new HashMap<String, Object>(),
438
+ new Handler<Collection<es.situm.sdk.v1.SitumEvent>>() {
439
+ @Override
440
+ public void onSuccess(Collection<SitumEvent> situmEvents) {
441
+ try {
442
+ Log.d(PluginHelper.TAG, "onSuccess: Floors fetched successfully.");
443
+ JSONArray jsonaEvents = new JSONArray();
444
+ for (SitumEvent situmEvent : situmEvents) {
445
+ Log.i(PluginHelper.TAG,
446
+ "onSuccess: " + situmEvent.getId() + " - " + situmEvent.getName());
447
+ JSONObject jsonoSitumEvent = SitumMapper.situmEventToJsonObject(situmEvent);
448
+ jsonaEvents.put(jsonoSitumEvent);
449
+ }
450
+ if (situmEvents.isEmpty()) {
451
+ Log.e(PluginHelper.TAG, "onSuccess: you have no events defined for this building");
452
+ }
453
+ callbackContext.sendPluginResult(new PluginResult(Status.OK, jsonaEvents));
454
+ } catch (JSONException e) {
455
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, e.getMessage()));
456
+ }
457
+ }
458
+
459
+ @Override
460
+ public void onFailure(Error error) {
461
+ Log.e(PluginHelper.TAG, "onFailure:" + error);
462
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, error.getMessage()));
463
+ }
464
+ });
465
+ } catch (Exception e) {
466
+ Log.e(TAG, "Unexpected error in situm event response", e.getCause());
467
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, e.getMessage()));
468
+ }
469
+ }
470
+
471
+ public void fetchMapFromFloor(CordovaInterface cordova, CordovaWebView webView, final JSONArray args,
472
+ final CallbackContext callbackContext) {
473
+ try {
474
+ JSONObject jsonoFloor = args.getJSONObject(0);
475
+ Floor floor = SitumMapper.floorJsonObjectToFloor(jsonoFloor);
476
+ getCommunicationManagerInstance().fetchMapFromFloor(floor, new Handler<Bitmap>() {
477
+ @Override
478
+ public void onSuccess(Bitmap bitmap) {
479
+ try {
480
+ Log.d(PluginHelper.TAG, "onSuccess: Map fetched successfully");
481
+ JSONObject jsonoMap = SitumMapper.bitmapToString(bitmap);
482
+ callbackContext.sendPluginResult(new PluginResult(Status.OK, jsonoMap));
483
+ } catch (JSONException e) {
484
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, e.getMessage()));
485
+ }
486
+ }
487
+
488
+ @Override
489
+ public void onFailure(Error error) {
490
+ Log.e(PluginHelper.TAG, "onFailure: " + error);
491
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, error.getMessage()));
492
+ }
493
+ });
494
+ } catch (Exception e) {
495
+ Log.e(TAG, "Unexpected error in map download", e.getCause());
496
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, e.getMessage()));
497
+ }
498
+ }
499
+
500
+ public void startPositioning(final CordovaInterface cordova, CordovaWebView webView, JSONArray args,
501
+ final CallbackContext callbackContext) {
502
+ try {
503
+ LocationRequest locationRequest = SitumMapper.locationRequestJSONObjectToLocationRequest(args);
504
+
505
+ Log.i(TAG, "startPositioning: starting positioning in " + locationRequest);
506
+ if (locationListener != null) {
507
+ SitumSdk.locationManager().removeLocationListener(locationListener);
508
+ }
509
+ locationListener = new LocationListener() {
510
+ public void onLocationChanged(Location location) {
511
+ try {
512
+ PluginHelper.this.computedLocation = location; // This is for testing purposes
513
+ Log.i(PluginHelper.TAG, "onLocationChanged() called with: location = [" + location + "]");
514
+ JSONObject jsonObject = SitumMapper.locationToJsonObject(location);
515
+ PluginResult result = new PluginResult(Status.OK, jsonObject);
516
+ result.setKeepCallback(true);
517
+ callbackContext.sendPluginResult(result);
518
+ } catch (JSONException e) {
519
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, e.getMessage()));
520
+ }
521
+ }
522
+
523
+ public void onStatusChanged(LocationStatus status) {
524
+ try {
525
+ Log.i(PluginHelper.TAG, "onStatusChanged() called with: status = [" + status + "]");
526
+ JSONObject jsonObject = SitumMapper.locationStatusToJsonObject(status);
527
+ PluginResult result = new PluginResult(Status.OK, jsonObject);
528
+ result.setKeepCallback(true);
529
+ callbackContext.sendPluginResult(result);
530
+ } catch (JSONException e) {
531
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, e.getMessage()));
532
+ }
533
+ }
534
+
535
+ public void onError(Error error) {
536
+ Log.e(PluginHelper.TAG, "onError() called with: error = [" + error + "]");
537
+ locationListener = null;
538
+ PluginResult result = new PluginResult(Status.ERROR, error.getMessage());
539
+ result.setKeepCallback(true);
540
+ callbackContext.sendPluginResult(result);
541
+ switch (error.getCode()) {
542
+ case 8001:
543
+ requestLocationPermission(cordova);
544
+ return;
545
+ case 8002:
546
+ showLocationSettings(cordova);
547
+ return;
548
+ default:
549
+ return;
550
+ }
551
+ }
552
+ };
553
+ try {
554
+ SitumSdk.locationManager().addLocationListener(locationListener);
555
+ SitumSdk.locationManager().requestLocationUpdates(locationRequest);
556
+ } catch (Exception e) {
557
+ Log.e(PluginHelper.TAG, "onError() called with: error = [" + e + "]");
558
+ }
559
+ } catch (Exception e) {
560
+ Log.e(TAG, "Unexpected error building response", e.getCause());
561
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, e.getMessage()));
562
+ }
563
+ }
564
+
565
+ public void stopPositioning(
566
+ CordovaInterface cordova,
567
+ CordovaWebView webView,
568
+ JSONArray args,
569
+ CallbackContext callbackContext) {
570
+ try {
571
+ SitumSdk.locationManager().removeUpdates();
572
+ } catch (Exception e) {
573
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, e.getMessage()));
574
+ }
575
+ if (locationListener != null) {
576
+ SitumSdk.locationManager().removeLocationListener(locationListener);
577
+ locationListener = null;
578
+ }
579
+ callbackContext.sendPluginResult(new PluginResult(Status.OK, "Success"));
580
+ }
581
+
582
+ public void onEnterGeofences(CordovaInterface cordova, CordovaWebView webView, JSONArray args,
583
+ CallbackContext callbackContext) {
584
+ this.callbackEnterGeofences = callbackContext;
585
+ createAndSetGeofenceListener();
586
+ }
587
+
588
+ public void onExitGeofences(CordovaInterface cordova, CordovaWebView webView, JSONArray args,
589
+ CallbackContext callbackContext) {
590
+ this.callbackExitGeofences = callbackContext;
591
+ createAndSetGeofenceListener();
592
+ }
593
+
594
+ private void createAndSetGeofenceListener() {
595
+ GeofenceListener geofenceListener = new GeofenceListener() {
596
+ public void onEnteredGeofences(List<Geofence> enteredGeofences) {
597
+ if (callbackEnterGeofences != null) {
598
+ notifyGeofences(callbackEnterGeofences, enteredGeofences);
599
+ }
600
+ }
601
+
602
+ public void onExitedGeofences(List<Geofence> exitedGeofences) {
603
+ if (callbackExitGeofences != null) {
604
+ notifyGeofences(callbackExitGeofences, exitedGeofences);
605
+ }
606
+ }
607
+ };
608
+ SitumSdk.locationManager().setGeofenceListener(geofenceListener);
609
+ }
610
+
611
+ private void notifyGeofences(CallbackContext callbackContext, List<Geofence> geofences) {
612
+ JSONArray jsonaGeofences;
613
+ try {
614
+ jsonaGeofences = SitumMapper.parseGeofencesToJsonArray(geofences);
615
+ } catch (JSONException e) {
616
+ PluginResult pluginResult = new PluginResult(Status.ERROR, e.getMessage());
617
+ pluginResult.setKeepCallback(true);
618
+ callbackContext.sendPluginResult(pluginResult);
619
+ return;
620
+ }
621
+ PluginResult pluginResult = new PluginResult(Status.OK, jsonaGeofences);
622
+ pluginResult.setKeepCallback(true);
623
+ callbackContext.sendPluginResult(pluginResult);
624
+ }
625
+
626
+ private void showLocationSettings(CordovaInterface cordova) {
627
+ Toast.makeText(cordova.getActivity(), "You must enable location", Toast.LENGTH_LONG).show();
628
+ cordova.getActivity().startActivityForResult(new Intent("android.settings.LOCATION_SOURCE_SETTINGS"), 0);
629
+ }
630
+
631
+ private void requestLocationPermission(CordovaInterface cordova) {
632
+ ActivityCompat.requestPermissions(cordova.getActivity(),
633
+ new String[] { "android.permission.ACCESS_FINE_LOCATION" }, 0);
634
+ }
635
+
636
+ public void returnDefaultResponse(CallbackContext callbackContext) {
637
+ String message = "Error function name not found";
638
+ Log.e(TAG, message);
639
+ callbackContext.sendPluginResult(new PluginResult(Status.OK, message));
640
+ }
641
+
642
+ public void invalidateCache(CallbackContext callbackContext) {
643
+ getCommunicationManagerInstance().invalidateCache();
644
+ callbackContext.sendPluginResult(new PluginResult(Status.OK, "Cache invalidated"));
645
+ }
646
+
647
+ public void requestNavigationUpdates(final CordovaInterface cordova,
648
+ CordovaWebView webView,
649
+ JSONArray args,
650
+ final CallbackContext callbackContext) {
651
+ // 1) Parse and check arguments
652
+
653
+ if (this.computedRoute == null) {
654
+ Log.d(TAG, "Situm >> There is not an stored route so you are not allowed to navigate");
655
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, "Compute a valid route with requestDirections before trying to navigate within a route"));
656
+ return;
657
+ }
658
+ // try??
659
+ Route route = this.computedRoute; // args.getJSONObject(0); // Retrieve route from arguments, we do this since Route object has internal properties that we do not want to expose
660
+ // 2) Build Navigation Arguments
661
+ // 2.1) Build Navigation Request
662
+ Log.d(TAG,"requestNavigationUpdates executed: passed route: " + route);
663
+ NavigationRequest.Builder builder = new NavigationRequest.Builder().route(route);
664
+
665
+ try {
666
+ JSONObject navigationJSONOptions = args.getJSONObject(0); // Route should be the first parameter
667
+
668
+ if (navigationJSONOptions.has(SitumMapper.DISTANCE_TO_IGNORE_FIRST_INDICATION)) {
669
+ Double distanceToIgnoreFirstIndication = navigationJSONOptions.getDouble(SitumMapper.DISTANCE_TO_IGNORE_FIRST_INDICATION);
670
+ builder.distanceToIgnoreFirstIndication(distanceToIgnoreFirstIndication);
671
+ }
672
+
673
+ if (navigationJSONOptions.has(SitumMapper.OUTSIDE_ROUTE_THRESHOLD)) {
674
+ Double outsideRouteThreshold = navigationJSONOptions.getDouble(SitumMapper.OUTSIDE_ROUTE_THRESHOLD);
675
+ builder.outsideRouteThreshold(outsideRouteThreshold);
676
+ }
677
+
678
+ if (navigationJSONOptions.has(SitumMapper.DISTANCE_TO_GOAL_THRESHOLD)) {
679
+ Double distanceToGoalThreshold = navigationJSONOptions.getDouble(SitumMapper.DISTANCE_TO_GOAL_THRESHOLD);
680
+ builder.distanceToGoalThreshold(distanceToGoalThreshold);
681
+ }
682
+
683
+ if (navigationJSONOptions.has(SitumMapper.DISTANCE_TO_CHANGE_FLOOR_THRESHOLD)) {
684
+ Double distanceToChangeFloorThreshold = navigationJSONOptions.getDouble(SitumMapper.DISTANCE_TO_CHANGE_FLOOR_THRESHOLD);
685
+ builder.distanceToChangeFloorThreshold(distanceToChangeFloorThreshold);
686
+ }
687
+
688
+ if (navigationJSONOptions.has(SitumMapper.DISTANCE_TO_CHANGE_INDICATION_THRESHOLD)) {
689
+ Double distanceToChangeIndicationThreshold = navigationJSONOptions.getDouble(SitumMapper.DISTANCE_TO_CHANGE_INDICATION_THRESHOLD);
690
+ builder.distanceToChangeIndicationThreshold(distanceToChangeIndicationThreshold);
691
+ }
692
+
693
+ if (navigationJSONOptions.has(SitumMapper.INDICATIONS_INTERVAL)) {
694
+ Long indicationsInterval = navigationJSONOptions.getLong(SitumMapper.INDICATIONS_INTERVAL);
695
+ builder.indicationsInterval(indicationsInterval);
696
+ }
697
+
698
+ if (navigationJSONOptions.has(SitumMapper.TIME_TO_FIRST_INDICATION)) {
699
+ Long timeToFirstIndication = navigationJSONOptions.getLong(SitumMapper.TIME_TO_FIRST_INDICATION);
700
+ builder.timeToFirstIndication(timeToFirstIndication);
701
+ }
702
+
703
+ if (navigationJSONOptions.has(SitumMapper.ROUND_INDICATION_STEP)) {
704
+ Integer roundIndicationsStep = navigationJSONOptions.getInt(SitumMapper.ROUND_INDICATION_STEP);
705
+ builder.roundIndicationsStep(roundIndicationsStep);
706
+ }
707
+
708
+ if (navigationJSONOptions.has(SitumMapper.TIME_TO_IGNORE_UNEXPECTED_FLOOR_CHANGES)) {
709
+ Integer timeToIgnoreUnexpectedFloorChanges = navigationJSONOptions.getInt(SitumMapper.TIME_TO_IGNORE_UNEXPECTED_FLOOR_CHANGES);
710
+ builder.timeToIgnoreUnexpectedFloorChanges(timeToIgnoreUnexpectedFloorChanges);
711
+ }
712
+
713
+ if (navigationJSONOptions.has(SitumMapper.IGNORE_LOW_QUALITY_LOCATIONS)) {
714
+ Boolean ignoreLowQualityLocations = navigationJSONOptions.getBoolean(SitumMapper.IGNORE_LOW_QUALITY_LOCATIONS);
715
+ builder.ignoreLowQualityLocations(ignoreLowQualityLocations);
716
+ }
717
+
718
+ } catch (Exception e) {
719
+ //TODO: handle exception
720
+ Log.d(TAG, "Situm >> Unable to retrieve navigation options. Applying default ones");
721
+ }
722
+
723
+ navigationRequest = builder.build();
724
+
725
+ // 2.2) Build Navigation Callback
726
+ navigationListener = new NavigationListener() {
727
+ public void onProgress(NavigationProgress progress) {
728
+ Log.d(TAG, "On progress received: " + progress);
729
+ try {
730
+ JSONObject jsonProgress = SitumMapper.navigationProgressToJsonObject(progress, cordova.getActivity());
731
+ try {
732
+ jsonProgress.put("type", "progress");
733
+ } catch (JSONException e) {
734
+ Log.e(TAG, "error inserting type in navigation progress");
735
+ }
736
+ PluginResult result = new PluginResult(Status.OK, jsonProgress ); // TODO: Change this to return an object with valid information
737
+ result.setKeepCallback(true);
738
+ callbackContext.sendPluginResult(result);
739
+
740
+ } catch (Exception e) {
741
+ //TODO: handle exception
742
+ Log.d(TAG, "On Error parsing progress: " + progress);
743
+ PluginResult result = new PluginResult(Status.ERROR, e.getMessage());
744
+ result.setKeepCallback(true);
745
+ callbackContext.sendPluginResult(result);
746
+ }
747
+ };
748
+
749
+ public void onDestinationReached() {
750
+ Log.d(TAG, "On destination reached: ");
751
+ JSONObject jsonResult = new JSONObject();
752
+ try {
753
+ jsonResult.put("type", "destinationReached");
754
+ jsonResult.put("message", "Destination reached");
755
+ } catch (JSONException e) {
756
+ Log.e(TAG, "error inserting type in destination reached");
757
+ }
758
+ PluginResult result = new PluginResult(Status.OK,jsonResult);
759
+ result.setKeepCallback(true);
760
+ callbackContext.sendPluginResult(result);
761
+ };
762
+
763
+ public void onUserOutsideRoute() {
764
+ Log.d(TAG, "On user outside route: " );
765
+ JSONObject jsonResult = new JSONObject();
766
+ try {
767
+ jsonResult.put("type", "userOutsideRoute");
768
+ jsonResult.put("message", "User outside route");
769
+ } catch (JSONException e) {
770
+ Log.e(TAG, "error inserting type in user outside route");
771
+ }
772
+ PluginResult result = new PluginResult(Status.OK,jsonResult);
773
+ result.setKeepCallback(true);
774
+ callbackContext.sendPluginResult(result);
775
+ }
776
+ };
777
+
778
+ // 3) Connect interfaces and connect callback back to js
779
+ getNavigationManagerInstance().requestNavigationUpdates(navigationRequest, navigationListener); // Be carefull with exceptions
780
+
781
+ PluginResult result = new PluginResult(Status.OK, "Requested navigation successfully"); // TODO: Change this to return an object with valid information
782
+ result.setKeepCallback(true);
783
+ callbackContext.sendPluginResult(result);
784
+
785
+ }
786
+
787
+ public void requestRealTimeUpdates(final CordovaInterface cordova,
788
+ CordovaWebView webView,
789
+ JSONArray args,
790
+ final CallbackContext callbackContext) {
791
+ try {
792
+ // Convert request to native
793
+ JSONObject jsonRequest = args.getJSONObject(0);
794
+
795
+ RealTimeRequest request = SitumMapper.jsonObjectRealtimeRequest(jsonRequest);
796
+ // Call
797
+
798
+ realtimeListener = new RealTimeListener() {
799
+
800
+ @Override
801
+ public void onUserLocations(RealTimeData realTimeData) {
802
+ Log.d(TAG, "Success retrieving realtime data" + realTimeData);
803
+
804
+ try {
805
+ // Parse information
806
+ JSONObject jsonResult = SitumMapper.realtimeDataToJson(realTimeData);
807
+
808
+ // Send it back to (removing user information)
809
+ PluginResult result = new PluginResult(Status.OK,jsonResult);
810
+ result.setKeepCallback(true);
811
+ callbackContext.sendPluginResult(result);
812
+ } catch (Exception e) {
813
+ Log.d(TAG, "Error exception realtime data" + e);
814
+ }
815
+
816
+
817
+ }
818
+
819
+ @Override
820
+ public void onError(Error error) {
821
+ Log.e(TAG, "Error request realtime data" + error);
822
+ PluginResult result = new PluginResult(Status.ERROR, error.getMessage());
823
+ result.setKeepCallback(true);
824
+ callbackContext.sendPluginResult(result);
825
+ }
826
+
827
+ };
828
+ try {
829
+ getRealtimeManagerInstance().requestRealTimeUpdates(request, realtimeListener);
830
+ } catch (Exception e) {
831
+ Log.e(PluginHelper.TAG, "onError() called with: error = [" + e + "]");
832
+ }
833
+ } catch (Exception e) {
834
+ Log.d(TAG, "exception: " + e);
835
+
836
+ e.printStackTrace();
837
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, e.getMessage()));
838
+ }
839
+ }
840
+
841
+ public void removeRealTimeUpdates(CordovaInterface cordova,
842
+ CordovaWebView webView,
843
+ JSONArray args,
844
+ final CallbackContext callbackContext) {
845
+ //
846
+ Log.i(TAG, "Remove realtime updates");
847
+ getRealtimeManagerInstance().removeRealTimeUpdates(); // TODO: Incorporate sending a result to the exterior
848
+ }
849
+
850
+ // Initialize Navigation Component
851
+
852
+ public void updateNavigationWithLocation(CordovaInterface cordova,
853
+ CordovaWebView webView,
854
+ JSONArray args,
855
+ final CallbackContext callbackContext) {
856
+ try {
857
+ // 1) Check for location arguments
858
+ JSONObject jsonLocation = args.getJSONArray(0).getJSONObject(0); // What if json is not specified?
859
+
860
+ // 2) Create a Location Object from argument
861
+ Location actualLocation = SitumMapper.jsonLocationObjectToLocation(jsonLocation); // Location Objet from JSON
862
+ // Location actualLocation = PluginHelper.computedLocation;
863
+ Log.i(TAG, "UpdateNavigation with Location: " + actualLocation);
864
+
865
+ // 3) Connect interfaces
866
+ getNavigationManagerInstance().updateWithLocation(actualLocation);
867
+ callbackContext.sendPluginResult(new PluginResult(Status.OK, "Navigation updated"));
868
+ } catch (Exception e) {
869
+ e.printStackTrace();
870
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, e.getMessage()));
871
+ }
872
+ }
873
+
874
+ public void removeNavigationUpdates(CordovaInterface cordova,
875
+ CordovaWebView webView,
876
+ JSONArray args,
877
+ final CallbackContext callbackContext) {
878
+ //
879
+ Log.i(TAG, "Remove navigation updates");
880
+ getNavigationManagerInstance().removeUpdates(); // TODO: Incorporate sending a result to the exterior
881
+ }
882
+
883
+ public void requestDirections(final CordovaInterface cordova, CordovaWebView webView, JSONArray args,
884
+ final CallbackContext callbackContext) {
885
+ try {
886
+ JSONObject jsonoBuilding = args.getJSONObject(0);
887
+ JSONObject jsonoFrom = args.getJSONObject(1);
888
+ JSONObject jsonoTo = args.getJSONObject(2);
889
+ JSONObject jsonoOptions = null;
890
+ if (args.length() >= 4) {
891
+ jsonoOptions = args.getJSONObject(3);
892
+ }
893
+ DirectionsRequest directionRequest =
894
+ SitumMapper.jsonObjectToDirectionsRequest(jsonoBuilding, jsonoFrom, jsonoTo, jsonoOptions);
895
+ SitumSdk.directionsManager().requestDirections(directionRequest, new Handler<Route>() {
896
+ @Override
897
+ public void onSuccess(Route route) {
898
+ try {
899
+ PluginHelper.this.computedRoute = route;
900
+ JSONObject jsonoRoute = SitumMapper.routeToJsonObject(route, cordova.getActivity());
901
+ Log.i(TAG, "onSuccess: Route calculated successfully" + route);
902
+ callbackContext.sendPluginResult(new PluginResult(Status.OK, jsonoRoute));
903
+ } catch (JSONException e) {
904
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, e.getMessage()));
905
+ }
906
+ }
907
+
908
+ @Override
909
+ public void onFailure(Error error) {
910
+ Log.e(TAG, "onError:" + error.getMessage());
911
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, error.getMessage()));
912
+ }
913
+ });
914
+ } catch (Exception e) {
915
+ e.printStackTrace();
916
+ callbackContext.sendPluginResult(new PluginResult(Status.ERROR, e.getMessage()));
917
+ }
918
+ }
919
+ }