Commit 57574cc3 authored by Chris Scott's avatar Chris Scott

Fix bug, accidentally disabled setting locationCallback in configure

parent 8a13993f
...@@ -56,7 +56,7 @@ public class BackgroundGeolocationPlugin extends CordovaPlugin implements Locati ...@@ -56,7 +56,7 @@ public class BackgroundGeolocationPlugin extends CordovaPlugin implements Locati
private Integer activityRecognitionInterval = 60000; private Integer activityRecognitionInterval = 60000;
// Geolocation callback // Geolocation callback
private CallbackContext callback; private CallbackContext locationCallback;
// Called when DetectedActivity is STILL // Called when DetectedActivity is STILL
private CallbackContext stationaryCallback; private CallbackContext stationaryCallback;
...@@ -119,6 +119,7 @@ public class BackgroundGeolocationPlugin extends CordovaPlugin implements Locati ...@@ -119,6 +119,7 @@ public class BackgroundGeolocationPlugin extends CordovaPlugin implements Locati
} else if (ACTION_CONFIGURE.equalsIgnoreCase(action)) { } else if (ACTION_CONFIGURE.equalsIgnoreCase(action)) {
result = applyConfig(data); result = applyConfig(data);
if (result) { if (result) {
this.locationCallback = callbackContext;
if (isDebugging) { if (isDebugging) {
toneGenerator = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 100); toneGenerator = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 100);
} }
...@@ -253,6 +254,9 @@ public class BackgroundGeolocationPlugin extends CordovaPlugin implements Locati ...@@ -253,6 +254,9 @@ public class BackgroundGeolocationPlugin extends CordovaPlugin implements Locati
} }
public void onEventMainThread(DetectedActivity probableActivity) { public void onEventMainThread(DetectedActivity probableActivity) {
String probableActivityName = getActivityName(probableActivity.getType());
Log.w(TAG, "- DetectedActivity: " + probableActivityName + ", confidence: " + probableActivity.getConfidence());
currentActivity = probableActivity; currentActivity = probableActivity;
boolean wasMoving = isMoving; boolean wasMoving = isMoving;
...@@ -270,9 +274,9 @@ public class BackgroundGeolocationPlugin extends CordovaPlugin implements Locati ...@@ -270,9 +274,9 @@ public class BackgroundGeolocationPlugin extends CordovaPlugin implements Locati
nowMoving = false; nowMoving = false;
break; break;
case DetectedActivity.UNKNOWN: case DetectedActivity.UNKNOWN:
break;
case DetectedActivity.TILTING: case DetectedActivity.TILTING:
break; // We don't let these ActivityType affect movement/stationary state.
return;
} }
boolean startedMoving = !wasMoving && nowMoving; boolean startedMoving = !wasMoving && nowMoving;
...@@ -282,9 +286,6 @@ public class BackgroundGeolocationPlugin extends CordovaPlugin implements Locati ...@@ -282,9 +286,6 @@ public class BackgroundGeolocationPlugin extends CordovaPlugin implements Locati
if ( startedMoving || justStopped || initialState ) { if ( startedMoving || justStopped || initialState ) {
setPace(nowMoving); setPace(nowMoving);
} }
String probableActivityName = getActivityName(probableActivity.getType());
Log.w(TAG, "- DetectedActivity: " + probableActivityName + ", confidence: " + probableActivity.getConfidence());
} }
public void onEventMainThread(Location location) { public void onEventMainThread(Location location) {
...@@ -293,7 +294,7 @@ public class BackgroundGeolocationPlugin extends CordovaPlugin implements Locati ...@@ -293,7 +294,7 @@ public class BackgroundGeolocationPlugin extends CordovaPlugin implements Locati
PluginResult result = new PluginResult(PluginResult.Status.OK, locationToJson(location)); PluginResult result = new PluginResult(PluginResult.Status.OK, locationToJson(location));
result.setKeepCallback(true); result.setKeepCallback(true);
runInBackground(callback, result); runInBackground(locationCallback, result);
} }
/** /**
......
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