@josuelmm/cordova-background-geolocation 3.0.2 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +50 -0
- package/README.md +154 -8
- package/RELEASE.MD +15 -4
- package/android/CDVBackgroundGeolocation/src/main/java/com/marianhello/bgloc/cordova/ConfigMapper.java +28 -0
- package/android/CDVBackgroundGeolocation/src/main/java/com/tenforwardconsulting/bgloc/cordova/BackgroundGeolocationPlugin.java +32 -2
- package/android/CDVBackgroundGeolocation/src/test/java/com/marianhello/ConfigMapperTest.java +12 -0
- package/android/common/src/main/java/com/marianhello/bgloc/BackgroundGeolocationFacade.java +24 -1
- package/android/common/src/main/java/com/marianhello/bgloc/Config.java +131 -0
- package/android/common/src/main/java/com/marianhello/bgloc/HttpPostService.java +34 -1
- package/android/common/src/main/java/com/marianhello/bgloc/data/LocationDAO.java +5 -0
- package/android/common/src/main/java/com/marianhello/bgloc/data/provider/ContentProviderLocationDAO.java +11 -0
- package/android/common/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteConfigurationContract.java +15 -1
- package/android/common/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteConfigurationDAO.java +37 -1
- package/android/common/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteLocationDAO.java +13 -0
- package/android/common/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteOpenHelper.java +18 -1
- package/android/common/src/main/java/com/marianhello/bgloc/service/LocationServiceImpl.java +127 -3
- package/android/common/src/main/java/com/marianhello/bgloc/sync/SyncAdapter.java +14 -9
- package/angular/background-geolocation.service.ts +14 -0
- package/angular/dist/background-geolocation.service.d.ts +2 -0
- package/angular/dist/esm2022/background-geolocation.service.mjs +7 -1
- package/angular/dist/fesm2022/josuelmm-cordova-background-geolocation.mjs +6 -0
- package/angular/dist/fesm2022/josuelmm-cordova-background-geolocation.mjs.map +1 -1
- package/angular/dist/public-api.d.ts +1 -1
- package/ios/CDVBackgroundGeolocation/CDVBackgroundGeolocation.h +2 -0
- package/ios/CDVBackgroundGeolocation/CDVBackgroundGeolocation.m +16 -0
- package/ios/common/BackgroundGeolocation/MAURBackgroundGeolocationFacade.h +2 -0
- package/ios/common/BackgroundGeolocation/MAURBackgroundGeolocationFacade.m +22 -0
- package/ios/common/BackgroundGeolocation/MAURConfig.h +3 -0
- package/ios/common/BackgroundGeolocation/MAURConfig.m +20 -1
- package/ios/common/BackgroundGeolocation/MAURConfigurationContract.h +1 -0
- package/ios/common/BackgroundGeolocation/MAURConfigurationContract.m +1 -0
- package/ios/common/BackgroundGeolocation/MAURGeolocationOpenHelper.m +5 -1
- package/ios/common/BackgroundGeolocation/MAURPostLocationTask.m +4 -3
- package/ios/common/BackgroundGeolocation/MAURSQLiteConfigurationDAO.m +16 -9
- package/ios/common/BackgroundGeolocation/MAURSQLiteLocationDAO.h +2 -0
- package/ios/common/BackgroundGeolocation/MAURSQLiteLocationDAO.m +20 -0
- package/package.json +8 -3
- package/plugin.xml +1 -1
- package/www/BackgroundGeolocation.d.ts +83 -0
- package/www/BackgroundGeolocation.js +12 -0
- package/www/cordova-channel-stub.js +27 -0
- package/www/cordova-exec-stub.js +15 -0
|
@@ -45,6 +45,10 @@ public class Config implements Parcelable
|
|
|
45
45
|
private Boolean debug;
|
|
46
46
|
private String notificationTitle;
|
|
47
47
|
private String notificationText;
|
|
48
|
+
private String notificationSyncTitle;
|
|
49
|
+
private String notificationSyncText;
|
|
50
|
+
private String notificationSyncCompletedText;
|
|
51
|
+
private String notificationSyncFailedText;
|
|
48
52
|
private String notificationIconLarge;
|
|
49
53
|
private String notificationIconSmall;
|
|
50
54
|
private String notificationIconColor;
|
|
@@ -60,10 +64,13 @@ public class Config implements Parcelable
|
|
|
60
64
|
private String url;
|
|
61
65
|
private String syncUrl;
|
|
62
66
|
private Integer syncThreshold;
|
|
67
|
+
private Boolean syncEnabled;
|
|
63
68
|
private HashMap httpHeaders;
|
|
64
69
|
private Integer maxLocations;
|
|
65
70
|
private LocationTemplate template;
|
|
66
71
|
private Boolean enableWatchdog;
|
|
72
|
+
private Boolean showTime;
|
|
73
|
+
private Boolean showDistance;
|
|
67
74
|
|
|
68
75
|
public Config () {
|
|
69
76
|
}
|
|
@@ -76,6 +83,10 @@ public class Config implements Parcelable
|
|
|
76
83
|
this.debug = config.debug;
|
|
77
84
|
this.notificationTitle = config.notificationTitle;
|
|
78
85
|
this.notificationText = config.notificationText;
|
|
86
|
+
this.notificationSyncTitle = config.notificationSyncTitle;
|
|
87
|
+
this.notificationSyncText = config.notificationSyncText;
|
|
88
|
+
this.notificationSyncCompletedText = config.notificationSyncCompletedText;
|
|
89
|
+
this.notificationSyncFailedText = config.notificationSyncFailedText;
|
|
79
90
|
this.notificationIconLarge = config.notificationIconLarge;
|
|
80
91
|
this.notificationIconSmall = config.notificationIconSmall;
|
|
81
92
|
this.notificationIconColor = config.notificationIconColor;
|
|
@@ -91,9 +102,12 @@ public class Config implements Parcelable
|
|
|
91
102
|
this.url = config.url;
|
|
92
103
|
this.syncUrl = config.syncUrl;
|
|
93
104
|
this.syncThreshold = config.syncThreshold;
|
|
105
|
+
this.syncEnabled = config.syncEnabled;
|
|
94
106
|
this.httpHeaders = CloneHelper.deepCopy(config.httpHeaders);
|
|
95
107
|
this.maxLocations = config.maxLocations;
|
|
96
108
|
this.enableWatchdog = config.enableWatchdog;
|
|
109
|
+
this.showTime = config.showTime;
|
|
110
|
+
this.showDistance = config.showDistance;
|
|
97
111
|
if (config.template instanceof AbstractLocationTemplate) {
|
|
98
112
|
this.template = ((AbstractLocationTemplate)config.template).clone();
|
|
99
113
|
}
|
|
@@ -106,6 +120,10 @@ public class Config implements Parcelable
|
|
|
106
120
|
setDebugging((Boolean) in.readValue(null));
|
|
107
121
|
setNotificationTitle(in.readString());
|
|
108
122
|
setNotificationText(in.readString());
|
|
123
|
+
setNotificationSyncTitle(in.readString());
|
|
124
|
+
setNotificationSyncText(in.readString());
|
|
125
|
+
setNotificationSyncCompletedText(in.readString());
|
|
126
|
+
setNotificationSyncFailedText(in.readString());
|
|
109
127
|
setLargeNotificationIcon(in.readString());
|
|
110
128
|
setSmallNotificationIcon(in.readString());
|
|
111
129
|
setNotificationIconColor(in.readString());
|
|
@@ -121,8 +139,11 @@ public class Config implements Parcelable
|
|
|
121
139
|
setUrl(in.readString());
|
|
122
140
|
setSyncUrl(in.readString());
|
|
123
141
|
setSyncThreshold(in.readInt());
|
|
142
|
+
setSyncEnabled((Boolean) in.readValue(null));
|
|
124
143
|
setMaxLocations(in.readInt());
|
|
125
144
|
setEnableWatchdog((Boolean) in.readValue(null));
|
|
145
|
+
setShowTime((Boolean) in.readValue(null));
|
|
146
|
+
setShowDistance((Boolean) in.readValue(null));
|
|
126
147
|
Bundle bundle = in.readBundle();
|
|
127
148
|
setHttpHeaders((HashMap<String, String>) bundle.getSerializable("httpHeaders"));
|
|
128
149
|
setTemplate((LocationTemplate) bundle.getSerializable(AbstractLocationTemplate.BUNDLE_KEY));
|
|
@@ -136,6 +157,10 @@ public class Config implements Parcelable
|
|
|
136
157
|
config.debug = false;
|
|
137
158
|
config.notificationTitle = "Background tracking";
|
|
138
159
|
config.notificationText = "ENABLED";
|
|
160
|
+
config.notificationSyncTitle = "Syncing locations";
|
|
161
|
+
config.notificationSyncText = "Sync in progress";
|
|
162
|
+
config.notificationSyncCompletedText = "Sync completed";
|
|
163
|
+
config.notificationSyncFailedText = "Sync failed";
|
|
139
164
|
config.notificationIconLarge = "";
|
|
140
165
|
config.notificationIconSmall = "";
|
|
141
166
|
config.notificationIconColor = "";
|
|
@@ -151,10 +176,13 @@ public class Config implements Parcelable
|
|
|
151
176
|
config.url = "";
|
|
152
177
|
config.syncUrl = "";
|
|
153
178
|
config.syncThreshold = 100;
|
|
179
|
+
config.syncEnabled = true;
|
|
154
180
|
config.httpHeaders = null;
|
|
155
181
|
config.maxLocations = 10000;
|
|
156
182
|
config.template = null;
|
|
157
183
|
config.enableWatchdog = false;
|
|
184
|
+
config.showTime = false;
|
|
185
|
+
config.showDistance = false;
|
|
158
186
|
|
|
159
187
|
return config;
|
|
160
188
|
}
|
|
@@ -171,6 +199,10 @@ public class Config implements Parcelable
|
|
|
171
199
|
out.writeValue(isDebugging());
|
|
172
200
|
out.writeString(getNotificationTitle());
|
|
173
201
|
out.writeString(getNotificationText());
|
|
202
|
+
out.writeString(getNotificationSyncTitle());
|
|
203
|
+
out.writeString(getNotificationSyncText());
|
|
204
|
+
out.writeString(getNotificationSyncCompletedText());
|
|
205
|
+
out.writeString(getNotificationSyncFailedText());
|
|
174
206
|
out.writeString(getLargeNotificationIcon());
|
|
175
207
|
out.writeString(getSmallNotificationIcon());
|
|
176
208
|
out.writeString(getNotificationIconColor());
|
|
@@ -186,8 +218,11 @@ public class Config implements Parcelable
|
|
|
186
218
|
out.writeString(getUrl());
|
|
187
219
|
out.writeString(getSyncUrl());
|
|
188
220
|
out.writeInt(getSyncThreshold());
|
|
221
|
+
out.writeValue(getSyncEnabled());
|
|
189
222
|
out.writeInt(getMaxLocations());
|
|
190
223
|
out.writeValue(getEnableWatchdog());
|
|
224
|
+
out.writeValue(getShowTime());
|
|
225
|
+
out.writeValue(getShowDistance());
|
|
191
226
|
Bundle bundle = new Bundle();
|
|
192
227
|
bundle.putSerializable("httpHeaders", getHttpHeaders());
|
|
193
228
|
bundle.putSerializable(AbstractLocationTemplate.BUNDLE_KEY, (AbstractLocationTemplate) getTemplate());
|
|
@@ -293,6 +328,38 @@ public class Config implements Parcelable
|
|
|
293
328
|
this.notificationText = notificationText;
|
|
294
329
|
}
|
|
295
330
|
|
|
331
|
+
public String getNotificationSyncTitle() {
|
|
332
|
+
return notificationSyncTitle != null ? notificationSyncTitle : "Syncing locations";
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
public void setNotificationSyncTitle(String notificationSyncTitle) {
|
|
336
|
+
this.notificationSyncTitle = notificationSyncTitle;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
public String getNotificationSyncText() {
|
|
340
|
+
return notificationSyncText != null ? notificationSyncText : "Sync in progress";
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
public void setNotificationSyncText(String notificationSyncText) {
|
|
344
|
+
this.notificationSyncText = notificationSyncText;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
public String getNotificationSyncCompletedText() {
|
|
348
|
+
return notificationSyncCompletedText != null ? notificationSyncCompletedText : "Sync completed";
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
public void setNotificationSyncCompletedText(String notificationSyncCompletedText) {
|
|
352
|
+
this.notificationSyncCompletedText = notificationSyncCompletedText;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
public String getNotificationSyncFailedText() {
|
|
356
|
+
return notificationSyncFailedText != null ? notificationSyncFailedText : "Sync failed";
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
public void setNotificationSyncFailedText(String notificationSyncFailedText) {
|
|
360
|
+
this.notificationSyncFailedText = notificationSyncFailedText;
|
|
361
|
+
}
|
|
362
|
+
|
|
296
363
|
public boolean hasLargeNotificationIcon() {
|
|
297
364
|
return notificationIconLarge != null && !notificationIconLarge.isEmpty();
|
|
298
365
|
}
|
|
@@ -468,6 +535,20 @@ public class Config implements Parcelable
|
|
|
468
535
|
this.syncThreshold = syncThreshold;
|
|
469
536
|
}
|
|
470
537
|
|
|
538
|
+
public boolean hasSyncEnabled() {
|
|
539
|
+
return syncEnabled != null;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
/** Whether synchronization to syncUrl is enabled. Default true. */
|
|
543
|
+
@Nullable
|
|
544
|
+
public Boolean getSyncEnabled() {
|
|
545
|
+
return syncEnabled != null ? syncEnabled : true;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
public void setSyncEnabled(@Nullable Boolean syncEnabled) {
|
|
549
|
+
this.syncEnabled = syncEnabled;
|
|
550
|
+
}
|
|
551
|
+
|
|
471
552
|
public boolean hasHttpHeaders() {
|
|
472
553
|
return httpHeaders != null;
|
|
473
554
|
}
|
|
@@ -538,6 +619,32 @@ public class Config implements Parcelable
|
|
|
538
619
|
this.enableWatchdog = enableWatchdog;
|
|
539
620
|
}
|
|
540
621
|
|
|
622
|
+
public boolean hasShowTime() {
|
|
623
|
+
return showTime != null;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
@Nullable
|
|
627
|
+
public Boolean getShowTime() {
|
|
628
|
+
return showTime;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
public void setShowTime(Boolean showTime) {
|
|
632
|
+
this.showTime = showTime;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
public boolean hasShowDistance() {
|
|
636
|
+
return showDistance != null;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
@Nullable
|
|
640
|
+
public Boolean getShowDistance() {
|
|
641
|
+
return showDistance;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
public void setShowDistance(Boolean showDistance) {
|
|
645
|
+
this.showDistance = showDistance;
|
|
646
|
+
}
|
|
647
|
+
|
|
541
648
|
@Override
|
|
542
649
|
public String toString () {
|
|
543
650
|
return new StringBuffer()
|
|
@@ -562,9 +669,12 @@ public class Config implements Parcelable
|
|
|
562
669
|
.append(" url=").append(getUrl())
|
|
563
670
|
.append(" syncUrl=").append(getSyncUrl())
|
|
564
671
|
.append(" syncThreshold=").append(getSyncThreshold())
|
|
672
|
+
.append(" syncEnabled=").append(getSyncEnabled())
|
|
565
673
|
.append(" httpHeaders=").append(getHttpHeaders().toString())
|
|
566
674
|
.append(" maxLocations=").append(getMaxLocations())
|
|
567
675
|
.append(" postTemplate=").append(hasTemplate() ? getTemplate().toString() : null)
|
|
676
|
+
.append(" showTime=").append(getShowTime())
|
|
677
|
+
.append(" showDistance=").append(getShowDistance())
|
|
568
678
|
.append("]")
|
|
569
679
|
.toString();
|
|
570
680
|
}
|
|
@@ -603,6 +713,18 @@ public class Config implements Parcelable
|
|
|
603
713
|
if (config2.hasNotificationText()) {
|
|
604
714
|
merger.setNotificationText(config2.getNotificationText());
|
|
605
715
|
}
|
|
716
|
+
if (config2.notificationSyncTitle != null) {
|
|
717
|
+
merger.setNotificationSyncTitle(config2.getNotificationSyncTitle());
|
|
718
|
+
}
|
|
719
|
+
if (config2.notificationSyncText != null) {
|
|
720
|
+
merger.setNotificationSyncText(config2.getNotificationSyncText());
|
|
721
|
+
}
|
|
722
|
+
if (config2.notificationSyncCompletedText != null) {
|
|
723
|
+
merger.setNotificationSyncCompletedText(config2.getNotificationSyncCompletedText());
|
|
724
|
+
}
|
|
725
|
+
if (config2.notificationSyncFailedText != null) {
|
|
726
|
+
merger.setNotificationSyncFailedText(config2.getNotificationSyncFailedText());
|
|
727
|
+
}
|
|
606
728
|
if (config2.hasStopOnTerminate()) {
|
|
607
729
|
merger.setStopOnTerminate(config2.getStopOnTerminate());
|
|
608
730
|
}
|
|
@@ -648,6 +770,9 @@ public class Config implements Parcelable
|
|
|
648
770
|
if (config2.hasSyncThreshold()) {
|
|
649
771
|
merger.setSyncThreshold(config2.getSyncThreshold());
|
|
650
772
|
}
|
|
773
|
+
if (config2.hasSyncEnabled()) {
|
|
774
|
+
merger.setSyncEnabled(config2.getSyncEnabled());
|
|
775
|
+
}
|
|
651
776
|
if (config2.hasHttpHeaders()) {
|
|
652
777
|
merger.setHttpHeaders(config2.getHttpHeaders());
|
|
653
778
|
}
|
|
@@ -657,6 +782,12 @@ public class Config implements Parcelable
|
|
|
657
782
|
if (config2.hasTemplate()) {
|
|
658
783
|
merger.setTemplate(config2.getTemplate());
|
|
659
784
|
}
|
|
785
|
+
if (config2.hasShowTime()) {
|
|
786
|
+
merger.setShowTime(config2.getShowTime());
|
|
787
|
+
}
|
|
788
|
+
if (config2.hasShowDistance()) {
|
|
789
|
+
merger.setShowDistance(config2.getShowDistance());
|
|
790
|
+
}
|
|
660
791
|
|
|
661
792
|
return merger;
|
|
662
793
|
}
|
|
@@ -203,11 +203,44 @@ public class HttpPostService {
|
|
|
203
203
|
}
|
|
204
204
|
stream.close();
|
|
205
205
|
byte[] bodyBytes = baos.toByteArray();
|
|
206
|
+
String jsonString = new String(bodyBytes, StandardCharsets.UTF_8);
|
|
207
|
+
|
|
208
|
+
// When form-urlencoded and body is a JSON array, send one POST per location (same flat
|
|
209
|
+
// format as real-time posting) so the same server endpoint accepts both.
|
|
210
|
+
if (isFormUrlEncoded) {
|
|
211
|
+
try {
|
|
212
|
+
Object parsed = new JSONTokener(jsonString).nextValue();
|
|
213
|
+
if (parsed instanceof JSONArray) {
|
|
214
|
+
JSONArray arr = (JSONArray) parsed;
|
|
215
|
+
int len = arr.length();
|
|
216
|
+
if (len == 0) {
|
|
217
|
+
if (listener != null) listener.onProgress(100);
|
|
218
|
+
return 200;
|
|
219
|
+
}
|
|
220
|
+
for (int i = 0; i < len; i++) {
|
|
221
|
+
JSONObject item = arr.getJSONObject(i);
|
|
222
|
+
HttpPostService perRequest = new HttpPostService(mUrl);
|
|
223
|
+
int code = perRequest.postJSON(item, headers);
|
|
224
|
+
if (listener != null && len > 0) {
|
|
225
|
+
listener.onProgress((i + 1) * 100 / len);
|
|
226
|
+
}
|
|
227
|
+
if (code < 200 || code >= 300) {
|
|
228
|
+
return code;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
if (listener != null) {
|
|
232
|
+
listener.onProgress(100);
|
|
233
|
+
}
|
|
234
|
+
return 200;
|
|
235
|
+
}
|
|
236
|
+
} catch (Exception e) {
|
|
237
|
+
// Fall through to single-POST with jsonToUrlEncoded (e.g. array wrap)
|
|
238
|
+
}
|
|
239
|
+
}
|
|
206
240
|
|
|
207
241
|
byte[] outputBytes;
|
|
208
242
|
if (isFormUrlEncoded) {
|
|
209
243
|
try {
|
|
210
|
-
String jsonString = new String(bodyBytes, StandardCharsets.UTF_8);
|
|
211
244
|
String formBody = jsonToUrlEncoded(jsonString);
|
|
212
245
|
outputBytes = formBody.getBytes(StandardCharsets.UTF_8);
|
|
213
246
|
} catch (Exception e) {
|
|
@@ -19,4 +19,9 @@ public interface LocationDAO {
|
|
|
19
19
|
BackgroundLocation deleteFirstUnpostedLocation();
|
|
20
20
|
int deleteAllLocations();
|
|
21
21
|
int deleteUnpostedLocations();
|
|
22
|
+
/**
|
|
23
|
+
* Delete (mark as deleted) all locations that are pending sync to syncUrl.
|
|
24
|
+
* Same effect as discarding the pending sync queue without sending to server.
|
|
25
|
+
*/
|
|
26
|
+
int deletePendingSyncLocations();
|
|
22
27
|
}
|
|
@@ -392,4 +392,15 @@ public class ContentProviderLocationDAO implements LocationDAO {
|
|
|
392
392
|
|
|
393
393
|
return mResolver.update(mContentUri, values, whereClause, whereArgs);
|
|
394
394
|
}
|
|
395
|
+
|
|
396
|
+
@Override
|
|
397
|
+
public int deletePendingSyncLocations() {
|
|
398
|
+
ContentValues values = new ContentValues();
|
|
399
|
+
values.put(LocationEntry.COLUMN_NAME_STATUS, BackgroundLocation.DELETED);
|
|
400
|
+
|
|
401
|
+
String whereClause = LocationEntry.COLUMN_NAME_STATUS + " = ?";
|
|
402
|
+
String[] whereArgs = { String.valueOf(BackgroundLocation.SYNC_PENDING) };
|
|
403
|
+
|
|
404
|
+
return mResolver.update(mContentUri, values, whereClause, whereArgs);
|
|
405
|
+
}
|
|
395
406
|
}
|
|
@@ -22,6 +22,10 @@ public final class SQLiteConfigurationContract {
|
|
|
22
22
|
public static final String COLUMN_NAME_DEBUG = "debugging";
|
|
23
23
|
public static final String COLUMN_NAME_NOTIF_TITLE = "notification_title";
|
|
24
24
|
public static final String COLUMN_NAME_NOTIF_TEXT = "notification_text";
|
|
25
|
+
public static final String COLUMN_NAME_NOTIF_SYNC_TITLE = "notification_sync_title";
|
|
26
|
+
public static final String COLUMN_NAME_NOTIF_SYNC_TEXT = "notification_sync_text";
|
|
27
|
+
public static final String COLUMN_NAME_NOTIF_SYNC_COMPLETED = "notification_sync_completed_text";
|
|
28
|
+
public static final String COLUMN_NAME_NOTIF_SYNC_FAILED = "notification_sync_failed_text";
|
|
25
29
|
public static final String COLUMN_NAME_NOTIF_ICON_LARGE = "notification_icon_large";
|
|
26
30
|
public static final String COLUMN_NAME_NOTIF_ICON_SMALL = "notification_icon_small";
|
|
27
31
|
public static final String COLUMN_NAME_NOTIF_COLOR = "notification_icon_color";
|
|
@@ -37,9 +41,12 @@ public final class SQLiteConfigurationContract {
|
|
|
37
41
|
public static final String COLUMN_NAME_URL = "url";
|
|
38
42
|
public static final String COLUMN_NAME_SYNC_URL = "sync_url";
|
|
39
43
|
public static final String COLUMN_NAME_SYNC_THRESHOLD = "sync_threshold";
|
|
44
|
+
public static final String COLUMN_NAME_SYNC_ENABLED = "sync_enabled";
|
|
40
45
|
public static final String COLUMN_NAME_HEADERS = "http_headers";
|
|
41
46
|
public static final String COLUMN_NAME_MAX_LOCATIONS = "max_locations";
|
|
42
47
|
public static final String COLUMN_NAME_TEMPLATE = "template";
|
|
48
|
+
public static final String COLUMN_NAME_SHOW_TIME = "show_time";
|
|
49
|
+
public static final String COLUMN_NAME_SHOW_DISTANCE = "show_distance";
|
|
43
50
|
|
|
44
51
|
public static final String SQL_CREATE_CONFIG_TABLE =
|
|
45
52
|
"CREATE TABLE " + ConfigurationEntry.TABLE_NAME + " (" +
|
|
@@ -50,6 +57,10 @@ public final class SQLiteConfigurationContract {
|
|
|
50
57
|
ConfigurationEntry.COLUMN_NAME_DEBUG + INTEGER_TYPE + COMMA_SEP +
|
|
51
58
|
ConfigurationEntry.COLUMN_NAME_NOTIF_TITLE + TEXT_TYPE + COMMA_SEP +
|
|
52
59
|
ConfigurationEntry.COLUMN_NAME_NOTIF_TEXT + TEXT_TYPE + COMMA_SEP +
|
|
60
|
+
ConfigurationEntry.COLUMN_NAME_NOTIF_SYNC_TITLE + TEXT_TYPE + COMMA_SEP +
|
|
61
|
+
ConfigurationEntry.COLUMN_NAME_NOTIF_SYNC_TEXT + TEXT_TYPE + COMMA_SEP +
|
|
62
|
+
ConfigurationEntry.COLUMN_NAME_NOTIF_SYNC_COMPLETED + TEXT_TYPE + COMMA_SEP +
|
|
63
|
+
ConfigurationEntry.COLUMN_NAME_NOTIF_SYNC_FAILED + TEXT_TYPE + COMMA_SEP +
|
|
53
64
|
ConfigurationEntry.COLUMN_NAME_NOTIF_ICON_SMALL + TEXT_TYPE + COMMA_SEP +
|
|
54
65
|
ConfigurationEntry.COLUMN_NAME_NOTIF_ICON_LARGE + TEXT_TYPE + COMMA_SEP +
|
|
55
66
|
ConfigurationEntry.COLUMN_NAME_NOTIF_COLOR + TEXT_TYPE + COMMA_SEP +
|
|
@@ -65,9 +76,12 @@ public final class SQLiteConfigurationContract {
|
|
|
65
76
|
ConfigurationEntry.COLUMN_NAME_URL + TEXT_TYPE + COMMA_SEP +
|
|
66
77
|
ConfigurationEntry.COLUMN_NAME_SYNC_URL + TEXT_TYPE + COMMA_SEP +
|
|
67
78
|
ConfigurationEntry.COLUMN_NAME_SYNC_THRESHOLD + INTEGER_TYPE + COMMA_SEP +
|
|
79
|
+
ConfigurationEntry.COLUMN_NAME_SYNC_ENABLED + INTEGER_TYPE + COMMA_SEP +
|
|
68
80
|
ConfigurationEntry.COLUMN_NAME_HEADERS + TEXT_TYPE + COMMA_SEP +
|
|
69
81
|
ConfigurationEntry.COLUMN_NAME_MAX_LOCATIONS + INTEGER_TYPE + COMMA_SEP +
|
|
70
|
-
ConfigurationEntry.COLUMN_NAME_TEMPLATE + TEXT_TYPE +
|
|
82
|
+
ConfigurationEntry.COLUMN_NAME_TEMPLATE + TEXT_TYPE + COMMA_SEP +
|
|
83
|
+
ConfigurationEntry.COLUMN_NAME_SHOW_TIME + INTEGER_TYPE + COMMA_SEP +
|
|
84
|
+
ConfigurationEntry.COLUMN_NAME_SHOW_DISTANCE + INTEGER_TYPE +
|
|
71
85
|
" )";
|
|
72
86
|
|
|
73
87
|
public static final String SQL_DROP_CONFIG_TABLE =
|
package/android/common/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteConfigurationDAO.java
CHANGED
|
@@ -39,6 +39,10 @@ public class SQLiteConfigurationDAO implements ConfigurationDAO {
|
|
|
39
39
|
ConfigurationEntry.COLUMN_NAME_DEBUG,
|
|
40
40
|
ConfigurationEntry.COLUMN_NAME_NOTIF_TITLE,
|
|
41
41
|
ConfigurationEntry.COLUMN_NAME_NOTIF_TEXT,
|
|
42
|
+
ConfigurationEntry.COLUMN_NAME_NOTIF_SYNC_TITLE,
|
|
43
|
+
ConfigurationEntry.COLUMN_NAME_NOTIF_SYNC_TEXT,
|
|
44
|
+
ConfigurationEntry.COLUMN_NAME_NOTIF_SYNC_COMPLETED,
|
|
45
|
+
ConfigurationEntry.COLUMN_NAME_NOTIF_SYNC_FAILED,
|
|
42
46
|
ConfigurationEntry.COLUMN_NAME_NOTIF_ICON_LARGE,
|
|
43
47
|
ConfigurationEntry.COLUMN_NAME_NOTIF_ICON_SMALL,
|
|
44
48
|
ConfigurationEntry.COLUMN_NAME_NOTIF_COLOR,
|
|
@@ -54,9 +58,12 @@ public class SQLiteConfigurationDAO implements ConfigurationDAO {
|
|
|
54
58
|
ConfigurationEntry.COLUMN_NAME_URL,
|
|
55
59
|
ConfigurationEntry.COLUMN_NAME_SYNC_URL,
|
|
56
60
|
ConfigurationEntry.COLUMN_NAME_SYNC_THRESHOLD,
|
|
61
|
+
ConfigurationEntry.COLUMN_NAME_SYNC_ENABLED,
|
|
57
62
|
ConfigurationEntry.COLUMN_NAME_HEADERS,
|
|
58
63
|
ConfigurationEntry.COLUMN_NAME_MAX_LOCATIONS,
|
|
59
|
-
ConfigurationEntry.COLUMN_NAME_TEMPLATE
|
|
64
|
+
ConfigurationEntry.COLUMN_NAME_TEMPLATE,
|
|
65
|
+
ConfigurationEntry.COLUMN_NAME_SHOW_TIME,
|
|
66
|
+
ConfigurationEntry.COLUMN_NAME_SHOW_DISTANCE
|
|
60
67
|
};
|
|
61
68
|
|
|
62
69
|
String whereClause = null;
|
|
@@ -105,6 +112,16 @@ public class SQLiteConfigurationDAO implements ConfigurationDAO {
|
|
|
105
112
|
config.setDebugging( (c.getInt(c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_DEBUG)) == 1) ? true : false );
|
|
106
113
|
config.setNotificationTitle(c.getString(c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_NOTIF_TITLE)));
|
|
107
114
|
config.setNotificationText(c.getString(c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_NOTIF_TEXT)));
|
|
115
|
+
int idxSyncTitle = c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_NOTIF_SYNC_TITLE);
|
|
116
|
+
if (idxSyncTitle >= 0) {
|
|
117
|
+
if (!c.isNull(idxSyncTitle)) config.setNotificationSyncTitle(c.getString(idxSyncTitle));
|
|
118
|
+
int idxSyncText = c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_NOTIF_SYNC_TEXT);
|
|
119
|
+
if (idxSyncText >= 0 && !c.isNull(idxSyncText)) config.setNotificationSyncText(c.getString(idxSyncText));
|
|
120
|
+
int idxSyncCompleted = c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_NOTIF_SYNC_COMPLETED);
|
|
121
|
+
if (idxSyncCompleted >= 0 && !c.isNull(idxSyncCompleted)) config.setNotificationSyncCompletedText(c.getString(idxSyncCompleted));
|
|
122
|
+
int idxSyncFailed = c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_NOTIF_SYNC_FAILED);
|
|
123
|
+
if (idxSyncFailed >= 0 && !c.isNull(idxSyncFailed)) config.setNotificationSyncFailedText(c.getString(idxSyncFailed));
|
|
124
|
+
}
|
|
108
125
|
config.setSmallNotificationIcon(c.getString(c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_NOTIF_ICON_SMALL)));
|
|
109
126
|
config.setLargeNotificationIcon(c.getString(c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_NOTIF_ICON_LARGE)));
|
|
110
127
|
config.setNotificationIconColor(c.getString(c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_NOTIF_COLOR)));
|
|
@@ -120,9 +137,21 @@ public class SQLiteConfigurationDAO implements ConfigurationDAO {
|
|
|
120
137
|
config.setUrl(c.getString(c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_URL)));
|
|
121
138
|
config.setSyncUrl(c.getString(c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_SYNC_URL)));
|
|
122
139
|
config.setSyncThreshold(c.getInt(c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_SYNC_THRESHOLD)));
|
|
140
|
+
int idxSyncEnabled = c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_SYNC_ENABLED);
|
|
141
|
+
if (idxSyncEnabled >= 0 && !c.isNull(idxSyncEnabled)) {
|
|
142
|
+
config.setSyncEnabled(c.getInt(idxSyncEnabled) == 1);
|
|
143
|
+
}
|
|
123
144
|
config.setHttpHeaders(new JSONObject(c.getString(c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_HEADERS))));
|
|
124
145
|
config.setMaxLocations(c.getInt(c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_MAX_LOCATIONS)));
|
|
125
146
|
config.setTemplate(LocationTemplateFactory.fromJSONString(c.getString(c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_TEMPLATE))));
|
|
147
|
+
int idxShowTime = c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_SHOW_TIME);
|
|
148
|
+
if (idxShowTime >= 0 && !c.isNull(idxShowTime)) {
|
|
149
|
+
config.setShowTime(c.getInt(idxShowTime) == 1);
|
|
150
|
+
}
|
|
151
|
+
int idxShowDistance = c.getColumnIndex(ConfigurationEntry.COLUMN_NAME_SHOW_DISTANCE);
|
|
152
|
+
if (idxShowDistance >= 0 && !c.isNull(idxShowDistance)) {
|
|
153
|
+
config.setShowDistance(c.getInt(idxShowDistance) == 1);
|
|
154
|
+
}
|
|
126
155
|
|
|
127
156
|
return config;
|
|
128
157
|
}
|
|
@@ -136,6 +165,10 @@ public class SQLiteConfigurationDAO implements ConfigurationDAO {
|
|
|
136
165
|
values.put(ConfigurationEntry.COLUMN_NAME_DEBUG, (config.isDebugging() == true) ? 1 : 0);
|
|
137
166
|
values.put(ConfigurationEntry.COLUMN_NAME_NOTIF_TITLE, config.getNotificationTitle());
|
|
138
167
|
values.put(ConfigurationEntry.COLUMN_NAME_NOTIF_TEXT, config.getNotificationText());
|
|
168
|
+
values.put(ConfigurationEntry.COLUMN_NAME_NOTIF_SYNC_TITLE, config.getNotificationSyncTitle());
|
|
169
|
+
values.put(ConfigurationEntry.COLUMN_NAME_NOTIF_SYNC_TEXT, config.getNotificationSyncText());
|
|
170
|
+
values.put(ConfigurationEntry.COLUMN_NAME_NOTIF_SYNC_COMPLETED, config.getNotificationSyncCompletedText());
|
|
171
|
+
values.put(ConfigurationEntry.COLUMN_NAME_NOTIF_SYNC_FAILED, config.getNotificationSyncFailedText());
|
|
139
172
|
values.put(ConfigurationEntry.COLUMN_NAME_NOTIF_ICON_SMALL, config.getSmallNotificationIcon());
|
|
140
173
|
values.put(ConfigurationEntry.COLUMN_NAME_NOTIF_ICON_LARGE, config.getLargeNotificationIcon());
|
|
141
174
|
values.put(ConfigurationEntry.COLUMN_NAME_NOTIF_COLOR, config.getNotificationIconColor());
|
|
@@ -151,9 +184,12 @@ public class SQLiteConfigurationDAO implements ConfigurationDAO {
|
|
|
151
184
|
values.put(ConfigurationEntry.COLUMN_NAME_URL, config.getUrl());
|
|
152
185
|
values.put(ConfigurationEntry.COLUMN_NAME_SYNC_URL, config.getSyncUrl());
|
|
153
186
|
values.put(ConfigurationEntry.COLUMN_NAME_SYNC_THRESHOLD, config.getSyncThreshold());
|
|
187
|
+
values.put(ConfigurationEntry.COLUMN_NAME_SYNC_ENABLED, Boolean.TRUE.equals(config.getSyncEnabled()) ? 1 : 0);
|
|
154
188
|
values.put(ConfigurationEntry.COLUMN_NAME_HEADERS, new JSONObject(config.getHttpHeaders()).toString());
|
|
155
189
|
values.put(ConfigurationEntry.COLUMN_NAME_MAX_LOCATIONS, config.getMaxLocations());
|
|
156
190
|
values.put(ConfigurationEntry.COLUMN_NAME_TEMPLATE, config.hasTemplate() ? config.getTemplate().toString() : null);
|
|
191
|
+
values.put(ConfigurationEntry.COLUMN_NAME_SHOW_TIME, Boolean.TRUE.equals(config.getShowTime()) ? 1 : 0);
|
|
192
|
+
values.put(ConfigurationEntry.COLUMN_NAME_SHOW_DISTANCE, Boolean.TRUE.equals(config.getShowDistance()) ? 1 : 0);
|
|
157
193
|
|
|
158
194
|
return values;
|
|
159
195
|
}
|
package/android/common/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteLocationDAO.java
CHANGED
|
@@ -418,6 +418,19 @@ public class SQLiteLocationDAO implements LocationDAO {
|
|
|
418
418
|
return db.update(LocationEntry.TABLE_NAME, values, whereClause, whereArgs);
|
|
419
419
|
}
|
|
420
420
|
|
|
421
|
+
/**
|
|
422
|
+
* Mark all locations pending sync (SYNC_PENDING) as deleted. Clears the sync queue without sending.
|
|
423
|
+
*/
|
|
424
|
+
public int deletePendingSyncLocations() {
|
|
425
|
+
ContentValues values = new ContentValues();
|
|
426
|
+
values.put(LocationEntry.COLUMN_NAME_STATUS, BackgroundLocation.DELETED);
|
|
427
|
+
|
|
428
|
+
String whereClause = LocationEntry.COLUMN_NAME_STATUS + " = ?";
|
|
429
|
+
String[] whereArgs = { String.valueOf(BackgroundLocation.SYNC_PENDING) };
|
|
430
|
+
|
|
431
|
+
return db.update(LocationEntry.TABLE_NAME, values, whereClause, whereArgs);
|
|
432
|
+
}
|
|
433
|
+
|
|
421
434
|
private BackgroundLocation hydrate(Cursor c) {
|
|
422
435
|
BackgroundLocation l = new BackgroundLocation(c.getString(c.getColumnIndex(LocationEntry.COLUMN_NAME_PROVIDER)));
|
|
423
436
|
l.setTime(c.getLong(c.getColumnIndex(LocationEntry.COLUMN_NAME_TIME)));
|
package/android/common/src/main/java/com/marianhello/bgloc/data/sqlite/SQLiteOpenHelper.java
CHANGED
|
@@ -21,7 +21,7 @@ import static com.marianhello.bgloc.data.sqlite.SQLiteLocationContract.LocationE
|
|
|
21
21
|
public class SQLiteOpenHelper extends android.database.sqlite.SQLiteOpenHelper {
|
|
22
22
|
private static final String TAG = SQLiteOpenHelper.class.getName();
|
|
23
23
|
public static final String SQLITE_DATABASE_NAME = "cordova_bg_geolocation.db";
|
|
24
|
-
public static final int DATABASE_VERSION =
|
|
24
|
+
public static final int DATABASE_VERSION = 19;
|
|
25
25
|
|
|
26
26
|
public static final String TEXT_TYPE = " TEXT";
|
|
27
27
|
public static final String INTEGER_TYPE = " INTEGER";
|
|
@@ -120,6 +120,23 @@ public class SQLiteOpenHelper extends android.database.sqlite.SQLiteOpenHelper {
|
|
|
120
120
|
alterSql.add("UPDATE " + LocationEntry.TABLE_NAME +
|
|
121
121
|
" SET " + LocationEntry.COLUMN_NAME_VERTICAL_ACCURACY + "= -1," +
|
|
122
122
|
LocationEntry.COLUMN_NAME_HAS_VERTICAL_ACCURACY + "= 0");
|
|
123
|
+
case 16:
|
|
124
|
+
alterSql.add("ALTER TABLE " + ConfigurationEntry.TABLE_NAME +
|
|
125
|
+
" ADD COLUMN " + ConfigurationEntry.COLUMN_NAME_NOTIF_SYNC_TITLE + TEXT_TYPE);
|
|
126
|
+
alterSql.add("ALTER TABLE " + ConfigurationEntry.TABLE_NAME +
|
|
127
|
+
" ADD COLUMN " + ConfigurationEntry.COLUMN_NAME_NOTIF_SYNC_TEXT + TEXT_TYPE);
|
|
128
|
+
alterSql.add("ALTER TABLE " + ConfigurationEntry.TABLE_NAME +
|
|
129
|
+
" ADD COLUMN " + ConfigurationEntry.COLUMN_NAME_NOTIF_SYNC_COMPLETED + TEXT_TYPE);
|
|
130
|
+
alterSql.add("ALTER TABLE " + ConfigurationEntry.TABLE_NAME +
|
|
131
|
+
" ADD COLUMN " + ConfigurationEntry.COLUMN_NAME_NOTIF_SYNC_FAILED + TEXT_TYPE);
|
|
132
|
+
case 17:
|
|
133
|
+
alterSql.add("ALTER TABLE " + ConfigurationEntry.TABLE_NAME +
|
|
134
|
+
" ADD COLUMN " + ConfigurationEntry.COLUMN_NAME_SYNC_ENABLED + INTEGER_TYPE);
|
|
135
|
+
case 18:
|
|
136
|
+
alterSql.add("ALTER TABLE " + ConfigurationEntry.TABLE_NAME +
|
|
137
|
+
" ADD COLUMN " + ConfigurationEntry.COLUMN_NAME_SHOW_TIME + INTEGER_TYPE);
|
|
138
|
+
alterSql.add("ALTER TABLE " + ConfigurationEntry.TABLE_NAME +
|
|
139
|
+
" ADD COLUMN " + ConfigurationEntry.COLUMN_NAME_SHOW_DISTANCE + INTEGER_TYPE);
|
|
123
140
|
|
|
124
141
|
break; // DO NOT FORGET TO MOVE DOWN BREAK ON DB UPGRADE!!!
|
|
125
142
|
default:
|