Commit 4a23a4c6 authored by Chris Scott's avatar Chris Scott

Implement changePace for Android

parent 6d93955c
......@@ -35,6 +35,7 @@ public class BackgroundGeolocationPlugin extends CordovaPlugin implements Locati
public static final String ACTION_START = "start";
public static final String ACTION_STOP = "stop";
public static final String ACTION_ON_PACE_CHANGE = "onPaceChange";
public static final String ACTION_CONFIGURE = "configure";
public static final String ACTION_SET_CONFIG = "setConfig";
......@@ -94,7 +95,7 @@ public class BackgroundGeolocationPlugin extends CordovaPlugin implements Locati
EventBus.getDefault().register(this);
}
public boolean execute(String action, JSONArray data, CallbackContext callbackContext) {
public boolean execute(String action, JSONArray data, CallbackContext callbackContext) throws JSONException {
Log.d(TAG, "execute / action : " + action);
Boolean result = false;
......@@ -136,6 +137,16 @@ public class BackgroundGeolocationPlugin extends CordovaPlugin implements Locati
} catch (JSONException e) {
callbackContext.error("Configuration error " + e.getMessage());
}
} else if (ACTION_ON_PACE_CHANGE.equalsIgnoreCase(action)) {
if (!isEnabled) {
Log.w(TAG, "- Cannot change pace while in #stop mode");
result = false;
callbackContext.error("Cannot #changePace while in #stop mode");
} else {
result = true;
isMoving = data.getBoolean(0);
callbackContext.success();
}
} else if (ACTION_SET_CONFIG.equalsIgnoreCase(action)) {
result = true;
// TODO reconfigure Service
......@@ -188,7 +199,9 @@ public class BackgroundGeolocationPlugin extends CordovaPlugin implements Locati
}
private void setPace(Boolean moving) {
if (moving) {
Log.i(TAG, "- setPace: " + moving);
isMoving = moving;
if (moving && isEnabled) {
LocationRequest request = LocationRequest.create()
.setPriority(translateDesiredAccuracy(desiredAccuracy))
.setInterval(this.locationUpdateInterval)
......
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