Commit bf1895f1 authored by Chris Scott's avatar Chris Scott

Merge pull request #95 from christocracy/change-plugin-clobbers

Change plugin clobbers
parents c6327323 58768c92
......@@ -3,7 +3,7 @@
<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="com.transistorsoft.cordova.background-geolocation"
version="0.5.2">
version="0.5.3">
<name>BackgroundGeolocation</name>
<description>Sophisticated, battery-efficient background-geolocation plugin for Cordova</description>
<license>MIT</license>
......@@ -13,10 +13,16 @@
<engine name="cordova" version=">=3.0.0" />
</engines>
<!--
Pre-Cordova 5, non-npm plugin reference. Uncomment this if you're not using Cordova 5.
<dependency id="org.apache.cordova.dialogs" />
-->
<js-module src="www/BackgroundGeoLocation.js" name="BackgroundGeoLocation">
<clobbers target="plugins.backgroundGeoLocation" />
<!-- Cordova 5 npm-style plugin referernce. Comment this out if you're not using Cordova 5 -->
<dependency id="cordova-plugin-dialogs" />
<js-module src="www/BackgroundGeolocation.js" name="BackgroundGeolocation">
<clobbers target="window.BackgroundGeolocation" />
</js-module>
<!-- android -->
......@@ -51,7 +57,7 @@
</config-file>
<config-file target="res/xml/config.xml" parent="/*">
<feature name="BackgroundGeoLocation">
<feature name="BackgroundGeolocation">
<param name="android-package" value="com.transistorsoft.cordova.bggeo.CDVBackgroundGeolocation"/>
</feature>
</config-file>
......@@ -61,7 +67,7 @@
<!-- required background modes: App registers for location updates -->
<config-file target="*-Info.plist" parent="NSLocationAlwaysUsageDescription">
<string>This app requires background location tracking</string>
<string>TSLocationManager requires background location tracking</string>
</config-file>
<config-file target="*-Info.plist" parent="UIBackgroundModes">
......@@ -71,7 +77,7 @@
</config-file>
<config-file target="config.xml" parent="/*">
<feature name="BackgroundGeoLocation">
<feature name="BackgroundGeolocation">
<param name="ios-package" value="CDVBackgroundGeolocation"/>
</feature>
</config-file>
......
......@@ -217,12 +217,8 @@ public class CDVBackgroundGeolocation extends CordovaPlugin {
callbackContext.success();
} else if (BackgroundGeolocationService.ACTION_GET_CURRENT_POSITION.equalsIgnoreCase(action)) {
result = true;
if (!isEnabled) {
callbackContext.error(401); // aka HTTP UNAUTHORIZED
} else {
onGetCurrentPosition(callbackContext);
}
}
return result;
}
......@@ -231,11 +227,19 @@ public class CDVBackgroundGeolocation extends CordovaPlugin {
isAcquiringCurrentPositionSince = System.nanoTime();
addCurrentPositionListener(callbackContext);
if (!isEnabled) {
EventBus.getDefault().register(this);
if (!BackgroundGeolocationService.isInstanceCreated()) {
backgroundServiceIntent.putExtra("command", BackgroundGeolocationService.ACTION_GET_CURRENT_POSITION);
this.cordova.getActivity().startService(backgroundServiceIntent);
}
} else {
Bundle event = new Bundle();
event.putString("name", BackgroundGeolocationService.ACTION_GET_CURRENT_POSITION);
event.putBoolean("request", true);
EventBus.getDefault().post(event);
}
}
private Boolean onAddGeofence(JSONObject config) {
try {
Bundle event = new Bundle();
......@@ -310,6 +314,8 @@ public class CDVBackgroundGeolocation extends CordovaPlugin {
try {
JSONObject location = new JSONObject(launchIntent.getStringExtra("location"));
onLocationChange(location);
launchIntent.removeExtra("forceReload");
launchIntent.removeExtra("location");
} catch (JSONException e) {
Log.w(TAG, e);
}
......@@ -553,15 +559,24 @@ public class CDVBackgroundGeolocation extends CordovaPlugin {
this.onLocationChange(locationData);
}
private void onLocationChange(JSONObject location) {
Log.i(TAG, "- CDVBackgroundGeolocation Rx Location: " + isEnabled);
PluginResult result = new PluginResult(PluginResult.Status.OK, location);
result.setKeepCallback(true);
result.setKeepCallback(true);
runInBackground(locationCallback, result);
if (isAcquiringCurrentPosition) {
// Current position has arrived: release the hounds.
isAcquiringCurrentPosition = false;
// When currentPosition is explicitly requested while plugin is stopped, shut Service down again and stop listening to EventBus
if (!isEnabled) {
backgroundServiceIntent.removeExtra("command");
EventBus.getDefault().unregister(this);
this.cordova.getActivity().stopService(backgroundServiceIntent);
}
// Execute callbacks.
for (CallbackContext callback : currentPositionCallbacks) {
result = new PluginResult(PluginResult.Status.OK, location);
result.setKeepCallback(false);
......
......@@ -324,13 +324,6 @@
- (void) getCurrentPosition:(CDVInvokedUrlCommand*)command
{
if (![bgGeo isEnabled]) {
NSLog(@"- CDVBackgroundGeolocation#getCurrentPosition cannot be used when plugin is disabled");
// If plugin isn't enabled, return 401 Unauthorized
CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:401];
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
return;
}
if (self.currentPositionListeners == nil) {
self.currentPositionListeners = [[NSMutableArray alloc] init];
}
......
......@@ -10,7 +10,7 @@
</data>
<key>Info.plist</key>
<data>
1G+AqP61j6Sq6MmsyYP98Uqa1/Y=
ksNaWGtWPICW6cxKIrDME82hHsk=
</data>
<key>Modules/module.modulemap</key>
<data>
......
......@@ -40,7 +40,7 @@ module.exports = {
}
exec(mySuccess,
failure || function() {},
'BackgroundGeoLocation',
'BackgroundGeolocation',
'configure',
[config]
);
......@@ -48,14 +48,14 @@ module.exports = {
start: function(success, failure, config) {
exec(success || function() {},
failure || function() {},
'BackgroundGeoLocation',
'BackgroundGeolocation',
'start',
[]);
},
stop: function(success, failure, config) {
exec(success || function() {},
failure || function() {},
'BackgroundGeoLocation',
'BackgroundGeolocation',
'stop',
[]);
},
......@@ -65,7 +65,7 @@ module.exports = {
}
exec(success || function() {},
failure || function() {},
'BackgroundGeoLocation',
'BackgroundGeolocation',
'finish',
[taskId]);
},
......@@ -75,14 +75,14 @@ module.exports = {
}
exec(function() {},
function() {},
'BackgroundGeoLocation',
'BackgroundGeolocation',
'error',
[taskId, message]);
},
changePace: function(isMoving, success, failure) {
exec(success || function() {},
failure || function() {},
'BackgroundGeoLocation',
'BackgroundGeolocation',
'changePace',
[isMoving]);
},
......@@ -96,7 +96,7 @@ module.exports = {
this._apply(this.config, config);
exec(success || function() {},
failure || function() {},
'BackgroundGeoLocation',
'BackgroundGeolocation',
'setConfig',
[config]);
},
......@@ -106,7 +106,7 @@ module.exports = {
getStationaryLocation: function(success, failure) {
exec(success || function() {},
failure || function() {},
'BackgroundGeoLocation',
'BackgroundGeolocation',
'getStationaryLocation',
[]);
},
......@@ -133,7 +133,7 @@ module.exports = {
};
exec(callback,
failure || function() {},
'BackgroundGeoLocation',
'BackgroundGeolocation',
'addStationaryRegionListener',
[]);
},
......@@ -162,7 +162,7 @@ module.exports = {
};
exec(callback,
failure || function() {},
'BackgroundGeoLocation',
'BackgroundGeolocation',
'addMotionChangeListener',
[]);
},
......@@ -180,7 +180,7 @@ module.exports = {
}
exec(mySuccess,
failure || function() {},
'BackgroundGeoLocation',
'BackgroundGeolocation',
'getLocations',
[]);
},
......@@ -202,7 +202,7 @@ module.exports = {
}
exec(mySuccess,
failure || function() {},
'BackgroundGeoLocation',
'BackgroundGeolocation',
'sync',
[]);
},
......@@ -212,7 +212,7 @@ module.exports = {
getOdometer: function(success, failure) {
exec(success || function() {},
failure || function() {},
'BackgroundGeoLocation',
'BackgroundGeolocation',
'getOdometer',
[]);
},
......@@ -222,7 +222,7 @@ module.exports = {
resetOdometer: function(success, failure) {
exec(success || function() {},
failure || function() {},
'BackgroundGeoLocation',
'BackgroundGeolocation',
'resetOdometer',
[]);
},
......@@ -245,7 +245,7 @@ module.exports = {
}
exec(success || function() {},
failure || function() {},
'BackgroundGeoLocation',
'BackgroundGeolocation',
'addGeofence',
[config]);
},
......@@ -259,7 +259,7 @@ module.exports = {
}
exec(success || function() {},
failure || function() {},
'BackgroundGeoLocation',
'BackgroundGeolocation',
'removeGeofence',
[identifier]);
},
......@@ -278,7 +278,7 @@ module.exports = {
};
exec(mySuccess,
failure || function() {},
'BackgroundGeoLocation',
'BackgroundGeolocation',
'onGeofence',
[]);
},
......@@ -288,7 +288,7 @@ module.exports = {
getGeofences: function(success, failure) {
exec(success || function() {},
failure || function() {},
'BackgroundGeoLocation',
'BackgroundGeolocation',
'getGeofences',
[]);
},
......@@ -313,7 +313,7 @@ module.exports = {
}
exec(mySuccess || function() {},
failure || function() {},
'BackgroundGeoLocation',
'BackgroundGeolocation',
'getCurrentPosition',
[]);
},
......@@ -327,7 +327,7 @@ module.exports = {
var failure = function() {};
exec(success,
failure,
'BackgroundGeoLocation',
'BackgroundGeolocation',
'playSound',
[soundId]);
},
......
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