Commit bda025f2 authored by Chris Scott's avatar Chris Scott

Merge branch 'android'

parents ba81579e 569a6e81
......@@ -21,6 +21,8 @@ public class BackgroundGpsPlugin extends CordovaPlugin {
private Intent updateServiceIntent;
private Boolean isEnabled = false;
private String authToken;
private String url;
private String stationaryRadius = "30";
......@@ -33,7 +35,8 @@ public class BackgroundGpsPlugin extends CordovaPlugin {
Activity activity = this.cordova.getActivity();
Boolean result = false;
updateServiceIntent = new Intent(activity, LocationUpdateService.class);
if (ACTION_START.equalsIgnoreCase(action)) {
if (ACTION_START.equalsIgnoreCase(action) && !isEnabled) {
result = true;
if (authToken == null || url == null) {
callbackContext.error("Call configure before calling start");
......@@ -49,8 +52,10 @@ public class BackgroundGpsPlugin extends CordovaPlugin {
updateServiceIntent.putExtra("isDebugging", isDebugging);
activity.startService(updateServiceIntent);
isEnabled = true;
}
} else if (ACTION_STOP.equalsIgnoreCase(action)) {
isEnabled = false;
result = true;
activity.stopService(updateServiceIntent);
callbackContext.success();
......
This diff is collapsed.
......@@ -9,6 +9,9 @@ public class Location {
private String latitude;
private String longitude;
private Date recordedAt;
private String accuracy;
private String speed;
private Long id;
public Long getId() {
......@@ -17,7 +20,6 @@ public class Location {
public void setId(Long id) {
this.id = id;
}
public String getLatitude() {
return latitude;
}
......@@ -36,12 +38,26 @@ public class Location {
public void setRecordedAt(Date recordedAt) {
this.recordedAt = recordedAt;
}
public String getAccuracy() {
return accuracy;
}
public void setAccuracy(String accuracy) {
this.accuracy = accuracy;
}
public String getSpeed() {
return speed;
}
public void setSpeed(String speed) {
this.speed = speed;
}
public static Location fromAndroidLocation(android.location.Location originalLocation) {
Location location = new Location();
location.setRecordedAt(new Date(originalLocation.getTime()));
location.setLongitude(String.valueOf(originalLocation.getLongitude()));
location.setLatitude(String.valueOf(originalLocation.getLatitude()));
location.setAccuracy(String.valueOf(originalLocation.getAccuracy()));
location.setSpeed(String.valueOf(originalLocation.getSpeed()));
return location;
}
......
......@@ -13,6 +13,8 @@ public class LocationOpenHelper extends SQLiteOpenHelper {
private static final String LOCATION_TABLE_COLUMNS =
" id INTEGER PRIMARY KEY AUTOINCREMENT," +
" recordedAt TEXT," +
" accuracy TEXT," +
" speed TEXT," +
" latitude TEXT," +
" longitude TEXT";
private static final String LOCATION_TABLE_CREATE =
......
......@@ -78,6 +78,8 @@ public class SQLiteLocationDAO implements LocationDAO {
l.setRecordedAt(stringToDate(c.getString(c.getColumnIndex("recordedAt"))));
l.setLatitude(c.getString(c.getColumnIndex("latitude")));
l.setLongitude(c.getString(c.getColumnIndex("longitude")));
l.setAccuracy(c.getString(c.getColumnIndex("accuracy")));
l.setSpeed(c.getString(c.getColumnIndex("speed")));
return l;
}
......@@ -87,7 +89,8 @@ public class SQLiteLocationDAO implements LocationDAO {
values.put("latitude", location.getLatitude());
values.put("longitude", location.getLongitude());
values.put("recordedAt", dateToString(location.getRecordedAt()));
values.put("accuracy", location.getAccuracy());
values.put("speed", location.getSpeed());
return values;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment