Commit aa765df9 authored by Chris Scott's avatar Chris Scott

Introduce new params

parent 50ff5a81
...@@ -6,21 +6,31 @@ import org.json.JSONArray; ...@@ -6,21 +6,31 @@ import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import android.app.Activity; import android.app.Activity;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.location.LocationManager;
import android.util.Log;
public class BackgroundGpsPlugin extends CordovaPlugin { public class BackgroundGpsPlugin extends CordovaPlugin {
private static final String TAG = "BackgroundGpsPlugin";
public static final String ACTION_START = "start"; public static final String ACTION_START = "start";
public static final String ACTION_STOP = "stop"; public static final String ACTION_STOP = "stop";
public static final String ACTION_CONFIGURE = "configure"; public static final String ACTION_CONFIGURE = "configure";
private Intent updateServiceIntent;
private String authToken; private String authToken;
private String url; private String url;
private String stationaryRadius = "30";
private String desiredAccuracy = "100";
private String distanceFilter = "30";
private String locationTimeout = "60";
private String isDebugging = "false";
@Override
public boolean execute(String action, JSONArray data, CallbackContext callbackContext) { public boolean execute(String action, JSONArray data, CallbackContext callbackContext) {
Activity activity = this.cordova.getActivity(); Activity activity = this.cordova.getActivity();
Intent updateServiceIntent = new Intent(activity, LocationUpdateService.class); updateServiceIntent = new Intent(activity, LocationUpdateService.class);
if (ACTION_START.equalsIgnoreCase(action)) { if (ACTION_START.equalsIgnoreCase(action)) {
if (authToken == null || url == null) { if (authToken == null || url == null) {
callbackContext.error("Call configure before calling start"); callbackContext.error("Call configure before calling start");
...@@ -28,14 +38,29 @@ public class BackgroundGpsPlugin extends CordovaPlugin { ...@@ -28,14 +38,29 @@ public class BackgroundGpsPlugin extends CordovaPlugin {
} }
updateServiceIntent.putExtra("authToken", authToken); updateServiceIntent.putExtra("authToken", authToken);
updateServiceIntent.putExtra("url", url); updateServiceIntent.putExtra("url", url);
updateServiceIntent.putExtra("stationaryRadius", stationaryRadius);
updateServiceIntent.putExtra("desiredAccuracy", desiredAccuracy);
updateServiceIntent.putExtra("distanceFilter", distanceFilter);
updateServiceIntent.putExtra("locationTimeout", locationTimeout);
updateServiceIntent.putExtra("desiredAccuracy", desiredAccuracy);
updateServiceIntent.putExtra("isDebugging", isDebugging);
activity.startService(updateServiceIntent); activity.startService(updateServiceIntent);
} else if (ACTION_STOP.equalsIgnoreCase(action)) { } else if (ACTION_STOP.equalsIgnoreCase(action)) {
activity.stopService(updateServiceIntent); activity.stopService(updateServiceIntent);
} else if (ACTION_CONFIGURE.equalsIgnoreCase(action)) { } else if (ACTION_CONFIGURE.equalsIgnoreCase(action)) {
try { try {
// [authToken, url, stationaryRadius, distanceFilter, locationTimeout, desiredAccuracy, debug]);
this.authToken = data.getString(0); this.authToken = data.getString(0);
this.url = data.getString(1); this.url = data.getString(1);
this.stationaryRadius = data.getString(2);
this.distanceFilter = data.getString(3);
this.locationTimeout = data.getString(4);
this.desiredAccuracy = data.getString(5);
this.isDebugging = data.getString(6);
} catch (JSONException e) { } catch (JSONException e) {
callbackContext.error("authToken/url required as parameters: " + e.getMessage()); callbackContext.error("authToken/url required as parameters: " + e.getMessage());
return false; return false;
......
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