@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,821 @@
1
+ /*
2
+ Licensed to the Apache Software Foundation (ASF) under one
3
+ or more contributor license agreements. See the NOTICE file
4
+ distributed with this work for additional information
5
+ regarding copyright ownership. The ASF licenses this file
6
+ to you under the Apache License, Version 2.0 (the
7
+ "License"); you may not use this file except in compliance
8
+ with the License. You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing,
13
+ software distributed under the License is distributed on an
14
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ KIND, either express or implied. See the License for the
16
+ specific language governing permissions and limitations
17
+ under the License.
18
+ */
19
+
20
+ #import <objc/message.h>
21
+ #import "CDV.h"
22
+ #import "CDVPlugin+Private.h"
23
+ #import "CDVUIWebViewDelegate.h"
24
+ #import "CDVConfigParser.h"
25
+ #import "CDVUserAgentUtil.h"
26
+ #import <AVFoundation/AVFoundation.h>
27
+ #import "NSDictionary+CordovaPreferences.h"
28
+ #import "CDVLocalStorage.h"
29
+ #import "CDVCommandDelegateImpl.h"
30
+ #import <Foundation/NSCharacterSet.h>
31
+
32
+ @interface CDVViewController () {
33
+ NSInteger _userAgentLockToken;
34
+ }
35
+
36
+ @property (nonatomic, readwrite, strong) NSXMLParser* configParser;
37
+ @property (nonatomic, readwrite, strong) NSMutableDictionary* settings;
38
+ @property (nonatomic, readwrite, strong) NSMutableDictionary* pluginObjects;
39
+ @property (nonatomic, readwrite, strong) NSMutableArray* startupPluginNames;
40
+ @property (nonatomic, readwrite, strong) NSDictionary* pluginsMap;
41
+ @property (nonatomic, readwrite, strong) id <CDVWebViewEngineProtocol> webViewEngine;
42
+
43
+ @property (readwrite, assign) BOOL initialized;
44
+
45
+ @property (atomic, strong) NSURL* openURL;
46
+
47
+ @end
48
+
49
+ @implementation CDVViewController
50
+
51
+ @synthesize supportedOrientations;
52
+ @synthesize pluginObjects, pluginsMap, startupPluginNames;
53
+ @synthesize configParser, settings;
54
+ @synthesize wwwFolderName, startPage, initialized, openURL, baseUserAgent;
55
+ @synthesize commandDelegate = _commandDelegate;
56
+ @synthesize commandQueue = _commandQueue;
57
+ @synthesize webViewEngine = _webViewEngine;
58
+ @dynamic webView;
59
+
60
+ - (void)__init
61
+ {
62
+ if ((self != nil) && !self.initialized) {
63
+ _commandQueue = [[CDVCommandQueue alloc] initWithViewController:self];
64
+ _commandDelegate = [[CDVCommandDelegateImpl alloc] initWithViewController:self];
65
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppWillTerminate:)
66
+ name:UIApplicationWillTerminateNotification object:nil];
67
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppWillResignActive:)
68
+ name:UIApplicationWillResignActiveNotification object:nil];
69
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppDidBecomeActive:)
70
+ name:UIApplicationDidBecomeActiveNotification object:nil];
71
+
72
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppWillEnterForeground:)
73
+ name:UIApplicationWillEnterForegroundNotification object:nil];
74
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppDidEnterBackground:)
75
+ name:UIApplicationDidEnterBackgroundNotification object:nil];
76
+
77
+ // read from UISupportedInterfaceOrientations (or UISupportedInterfaceOrientations~iPad, if its iPad) from -Info.plist
78
+ self.supportedOrientations = [self parseInterfaceOrientations:
79
+ [[[NSBundle mainBundle] infoDictionary] objectForKey:@"UISupportedInterfaceOrientations"]];
80
+
81
+ [self printVersion];
82
+ [self printMultitaskingInfo];
83
+ [self printPlatformVersionWarning];
84
+ self.initialized = YES;
85
+ }
86
+ }
87
+
88
+ - (id)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil
89
+ {
90
+ self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
91
+ [self __init];
92
+ return self;
93
+ }
94
+
95
+ - (id)initWithCoder:(NSCoder*)aDecoder
96
+ {
97
+ self = [super initWithCoder:aDecoder];
98
+ [self __init];
99
+ return self;
100
+ }
101
+
102
+ - (id)init
103
+ {
104
+ self = [super init];
105
+ [self __init];
106
+ return self;
107
+ }
108
+
109
+ - (void)printVersion
110
+ {
111
+ NSLog(@"Apache Cordova native platform version %@ is starting.", CDV_VERSION);
112
+ }
113
+
114
+ - (void)printPlatformVersionWarning
115
+ {
116
+ if (!IsAtLeastiOSVersion(@"8.0")) {
117
+ NSLog(@"CRITICAL: For Cordova 4.0.0 and above, you will need to upgrade to at least iOS 8.0 or greater. Your current version of iOS is %@.",
118
+ [[UIDevice currentDevice] systemVersion]
119
+ );
120
+ }
121
+ }
122
+
123
+ - (void)printMultitaskingInfo
124
+ {
125
+ UIDevice* device = [UIDevice currentDevice];
126
+ BOOL backgroundSupported = NO;
127
+
128
+ if ([device respondsToSelector:@selector(isMultitaskingSupported)]) {
129
+ backgroundSupported = device.multitaskingSupported;
130
+ }
131
+
132
+ NSNumber* exitsOnSuspend = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UIApplicationExitsOnSuspend"];
133
+ if (exitsOnSuspend == nil) { // if it's missing, it should be NO (i.e. multi-tasking on by default)
134
+ exitsOnSuspend = [NSNumber numberWithBool:NO];
135
+ }
136
+
137
+ NSLog(@"Multi-tasking -> Device: %@, App: %@", (backgroundSupported ? @"YES" : @"NO"), (![exitsOnSuspend intValue]) ? @"YES" : @"NO");
138
+ }
139
+
140
+ -(NSString*)configFilePath{
141
+ NSString* path = self.configFile ?: @"config.xml";
142
+
143
+ // if path is relative, resolve it against the main bundle
144
+ if(![path isAbsolutePath]){
145
+ NSString* absolutePath = [[NSBundle mainBundle] pathForResource:path ofType:nil];
146
+ if(!absolutePath){
147
+ NSAssert(NO, @"ERROR: %@ not found in the main bundle!", path);
148
+ }
149
+ path = absolutePath;
150
+ }
151
+
152
+ // Assert file exists
153
+ if (![[NSFileManager defaultManager] fileExistsAtPath:path]) {
154
+ NSAssert(NO, @"ERROR: %@ does not exist. Please run cordova-ios/bin/cordova_plist_to_config_xml path/to/project.", path);
155
+ return nil;
156
+ }
157
+
158
+ return path;
159
+ }
160
+
161
+ - (void)parseSettingsWithParser:(NSObject <NSXMLParserDelegate>*)delegate
162
+ {
163
+ // read from config.xml in the app bundle
164
+ NSString* path = [self configFilePath];
165
+
166
+ NSURL* url = [NSURL fileURLWithPath:path];
167
+
168
+ self.configParser = [[NSXMLParser alloc] initWithContentsOfURL:url];
169
+ if (self.configParser == nil) {
170
+ NSLog(@"Failed to initialize XML parser.");
171
+ return;
172
+ }
173
+ [self.configParser setDelegate:((id < NSXMLParserDelegate >)delegate)];
174
+ [self.configParser parse];
175
+ }
176
+
177
+ - (void)loadSettings
178
+ {
179
+ CDVConfigParser* delegate = [[CDVConfigParser alloc] init];
180
+
181
+ [self parseSettingsWithParser:delegate];
182
+
183
+ // Get the plugin dictionary, whitelist and settings from the delegate.
184
+ self.pluginsMap = delegate.pluginsDict;
185
+ self.startupPluginNames = delegate.startupPluginNames;
186
+ self.settings = delegate.settings;
187
+
188
+ // And the start folder/page.
189
+ if(self.wwwFolderName == nil){
190
+ self.wwwFolderName = @"www";
191
+ }
192
+ if(delegate.startPage && self.startPage == nil){
193
+ self.startPage = delegate.startPage;
194
+ }
195
+ if (self.startPage == nil) {
196
+ self.startPage = @"index.html";
197
+ }
198
+
199
+ // Initialize the plugin objects dict.
200
+ self.pluginObjects = [[NSMutableDictionary alloc] initWithCapacity:20];
201
+ }
202
+
203
+ - (NSURL*)appUrl
204
+ {
205
+ NSURL* appURL = nil;
206
+
207
+ if ([self.startPage rangeOfString:@"://"].location != NSNotFound) {
208
+ appURL = [NSURL URLWithString:self.startPage];
209
+ } else if ([self.wwwFolderName rangeOfString:@"://"].location != NSNotFound) {
210
+ appURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@/%@", self.wwwFolderName, self.startPage]];
211
+ } else if([self.wwwFolderName rangeOfString:@".bundle"].location != NSNotFound){
212
+ // www folder is actually a bundle
213
+ NSBundle* bundle = [NSBundle bundleWithPath:self.wwwFolderName];
214
+ appURL = [bundle URLForResource:self.startPage withExtension:nil];
215
+ } else if([self.wwwFolderName rangeOfString:@".framework"].location != NSNotFound){
216
+ // www folder is actually a framework
217
+ NSBundle* bundle = [NSBundle bundleWithPath:self.wwwFolderName];
218
+ appURL = [bundle URLForResource:self.startPage withExtension:nil];
219
+ } else {
220
+ // CB-3005 strip parameters from start page to check if page exists in resources
221
+ NSURL* startURL = [NSURL URLWithString:self.startPage];
222
+ NSString* startFilePath = [self.commandDelegate pathForResource:[startURL path]];
223
+
224
+ if (startFilePath == nil) {
225
+ appURL = nil;
226
+ } else {
227
+ appURL = [NSURL fileURLWithPath:startFilePath];
228
+ // CB-3005 Add on the query params or fragment.
229
+ NSString* startPageNoParentDirs = self.startPage;
230
+ NSRange r = [startPageNoParentDirs rangeOfCharacterFromSet:[NSCharacterSet characterSetWithCharactersInString:@"?#"] options:0];
231
+ if (r.location != NSNotFound) {
232
+ NSString* queryAndOrFragment = [self.startPage substringFromIndex:r.location];
233
+ appURL = [NSURL URLWithString:queryAndOrFragment relativeToURL:appURL];
234
+ }
235
+ }
236
+ }
237
+
238
+ return appURL;
239
+ }
240
+
241
+ - (NSURL*)errorURL
242
+ {
243
+ NSURL* errorUrl = nil;
244
+
245
+ id setting = [self.settings cordovaSettingForKey:@"ErrorUrl"];
246
+
247
+ if (setting) {
248
+ NSString* errorUrlString = (NSString*)setting;
249
+ if ([errorUrlString rangeOfString:@"://"].location != NSNotFound) {
250
+ errorUrl = [NSURL URLWithString:errorUrlString];
251
+ } else {
252
+ NSURL* url = [NSURL URLWithString:(NSString*)setting];
253
+ NSString* errorFilePath = [self.commandDelegate pathForResource:[url path]];
254
+ if (errorFilePath) {
255
+ errorUrl = [NSURL fileURLWithPath:errorFilePath];
256
+ }
257
+ }
258
+ }
259
+
260
+ return errorUrl;
261
+ }
262
+
263
+ - (UIView*)webView
264
+ {
265
+ if (self.webViewEngine != nil) {
266
+ return self.webViewEngine.engineWebView;
267
+ }
268
+
269
+ return nil;
270
+ }
271
+
272
+ // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
273
+ - (void)viewDidLoad
274
+ {
275
+ [super viewDidLoad];
276
+
277
+ // Load settings
278
+ [self loadSettings];
279
+
280
+ NSString* backupWebStorageType = @"cloud"; // default value
281
+
282
+ id backupWebStorage = [self.settings cordovaSettingForKey:@"BackupWebStorage"];
283
+ if ([backupWebStorage isKindOfClass:[NSString class]]) {
284
+ backupWebStorageType = backupWebStorage;
285
+ }
286
+ [self.settings setCordovaSetting:backupWebStorageType forKey:@"BackupWebStorage"];
287
+
288
+ [CDVLocalStorage __fixupDatabaseLocationsWithBackupType:backupWebStorageType];
289
+
290
+ // // Instantiate the WebView ///////////////
291
+
292
+ if (!self.webView) {
293
+ [self createGapView];
294
+ }
295
+
296
+ // /////////////////
297
+
298
+ /*
299
+ * Fire up CDVLocalStorage to work-around WebKit storage limitations: on all iOS 5.1+ versions for local-only backups, but only needed on iOS 5.1 for cloud backup.
300
+ With minimum iOS 7/8 supported, only first clause applies.
301
+ */
302
+ if ([backupWebStorageType isEqualToString:@"local"]) {
303
+ NSString* localStorageFeatureName = @"localstorage";
304
+ if ([self.pluginsMap objectForKey:localStorageFeatureName]) { // plugin specified in config
305
+ [self.startupPluginNames addObject:localStorageFeatureName];
306
+ }
307
+ }
308
+
309
+ if ([self.startupPluginNames count] > 0) {
310
+ [CDVTimer start:@"TotalPluginStartup"];
311
+
312
+ for (NSString* pluginName in self.startupPluginNames) {
313
+ [CDVTimer start:pluginName];
314
+ [self getCommandInstance:pluginName];
315
+ [CDVTimer stop:pluginName];
316
+ }
317
+
318
+ [CDVTimer stop:@"TotalPluginStartup"];
319
+ }
320
+
321
+ // /////////////////
322
+ NSURL* appURL = [self appUrl];
323
+ __weak __typeof__(self) weakSelf = self;
324
+
325
+ [CDVUserAgentUtil acquireLock:^(NSInteger lockToken) {
326
+ // Fix the memory leak caused by the strong reference.
327
+ [weakSelf setLockToken:lockToken];
328
+ if (appURL) {
329
+ NSURLRequest* appReq = [NSURLRequest requestWithURL:appURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20.0];
330
+ [self.webViewEngine loadRequest:appReq];
331
+ } else {
332
+ NSString* loadErr = [NSString stringWithFormat:@"ERROR: Start Page at '%@/%@' was not found.", self.wwwFolderName, self.startPage];
333
+ NSLog(@"%@", loadErr);
334
+
335
+ NSURL* errorUrl = [self errorURL];
336
+ if (errorUrl) {
337
+ errorUrl = [NSURL URLWithString:[NSString stringWithFormat:@"?error=%@", [loadErr stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLPathAllowedCharacterSet]] relativeToURL:errorUrl];
338
+ NSLog(@"%@", [errorUrl absoluteString]);
339
+ [self.webViewEngine loadRequest:[NSURLRequest requestWithURL:errorUrl]];
340
+ } else {
341
+ NSString* html = [NSString stringWithFormat:@"<html><body> %@ </body></html>", loadErr];
342
+ [self.webViewEngine loadHTMLString:html baseURL:nil];
343
+ }
344
+ }
345
+ }];
346
+
347
+ // /////////////////
348
+
349
+ NSString* bgColorString = [self.settings cordovaSettingForKey:@"BackgroundColor"];
350
+ UIColor* bgColor = [self colorFromColorString:bgColorString];
351
+ [self.webView setBackgroundColor:bgColor];
352
+ }
353
+
354
+ - (void)setLockToken:(NSInteger)lockToken
355
+ {
356
+ _userAgentLockToken = lockToken;
357
+ [CDVUserAgentUtil setUserAgent:self.userAgent lockToken:lockToken];
358
+ }
359
+
360
+ -(void)viewWillAppear:(BOOL)animated
361
+ {
362
+ [super viewWillAppear:animated];
363
+ [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVViewWillAppearNotification object:nil]];
364
+ }
365
+
366
+ -(void)viewDidAppear:(BOOL)animated
367
+ {
368
+ [super viewDidAppear:animated];
369
+ [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVViewDidAppearNotification object:nil]];
370
+ }
371
+
372
+ -(void)viewWillDisappear:(BOOL)animated
373
+ {
374
+ [super viewWillDisappear:animated];
375
+ [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVViewWillDisappearNotification object:nil]];
376
+ }
377
+
378
+ -(void)viewDidDisappear:(BOOL)animated
379
+ {
380
+ [super viewDidDisappear:animated];
381
+ [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVViewDidDisappearNotification object:nil]];
382
+ }
383
+
384
+ -(void)viewWillLayoutSubviews
385
+ {
386
+ [super viewWillLayoutSubviews];
387
+ [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVViewWillLayoutSubviewsNotification object:nil]];
388
+ }
389
+
390
+ -(void)viewDidLayoutSubviews
391
+ {
392
+ [super viewDidLayoutSubviews];
393
+ [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVViewDidLayoutSubviewsNotification object:nil]];
394
+ }
395
+
396
+ -(void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
397
+ {
398
+ [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
399
+ [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVViewWillTransitionToSizeNotification object:[NSValue valueWithCGSize:size]]];
400
+ }
401
+
402
+ - (UIColor*)colorFromColorString:(NSString*)colorString
403
+ {
404
+ // No value, nothing to do
405
+ if (!colorString) {
406
+ return nil;
407
+ }
408
+
409
+ // Validate format
410
+ NSError* error = NULL;
411
+ NSRegularExpression* regex = [NSRegularExpression regularExpressionWithPattern:@"^(#[0-9A-F]{3}|(0x|#)([0-9A-F]{2})?[0-9A-F]{6})$" options:NSRegularExpressionCaseInsensitive error:&error];
412
+ NSUInteger countMatches = [regex numberOfMatchesInString:colorString options:0 range:NSMakeRange(0, [colorString length])];
413
+
414
+ if (!countMatches) {
415
+ return nil;
416
+ }
417
+
418
+ // #FAB to #FFAABB
419
+ if ([colorString hasPrefix:@"#"] && [colorString length] == 4) {
420
+ NSString* r = [colorString substringWithRange:NSMakeRange(1, 1)];
421
+ NSString* g = [colorString substringWithRange:NSMakeRange(2, 1)];
422
+ NSString* b = [colorString substringWithRange:NSMakeRange(3, 1)];
423
+ colorString = [NSString stringWithFormat:@"#%@%@%@%@%@%@", r, r, g, g, b, b];
424
+ }
425
+
426
+ // #RRGGBB to 0xRRGGBB
427
+ colorString = [colorString stringByReplacingOccurrencesOfString:@"#" withString:@"0x"];
428
+
429
+ // 0xRRGGBB to 0xAARRGGBB
430
+ if ([colorString hasPrefix:@"0x"] && [colorString length] == 8) {
431
+ colorString = [@"0xFF" stringByAppendingString:[colorString substringFromIndex:2]];
432
+ }
433
+
434
+ // 0xAARRGGBB to int
435
+ unsigned colorValue = 0;
436
+ NSScanner *scanner = [NSScanner scannerWithString:colorString];
437
+ if (![scanner scanHexInt:&colorValue]) {
438
+ return nil;
439
+ }
440
+
441
+ // int to UIColor
442
+ return [UIColor colorWithRed:((float)((colorValue & 0x00FF0000) >> 16))/255.0
443
+ green:((float)((colorValue & 0x0000FF00) >> 8))/255.0
444
+ blue:((float)((colorValue & 0x000000FF) >> 0))/255.0
445
+ alpha:((float)((colorValue & 0xFF000000) >> 24))/255.0];
446
+ }
447
+
448
+ - (NSArray*)parseInterfaceOrientations:(NSArray*)orientations
449
+ {
450
+ NSMutableArray* result = [[NSMutableArray alloc] init];
451
+
452
+ if (orientations != nil) {
453
+ NSEnumerator* enumerator = [orientations objectEnumerator];
454
+ NSString* orientationString;
455
+
456
+ while (orientationString = [enumerator nextObject]) {
457
+ if ([orientationString isEqualToString:@"UIInterfaceOrientationPortrait"]) {
458
+ [result addObject:[NSNumber numberWithInt:UIInterfaceOrientationPortrait]];
459
+ } else if ([orientationString isEqualToString:@"UIInterfaceOrientationPortraitUpsideDown"]) {
460
+ [result addObject:[NSNumber numberWithInt:UIInterfaceOrientationPortraitUpsideDown]];
461
+ } else if ([orientationString isEqualToString:@"UIInterfaceOrientationLandscapeLeft"]) {
462
+ [result addObject:[NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft]];
463
+ } else if ([orientationString isEqualToString:@"UIInterfaceOrientationLandscapeRight"]) {
464
+ [result addObject:[NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight]];
465
+ }
466
+ }
467
+ }
468
+
469
+ // default
470
+ if ([result count] == 0) {
471
+ [result addObject:[NSNumber numberWithInt:UIInterfaceOrientationPortrait]];
472
+ }
473
+
474
+ return result;
475
+ }
476
+
477
+ - (BOOL)shouldAutorotate
478
+ {
479
+ return YES;
480
+ }
481
+
482
+ // CB-12098
483
+ #if __IPHONE_OS_VERSION_MAX_ALLOWED < 90000
484
+ - (NSUInteger)supportedInterfaceOrientations
485
+ #else
486
+ - (UIInterfaceOrientationMask)supportedInterfaceOrientations
487
+ #endif
488
+ {
489
+ NSUInteger ret = 0;
490
+
491
+ if ([self supportsOrientation:UIInterfaceOrientationPortrait]) {
492
+ ret = ret | (1 << UIInterfaceOrientationPortrait);
493
+ }
494
+ if ([self supportsOrientation:UIInterfaceOrientationPortraitUpsideDown]) {
495
+ ret = ret | (1 << UIInterfaceOrientationPortraitUpsideDown);
496
+ }
497
+ if ([self supportsOrientation:UIInterfaceOrientationLandscapeRight]) {
498
+ ret = ret | (1 << UIInterfaceOrientationLandscapeRight);
499
+ }
500
+ if ([self supportsOrientation:UIInterfaceOrientationLandscapeLeft]) {
501
+ ret = ret | (1 << UIInterfaceOrientationLandscapeLeft);
502
+ }
503
+
504
+ return ret;
505
+ }
506
+
507
+ - (BOOL)supportsOrientation:(UIInterfaceOrientation)orientation
508
+ {
509
+ return [self.supportedOrientations containsObject:[NSNumber numberWithInt:orientation]];
510
+ }
511
+
512
+ - (UIView*)newCordovaViewWithFrame:(CGRect)bounds
513
+ {
514
+ NSString* defaultWebViewEngineClass = [self.settings cordovaSettingForKey:@"CordovaDefaultWebViewEngine"];
515
+ NSString* webViewEngineClass = [self.settings cordovaSettingForKey:@"CordovaWebViewEngine"];
516
+
517
+ if (!defaultWebViewEngineClass) {
518
+ defaultWebViewEngineClass = @"CDVUIWebViewEngine";
519
+ }
520
+ if (!webViewEngineClass) {
521
+ webViewEngineClass = defaultWebViewEngineClass;
522
+ }
523
+
524
+ // Find webViewEngine
525
+ if (NSClassFromString(webViewEngineClass)) {
526
+ self.webViewEngine = [[NSClassFromString(webViewEngineClass) alloc] initWithFrame:bounds];
527
+ // if a webView engine returns nil (not supported by the current iOS version) or doesn't conform to the protocol, or can't load the request, we use UIWebView
528
+ if (!self.webViewEngine || ![self.webViewEngine conformsToProtocol:@protocol(CDVWebViewEngineProtocol)] || ![self.webViewEngine canLoadRequest:[NSURLRequest requestWithURL:self.appUrl]]) {
529
+ self.webViewEngine = [[NSClassFromString(defaultWebViewEngineClass) alloc] initWithFrame:bounds];
530
+ }
531
+ } else {
532
+ self.webViewEngine = [[NSClassFromString(defaultWebViewEngineClass) alloc] initWithFrame:bounds];
533
+ }
534
+
535
+ if ([self.webViewEngine isKindOfClass:[CDVPlugin class]]) {
536
+ [self registerPlugin:(CDVPlugin*)self.webViewEngine withClassName:webViewEngineClass];
537
+ }
538
+
539
+ return self.webViewEngine.engineWebView;
540
+ }
541
+
542
+ - (NSString*)userAgent
543
+ {
544
+ if (_userAgent != nil) {
545
+ return _userAgent;
546
+ }
547
+
548
+ NSString* localBaseUserAgent;
549
+ if (self.baseUserAgent != nil) {
550
+ localBaseUserAgent = self.baseUserAgent;
551
+ } else if ([self.settings cordovaSettingForKey:@"OverrideUserAgent"] != nil) {
552
+ localBaseUserAgent = [self.settings cordovaSettingForKey:@"OverrideUserAgent"];
553
+ } else {
554
+ localBaseUserAgent = [CDVUserAgentUtil originalUserAgent];
555
+ }
556
+ NSString* appendUserAgent = [self.settings cordovaSettingForKey:@"AppendUserAgent"];
557
+ if (appendUserAgent) {
558
+ _userAgent = [NSString stringWithFormat:@"%@ %@", localBaseUserAgent, appendUserAgent];
559
+ } else {
560
+ // Use our address as a unique number to append to the User-Agent.
561
+ _userAgent = localBaseUserAgent;
562
+ }
563
+ return _userAgent;
564
+ }
565
+
566
+ - (void)createGapView
567
+ {
568
+ CGRect webViewBounds = self.view.bounds;
569
+
570
+ webViewBounds.origin = self.view.bounds.origin;
571
+
572
+ UIView* view = [self newCordovaViewWithFrame:webViewBounds];
573
+
574
+ view.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
575
+ [self.view addSubview:view];
576
+ [self.view sendSubviewToBack:view];
577
+ }
578
+
579
+ - (void)didReceiveMemoryWarning
580
+ {
581
+ // iterate through all the plugin objects, and call hasPendingOperation
582
+ // if at least one has a pending operation, we don't call [super didReceiveMemoryWarning]
583
+
584
+ NSEnumerator* enumerator = [self.pluginObjects objectEnumerator];
585
+ CDVPlugin* plugin;
586
+
587
+ BOOL doPurge = YES;
588
+
589
+ while ((plugin = [enumerator nextObject])) {
590
+ if (plugin.hasPendingOperation) {
591
+ NSLog(@"Plugin '%@' has a pending operation, memory purge is delayed for didReceiveMemoryWarning.", NSStringFromClass([plugin class]));
592
+ doPurge = NO;
593
+ }
594
+ }
595
+
596
+ if (doPurge) {
597
+ // Releases the view if it doesn't have a superview.
598
+ [super didReceiveMemoryWarning];
599
+ }
600
+
601
+ // Release any cached data, images, etc. that aren't in use.
602
+ }
603
+
604
+ - (void)viewDidUnload
605
+ {
606
+ // Release any retained subviews of the main view.
607
+ // e.g. self.myOutlet = nil;
608
+
609
+ [CDVUserAgentUtil releaseLock:&_userAgentLockToken];
610
+
611
+ [super viewDidUnload];
612
+ }
613
+
614
+ #pragma mark CordovaCommands
615
+
616
+ - (void)registerPlugin:(CDVPlugin*)plugin withClassName:(NSString*)className
617
+ {
618
+ if ([plugin respondsToSelector:@selector(setViewController:)]) {
619
+ [plugin setViewController:self];
620
+ }
621
+
622
+ if ([plugin respondsToSelector:@selector(setCommandDelegate:)]) {
623
+ [plugin setCommandDelegate:_commandDelegate];
624
+ }
625
+
626
+ [self.pluginObjects setObject:plugin forKey:className];
627
+ [plugin pluginInitialize];
628
+ }
629
+
630
+ - (void)registerPlugin:(CDVPlugin*)plugin withPluginName:(NSString*)pluginName
631
+ {
632
+ if ([plugin respondsToSelector:@selector(setViewController:)]) {
633
+ [plugin setViewController:self];
634
+ }
635
+
636
+ if ([plugin respondsToSelector:@selector(setCommandDelegate:)]) {
637
+ [plugin setCommandDelegate:_commandDelegate];
638
+ }
639
+
640
+ NSString* className = NSStringFromClass([plugin class]);
641
+ [self.pluginObjects setObject:plugin forKey:className];
642
+ [self.pluginsMap setValue:className forKey:[pluginName lowercaseString]];
643
+ [plugin pluginInitialize];
644
+ }
645
+
646
+ /**
647
+ Returns an instance of a CordovaCommand object, based on its name. If one exists already, it is returned.
648
+ */
649
+ - (id)getCommandInstance:(NSString*)pluginName
650
+ {
651
+ // first, we try to find the pluginName in the pluginsMap
652
+ // (acts as a whitelist as well) if it does not exist, we return nil
653
+ // NOTE: plugin names are matched as lowercase to avoid problems - however, a
654
+ // possible issue is there can be duplicates possible if you had:
655
+ // "org.apache.cordova.Foo" and "org.apache.cordova.foo" - only the lower-cased entry will match
656
+ NSString* className = [self.pluginsMap objectForKey:[pluginName lowercaseString]];
657
+
658
+ if (className == nil) {
659
+ return nil;
660
+ }
661
+
662
+ id obj = [self.pluginObjects objectForKey:className];
663
+ if (!obj) {
664
+ obj = [[NSClassFromString(className)alloc] initWithWebViewEngine:_webViewEngine];
665
+ if (!obj) {
666
+ NSString* fullClassName = [NSString stringWithFormat:@"%@.%@",
667
+ NSBundle.mainBundle.infoDictionary[@"CFBundleExecutable"],
668
+ className];
669
+ obj = [[NSClassFromString(fullClassName)alloc] initWithWebViewEngine:_webViewEngine];
670
+ }
671
+
672
+ if (obj != nil) {
673
+ [self registerPlugin:obj withClassName:className];
674
+ } else {
675
+ NSLog(@"CDVPlugin class %@ (pluginName: %@) does not exist.", className, pluginName);
676
+ }
677
+ }
678
+ return obj;
679
+ }
680
+
681
+ #pragma mark -
682
+
683
+ - (NSString*)appURLScheme
684
+ {
685
+ NSString* URLScheme = nil;
686
+
687
+ NSArray* URLTypes = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleURLTypes"];
688
+
689
+ if (URLTypes != nil) {
690
+ NSDictionary* dict = [URLTypes objectAtIndex:0];
691
+ if (dict != nil) {
692
+ NSArray* URLSchemes = [dict objectForKey:@"CFBundleURLSchemes"];
693
+ if (URLSchemes != nil) {
694
+ URLScheme = [URLSchemes objectAtIndex:0];
695
+ }
696
+ }
697
+ }
698
+
699
+ return URLScheme;
700
+ }
701
+
702
+ #pragma mark -
703
+ #pragma mark UIApplicationDelegate impl
704
+
705
+ /*
706
+ This method lets your application know that it is about to be terminated and purged from memory entirely
707
+ */
708
+ - (void)onAppWillTerminate:(NSNotification*)notification
709
+ {
710
+ // empty the tmp directory
711
+ NSFileManager* fileMgr = [[NSFileManager alloc] init];
712
+ NSError* __autoreleasing err = nil;
713
+
714
+ // clear contents of NSTemporaryDirectory
715
+ NSString* tempDirectoryPath = NSTemporaryDirectory();
716
+ NSDirectoryEnumerator* directoryEnumerator = [fileMgr enumeratorAtPath:tempDirectoryPath];
717
+ NSString* fileName = nil;
718
+ BOOL result;
719
+
720
+ while ((fileName = [directoryEnumerator nextObject])) {
721
+ NSString* filePath = [tempDirectoryPath stringByAppendingPathComponent:fileName];
722
+ result = [fileMgr removeItemAtPath:filePath error:&err];
723
+ if (!result && err) {
724
+ NSLog(@"Failed to delete: %@ (error: %@)", filePath, err);
725
+ }
726
+ }
727
+ }
728
+
729
+ - (bool)isUrlEmpty:(NSURL *)url
730
+ {
731
+ if (!url || (url == (id) [NSNull null])) {
732
+ return true;
733
+ }
734
+ NSString *urlAsString = [url absoluteString];
735
+ return (urlAsString == (id) [NSNull null] || [urlAsString length]==0 || [urlAsString isEqualToString:@"about:blank"]);
736
+ }
737
+
738
+ - (bool)checkAndReinitViewUrl
739
+ {
740
+ NSURL* appURL = [self appUrl];
741
+ if ([self isUrlEmpty: [self.webViewEngine URL]] && ![self isUrlEmpty: appURL]) {
742
+ NSURLRequest* appReq = [NSURLRequest requestWithURL:appURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20.0];
743
+ [self.webViewEngine loadRequest:appReq];
744
+ return true;
745
+ }
746
+ return false;
747
+ }
748
+
749
+ /*
750
+ This method is called to let your application know that it is about to move from the active to inactive state.
751
+ You should use this method to pause ongoing tasks, disable timer, ...
752
+ */
753
+ - (void)onAppWillResignActive:(NSNotification*)notification
754
+ {
755
+ [self checkAndReinitViewUrl];
756
+ // NSLog(@"%@",@"applicationWillResignActive");
757
+ [self.commandDelegate evalJs:@"cordova.fireDocumentEvent('resign');" scheduledOnRunLoop:NO];
758
+ }
759
+
760
+ /*
761
+ In iOS 4.0 and later, this method is called as part of the transition from the background to the inactive state.
762
+ You can use this method to undo many of the changes you made to your application upon entering the background.
763
+ invariably followed by applicationDidBecomeActive
764
+ */
765
+ - (void)onAppWillEnterForeground:(NSNotification*)notification
766
+ {
767
+ [self checkAndReinitViewUrl];
768
+ // NSLog(@"%@",@"applicationWillEnterForeground");
769
+ [self.commandDelegate evalJs:@"cordova.fireDocumentEvent('resume');"];
770
+
771
+ if (!IsAtLeastiOSVersion(@"11.0")) {
772
+ /** Clipboard fix **/
773
+ UIPasteboard* pasteboard = [UIPasteboard generalPasteboard];
774
+ NSString* string = pasteboard.string;
775
+ if (string) {
776
+ [pasteboard setValue:string forPasteboardType:@"public.text"];
777
+ }
778
+ }
779
+ }
780
+
781
+ // This method is called to let your application know that it moved from the inactive to active state.
782
+ - (void)onAppDidBecomeActive:(NSNotification*)notification
783
+ {
784
+ [self checkAndReinitViewUrl];
785
+ // NSLog(@"%@",@"applicationDidBecomeActive");
786
+ [self.commandDelegate evalJs:@"cordova.fireDocumentEvent('active');"];
787
+ }
788
+
789
+ /*
790
+ In iOS 4.0 and later, this method is called instead of the applicationWillTerminate: method
791
+ when the user quits an application that supports background execution.
792
+ */
793
+ - (void)onAppDidEnterBackground:(NSNotification*)notification
794
+ {
795
+ [self checkAndReinitViewUrl];
796
+ // NSLog(@"%@",@"applicationDidEnterBackground");
797
+ [self.commandDelegate evalJs:@"cordova.fireDocumentEvent('pause', null, true);" scheduledOnRunLoop:NO];
798
+ }
799
+
800
+ // ///////////////////////
801
+
802
+ - (void)dealloc
803
+ {
804
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
805
+
806
+ [CDVUserAgentUtil releaseLock:&_userAgentLockToken];
807
+ [_commandQueue dispose];
808
+ [[self.pluginObjects allValues] makeObjectsPerformSelector:@selector(dispose)];
809
+
810
+ [self.webViewEngine loadHTMLString:@"about:blank" baseURL:nil];
811
+ [self.pluginObjects removeAllObjects];
812
+ [self.webView removeFromSuperview];
813
+ self.webViewEngine = nil;
814
+ }
815
+
816
+ - (NSInteger*)userAgentLockToken
817
+ {
818
+ return &_userAgentLockToken;
819
+ }
820
+
821
+ @end