react-native-nitro-background-geolocation 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (306) hide show
  1. package/NitroBackgroundGeolocation.podspec +29 -0
  2. package/android/CMakeLists.txt +24 -0
  3. package/android/build.gradle +133 -0
  4. package/android/src/main/AndroidManifest.xml +65 -0
  5. package/android/src/main/cpp/cpp-adapter.cpp +11 -0
  6. package/android/src/main/java/com/margelo/nitro/nitrobackgroundgeolocation/ConfigMapper.kt +332 -0
  7. package/android/src/main/java/com/margelo/nitro/nitrobackgroundgeolocation/HeadlessTaskRegistry.kt +23 -0
  8. package/android/src/main/java/com/margelo/nitro/nitrobackgroundgeolocation/HeadlessTaskService.kt +66 -0
  9. package/android/src/main/java/com/margelo/nitro/nitrobackgroundgeolocation/NitroBackgroundGeolocation.kt +538 -0
  10. package/android/src/main/java/com/margelo/nitro/nitrobackgroundgeolocation/NitroBackgroundGeolocationPackage.kt +22 -0
  11. package/android/src/main/java/com/margelo/nitro/nitrobackgroundgeolocation/ReactNativeHeadlessTaskRunner.kt +62 -0
  12. package/android/src/main/java/com/marianhello/bgloc/BackgroundGeolocationFacade.java +542 -0
  13. package/android/src/main/java/com/marianhello/bgloc/BootCompletedReceiver.java +59 -0
  14. package/android/src/main/java/com/marianhello/bgloc/Config.java +652 -0
  15. package/android/src/main/java/com/marianhello/bgloc/ConnectivityListener.java +5 -0
  16. package/android/src/main/java/com/marianhello/bgloc/HttpPostService.java +168 -0
  17. package/android/src/main/java/com/marianhello/bgloc/LocationManager.java +138 -0
  18. package/android/src/main/java/com/marianhello/bgloc/PluginDelegate.java +19 -0
  19. package/android/src/main/java/com/marianhello/bgloc/PluginException.java +38 -0
  20. package/android/src/main/java/com/marianhello/bgloc/PostLocationTask.java +186 -0
  21. package/android/src/main/java/com/marianhello/bgloc/ResourceResolver.java +55 -0
  22. package/android/src/main/java/com/marianhello/bgloc/data/AbstractLocationTemplate.java +69 -0
  23. package/android/src/main/java/com/marianhello/bgloc/data/ArrayListLocationTemplate.java +88 -0
  24. package/android/src/main/java/com/marianhello/bgloc/data/BackgroundActivity.java +108 -0
  25. package/android/src/main/java/com/marianhello/bgloc/data/BackgroundLocation.java +994 -0
  26. package/android/src/main/java/com/marianhello/bgloc/data/ConfigurationDAO.java +13 -0
  27. package/android/src/main/java/com/marianhello/bgloc/data/DAOFactory.java +17 -0
  28. package/android/src/main/java/com/marianhello/bgloc/data/HashMapLocationTemplate.java +82 -0
  29. package/android/src/main/java/com/marianhello/bgloc/data/LocationDAO.java +22 -0
  30. package/android/src/main/java/com/marianhello/bgloc/data/LocationTemplate.java +12 -0
  31. package/android/src/main/java/com/marianhello/bgloc/data/LocationTemplateFactory.java +65 -0
  32. package/android/src/main/java/com/marianhello/bgloc/data/LocationTransform.java +19 -0
  33. package/android/src/main/java/com/marianhello/bgloc/data/provider/ContentProviderLocationDAO.java +395 -0
  34. package/android/src/main/java/com/marianhello/bgloc/data/provider/LocationContentProvider.java +321 -0
  35. package/android/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteConfigurationContract.java +76 -0
  36. package/android/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteConfigurationDAO.java +160 -0
  37. package/android/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteLocationContract.java +112 -0
  38. package/android/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteLocationDAO.java +506 -0
  39. package/android/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteOpenHelper.java +151 -0
  40. package/android/src/main/java/com/marianhello/bgloc/headless/AbstractTaskRunner.java +15 -0
  41. package/android/src/main/java/com/marianhello/bgloc/headless/ActivityTask.java +48 -0
  42. package/android/src/main/java/com/marianhello/bgloc/headless/JsCallback.java +10 -0
  43. package/android/src/main/java/com/marianhello/bgloc/headless/LocationTask.java +61 -0
  44. package/android/src/main/java/com/marianhello/bgloc/headless/StationaryTask.java +25 -0
  45. package/android/src/main/java/com/marianhello/bgloc/headless/Task.java +8 -0
  46. package/android/src/main/java/com/marianhello/bgloc/headless/TaskRunner.java +5 -0
  47. package/android/src/main/java/com/marianhello/bgloc/headless/TaskRunnerFactory.java +8 -0
  48. package/android/src/main/java/com/marianhello/bgloc/provider/AbstractLocationProvider.java +171 -0
  49. package/android/src/main/java/com/marianhello/bgloc/provider/ActivityRecognitionLocationProvider.java +280 -0
  50. package/android/src/main/java/com/marianhello/bgloc/provider/DistanceFilterLocationProvider.java +586 -0
  51. package/android/src/main/java/com/marianhello/bgloc/provider/LocationProvider.java +32 -0
  52. package/android/src/main/java/com/marianhello/bgloc/provider/LocationProviderFactory.java +47 -0
  53. package/android/src/main/java/com/marianhello/bgloc/provider/ProviderDelegate.java +12 -0
  54. package/android/src/main/java/com/marianhello/bgloc/provider/RawLocationProvider.java +142 -0
  55. package/android/src/main/java/com/marianhello/bgloc/service/LocationService.java +17 -0
  56. package/android/src/main/java/com/marianhello/bgloc/service/LocationServiceImpl.java +760 -0
  57. package/android/src/main/java/com/marianhello/bgloc/service/LocationServiceInfo.java +6 -0
  58. package/android/src/main/java/com/marianhello/bgloc/service/LocationServiceInfoImpl.java +41 -0
  59. package/android/src/main/java/com/marianhello/bgloc/service/LocationServiceIntentBuilder.java +203 -0
  60. package/android/src/main/java/com/marianhello/bgloc/service/LocationServiceProxy.java +140 -0
  61. package/android/src/main/java/com/marianhello/bgloc/sync/AccountHelper.java +39 -0
  62. package/android/src/main/java/com/marianhello/bgloc/sync/Authenticator.java +68 -0
  63. package/android/src/main/java/com/marianhello/bgloc/sync/AuthenticatorService.java +28 -0
  64. package/android/src/main/java/com/marianhello/bgloc/sync/BatchManager.java +246 -0
  65. package/android/src/main/java/com/marianhello/bgloc/sync/NotificationHelper.java +148 -0
  66. package/android/src/main/java/com/marianhello/bgloc/sync/SyncAdapter.java +233 -0
  67. package/android/src/main/java/com/marianhello/bgloc/sync/SyncService.java +68 -0
  68. package/android/src/main/java/com/marianhello/logging/DBLogReader.java +203 -0
  69. package/android/src/main/java/com/marianhello/logging/LogEntry.java +99 -0
  70. package/android/src/main/java/com/marianhello/logging/LoggerManager.java +70 -0
  71. package/android/src/main/java/com/marianhello/logging/UncaughtExceptionLogger.java +36 -0
  72. package/android/src/main/java/com/marianhello/utils/CloneHelper.java +22 -0
  73. package/android/src/main/java/com/marianhello/utils/Convert.java +56 -0
  74. package/android/src/main/java/com/marianhello/utils/TextUtils.java +72 -0
  75. package/android/src/main/java/com/marianhello/utils/ToneGenerator.java +68 -0
  76. package/android/src/main/java/org/apache/commons/io/Charsets.java +153 -0
  77. package/android/src/main/java/org/apache/commons/io/input/ReversedLinesFileReader.java +344 -0
  78. package/android/src/main/java/org/chromium/content/browser/ThreadUtils.java +134 -0
  79. package/android/src/main/java/ru/andremoniy/sqlbuilder/SqlExpression.java +398 -0
  80. package/android/src/main/java/ru/andremoniy/sqlbuilder/SqlSelectStatement.java +671 -0
  81. package/android/src/main/java/ru/andremoniy/sqlbuilder/SqlStatement.java +29 -0
  82. package/android/src/main/java/ru/andremoniy/utils/TextUtils.java +61 -0
  83. package/android/src/main/res/values/strings.xml +6 -0
  84. package/android/src/main/res/xml/authenticator.xml +7 -0
  85. package/android/src/main/res/xml/syncadapter.xml +9 -0
  86. package/app.plugin.js +64 -0
  87. package/ios/NitroBackgroundGeolocation.swift +719 -0
  88. package/ios/NitroBackgroundGeolocationBootstrap.m +98 -0
  89. package/ios/common/BackgroundGeolocation/CocoaLumberjack.h +1945 -0
  90. package/ios/common/BackgroundGeolocation/CocoaLumberjack.m +5255 -0
  91. package/ios/common/BackgroundGeolocation/FMDB.h +2357 -0
  92. package/ios/common/BackgroundGeolocation/FMDB.m +2672 -0
  93. package/ios/common/BackgroundGeolocation/FMDBLogger.h +42 -0
  94. package/ios/common/BackgroundGeolocation/FMDBLogger.m +264 -0
  95. package/ios/common/BackgroundGeolocation/INTULocationManager/INTUHeadingRequest.h +41 -0
  96. package/ios/common/BackgroundGeolocation/INTULocationManager/INTUHeadingRequest.m +68 -0
  97. package/ios/common/BackgroundGeolocation/INTULocationManager/INTULocationManager+Internal.h +33 -0
  98. package/ios/common/BackgroundGeolocation/INTULocationManager/INTULocationManager.h +178 -0
  99. package/ios/common/BackgroundGeolocation/INTULocationManager/INTULocationManager.m +1025 -0
  100. package/ios/common/BackgroundGeolocation/INTULocationManager/INTULocationRequest.h +103 -0
  101. package/ios/common/BackgroundGeolocation/INTULocationManager/INTULocationRequest.m +238 -0
  102. package/ios/common/BackgroundGeolocation/INTULocationManager/INTULocationRequestDefines.h +163 -0
  103. package/ios/common/BackgroundGeolocation/INTULocationManager/INTURequestIDGenerator.h +39 -0
  104. package/ios/common/BackgroundGeolocation/INTULocationManager/INTURequestIDGenerator.m +37 -0
  105. package/ios/common/BackgroundGeolocation/MAURAbstractLocationProvider.h +51 -0
  106. package/ios/common/BackgroundGeolocation/MAURAbstractLocationProvider.m +53 -0
  107. package/ios/common/BackgroundGeolocation/MAURActivity.h +23 -0
  108. package/ios/common/BackgroundGeolocation/MAURActivity.m +52 -0
  109. package/ios/common/BackgroundGeolocation/MAURActivityLocationProvider.h +18 -0
  110. package/ios/common/BackgroundGeolocation/MAURActivityLocationProvider.m +202 -0
  111. package/ios/common/BackgroundGeolocation/MAURBackgroundGeolocationFacade.h +62 -0
  112. package/ios/common/BackgroundGeolocation/MAURBackgroundGeolocationFacade.m +650 -0
  113. package/ios/common/BackgroundGeolocation/MAURBackgroundSync.h +34 -0
  114. package/ios/common/BackgroundGeolocation/MAURBackgroundSync.m +184 -0
  115. package/ios/common/BackgroundGeolocation/MAURBackgroundTaskManager.h +25 -0
  116. package/ios/common/BackgroundGeolocation/MAURBackgroundTaskManager.m +105 -0
  117. package/ios/common/BackgroundGeolocation/MAURConfig.h +74 -0
  118. package/ios/common/BackgroundGeolocation/MAURConfig.m +485 -0
  119. package/ios/common/BackgroundGeolocation/MAURConfigurationContract.h +49 -0
  120. package/ios/common/BackgroundGeolocation/MAURConfigurationContract.m +51 -0
  121. package/ios/common/BackgroundGeolocation/MAURDistanceFilterLocationProvider.h +20 -0
  122. package/ios/common/BackgroundGeolocation/MAURDistanceFilterLocationProvider.m +523 -0
  123. package/ios/common/BackgroundGeolocation/MAURGeolocationOpenHelper.h +17 -0
  124. package/ios/common/BackgroundGeolocation/MAURGeolocationOpenHelper.m +97 -0
  125. package/ios/common/BackgroundGeolocation/MAURLocation.h +59 -0
  126. package/ios/common/BackgroundGeolocation/MAURLocation.m +349 -0
  127. package/ios/common/BackgroundGeolocation/MAURLocationContract.h +34 -0
  128. package/ios/common/BackgroundGeolocation/MAURLocationContract.m +35 -0
  129. package/ios/common/BackgroundGeolocation/MAURLocationManager.h +53 -0
  130. package/ios/common/BackgroundGeolocation/MAURLocationManager.m +308 -0
  131. package/ios/common/BackgroundGeolocation/MAURLogReader.h +26 -0
  132. package/ios/common/BackgroundGeolocation/MAURLogReader.m +122 -0
  133. package/ios/common/BackgroundGeolocation/MAURLogging.h +19 -0
  134. package/ios/common/BackgroundGeolocation/MAURPostLocationTask.h +40 -0
  135. package/ios/common/BackgroundGeolocation/MAURPostLocationTask.m +218 -0
  136. package/ios/common/BackgroundGeolocation/MAURProviderDelegate.h +52 -0
  137. package/ios/common/BackgroundGeolocation/MAURRawLocationProvider.h +18 -0
  138. package/ios/common/BackgroundGeolocation/MAURRawLocationProvider.m +129 -0
  139. package/ios/common/BackgroundGeolocation/MAURSQLiteConfigurationDAO.h +26 -0
  140. package/ios/common/BackgroundGeolocation/MAURSQLiteConfigurationDAO.m +278 -0
  141. package/ios/common/BackgroundGeolocation/MAURSQLiteHelper.h +57 -0
  142. package/ios/common/BackgroundGeolocation/MAURSQLiteHelper.m +93 -0
  143. package/ios/common/BackgroundGeolocation/MAURSQLiteLocationDAO.h +38 -0
  144. package/ios/common/BackgroundGeolocation/MAURSQLiteLocationDAO.m +380 -0
  145. package/ios/common/BackgroundGeolocation/MAURSQLiteOpenHelper.h +32 -0
  146. package/ios/common/BackgroundGeolocation/MAURSQLiteOpenHelper.m +276 -0
  147. package/ios/common/BackgroundGeolocation/MAURUncaughtExceptionLogger.h +20 -0
  148. package/ios/common/BackgroundGeolocation/MAURUncaughtExceptionLogger.m +62 -0
  149. package/ios/common/BackgroundGeolocation/Reachability.h +102 -0
  150. package/ios/common/BackgroundGeolocation/Reachability.m +474 -0
  151. package/ios/common/BackgroundGeolocation/SOMotionDetector/SOLocationManager.h +80 -0
  152. package/ios/common/BackgroundGeolocation/SOMotionDetector/SOLocationManager.m +147 -0
  153. package/ios/common/BackgroundGeolocation/SOMotionDetector/SOMotionActivity.h +30 -0
  154. package/ios/common/BackgroundGeolocation/SOMotionDetector/SOMotionActivity.m +42 -0
  155. package/ios/common/BackgroundGeolocation/SOMotionDetector/SOMotionDetector.h +99 -0
  156. package/ios/common/BackgroundGeolocation/SOMotionDetector/SOMotionDetector.m +327 -0
  157. package/ios/common/BackgroundGeolocation/SOMotionDetector/SOStepDetector.h +44 -0
  158. package/ios/common/BackgroundGeolocation/SOMotionDetector/SOStepDetector.m +94 -0
  159. package/ios/common/BackgroundGeolocation/SQLQueryBuilder/ext/NSString+ZIMString.h +55 -0
  160. package/ios/common/BackgroundGeolocation/SQLQueryBuilder/ext/NSString+ZIMString.m +47 -0
  161. package/ios/common/BackgroundGeolocation/SQLQueryBuilder/sql/ZIMSqlDataManipulationCommand.h +27 -0
  162. package/ios/common/BackgroundGeolocation/SQLQueryBuilder/sql/ZIMSqlExpression.h +250 -0
  163. package/ios/common/BackgroundGeolocation/SQLQueryBuilder/sql/ZIMSqlExpression.m +259 -0
  164. package/ios/common/BackgroundGeolocation/SQLQueryBuilder/sql/ZIMSqlSelectStatement.h +360 -0
  165. package/ios/common/BackgroundGeolocation/SQLQueryBuilder/sql/ZIMSqlSelectStatement.m +427 -0
  166. package/ios/common/BackgroundGeolocation/SQLQueryBuilder/sql/ZIMSqlStatement.h +37 -0
  167. package/lib/module/NitroBackgroundGeolocation.nitro.js +172 -0
  168. package/lib/module/NitroBackgroundGeolocation.nitro.js.map +1 -0
  169. package/lib/module/headless.js +72 -0
  170. package/lib/module/headless.js.map +1 -0
  171. package/lib/module/index.js +60 -0
  172. package/lib/module/index.js.map +1 -0
  173. package/lib/module/package.json +1 -0
  174. package/lib/typescript/package.json +1 -0
  175. package/lib/typescript/src/NitroBackgroundGeolocation.nitro.d.ts +616 -0
  176. package/lib/typescript/src/NitroBackgroundGeolocation.nitro.d.ts.map +1 -0
  177. package/lib/typescript/src/headless.d.ts +40 -0
  178. package/lib/typescript/src/headless.d.ts.map +1 -0
  179. package/lib/typescript/src/index.d.ts +8 -0
  180. package/lib/typescript/src/index.d.ts.map +1 -0
  181. package/nitro.json +23 -0
  182. package/nitrogen/generated/android/c++/JActivity.hpp +61 -0
  183. package/nitrogen/generated/android/c++/JAuthorizationStatus.hpp +61 -0
  184. package/nitrogen/generated/android/c++/JBackgroundGeolocationError.hpp +61 -0
  185. package/nitrogen/generated/android/c++/JConfigureOptions.hpp +179 -0
  186. package/nitrogen/generated/android/c++/JFunc_void.hpp +75 -0
  187. package/nitrogen/generated/android/c++/JFunc_void_Activity.hpp +78 -0
  188. package/nitrogen/generated/android/c++/JFunc_void_AuthorizationStatus.hpp +77 -0
  189. package/nitrogen/generated/android/c++/JFunc_void_BackgroundGeolocationError.hpp +78 -0
  190. package/nitrogen/generated/android/c++/JFunc_void_Location.hpp +78 -0
  191. package/nitrogen/generated/android/c++/JFunc_void_StationaryLocation.hpp +78 -0
  192. package/nitrogen/generated/android/c++/JHybridNitroBackgroundGeolocationSpec.cpp +530 -0
  193. package/nitrogen/generated/android/c++/JHybridNitroBackgroundGeolocationSpec.hpp +90 -0
  194. package/nitrogen/generated/android/c++/JLocation.hpp +105 -0
  195. package/nitrogen/generated/android/c++/JLocationAccuracy.hpp +64 -0
  196. package/nitrogen/generated/android/c++/JLocationOptions.hpp +65 -0
  197. package/nitrogen/generated/android/c++/JLocationProvider.hpp +61 -0
  198. package/nitrogen/generated/android/c++/JLogEntry.hpp +73 -0
  199. package/nitrogen/generated/android/c++/JNativeLogLevel.hpp +67 -0
  200. package/nitrogen/generated/android/c++/JServiceStatus.hpp +66 -0
  201. package/nitrogen/generated/android/c++/JStationaryLocation.hpp +109 -0
  202. package/nitrogen/generated/android/c++/JVariant_NullType_AnyMap.cpp +26 -0
  203. package/nitrogen/generated/android/c++/JVariant_NullType_AnyMap.hpp +71 -0
  204. package/nitrogen/generated/android/c++/JVariant_NullType_Boolean.cpp +26 -0
  205. package/nitrogen/generated/android/c++/JVariant_NullType_Boolean.hpp +69 -0
  206. package/nitrogen/generated/android/c++/JVariant_NullType_Double.cpp +26 -0
  207. package/nitrogen/generated/android/c++/JVariant_NullType_Double.hpp +69 -0
  208. package/nitrogen/generated/android/c++/JVariant_NullType_LocationAccuracy.cpp +26 -0
  209. package/nitrogen/generated/android/c++/JVariant_NullType_LocationAccuracy.hpp +71 -0
  210. package/nitrogen/generated/android/c++/JVariant_NullType_LocationProvider.cpp +26 -0
  211. package/nitrogen/generated/android/c++/JVariant_NullType_LocationProvider.hpp +71 -0
  212. package/nitrogen/generated/android/c++/JVariant_NullType_Map_String__String_.cpp +33 -0
  213. package/nitrogen/generated/android/c++/JVariant_NullType_Map_String__String_.hpp +77 -0
  214. package/nitrogen/generated/android/c++/JVariant_NullType_String.cpp +26 -0
  215. package/nitrogen/generated/android/c++/JVariant_NullType_String.hpp +70 -0
  216. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/Activity.kt +56 -0
  217. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/AuthorizationStatus.kt +24 -0
  218. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/BackgroundGeolocationError.kt +56 -0
  219. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/ConfigureOptions.kt +182 -0
  220. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/Func_void.kt +80 -0
  221. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/Func_void_Activity.kt +80 -0
  222. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/Func_void_AuthorizationStatus.kt +80 -0
  223. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/Func_void_BackgroundGeolocationError.kt +80 -0
  224. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/Func_void_Location.kt +80 -0
  225. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/Func_void_StationaryLocation.kt +80 -0
  226. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/HybridNitroBackgroundGeolocationSpec.kt +218 -0
  227. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/Location.kt +111 -0
  228. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/LocationAccuracy.kt +25 -0
  229. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/LocationOptions.kt +61 -0
  230. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/LocationProvider.kt +24 -0
  231. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/LogEntry.kt +71 -0
  232. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/NativeLogLevel.kt +26 -0
  233. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/ServiceStatus.kt +61 -0
  234. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/StationaryLocation.kt +116 -0
  235. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/Variant_NullType_AnyMap.kt +63 -0
  236. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/Variant_NullType_Boolean.kt +62 -0
  237. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/Variant_NullType_Double.kt +62 -0
  238. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/Variant_NullType_LocationAccuracy.kt +62 -0
  239. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/Variant_NullType_LocationProvider.kt +62 -0
  240. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/Variant_NullType_Map_String__String_.kt +62 -0
  241. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/Variant_NullType_String.kt +62 -0
  242. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobackgroundgeolocation/nitrobackgroundgeolocationOnLoad.kt +35 -0
  243. package/nitrogen/generated/android/nitrobackgroundgeolocation+autolinking.cmake +88 -0
  244. package/nitrogen/generated/android/nitrobackgroundgeolocation+autolinking.gradle +27 -0
  245. package/nitrogen/generated/android/nitrobackgroundgeolocationOnLoad.cpp +66 -0
  246. package/nitrogen/generated/android/nitrobackgroundgeolocationOnLoad.hpp +34 -0
  247. package/nitrogen/generated/ios/NitroBackgroundGeolocation+autolinking.rb +62 -0
  248. package/nitrogen/generated/ios/NitroBackgroundGeolocation-Swift-Cxx-Bridge.cpp +129 -0
  249. package/nitrogen/generated/ios/NitroBackgroundGeolocation-Swift-Cxx-Bridge.hpp +911 -0
  250. package/nitrogen/generated/ios/NitroBackgroundGeolocation-Swift-Cxx-Umbrella.hpp +88 -0
  251. package/nitrogen/generated/ios/NitroBackgroundGeolocationAutolinking.mm +33 -0
  252. package/nitrogen/generated/ios/NitroBackgroundGeolocationAutolinking.swift +26 -0
  253. package/nitrogen/generated/ios/c++/HybridNitroBackgroundGeolocationSpecSwift.cpp +11 -0
  254. package/nitrogen/generated/ios/c++/HybridNitroBackgroundGeolocationSpecSwift.hpp +335 -0
  255. package/nitrogen/generated/ios/swift/Activity.swift +34 -0
  256. package/nitrogen/generated/ios/swift/AuthorizationStatus.swift +44 -0
  257. package/nitrogen/generated/ios/swift/BackgroundGeolocationError.swift +34 -0
  258. package/nitrogen/generated/ios/swift/ConfigureOptions.swift +1037 -0
  259. package/nitrogen/generated/ios/swift/Func_void.swift +46 -0
  260. package/nitrogen/generated/ios/swift/Func_void_Activity.swift +46 -0
  261. package/nitrogen/generated/ios/swift/Func_void_AuthorizationStatus.swift +46 -0
  262. package/nitrogen/generated/ios/swift/Func_void_BackgroundGeolocationError.swift +46 -0
  263. package/nitrogen/generated/ios/swift/Func_void_ConfigureOptions.swift +46 -0
  264. package/nitrogen/generated/ios/swift/Func_void_Location.swift +46 -0
  265. package/nitrogen/generated/ios/swift/Func_void_ServiceStatus.swift +46 -0
  266. package/nitrogen/generated/ios/swift/Func_void_StationaryLocation.swift +46 -0
  267. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
  268. package/nitrogen/generated/ios/swift/Func_void_std__optional_StationaryLocation_.swift +46 -0
  269. package/nitrogen/generated/ios/swift/Func_void_std__vector_Location_.swift +46 -0
  270. package/nitrogen/generated/ios/swift/Func_void_std__vector_LogEntry_.swift +46 -0
  271. package/nitrogen/generated/ios/swift/HybridNitroBackgroundGeolocationSpec.swift +82 -0
  272. package/nitrogen/generated/ios/swift/HybridNitroBackgroundGeolocationSpec_cxx.swift +675 -0
  273. package/nitrogen/generated/ios/swift/Location.swift +89 -0
  274. package/nitrogen/generated/ios/swift/LocationAccuracy.swift +48 -0
  275. package/nitrogen/generated/ios/swift/LocationOptions.swift +78 -0
  276. package/nitrogen/generated/ios/swift/LocationProvider.swift +44 -0
  277. package/nitrogen/generated/ios/swift/LogEntry.swift +49 -0
  278. package/nitrogen/generated/ios/swift/NativeLogLevel.swift +52 -0
  279. package/nitrogen/generated/ios/swift/ServiceStatus.swift +39 -0
  280. package/nitrogen/generated/ios/swift/StationaryLocation.swift +94 -0
  281. package/nitrogen/generated/ios/swift/Variant_NullType_AnyMap.swift +30 -0
  282. package/nitrogen/generated/ios/swift/Variant_NullType_Bool.swift +30 -0
  283. package/nitrogen/generated/ios/swift/Variant_NullType_Dictionary_String__String_.swift +30 -0
  284. package/nitrogen/generated/ios/swift/Variant_NullType_Double.swift +30 -0
  285. package/nitrogen/generated/ios/swift/Variant_NullType_LocationAccuracy.swift +30 -0
  286. package/nitrogen/generated/ios/swift/Variant_NullType_LocationProvider.swift +30 -0
  287. package/nitrogen/generated/ios/swift/Variant_NullType_String.swift +30 -0
  288. package/nitrogen/generated/shared/c++/Activity.hpp +87 -0
  289. package/nitrogen/generated/shared/c++/AuthorizationStatus.hpp +63 -0
  290. package/nitrogen/generated/shared/c++/BackgroundGeolocationError.hpp +87 -0
  291. package/nitrogen/generated/shared/c++/ConfigureOptions.hpp +197 -0
  292. package/nitrogen/generated/shared/c++/HybridNitroBackgroundGeolocationSpec.cpp +48 -0
  293. package/nitrogen/generated/shared/c++/HybridNitroBackgroundGeolocationSpec.hpp +121 -0
  294. package/nitrogen/generated/shared/c++/Location.hpp +131 -0
  295. package/nitrogen/generated/shared/c++/LocationAccuracy.hpp +69 -0
  296. package/nitrogen/generated/shared/c++/LocationOptions.hpp +91 -0
  297. package/nitrogen/generated/shared/c++/LocationProvider.hpp +63 -0
  298. package/nitrogen/generated/shared/c++/LogEntry.hpp +99 -0
  299. package/nitrogen/generated/shared/c++/NativeLogLevel.hpp +65 -0
  300. package/nitrogen/generated/shared/c++/ServiceStatus.hpp +92 -0
  301. package/nitrogen/generated/shared/c++/StationaryLocation.hpp +135 -0
  302. package/package.json +112 -0
  303. package/react-native.config.js +10 -0
  304. package/src/NitroBackgroundGeolocation.nitro.ts +656 -0
  305. package/src/headless.ts +91 -0
  306. package/src/index.tsx +100 -0
