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