@@ -0,0 +1,321 @@
1
+ package com.marianhello.bgloc.data.provider;
2
+
3
+ import android.content.ContentProvider;
4
+ import android.content.ContentResolver;
5
+ import android.content.ContentUris;
6
+ import android.content.ContentValues;
7
+ import android.content.Context;
8
+ import android.content.UriMatcher;
9
+ import android.database.Cursor;
10
+ import android.database.SQLException;
11
+ import android.database.sqlite.SQLiteDatabase;
12
+ import android.database.sqlite.SQLiteQueryBuilder;
13
+ import android.net.Uri;
14
+ import android.text.TextUtils;
15
+
16
+ import com.marianhello.bgloc.ResourceResolver;
17
+ import com.marianhello.bgloc.data.sqlite.SQLiteLocationContract.LocationEntry;
18
+ import com.marianhello.bgloc.data.sqlite.SQLiteOpenHelper;
19
+
20
+ /**
21
+ * Content provider implementation based on
22
+ * https://shellmonger.com/2017/06/28/android-notes-app-content-providers/
23
+ */
24
+ public class LocationContentProvider extends ContentProvider {
25
+
26
+ /**
27
+ * Creates a UriMatcher for matching the path elements for this content provider
28
+ */
29
+ private static final UriMatcher sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
30
+
31
+ /**
32
+ * The code for the UriMatch matching all notes
33
+ */
34
+ private static final int ALL_ITEMS = 10;
35
+
36
+ /**
37
+ * The code for the UriMatch matching a single note
38
+ */
39
+ private static final int ONE_ITEM = 20;
40
+
41
+ /**
42
+ * The database helper for this content provider
43
+ */
44
+ private SQLiteOpenHelper mDatabaseHelper;
45
+
46
+ /*
47
+ * Initialize the UriMatcher with the URIs that this content provider handles
48
+ *
49
+ * All paths added to the UriMatcher have a corresponding code to return when a match is
50
+ * found. The code passed into the constructor of UriMatcher here represents the code to
51
+ * return for the root URI. It's common to use NO_MATCH as the code for this case.
52
+ */
53
+ private static void initialize(String authority) {
54
+
55
+ /* This URI is content://com.example.location/location/ */
56
+ sUriMatcher.addURI(
57
+ authority,
58
+ LocationEntry.TABLE_NAME,
59
+ ALL_ITEMS);
60
+
61
+
62
+ /*
63
+ * This URI would look something like content://com.example.location/location/1
64
+ * The "/#" signifies to the UriMatcher that if TABLE_NAME is followed by ANY number,
65
+ * that it should return the ONE_ITEM code
66
+ */
67
+ sUriMatcher.addURI(
68
+ authority,
69
+ LocationEntry.TABLE_NAME + "/#",
70
+ ONE_ITEM);
71
+ }
72
+
73
+ /**
74
+ * Part of the Content Provider interface. The system calls onCreate() when it starts up
75
+ * the provider. You should only perform fast-running initialization tasks in this method.
76
+ * Defer database creation and data loading until the provider actually receives a request
77
+ * for the data. This runs on the UI thread.
78
+ *
79
+ * @return true if the provider was successfully loaded; false otherwise
80
+ */
81
+ @Override
82
+ public boolean onCreate() {
83
+ Context context = getContext();
84
+ ResourceResolver resourceResolver = ResourceResolver.newInstance(getContext());
85
+ initialize(resourceResolver.getAuthority());
86
+ mDatabaseHelper = new SQLiteOpenHelper(context);
87
+ return true;
88
+ }
89
+
90
+ /**
91
+ * The content provider must return the content type for its supported URIs. The supported
92
+ * URIs are defined in the UriMatcher
93
+ *
94
+ * As we don't export this content provider, we return null here.
95
+ *
96
+ * @param uri the URI for typing
97
+ * @return the type of the URI
98
+ */
99
+ @Override
100
+ public String getType(Uri uri) {
101
+ return null;
102
+ }
103
+
104
+ /**
105
+ * Handles query requests from clients. We will use this method to query for all
106
+ * of our location data as well as to query for the specific location record.
107
+ *
108
+ * @param uri The URI to query
109
+ * @param projection The list of columns to put into the cursor. If null, all columns are
110
+ * included.
111
+ * @param selection A selection criteria to apply when filtering rows. If null, then all
112
+ * rows are included.
113
+ * @param selectionArgs You may include ?s in selection, which will be replaced by
114
+ * the values from selectionArgs, in order that they appear in the
115
+ * selection.
116
+ * @param sortOrder How the rows in the cursor should be sorted.
117
+ * @return A Cursor containing the results of the query. In our implementation,
118
+ */
119
+ @Override
120
+ public Cursor query(
121
+ Uri uri,
122
+ String[] projection,
123
+ String selection,
124
+ String[] selectionArgs,
125
+ String sortOrder) {
126
+
127
+ int uriType = sUriMatcher.match(uri);
128
+ SQLiteDatabase db = mDatabaseHelper.getWritableDatabase();
129
+ SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
130
+
131
+ switch (uriType) {
132
+ /*
133
+ * When sUriMatcher's match method is called with a URI that looks EXACTLY like this
134
+ *
135
+ * content://com.example.location/location
136
+ *
137
+ * sUriMatcher's match method will return the code that indicates to us that we need
138
+ * to return all of the records in our location table.
139
+ *
140
+ * In this case, we want to return a cursor that contains every record
141
+ * in our location table.
142
+ */
143
+ case ALL_ITEMS:
144
+ queryBuilder.setTables(LocationEntry.TABLE_NAME);
145
+ if (TextUtils.isEmpty(sortOrder)) {
146
+ sortOrder = LocationEntry.COLUMN_NAME_TIME + " ASC";
147
+ }
148
+ break;
149
+
150
+
151
+ /*
152
+ * When sUriMatcher's match method is called with a URI that looks something like this
153
+ *
154
+ * content://com.example.location/location/2
155
+ *
156
+ * sUriMatcher's match method will return the code that indicates to us that we need
157
+ * to return the location for a particular id. The id in this code is encoded in
158
+ * int and is at the very end of the URI (2) and can be accessed
159
+ * programmatically using Uri's getLastPathSegment method.
160
+ *
161
+ * In this case, we want to return a cursor that contains one row of location data for
162
+ * a particular date.
163
+ */
164
+ case ONE_ITEM:
165
+ queryBuilder.setTables(LocationEntry.TABLE_NAME);
166
+ queryBuilder.appendWhere(LocationEntry._ID + " = " + uri.getLastPathSegment());
167
+ break;
168
+
169
+ default:
170
+ throw new IllegalArgumentException("Unsupported URI: " + uri);
171
+ }
172
+
173
+ Cursor cursor = queryBuilder.query(db, projection, selection, selectionArgs, null, null, sortOrder);
174
+ cursor.setNotificationUri(getContext().getContentResolver(), uri);
175
+ return cursor;
176
+ }
177
+
178
+ /**
179
+ * Insert a new record into the database.
180
+ *
181
+ * @param uri the base URI to insert at (must be a directory-based URI)
182
+ * @param values the values to be inserted
183
+ * @return the URI of the inserted item
184
+ */
185
+ @Override
186
+ public Uri insert(Uri uri, ContentValues values) {
187
+ int uriType = sUriMatcher.match(uri);
188
+ switch (uriType) {
189
+ case ALL_ITEMS:
190
+ SQLiteDatabase db = mDatabaseHelper.getWritableDatabase();
191
+ long id = db.insert(
192
+ LocationEntry.TABLE_NAME,
193
+ null,
194
+ values);
195
+ if (id > 0) {
196
+ Uri item = ContentUris.withAppendedId(uri, id);
197
+ notifyAllListeners(item);
198
+ return item;
199
+ }
200
+
201
+ throw new SQLException("Error inserting for URI " + uri + " result:" + id);
202
+ default:
203
+ throw new IllegalArgumentException("Unsupported URI: " + uri);
204
+ }
205
+ }
206
+
207
+ /**
208
+ * Delete one or more records from the SQLite database.
209
+ *
210
+ * @param uri the URI of the record(s) to delete
211
+ * @param selection A WHERE clause to use for the deletion
212
+ * @param selectionArgs Any arguments to replace the ? in the selection
213
+ * @return the number of rows deleted.
214
+ */
215
+ @Override
216
+ public int delete(Uri uri, String selection, String[] selectionArgs) {
217
+ int uriType = sUriMatcher.match(uri);
218
+ int rows;
219
+ SQLiteDatabase db = mDatabaseHelper.getWritableDatabase();
220
+ switch (uriType) {
221
+ case ALL_ITEMS:
222
+ rows = db.delete(
223
+ LocationEntry.TABLE_NAME, // The table name
224
+ selection, selectionArgs); // The WHERE clause
225
+ break;
226
+ case ONE_ITEM:
227
+ String where = LocationEntry._ID + " = " + uri.getLastPathSegment();
228
+ if (!TextUtils.isEmpty(selection)) {
229
+ where += " AND " + selection;
230
+ }
231
+ rows = db.delete(
232
+ LocationEntry.TABLE_NAME, // The table name
233
+ where, selectionArgs); // The WHERE clause
234
+ break;
235
+ default:
236
+ throw new IllegalArgumentException("Unsupported URI: " + uri);
237
+ }
238
+ if (rows > 0) {
239
+ notifyAllListeners(uri);
240
+ }
241
+ return rows;
242
+ }
243
+
244
+ @Override
245
+ public int update(
246
+ Uri uri,
247
+ ContentValues values,
248
+ String selection,
249
+ String[] selectionArgs) {
250
+ int uriType = sUriMatcher.match(uri);
251
+ int rows;
252
+ SQLiteDatabase db = mDatabaseHelper.getWritableDatabase();
253
+ switch (uriType) {
254
+ case ALL_ITEMS:
255
+ rows = db.update(
256
+ LocationEntry.TABLE_NAME, // The table name
257
+ values, // The values to replace
258
+ selection, selectionArgs); // The WHERE clause
259
+ break;
260
+ case ONE_ITEM:
261
+ String where = LocationEntry._ID + " = " + uri.getLastPathSegment();
262
+ if (!TextUtils.isEmpty(selection)) {
263
+ where += " AND " + selection;
264
+ }
265
+ rows = db.update(
266
+ LocationEntry.TABLE_NAME, // The table name
267
+ values, // The values to replace
268
+ where, selectionArgs); // The WHERE clause
269
+ break;
270
+ default:
271
+ throw new IllegalArgumentException("Unsupported URI: " + uri);
272
+ }
273
+ if (rows > 0) {
274
+ notifyAllListeners(uri);
275
+ }
276
+ return rows;
277
+ }
278
+
279
+ /**
280
+ * Notify all listeners that the specified URI has changed
281
+ * @param uri the URI that changed
282
+ */
283
+ private void notifyAllListeners(Uri uri) {
284
+ ContentResolver resolver = getContext().getContentResolver();
285
+ if (resolver != null) {
286
+ resolver.notifyChange(uri, null);
287
+ }
288
+ }
289
+
290
+ /**
291
+ * The base CONTENT_URI used to query the Location table from the content provider
292
+ */
293
+ public static Uri getBaseContentUri(String authority) {
294
+ return Uri.parse("content://" + authority);
295
+ }
296
+
297
+ /**
298
+ * The content URI for this table
299
+ */
300
+ public static Uri getContentUri(String authority) {
301
+ return getBaseContentUri(authority).buildUpon()
302
+ .appendPath(LocationEntry.TABLE_NAME)
303
+ .build();
304
+ }
305
+
306
+ /**
307
+ * Builds a URI that adds the task _ID to the end of the location content URI path.
308
+ * This is used to query details about a single location entry by _ID. This is what we
309
+ * use for the detail view query.
310
+ *
311
+ * @param authority The authority of the locations content provider
312
+ * @param id Unique id pointing to that row
313
+ * @return Uri to query details about a single location entry
314
+ */
315
+ public static Uri buildUriWithId(String authority, long id) {
316
+ return getContentUri(authority).buildUpon()
317
+ .appendPath(Long.toString(id))
318
+ .build();
319
+ }
320
+ }
321
+
@@ -0,0 +1,76 @@
1
+ package com.marianhello.bgloc.data.sqlite;
2
+
3
+ import android.provider.BaseColumns;
4
+
5
+ import static com.marianhello.bgloc.data.sqlite.SQLiteOpenHelper.COMMA_SEP;
6
+ import static com.marianhello.bgloc.data.sqlite.SQLiteOpenHelper.INTEGER_TYPE;
7
+ import static com.marianhello.bgloc.data.sqlite.SQLiteOpenHelper.REAL_TYPE;
8
+ import static com.marianhello.bgloc.data.sqlite.SQLiteOpenHelper.TEXT_TYPE;
9
+
10
+ public final class SQLiteConfigurationContract {
11
+ // To prevent someone from accidentally instantiating the contract class,
12
+ // give it an empty constructor.
13
+ public SQLiteConfigurationContract() {}
14
+
15
+ /* Inner class that defines the table contents */
16
+ public static abstract class ConfigurationEntry implements BaseColumns {
17
+ public static final String TABLE_NAME = "configuration";
18
+ public static final String COLUMN_NAME_NULLABLE = "NULLHACK";
19
+ public static final String COLUMN_NAME_RADIUS = "stationary_radius";
20
+ public static final String COLUMN_NAME_DISTANCE_FILTER = "distance_filter";
21
+ public static final String COLUMN_NAME_DESIRED_ACCURACY = "desired_accuracy";
22
+ public static final String COLUMN_NAME_DEBUG = "debugging";
23
+ public static final String COLUMN_NAME_NOTIF_TITLE = "notification_title";
24
+ public static final String COLUMN_NAME_NOTIF_TEXT = "notification_text";
25
+ public static final String COLUMN_NAME_NOTIF_ICON_LARGE = "notification_icon_large";
26
+ public static final String COLUMN_NAME_NOTIF_ICON_SMALL = "notification_icon_small";
27
+ public static final String COLUMN_NAME_NOTIF_COLOR = "notification_icon_color";
28
+ public static final String COLUMN_NAME_STOP_TERMINATE = "stop_terminate";
29
+ public static final String COLUMN_NAME_START_BOOT = "start_boot";
30
+ public static final String COLUMN_NAME_START_FOREGROUND = "start_foreground";
31
+ public static final String COLUMN_NAME_NOTIFICATIONS_ENABLED = "notifications_enabled";
32
+ public static final String COLUMN_NAME_STOP_ON_STILL = "stop_still";
33
+ public static final String COLUMN_NAME_LOCATION_PROVIDER = "service_provider";
34
+ public static final String COLUMN_NAME_INTERVAL = "interval";
35
+ public static final String COLUMN_NAME_FASTEST_INTERVAL = "fastest_interval";
36
+ public static final String COLUMN_NAME_ACTIVITIES_INTERVAL = "activities_interval";
37
+ public static final String COLUMN_NAME_URL = "url";
38
+ public static final String COLUMN_NAME_SYNC_URL = "sync_url";
39
+ public static final String COLUMN_NAME_SYNC_THRESHOLD = "sync_threshold";
40
+ public static final String COLUMN_NAME_HEADERS = "http_headers";
41
+ public static final String COLUMN_NAME_MAX_LOCATIONS = "max_locations";
42
+ public static final String COLUMN_NAME_TEMPLATE = "template";
43
+
44
+ public static final String SQL_CREATE_CONFIG_TABLE =
45
+ "CREATE TABLE " + ConfigurationEntry.TABLE_NAME + " (" +
46
+ ConfigurationEntry._ID + " INTEGER PRIMARY KEY," +
47
+ ConfigurationEntry.COLUMN_NAME_RADIUS + REAL_TYPE + COMMA_SEP +
48
+ ConfigurationEntry.COLUMN_NAME_DISTANCE_FILTER + INTEGER_TYPE + COMMA_SEP +
49
+ ConfigurationEntry.COLUMN_NAME_DESIRED_ACCURACY + INTEGER_TYPE + COMMA_SEP +
50
+ ConfigurationEntry.COLUMN_NAME_DEBUG + INTEGER_TYPE + COMMA_SEP +
51
+ ConfigurationEntry.COLUMN_NAME_NOTIF_TITLE + TEXT_TYPE + COMMA_SEP +
52
+ ConfigurationEntry.COLUMN_NAME_NOTIF_TEXT + TEXT_TYPE + COMMA_SEP +
53
+ ConfigurationEntry.COLUMN_NAME_NOTIF_ICON_SMALL + TEXT_TYPE + COMMA_SEP +
54
+ ConfigurationEntry.COLUMN_NAME_NOTIF_ICON_LARGE + TEXT_TYPE + COMMA_SEP +
55
+ ConfigurationEntry.COLUMN_NAME_NOTIF_COLOR + TEXT_TYPE + COMMA_SEP +
56
+ ConfigurationEntry.COLUMN_NAME_STOP_TERMINATE + INTEGER_TYPE + COMMA_SEP +
57
+ ConfigurationEntry.COLUMN_NAME_STOP_ON_STILL + INTEGER_TYPE + COMMA_SEP +
58
+ ConfigurationEntry.COLUMN_NAME_START_BOOT + INTEGER_TYPE + COMMA_SEP +
59
+ ConfigurationEntry.COLUMN_NAME_START_FOREGROUND + INTEGER_TYPE + COMMA_SEP +
60
+ ConfigurationEntry.COLUMN_NAME_NOTIFICATIONS_ENABLED + INTEGER_TYPE + COMMA_SEP +
61
+ ConfigurationEntry.COLUMN_NAME_LOCATION_PROVIDER + TEXT_TYPE + COMMA_SEP +
62
+ ConfigurationEntry.COLUMN_NAME_INTERVAL + INTEGER_TYPE + COMMA_SEP +
63
+ ConfigurationEntry.COLUMN_NAME_FASTEST_INTERVAL + INTEGER_TYPE + COMMA_SEP +
64
+ ConfigurationEntry.COLUMN_NAME_ACTIVITIES_INTERVAL + INTEGER_TYPE + COMMA_SEP +
65
+ ConfigurationEntry.COLUMN_NAME_URL + TEXT_TYPE + COMMA_SEP +
66
+ ConfigurationEntry.COLUMN_NAME_SYNC_URL + TEXT_TYPE + COMMA_SEP +
67
+ ConfigurationEntry.COLUMN_NAME_SYNC_THRESHOLD + INTEGER_TYPE + COMMA_SEP +
68
+ ConfigurationEntry.COLUMN_NAME_HEADERS + TEXT_TYPE + COMMA_SEP +
69
+ ConfigurationEntry.COLUMN_NAME_MAX_LOCATIONS + INTEGER_TYPE + COMMA_SEP +
70
+ ConfigurationEntry.COLUMN_NAME_TEMPLATE + TEXT_TYPE +
71
+ " )";
72
+
73
+ public static final String SQL_DROP_CONFIG_TABLE =
74
+ "DROP TABLE IF EXISTS " + ConfigurationEntry.TABLE_NAME;
75
+ }
76
+ }
@@ -0,0 +1,160 @@
1
+ package com.marianhello.bgloc.data.sqlite;
2
+
3
+ import android.content.ContentValues;
4
+ import android.content.Context;
5
+ import android.database.Cursor;
6
+ import android.database.sqlite.SQLiteDatabase;
7
+ import android.util.Log;
8
+
9
+ import org.json.JSONObject;
10
+ import org.json.JSONException;
11
+
12
+ import com.marianhello.bgloc.Config;
13
+ import com.marianhello.bgloc.data.ConfigurationDAO;
14
+ import com.marianhello.bgloc.data.LocationTemplateFactory;
15
+ import com.marianhello.bgloc.data.sqlite.SQLiteConfigurationContract.ConfigurationEntry;
16
+
17
+ public class SQLiteConfigurationDAO implements ConfigurationDAO {
18
+ private static final String TAG = SQLiteConfigurationDAO.class.getName();
19
+
20
+ private SQLiteDatabase db;
21
+
22
+ public SQLiteConfigurationDAO(Context context) {
23
+ SQLiteOpenHelper helper = SQLiteOpenHelper.getHelper(context);
24
+ this.db = helper.getWritableDatabase();
25
+ }
26
+
27
+ public SQLiteConfigurationDAO(SQLiteDatabase db) {
28
+ this.db = db;
29
+ }
30
+
31
+ public Config retrieveConfiguration() throws JSONException {
32
+ Cursor cursor = null;
33
+
34
+ String[] columns = {
35
+ ConfigurationEntry._ID,
36
+ ConfigurationEntry.COLUMN_NAME_RADIUS,
37
+ ConfigurationEntry.COLUMN_NAME_DISTANCE_FILTER,
38
+ ConfigurationEntry.COLUMN_NAME_DESIRED_ACCURACY,
39
+ ConfigurationEntry.COLUMN_NAME_DEBUG,
40
+ ConfigurationEntry.COLUMN_NAME_NOTIF_TITLE,
41
+ ConfigurationEntry.COLUMN_NAME_NOTIF_TEXT,
42
+ ConfigurationEntry.COLUMN_NAME_NOTIF_ICON_LARGE,
43
+ ConfigurationEntry.COLUMN_NAME_NOTIF_ICON_SMALL,
44
+ ConfigurationEntry.COLUMN_NAME_NOTIF_COLOR,
45
+ ConfigurationEntry.COLUMN_NAME_STOP_TERMINATE,
46
+ ConfigurationEntry.COLUMN_NAME_STOP_ON_STILL,
47
+ ConfigurationEntry.COLUMN_NAME_START_BOOT,
48
+ ConfigurationEntry.COLUMN_NAME_START_FOREGROUND,
49
+ ConfigurationEntry.COLUMN_NAME_NOTIFICATIONS_ENABLED,
50
+ ConfigurationEntry.COLUMN_NAME_LOCATION_PROVIDER,
51
+ ConfigurationEntry.COLUMN_NAME_INTERVAL,
52
+ ConfigurationEntry.COLUMN_NAME_FASTEST_INTERVAL,
53
+ ConfigurationEntry.COLUMN_NAME_ACTIVITIES_INTERVAL,
54
+ ConfigurationEntry.COLUMN_NAME_URL,
55
+ ConfigurationEntry.COLUMN_NAME_SYNC_URL,
56
+ ConfigurationEntry.COLUMN_NAME_SYNC_THRESHOLD,
57
+ ConfigurationEntry.COLUMN_NAME_HEADERS,
58
+ ConfigurationEntry.COLUMN_NAME_MAX_LOCATIONS,
59
+ ConfigurationEntry.COLUMN_NAME_TEMPLATE
60
+ };
61
+
62
+ String whereClause = null;
63
+ String[] whereArgs = null;
64
+ String groupBy = null;
65
+ String having = null;
66
+ String orderBy = null;
67
+
68
+ Config config = null;
69
+ try {
70
+ cursor = db.query(
71
+ ConfigurationEntry.TABLE_NAME, // The table to query
72
+ columns, // The columns to return
73
+ whereClause, // The columns for the WHERE clause
74
+ whereArgs, // The values for the WHERE clause
75
+ groupBy, // don't group the rows
76
+ having, // don't filter by row groups
77
+ orderBy // The sort order
78
+ );
79
+ if (cursor.moveToFirst()) {
80
+ config = hydrate(cursor);
81
+ }
82
+ } finally {
83
+ if (cursor != null) {
84
+ cursor.close();
85
+ }
86
+ }
87
+ return config;
88
+ }
89
+
90
+ public boolean persistConfiguration(Config config) throws NullPointerException {
91
+ long rowId = db.replace(ConfigurationEntry.TABLE_NAME, ConfigurationEntry.COLUMN_NAME_NULLABLE, getContentValues(config));
92
+ Log.d(TAG, "Configuration persisted with rowId = " + rowId);
93
+ if (rowId > -1) {
94
+ return true;
95
+ } else {
96
+ return false;
97
+ }
98
+ }
99
+
100
+ private Config hydrate(Cursor c) throws JSONException {
101
+ Config config = Config.getDefault();
102
+ config.setStationaryRadius(c.getFloat(c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_RADIUS)));
103
+ config.setDistanceFilter(c.getInt(c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_DISTANCE_FILTER)));
104
+ config.setDesiredAccuracy(c.getInt(c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_DESIRED_ACCURACY)));
105
+ config.setDebugging( (c.getInt(c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_DEBUG)) == 1) ? true : false );
106
+ config.setNotificationTitle(c.getString(c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_NOTIF_TITLE)));
107
+ config.setNotificationText(c.getString(c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_NOTIF_TEXT)));
108
+ config.setSmallNotificationIcon(c.getString(c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_NOTIF_ICON_SMALL)));
109
+ config.setLargeNotificationIcon(c.getString(c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_NOTIF_ICON_LARGE)));
110
+ config.setNotificationIconColor(c.getString(c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_NOTIF_COLOR)));
111
+ config.setStopOnTerminate( (c.getInt(c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_STOP_TERMINATE)) == 1) ? true : false );
112
+ config.setStopOnStillActivity( (c.getInt(c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_STOP_ON_STILL)) == 1) ? true : false );
113
+ config.setStartOnBoot( (c.getInt(c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_START_BOOT)) == 1) ? true : false );
114
+ config.setStartForeground( (c.getInt(c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_START_FOREGROUND)) == 1) ? true : false );
115
+ config.setNotificationsEnabled( (c.getInt(c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_NOTIFICATIONS_ENABLED)) == 1) ? true : false );
116
+ config.setLocationProvider(c.getInt(c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_LOCATION_PROVIDER)));
117
+ config.setInterval(c.getInt(c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_INTERVAL)));
118
+ config.setFastestInterval(c.getInt(c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_FASTEST_INTERVAL)));
119
+ config.setActivitiesInterval(c.getInt(c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_ACTIVITIES_INTERVAL)));
120
+ config.setUrl(c.getString(c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_URL)));
121
+ config.setSyncUrl(c.getString(c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_SYNC_URL)));
122
+ config.setSyncThreshold(c.getInt(c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_SYNC_THRESHOLD)));
123
+ config.setHttpHeaders(new JSONObject(c.getString(c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_HEADERS))));
124
+ config.setMaxLocations(c.getInt(c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_MAX_LOCATIONS)));
125
+ config.setTemplate(LocationTemplateFactory.fromJSONString(c.getString(c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_TEMPLATE))));
126
+
127
+ return config;
128
+ }
129
+
130
+ private ContentValues getContentValues(Config config) throws NullPointerException {
131
+ ContentValues values = new ContentValues();
132
+ values.put(ConfigurationEntry._ID, 1);
133
+ values.put(ConfigurationEntry.COLUMN_NAME_RADIUS, config.getStationaryRadius());
134
+ values.put(ConfigurationEntry.COLUMN_NAME_DISTANCE_FILTER, config.getDistanceFilter());
135
+ values.put(ConfigurationEntry.COLUMN_NAME_DESIRED_ACCURACY, config.getDesiredAccuracy());
136
+ values.put(ConfigurationEntry.COLUMN_NAME_DEBUG, (config.isDebugging() == true) ? 1 : 0);
137
+ values.put(ConfigurationEntry.COLUMN_NAME_NOTIF_TITLE, config.getNotificationTitle());
138
+ values.put(ConfigurationEntry.COLUMN_NAME_NOTIF_TEXT, config.getNotificationText());
139
+ values.put(ConfigurationEntry.COLUMN_NAME_NOTIF_ICON_SMALL, config.getSmallNotificationIcon());
140
+ values.put(ConfigurationEntry.COLUMN_NAME_NOTIF_ICON_LARGE, config.getLargeNotificationIcon());
141
+ values.put(ConfigurationEntry.COLUMN_NAME_NOTIF_COLOR, config.getNotificationIconColor());
142
+ values.put(ConfigurationEntry.COLUMN_NAME_STOP_TERMINATE, (config.getStopOnTerminate() == true) ? 1 : 0);
143
+ values.put(ConfigurationEntry.COLUMN_NAME_STOP_ON_STILL, (config.getStopOnStillActivity() == true) ? 1 : 0);
144
+ values.put(ConfigurationEntry.COLUMN_NAME_START_BOOT, (config.getStartOnBoot() == true) ? 1 : 0);
145
+ values.put(ConfigurationEntry.COLUMN_NAME_START_FOREGROUND, (config.getStartForeground() == true) ? 1 : 0);
146
+ values.put(ConfigurationEntry.COLUMN_NAME_NOTIFICATIONS_ENABLED, (config.getNotificationsEnabled() == true) ? 1 : 0);
147
+ values.put(ConfigurationEntry.COLUMN_NAME_LOCATION_PROVIDER, config.getLocationProvider());
148
+ values.put(ConfigurationEntry.COLUMN_NAME_INTERVAL, config.getInterval());
149
+ values.put(ConfigurationEntry.COLUMN_NAME_FASTEST_INTERVAL, config.getFastestInterval());
150
+ values.put(ConfigurationEntry.COLUMN_NAME_ACTIVITIES_INTERVAL, config.getActivitiesInterval());
151
+ values.put(ConfigurationEntry.COLUMN_NAME_URL, config.getUrl());
152
+ values.put(ConfigurationEntry.COLUMN_NAME_SYNC_URL, config.getSyncUrl());
153
+ values.put(ConfigurationEntry.COLUMN_NAME_SYNC_THRESHOLD, config.getSyncThreshold());
154
+ values.put(ConfigurationEntry.COLUMN_NAME_HEADERS, new JSONObject(config.getHttpHeaders()).toString());
155
+ values.put(ConfigurationEntry.COLUMN_NAME_MAX_LOCATIONS, config.getMaxLocations());
156
+ values.put(ConfigurationEntry.COLUMN_NAME_TEMPLATE, config.hasTemplate() ? config.getTemplate().toString() : null);
157
+
158
+ return values;
159
+ }
160
+ }
@@ -0,0 +1,112 @@
1
+ package com.marianhello.bgloc.data.sqlite;
2
+
3
+ import android.net.Uri;
4
+ import android.provider.BaseColumns;
5
+
6
+ import static com.marianhello.bgloc.data.sqlite.SQLiteOpenHelper.COMMA_SEP;
7
+ import static com.marianhello.bgloc.data.sqlite.SQLiteOpenHelper.INTEGER_TYPE;
8
+ import static com.marianhello.bgloc.data.sqlite.SQLiteOpenHelper.REAL_TYPE;
9
+ import static com.marianhello.bgloc.data.sqlite.SQLiteOpenHelper.TEXT_TYPE;
10
+
11
+ public final class SQLiteLocationContract {
12
+ // To prevent someone from accidentally instantiating the contract class,
13
+ // give it an empty constructor.
14
+ public SQLiteLocationContract() {}
15
+
16
+ /* Inner class that defines the table contents */
17
+ public static abstract class LocationEntry implements BaseColumns {
18
+ public static final String TABLE_NAME = "location";
19
+ public static final String COLUMN_NAME_NULLABLE = "NULLHACK";
20
+ public static final String COLUMN_NAME_TIME = "time";
21
+ public static final String COLUMN_NAME_ACCURACY = "accuracy";
22
+ public static final String COLUMN_NAME_VERTICAL_ACCURACY = "vertical_accuracy";
23
+ public static final String COLUMN_NAME_SPEED = "speed";
24
+ public static final String COLUMN_NAME_BEARING = "bearing";
25
+ public static final String COLUMN_NAME_ALTITUDE = "altitude";
26
+ public static final String COLUMN_NAME_LATITUDE = "latitude";
27
+ public static final String COLUMN_NAME_LONGITUDE = "longitude";
28
+ public static final String COLUMN_NAME_RADIUS = "radius";
29
+ public static final String COLUMN_NAME_HAS_ACCURACY = "has_accuracy";
30
+ public static final String COLUMN_NAME_HAS_VERTICAL_ACCURACY = "has_vertical_accuracy";
31
+ public static final String COLUMN_NAME_HAS_SPEED = "has_speed";
32
+ public static final String COLUMN_NAME_HAS_BEARING = "has_bearing";
33
+ public static final String COLUMN_NAME_HAS_ALTITUDE = "has_altitude";
34
+ public static final String COLUMN_NAME_HAS_RADIUS = "has_radius";
35
+ public static final String COLUMN_NAME_PROVIDER = "provider";
36
+ public static final String COLUMN_NAME_LOCATION_PROVIDER = "service_provider";
37
+ public static final String COLUMN_NAME_STATUS = "valid";
38
+ public static final String COLUMN_NAME_BATCH_START_MILLIS = "batch_start";
39
+ public static final String COLUMN_NAME_MOCK_FLAGS = "mock_flags";
40
+
41
+ public static final String SQL_CREATE_LOCATION_TABLE =
42
+ "CREATE TABLE " + LocationEntry.TABLE_NAME + " (" +
43
+ LocationEntry._ID + " INTEGER PRIMARY KEY," +
44
+ LocationEntry.COLUMN_NAME_TIME + INTEGER_TYPE + COMMA_SEP +
45
+ LocationEntry.COLUMN_NAME_ACCURACY + REAL_TYPE + COMMA_SEP +
46
+ LocationEntry.COLUMN_NAME_VERTICAL_ACCURACY + REAL_TYPE + COMMA_SEP +
47
+ LocationEntry.COLUMN_NAME_SPEED + REAL_TYPE + COMMA_SEP +
48
+ LocationEntry.COLUMN_NAME_BEARING + REAL_TYPE + COMMA_SEP +
49
+ LocationEntry.COLUMN_NAME_ALTITUDE + REAL_TYPE + COMMA_SEP +
50
+ LocationEntry.COLUMN_NAME_LATITUDE + REAL_TYPE + COMMA_SEP +
51
+ LocationEntry.COLUMN_NAME_LONGITUDE + REAL_TYPE + COMMA_SEP +
52
+ LocationEntry.COLUMN_NAME_RADIUS + REAL_TYPE + COMMA_SEP +
53
+ LocationEntry.COLUMN_NAME_HAS_ACCURACY + INTEGER_TYPE + COMMA_SEP +
54
+ LocationEntry.COLUMN_NAME_HAS_VERTICAL_ACCURACY + INTEGER_TYPE + COMMA_SEP +
55
+ LocationEntry.COLUMN_NAME_HAS_SPEED + INTEGER_TYPE + COMMA_SEP +
56
+ LocationEntry.COLUMN_NAME_HAS_BEARING + INTEGER_TYPE + COMMA_SEP +
57
+ LocationEntry.COLUMN_NAME_HAS_ALTITUDE + INTEGER_TYPE + COMMA_SEP +
58
+ LocationEntry.COLUMN_NAME_HAS_RADIUS + INTEGER_TYPE + COMMA_SEP +
59
+ LocationEntry.COLUMN_NAME_PROVIDER + TEXT_TYPE + COMMA_SEP +
60
+ LocationEntry.COLUMN_NAME_LOCATION_PROVIDER + INTEGER_TYPE + COMMA_SEP +
61
+ LocationEntry.COLUMN_NAME_STATUS + INTEGER_TYPE + COMMA_SEP +
62
+ LocationEntry.COLUMN_NAME_BATCH_START_MILLIS + INTEGER_TYPE + COMMA_SEP +
63
+ LocationEntry.COLUMN_NAME_MOCK_FLAGS + INTEGER_TYPE +
64
+ " )";
65
+
66
+ public static final String SQL_DROP_LOCATION_TABLE =
67
+ "DROP TABLE IF EXISTS " + LocationEntry.TABLE_NAME;
68
+
69
+ public static final String SQL_CREATE_LOCATION_TABLE_TIME_IDX =
70
+ "CREATE INDEX time_idx ON " + LocationEntry.TABLE_NAME + " (" + LocationEntry.COLUMN_NAME_TIME + ")";
71
+
72
+ public static final String SQL_CREATE_LOCATION_TABLE_BATCH_ID_IDX =
73
+ "CREATE INDEX batch_id_idx ON " + LocationEntry.TABLE_NAME + " (" + LocationEntry.COLUMN_NAME_BATCH_START_MILLIS + ")";
74
+
75
+ /**
76
+ * The directory base-path
77
+ */
78
+ public static final String DIR_BASEPATH = "locations";
79
+
80
+ /**
81
+ * The items base-path
82
+ */
83
+ public static final String ITEM_BASEPATH = "locations/#";
84
+
85
+ /**
86
+ * A projection of all columns in the items table
87
+ */
88
+ public static final String[] PROJECTION_ALL = {
89
+ _ID,
90
+ COLUMN_NAME_TIME,
91
+ COLUMN_NAME_ACCURACY,
92
+ COLUMN_NAME_VERTICAL_ACCURACY,
93
+ COLUMN_NAME_SPEED,
94
+ COLUMN_NAME_BEARING,
95
+ COLUMN_NAME_ALTITUDE,
96
+ COLUMN_NAME_LATITUDE,
97
+ COLUMN_NAME_LONGITUDE,
98
+ COLUMN_NAME_RADIUS,
99
+ COLUMN_NAME_HAS_ACCURACY,
100
+ COLUMN_NAME_HAS_VERTICAL_ACCURACY,
101
+ COLUMN_NAME_HAS_SPEED,
102
+ COLUMN_NAME_HAS_BEARING,
103
+ COLUMN_NAME_HAS_ALTITUDE,
104
+ COLUMN_NAME_HAS_RADIUS,
105
+ COLUMN_NAME_PROVIDER,
106
+ COLUMN_NAME_LOCATION_PROVIDER,
107
+ COLUMN_NAME_STATUS,
108
+ COLUMN_NAME_BATCH_START_MILLIS,
109
+ COLUMN_NAME_MOCK_FLAGS
110
+ };
111
+ }
112
+ }