diff options
Diffstat (limited to 'StoneIsland/plugins/cordova-plugin-geolocation')
40 files changed, 1156 insertions, 370 deletions
diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/CONTRIBUTING.md b/StoneIsland/plugins/cordova-plugin-geolocation/CONTRIBUTING.md index f7dbcaba..4c8e6a5e 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-geolocation/CONTRIBUTING.md +++ b/StoneIsland/plugins/cordova-plugin-geolocation/CONTRIBUTING.md @@ -27,7 +27,7 @@ There are multiple ways to contribute: report bugs, improve the docs, and contribute code. For instructions on this, start with the -[contribution overview](http://cordova.apache.org/#contribute). +[contribution overview](http://cordova.apache.org/contribute/). The details are explained there, but the important items are: - Sign and submit an Apache ICLA (Contributor License Agreement). diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/LICENSE b/StoneIsland/plugins/cordova-plugin-geolocation/LICENSE index 7a4a3ea2..7a4a3ea2 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-geolocation/LICENSE +++ b/StoneIsland/plugins/cordova-plugin-geolocation/LICENSE diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/NOTICE b/StoneIsland/plugins/cordova-plugin-geolocation/NOTICE index 8ec56a52..8ec56a52 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-geolocation/NOTICE +++ b/StoneIsland/plugins/cordova-plugin-geolocation/NOTICE diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/README.md b/StoneIsland/plugins/cordova-plugin-geolocation/README.md index eb10b9f8..77a3c9a7 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-geolocation/README.md +++ b/StoneIsland/plugins/cordova-plugin-geolocation/README.md @@ -1,3 +1,7 @@ +--- +title: Geolocation +description: Access GPS data. +--- <!-- # license: Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file @@ -17,17 +21,23 @@ # under the License. --> -# cordova-plugin-geolocation +|Android|iOS| Windows 8.1 Store | Windows 8.1 Phone | Windows 10 Store | Travis CI | +|:-:|:-:|:-:|:-:|:-:|:-:| +|[](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android,PLUGIN=cordova-plugin-geolocation/)|[](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=ios,PLUGIN=cordova-plugin-geolocation/)|[](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-8.1-store,PLUGIN=cordova-plugin-geolocation/)|[](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-8.1-phone,PLUGIN=cordova-plugin-geolocation/)|[](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-geolocation/)|[](https://travis-ci.org/apache/cordova-plugin-geolocation)| -[](https://travis-ci.org/apache/cordova-plugin-geolocation) +# cordova-plugin-geolocation This plugin provides information about the device's location, such as -latitude and longitude. Common sources of location information include +latitude and longitude. + +Common sources of location information include Global Positioning System (GPS) and location inferred from network signals such as IP address, RFID, WiFi and Bluetooth MAC addresses, and GSM/CDMA cell IDs. There is no guarantee that the API returns the device's actual location. +> To get a few ideas, check out the [sample](#sample) at the bottom of this page or go straight to the [reference](#reference) content. + This API is based on the [W3C Geolocation API Specification](http://dev.w3.org/geo/api/spec-source.html), and only executes on devices that don't already provide an implementation. @@ -45,7 +55,7 @@ accesses geolocation data (if the device operating system doesn't do so already). That notice should provide the same information noted above, as well as obtaining the user's permission (e.g., by presenting choices for __OK__ and __No Thanks__). For more information, please -see the Privacy Guide. +see the [Privacy Guide](http://cordova.apache.org/docs/en/latest/guide/appdev/privacy/index.html). This plugin defines a global `navigator.geolocation` object (for platforms where it is otherwise missing). @@ -53,11 +63,15 @@ where it is otherwise missing). Although the object is in the global scope, features provided by this plugin are not available until after the `deviceready` event. +```javascript + document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() { console.log("navigator.geolocation works well"); } +``` +## <a id="reference"></a>Reference ## Installation This requires cordova 5.0+ ( current stable 1.0.0 ) @@ -81,7 +95,6 @@ It is also possible to install via repo url directly ( unstable ) - iOS - Tizen - Windows Phone 7 and 8 -- Windows 8 - Windows ## Methods @@ -118,6 +131,8 @@ error, the `geolocationError` callback is passed a ### Example +```javascript + // onSuccess Callback // This method accepts a Position object, which contains the // current GPS coordinates @@ -142,6 +157,13 @@ error, the `geolocationError` callback is passed a navigator.geolocation.getCurrentPosition(onSuccess, onError); +``` + +### Android Quirks + +If Geolocation service is turned off the `onError` callback is invoked after `timeout` interval (if specified). +If `timeout` parameter is not specified then no callback is called. + ## navigator.geolocation.watchPosition Returns the device's current position when a change in position is detected. @@ -168,6 +190,8 @@ there is an error, the `geolocationError` callback executes with a ### Example +```javascript + // onSuccess Callback // This method accepts a `Position` object, which contains // the current GPS coordinates @@ -190,6 +214,7 @@ there is an error, the `geolocationError` callback executes with a // var watchID = navigator.geolocation.watchPosition(onSuccess, onError, { timeout: 30000 }); +``` ## geolocationOptions @@ -208,7 +233,8 @@ Optional parameters to customize the retrieval of the geolocation ### Android Quirks -Android 2.x emulators do not return a geolocation result unless the `enableHighAccuracy` option is set to `true`. +If Geolocation service is turned off the `onError` callback is invoked after `timeout` interval (if specified). +If `timeout` parameter is not specified then no callback is called. ## navigator.geolocation.clearWatch @@ -223,6 +249,8 @@ Stop watching for changes to the device's location referenced by the ### Example +```javascript + // Options: watch for changes in position, and use the most // accurate position acquisition method available. // @@ -232,6 +260,8 @@ Stop watching for changes to the device's location referenced by the navigator.geolocation.clearWatch(watchID); +``` + ## Position Contains `Position` coordinates and timestamp, created by the geolocation API. @@ -240,7 +270,7 @@ Contains `Position` coordinates and timestamp, created by the geolocation API. - __coords__: A set of geographic coordinates. _(Coordinates)_ -- __timestamp__: Creation timestamp for `coords`. _(Date)_ +- __timestamp__: Creation timestamp for `coords`. _(DOMTimeStamp)_ ## Coordinates @@ -291,3 +321,438 @@ callback function when an error occurs with navigator.geolocation. - Returned when the device is unable to retrieve a position. In general, this means the device is not connected to a network or can't get a satellite fix. - `PositionError.TIMEOUT` - Returned when the device is unable to retrieve a position within the time specified by the `timeout` included in `geolocationOptions`. When used with `navigator.geolocation.watchPosition`, this error could be repeatedly passed to the `geolocationError` callback every `timeout` milliseconds. + + +## <a id="sample"></a>Sample: Get the weather, find stores, and see photos of things nearby with Geolocation ## + +Use this plugin to help users find things near them such as Groupon deals, houses for sale, movies playing, sports and entertainment events and more. + +Here's a "cookbook" of ideas to get you started. In the snippets below, we'll show you some basic ways to add these features to your app. + +* [Get your coordinates](#coords). +* [Get the weather forecast](#weather). +* [Receive updated weather forecasts as you drive around](#receive). +* [See where you are on a map](#see). +* [Find stores near you](#find). +* [See pictures of things around you](#see). + +## <a id="coord"></a>Get your geolocation coordinates + +```javascript + +function getWeatherLocation() { + + navigator.geolocation.getCurrentPosition + (onWeatherSuccess, onWeatherError, { enableHighAccuracy: true }); +} + +``` +## <a id="weather"></a>Get the weather forecast + +```javascript + +// Success callback for get geo coordinates + +var onWeatherSuccess = function (position) { + + Latitude = position.coords.latitude; + Longitude = position.coords.longitude; + + getWeather(Latitude, Longitude); +} + +// Get weather by using coordinates + +function getWeather(latitude, longitude) { + + // Get a free key at http://openweathermap.org/. Replace the "Your_Key_Here" string with that key. + var OpenWeatherAppKey = "Your_Key_Here"; + + var queryString = + 'http://api.openweathermap.org/data/2.5/weather?lat=' + + latitude + '&lon=' + longitude + '&appid=' + OpenWeatherAppKey + '&units=imperial'; + + $.getJSON(queryString, function (results) { + + if (results.weather.length) { + + $.getJSON(queryString, function (results) { + + if (results.weather.length) { + + $('#description').text(results.name); + $('#temp').text(results.main.temp); + $('#wind').text(results.wind.speed); + $('#humidity').text(results.main.humidity); + $('#visibility').text(results.weather[0].main); + + var sunriseDate = new Date(results.sys.sunrise); + $('#sunrise').text(sunriseDate.toLocaleTimeString()); + + var sunsetDate = new Date(results.sys.sunrise); + $('#sunset').text(sunsetDate.toLocaleTimeString()); + } + + }); + } + }).fail(function () { + console.log("error getting location"); + }); +} + +// Error callback + +function onWeatherError(error) { + console.log('code: ' + error.code + '\n' + + 'message: ' + error.message + '\n'); +} + +``` + +## <a id="receive"></a>Receive updated weather forecasts as you drive around + +```javascript + +// Watch your changing position + +function watchWeatherPosition() { + + return navigator.geolocation.watchPosition + (onWeatherWatchSuccess, onWeatherError, { enableHighAccuracy: true }); +} + +// Success callback for watching your changing position + +var onWeatherWatchSuccess = function (position) { + + var updatedLatitude = position.coords.latitude; + var updatedLongitude = position.coords.longitude; + + if (updatedLatitude != Latitude && updatedLongitude != Longitude) { + + Latitude = updatedLatitude; + Longitude = updatedLongitude; + + // Calls function we defined earlier. + getWeather(updatedLatitude, updatedLongitude); + } +} + +``` + +## <a id="see"></a>See where you are on a map + +Both Bing and Google have map services. We'll use Google's. You'll need a key but it's free if you're just trying things out. + +Add a reference to the **maps** service. + +```HTML + + <script src="https://maps.googleapis.com/maps/api/js?key=Your_API_Key"></script> + +``` +Then, add code to use it. + +```javascript + +var Latitude = undefined; +var Longitude = undefined; + +// Get geo coordinates + +function getMapLocation() { + + navigator.geolocation.getCurrentPosition + (onMapSuccess, onMapError, { enableHighAccuracy: true }); +} + +// Success callback for get geo coordinates + +var onMapSuccess = function (position) { + + Latitude = position.coords.latitude; + Longitude = position.coords.longitude; + + getMap(Latitude, Longitude); + +} + +// Get map by using coordinates + +function getMap(latitude, longitude) { + + var mapOptions = { + center: new google.maps.LatLng(0, 0), + zoom: 1, + mapTypeId: google.maps.MapTypeId.ROADMAP + }; + + map = new google.maps.Map + (document.getElementById("map"), mapOptions); + + + var latLong = new google.maps.LatLng(latitude, longitude); + + var marker = new google.maps.Marker({ + position: latLong + }); + + marker.setMap(map); + map.setZoom(15); + map.setCenter(marker.getPosition()); +} + +// Success callback for watching your changing position + +var onMapWatchSuccess = function (position) { + + var updatedLatitude = position.coords.latitude; + var updatedLongitude = position.coords.longitude; + + if (updatedLatitude != Latitude && updatedLongitude != Longitude) { + + Latitude = updatedLatitude; + Longitude = updatedLongitude; + + getMap(updatedLatitude, updatedLongitude); + } +} + +// Error callback + +function onMapError(error) { + console.log('code: ' + error.code + '\n' + + 'message: ' + error.message + '\n'); +} + +// Watch your changing position + +function watchMapPosition() { + + return navigator.geolocation.watchPosition + (onMapWatchSuccess, onMapError, { enableHighAccuracy: true }); +} + +``` + +## <a id="find"></a>Find stores near you + +You can use the same Google key for this. + +Add a reference to the **places** service. + +```HTML + +<script src= +"https://maps.googleapis.com/maps/api/js?key=Your_API_Key&libraries=places"> +</script> + +``` + +Then, add code to use it. + +```javascript + +var Map; +var Infowindow; +var Latitude = undefined; +var Longitude = undefined; + +// Get geo coordinates + +function getPlacesLocation() { + navigator.geolocation.getCurrentPosition + (onPlacesSuccess, onPlacesError, { enableHighAccuracy: true }); +} + +// Success callback for get geo coordinates + +var onPlacesSuccess = function (position) { + + Latitude = position.coords.latitude; + Longitude = position.coords.longitude; + + getPlaces(Latitude, Longitude); + +} + +// Get places by using coordinates + +function getPlaces(latitude, longitude) { + + var latLong = new google.maps.LatLng(latitude, longitude); + + var mapOptions = { + + center: new google.maps.LatLng(latitude, longitude), + zoom: 15, + mapTypeId: google.maps.MapTypeId.ROADMAP + + }; + + Map = new google.maps.Map(document.getElementById("places"), mapOptions); + + Infowindow = new google.maps.InfoWindow(); + + var service = new google.maps.places.PlacesService(Map); + service.nearbySearch({ + + location: latLong, + radius: 500, + type: ['store'] + }, foundStoresCallback); + +} + +// Success callback for watching your changing position + +var onPlacesWatchSuccess = function (position) { + + var updatedLatitude = position.coords.latitude; + var updatedLongitude = position.coords.longitude; + + if (updatedLatitude != Latitude && updatedLongitude != Longitude) { + + Latitude = updatedLatitude; + Longitude = updatedLongitude; + + getPlaces(updatedLatitude, updatedLongitude); + } +} + +// Success callback for locating stores in the area + +function foundStoresCallback(results, status) { + + if (status === google.maps.places.PlacesServiceStatus.OK) { + + for (var i = 0; i < results.length; i++) { + + createMarker(results[i]); + + } + } +} + +// Place a pin for each store on the map + +function createMarker(place) { + + var placeLoc = place.geometry.location; + + var marker = new google.maps.Marker({ + map: Map, + position: place.geometry.location + }); + + google.maps.event.addListener(marker, 'click', function () { + + Infowindow.setContent(place.name); + Infowindow.open(Map, this); + + }); +} + +// Error callback + +function onPlacesError(error) { + console.log('code: ' + error.code + '\n' + + 'message: ' + error.message + '\n'); +} + +// Watch your changing position + +function watchPlacesPosition() { + + return navigator.geolocation.watchPosition + (onPlacesWatchSuccess, onPlacesError, { enableHighAccuracy: true }); +} + +``` + +## <a id="pictures"></a>See pictures of things around you + +Digital photos can contain geo coordinates that identify where the picture was taken. + +Use Flickr API's to find pictures that folks have taken near you. Like Google services, you'll need a key, but it's free if you just want to try things out. + +```javascript + +var Latitude = undefined; +var Longitude = undefined; + +// Get geo coordinates + +function getPicturesLocation() { + + navigator.geolocation.getCurrentPosition + (onPicturesSuccess, onPicturesError, { enableHighAccuracy: true }); + +} + +// Success callback for get geo coordinates + +var onPicturesSuccess = function (position) { + + Latitude = position.coords.latitude; + Longitude = position.coords.longitude; + + getPictures(Latitude, Longitude); +} + +// Get pictures by using coordinates + +function getPictures(latitude, longitude) { + + $('#pictures').empty(); + + var queryString = + "https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=Your_API_Key&lat=" + + latitude + "&lon=" + longitude + "&format=json&jsoncallback=?"; + + $.getJSON(queryString, function (results) { + $.each(results.photos.photo, function (index, item) { + + var photoURL = "http://farm" + item.farm + ".static.flickr.com/" + + item.server + "/" + item.id + "_" + item.secret + "_m.jpg"; + + $('#pictures').append($("<img />").attr("src", photoURL)); + + }); + } + ); +} + +// Success callback for watching your changing position + +var onPicturesWatchSuccess = function (position) { + + var updatedLatitude = position.coords.latitude; + var updatedLongitude = position.coords.longitude; + + if (updatedLatitude != Latitude && updatedLongitude != Longitude) { + + Latitude = updatedLatitude; + Longitude = updatedLongitude; + + getPictures(updatedLatitude, updatedLongitude); + } +} + +// Error callback + +function onPicturesError(error) { + + console.log('code: ' + error.code + '\n' + + 'message: ' + error.message + '\n'); +} + +// Watch your changing position + +function watchPicturePosition() { + + return navigator.geolocation.watchPosition + (onPicturesWatchSuccess, onPicturesError, { enableHighAccuracy: true }); +} + +``` diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/RELEASENOTES.md b/StoneIsland/plugins/cordova-plugin-geolocation/RELEASENOTES.md index 197b28e5..f622086b 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-geolocation/RELEASENOTES.md +++ b/StoneIsland/plugins/cordova-plugin-geolocation/RELEASENOTES.md @@ -20,110 +20,152 @@ --> # Release Notes -### 0.3.0 (Sept 5, 2013) -* Added support for windows 8 (Adds required permission) +### 2.4.0 (Sep 26, 2016) +* **Ubuntu** Fix altitude & accuracies retrieval +* [CB-11875](https://issues.apache.org/jira/browse/CB-11875) added `android.hardware.location.gps` `uses-feature`. -### 0.3.2 (Sept 25, 2013) -* CB-4889 bumping&resetting version -* [BlackBerry10] removed uneeded permission tags in plugin.xml -* CB-4889 renaming org.apache.cordova.core.geolocation to org.apache.cordova.geolocation +### 2.3.0 (Sep 08, 2016) +* [CB-11795](https://issues.apache.org/jira/browse/CB-11795) Add 'protective' entry to cordovaDependencies +* Plugin uses `Android Log class` and not `Cordova LOG class` +* Add badges for paramedic builds on Jenkins +* Add pull request template. +* Adding links to reference content and sample content to the top of the readme file +* Update **iOS** geolocation plugin to avoid `THREAD WARNING: ['Geolocation']`, operation occurs in new Thread +* [CB-10996](https://issues.apache.org/jira/browse/CB-10996) Adding front matter to README.md -### 0.3.3 (Oct 28, 2013) -* CB-5128: add repo + issue tag to plugin.xml for geolocation plugin -* [CB-4915] Incremented plugin version on dev branch. +### 2.2.0 (Apr 15, 2016) +* Replace `PermissionHelper.java` with `cordova-plugin-compat` +* [CB-10691](https://issues.apache.org/jira/browse/CB-10691) Check the context to avoid null errors +* [CB-10636](https://issues.apache.org/jira/browse/CB-10636) Add `JSHint` for plugins +* Using a fallback epsilon in case `Number.EPSILON` is not defined. +* [CB-10574](https://issues.apache.org/jira/browse/CB-10574) MobileSpec can't get results for **WP8.1** Builds -### 0.3.4 (Dec 4, 2013) -* Append proxy to platform definition in plugin.xml -* Append windows 8 Geolocation proxy -* Code clean-up for android src. -* Updated amazon-fireos platform + reverting some of the fixes in android code. -* Added amazon-fireos platform + some of the fixes in android code. -* CB-5334 [BlackBerry10] Use command proxy -* call FxOS's getCurrentProxy added -* pass by only coords -* proper implementation for firefoxos - -### 0.3.5 (Jan 02, 2014) -* CB-5658 Add doc/index.md for Geolocation plugin -* windows8: adds missing reference to PositionError (w/o it the app crashes) -* Removing incorrectly added closing comments for wp7 platform in plugin.xml +### 2.1.0 (Jan 15, 2016) +* [CB-10319](https://issues.apache.org/jira/browse/CB-10319) **Android** Adding reflective helper methods for permission requests +* [CB-8523](https://issues.apache.org/jira/browse/CB-8523) Fixed accuracy when `enableHighAccuracy: false` on **iOS**. +* [CB-10286](https://issues.apache.org/jira/browse/CB-10286) Don't skip automatic tests on **Android** devices +* [CB-10277](https://issues.apache.org/jira/browse/CB-10277) Error callback should be called w/ `PositionError` when location access is denied +* [CB-10285](https://issues.apache.org/jira/browse/CB-10285) Added tests for `PositionError` constants +* [CB-10278](https://issues.apache.org/jira/browse/CB-10278) geolocation `watchPosition` doesn't return `watchID` string +* [CB-8443](https://issues.apache.org/jira/browse/CB-8443) **Android** nothing happens if `GPS` is turned off +* [CB-10204](https://issues.apache.org/jira/browse/CB-10204) Fix `getCurrentPosition` options on **Android** +* [CB-7146](https://issues.apache.org/jira/browse/CB-7146) Remove built-in `WebView navigator.geolocation` manual tests +* [CB-2845](https://issues.apache.org/jira/browse/CB-2845) `PositionError` constants not attached to prototype as specified in W3C document -### 0.3.6 (Feb 05, 2014) -* add ubuntu platform support -* CB-5326 adding FFOS permission and updating supported platforms -* CB-5729 [BlackBerry10] Update GeolocationProxy to return collapsed object +### 2.0.0 (Nov 18, 2015) +* [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Updated `RELEASENOTES` to be newest to oldest +* [CB-9907](https://issues.apache.org/jira/browse/CB-9907) Handle **iOS** tests that fail when ios simulator does not have a location +* [CB-8826](https://issues.apache.org/jira/browse/CB-8826) Check for `NSLocationWhenInUseUsageDescription` first +* [CB-9105](https://issues.apache.org/jira/browse/CB-9105): Fixing `JS` errors in the shim +* Added support for new permissions model for **Android 6.0** aka **Marshmallow** +* Expect `lastPosition` to have a `timestamp` that is already in `msecs` +* [CB-4596](https://issues.apache.org/jira/browse/CB-4596) Date objects are supposed to be `DOMTimeStamp` +* Fixing contribute link. +* [CB-9355](https://issues.apache.org/jira/browse/CB-9355) Fix Geolocation plugin start watch fail related to unset `MovementThreshold` on **Windows 10** -### 0.3.7 (Apr 17, 2014) -* CB-6422: [windows8] use cordova/exec/proxy -* CB-6212: [iOS] fix warnings compiled under arm64 64-bit -* CB-5977: [android] Removing the Android Geolocation Code. Mission Accomplished. -* CB-6460: Update license headers -* Add NOTICE file +### 1.0.1 (Jun 17, 2015) +* [CB-9128](https://issues.apache.org/jira/browse/CB-9128) cordova-plugin-geolocation documentation translation: cordova-plugin-geolocation +* fix npm md issue +* [CB-8845](https://issues.apache.org/jira/browse/CB-8845) Updated comment why Android tests are currently pended +* [CB-8845](https://issues.apache.org/jira/browse/CB-8845) Pended tests for Android +* Add more install text for legacy versions of cordova tools. This closes #36 -### 0.3.8 (Jun 05, 2014) -* CB-6127 Spanish and French Translations added. Github close #14 -* CB-6804 Add license -* CB-5416 - Adding support for auto-managing permissions -* CB-6491 add CONTRIBUTING.md -* pass by only coords -* proper implementation for firefoxos -* call FxOS's getCurrentProxy added +### 1.0.0 (Apr 15, 2015) +* [CB-8746](https://issues.apache.org/jira/browse/CB-8746) gave plugin major version bump +* [CB-8683](https://issues.apache.org/jira/browse/CB-8683) changed plugin-id to pacakge-name +* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) properly updated translated docs to use new id +* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) updated translated docs to use new id +* Use TRAVIS_BUILD_DIR, install paramedic by npm +* [CB-8681](https://issues.apache.org/jira/browse/CB-8681) Fixed occasional test failures +* docs: added Windows to supported platforms +* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) Updated Readme +* [CB-8659](https://issues.apache.org/jira/browse/CB-8659): ios: 4.0.x Compatibility: Remove use of initWebView method +* [CB-8659](https://issues.apache.org/jira/browse/CB-8659): ios: 4.0.x Compatibility: Remove use of deprecated headers +* Wrong parameter in Firefox OS plugin +* [CB-8568](https://issues.apache.org/jira/browse/CB-8568) Integrate TravisCI +* [CB-8438](https://issues.apache.org/jira/browse/CB-8438) cordova-plugin-geolocation documentation translation: cordova-plugin-geolocation +* [CB-8538](https://issues.apache.org/jira/browse/CB-8538) Added package.json file +* [CB-8443](https://issues.apache.org/jira/browse/CB-8443) Geolocation tests fail on Windows due to done is called multiple times -### 0.3.9 (Aug 06, 2014) -* **FFOS** update GeolocationProxy.js -* CB-7187 ios: Add explicit dependency on CoreLocation.framework -* CB-7187 Delete unused #import of CDVShared.h -* CB-6127 Updated translations for docs -* ios: Changed distanceFilter from none to 5 meters, prevents it from spamming the callback even though nothing changed. +### 0.3.12 (Feb 04, 2015) +* [CB-8351](https://issues.apache.org/jira/browse/CB-8351) ios: Use argumentForIndex rather than NSArray extension +### 0.3.11 (Dec 02, 2014) +* Do not stop updating location when the error is `kCLErrorLocationUnknown` +* [CB-8094](https://issues.apache.org/jira/browse/CB-8094) Pended auto tests for **Windows** Store since they require user interaction +* [CB-8085](https://issues.apache.org/jira/browse/CB-8085) Fix geolocation plugin on **Windows** +* [CB-7977](https://issues.apache.org/jira/browse/CB-7977) Mention `deviceready` in plugin docs +* [CB-7700](https://issues.apache.org/jira/browse/CB-7700) cordova-plugin-geolocation documentation translation: cordova-plugin-geolocation ### 0.3.10 (Sep 17, 2014) -* CB-7556 iOS: Clearing all Watches does not stop Location Services -* CB-7158 Fix geolocation for ios 8 -* Revert CB-6911 partially (keeping Info.plist key installation for iOS 8) -* CB-6911 Geolocation fails in iOS 8 -* CB-5114 Windows 8.1 - Use a new proxy as old geolocation methods is deprecated -* CB-5114 Append Windows 8.1 into plugin.xml + Optimize Windows 8 Geolocation proxy +* [CB-7556](https://issues.apache.org/jira/browse/CB-7556) iOS: Clearing all Watches does not stop Location Services +* [CB-7158](https://issues.apache.org/jira/browse/CB-7158) Fix geolocation for ios 8 +* Revert [CB-6911](https://issues.apache.org/jira/browse/CB-6911) partially (keeping Info.plist key installation for iOS 8) +* [CB-6911](https://issues.apache.org/jira/browse/CB-6911) Geolocation fails in iOS 8 +* [CB-5114](https://issues.apache.org/jira/browse/CB-5114) Windows 8.1 - Use a new proxy as old geolocation methods is deprecated +* [CB-5114](https://issues.apache.org/jira/browse/CB-5114) Append Windows 8.1 into plugin.xml + Optimize Windows 8 Geolocation proxy * Renamed test dir, added nested plugin.xml * added documentation for manual tests -* CB-7146 Added manual tests +* [CB-7146](https://issues.apache.org/jira/browse/CB-7146) Added manual tests * Removed js-module for tests from plugin.xml * Changing cdvtest format to use module exports * register tests using new style * Convert tests to new style * Removed amazon-fireos code for geolocation. -* CB-7571 Bump version of nested plugin to match parent plugin +* [CB-7571](https://issues.apache.org/jira/browse/CB-7571) Bump version of nested plugin to match parent plugin -### 0.3.11 (Dec 02, 2014) -* Do not stop updating location when the error is `kCLErrorLocationUnknown` -* CB-8094 Pended auto tests for **Windows** Store since they require user interaction -* CB-8085 Fix geolocation plugin on **Windows** -* CB-7977 Mention `deviceready` in plugin docs -* CB-7700 cordova-plugin-geolocation documentation translation: cordova-plugin-geolocation +### 0.3.9 (Aug 06, 2014) +* **FFOS** update GeolocationProxy.js +* [CB-7187](https://issues.apache.org/jira/browse/CB-7187) ios: Add explicit dependency on CoreLocation.framework +* [CB-7187](https://issues.apache.org/jira/browse/CB-7187) Delete unused #import of CDVShared.h +* [CB-6127](https://issues.apache.org/jira/browse/CB-6127) Updated translations for docs +* ios: Changed distanceFilter from none to 5 meters, prevents it from spamming the callback even though nothing changed. -### 0.3.12 (Feb 04, 2015) -* CB-8351 ios: Use argumentForIndex rather than NSArray extension +### 0.3.8 (Jun 05, 2014) +* [CB-6127](https://issues.apache.org/jira/browse/CB-6127) Spanish and French Translations added. Github close #14 +* [CB-6804](https://issues.apache.org/jira/browse/CB-6804) Add license +* [CB-5416](https://issues.apache.org/jira/browse/CB-5416) - Adding support for auto-managing permissions +* [CB-6491](https://issues.apache.org/jira/browse/CB-6491) add CONTRIBUTING.md +* pass by only coords +* proper implementation for firefoxos +* call FxOS's getCurrentProxy added -### 1.0.0 (Apr 15, 2015) -* CB-8746 gave plugin major version bump -* CB-8683 changed plugin-id to pacakge-name -* CB-8653 properly updated translated docs to use new id -* CB-8653 updated translated docs to use new id -* Use TRAVIS_BUILD_DIR, install paramedic by npm -* CB-8681 Fixed occasional test failures -* docs: added Windows to supported platforms -* CB-8653 Updated Readme -* CB-8659: ios: 4.0.x Compatibility: Remove use of initWebView method -* CB-8659: ios: 4.0.x Compatibility: Remove use of deprecated headers -* Wrong parameter in Firefox OS plugin -* CB-8568 Integrate TravisCI -* CB-8438 cordova-plugin-geolocation documentation translation: cordova-plugin-geolocation -* CB-8538 Added package.json file -* CB-8443 Geolocation tests fail on Windows due to done is called multiple times +### 0.3.7 (Apr 17, 2014) +* [CB-6422](https://issues.apache.org/jira/browse/CB-6422): [windows8] use cordova/exec/proxy +* [CB-6212](https://issues.apache.org/jira/browse/CB-6212): [iOS] fix warnings compiled under arm64 64-bit +* [CB-5977](https://issues.apache.org/jira/browse/CB-5977): [android] Removing the Android Geolocation Code. Mission Accomplished. +* [CB-6460](https://issues.apache.org/jira/browse/CB-6460): Update license headers +* Add NOTICE file -### 1.0.1 (Jun 17, 2015) -* CB-9128 cordova-plugin-geolocation documentation translation: cordova-plugin-geolocation -* fix npm md issue -* CB-8845 Updated comment why Android tests are currently pended -* CB-8845 Pended tests for Android -* Add more install text for legacy versions of cordova tools. This closes #36 +### 0.3.6 (Feb 05, 2014) +* add ubuntu platform support +* [CB-5326](https://issues.apache.org/jira/browse/CB-5326) adding FFOS permission and updating supported platforms +* [CB-5729](https://issues.apache.org/jira/browse/CB-5729) [BlackBerry10] Update GeolocationProxy to return collapsed object + +### 0.3.5 (Jan 02, 2014) +* [CB-5658](https://issues.apache.org/jira/browse/CB-5658) Add doc/index.md for Geolocation plugin +* windows8: adds missing reference to PositionError (w/o it the app crashes) +* Removing incorrectly added closing comments for wp7 platform in plugin.xml + +### 0.3.4 (Dec 4, 2013) +* Append proxy to platform definition in plugin.xml +* Append windows 8 Geolocation proxy +* Code clean-up for android src. +* Updated amazon-fireos platform + reverting some of the fixes in android code. +* Added amazon-fireos platform + some of the fixes in android code. +* [CB-5334](https://issues.apache.org/jira/browse/CB-5334) [BlackBerry10] Use command proxy +* call FxOS's getCurrentProxy added +* pass by only coords +* proper implementation for firefoxos + +### 0.3.3 (Oct 28, 2013) +* [CB-5128](https://issues.apache.org/jira/browse/CB-5128): add repo + issue tag to plugin.xml for geolocation plugin +* [CB-4915](https://issues.apache.org/jira/browse/CB-4915) Incremented plugin version on dev branch. + +### 0.3.2 (Sept 25, 2013) +* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) bumping&resetting version +* [BlackBerry10] removed uneeded permission tags in plugin.xml +* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) renaming org.apache.cordova.core.geolocation to org.apache.cordova.geolocation + +### 0.3.0 (Sept 5, 2013) +* Added support for windows 8 (Adds required permission) diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/doc/de/README.md b/StoneIsland/plugins/cordova-plugin-geolocation/doc/de/README.md index 9cf693e5..17e14a53 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-geolocation/doc/de/README.md +++ b/StoneIsland/plugins/cordova-plugin-geolocation/doc/de/README.md @@ -218,7 +218,7 @@ Enthält `Position` koordinaten und Timestamp, erstellt von der Geolocation API. * **coords**: eine Reihe von geographischen Koordinaten. *(Coordinates)* - * **timestamp**: Zeitstempel der Erstellung für `coords` . *(Date)* + * **timestamp**: Zeitstempel der Erstellung für `coords` . *(DOMTimeStamp)* ## Coordinates diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/doc/de/index.md b/StoneIsland/plugins/cordova-plugin-geolocation/doc/de/index.md index 3fe4e4a8..92b2079b 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-geolocation/doc/de/index.md +++ b/StoneIsland/plugins/cordova-plugin-geolocation/doc/de/index.md @@ -205,7 +205,7 @@ Enthält `Position` koordinaten und Timestamp, erstellt von der Geolocation API. * **coords**: eine Reihe von geographischen Koordinaten. *(Coordinates)* -* **timestamp**: Zeitstempel der Erstellung für `coords` . *(Date)* +* **timestamp**: Zeitstempel der Erstellung für `coords` . *(DOMTimeStamp)* ## Coordinates diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/doc/es/README.md b/StoneIsland/plugins/cordova-plugin-geolocation/doc/es/README.md index 1a4bf006..7808a0e3 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-geolocation/doc/es/README.md +++ b/StoneIsland/plugins/cordova-plugin-geolocation/doc/es/README.md @@ -216,7 +216,7 @@ Contiene `Position` coordenadas y timestamp, creado por la API de geolocalizacià * **coordenadas**: un conjunto de coordenadas geográficas. *(Coordenadas)* - * **timestamp**: fecha y hora de creación `coords` . *(Fecha)* + * **timestamp**: fecha y hora de creación `coords` . *(DOMTimeStamp)* ## Coordinates diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/doc/es/index.md b/StoneIsland/plugins/cordova-plugin-geolocation/doc/es/index.md index 043e9294..041f3f82 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-geolocation/doc/es/index.md +++ b/StoneIsland/plugins/cordova-plugin-geolocation/doc/es/index.md @@ -164,7 +164,7 @@ Contiene `Position` coordenadas y timestamp, creado por la API de geolocalizacià * **coordenadas**: un conjunto de coordenadas geográficas. *(Coordenadas)* -* **timestamp**: fecha y hora de creación `coords` . *(Fecha)* +* **timestamp**: fecha y hora de creación `coords` . *(DOMTimeStamp)* ## Coordinates diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/doc/fr/README.md b/StoneIsland/plugins/cordova-plugin-geolocation/doc/fr/README.md index f9865dc6..775a487f 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-geolocation/doc/fr/README.md +++ b/StoneIsland/plugins/cordova-plugin-geolocation/doc/fr/README.md @@ -177,7 +177,7 @@ Contient `Position` coordonnées et timestamp, créé par l'API de géolocalisat * **coords** : un ensemble de coordonnées géographiques. *(Coordinates)* - * **timestamp** : horodatage de la création de `coords`. *(Date)* + * **timestamp** : horodatage de la création de `coords`. *(DOMTimeStamp)* ## Coordonnées diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/doc/fr/index.md b/StoneIsland/plugins/cordova-plugin-geolocation/doc/fr/index.md index bea18ddc..4d486375 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-geolocation/doc/fr/index.md +++ b/StoneIsland/plugins/cordova-plugin-geolocation/doc/fr/index.md @@ -164,7 +164,7 @@ Contient `Position` coordonnées et timestamp, créé par l'API de géolocalisat * **coords** : un ensemble de coordonnées géographiques. *(Coordinates)* -* **timestamp** : horodatage de la création de `coords`. *(Date)* +* **timestamp** : horodatage de la création de `coords`. *(DOMTimeStamp)* ## Coordonnées diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/doc/it/README.md b/StoneIsland/plugins/cordova-plugin-geolocation/doc/it/README.md index 8eb44be9..ffa472b3 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-geolocation/doc/it/README.md +++ b/StoneIsland/plugins/cordova-plugin-geolocation/doc/it/README.md @@ -218,7 +218,7 @@ Contiene le coordinate della `Position` e timestamp, creato da geolocation API. * **CoOrds**: un insieme di coordinate geografiche. *(Coordinate)* - * **timestamp**: timestamp di creazione per `coords` . *(Data)* + * **timestamp**: timestamp di creazione per `coords` . *(DOMTimeStamp)* ## Coordinates diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/doc/it/index.md b/StoneIsland/plugins/cordova-plugin-geolocation/doc/it/index.md index 41412a07..7ba7c5c6 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-geolocation/doc/it/index.md +++ b/StoneIsland/plugins/cordova-plugin-geolocation/doc/it/index.md @@ -205,7 +205,7 @@ Contiene le coordinate della `Position` e timestamp, creato da geolocation API. * **CoOrds**: un insieme di coordinate geografiche. *(Coordinate)* -* **timestamp**: timestamp di creazione per `coords` . *(Data)* +* **timestamp**: timestamp di creazione per `coords` . *(DOMTimeStamp)* ## Coordinates diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/doc/ja/README.md b/StoneIsland/plugins/cordova-plugin-geolocation/doc/ja/README.md index a519d2c2..59c5ed6c 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-geolocation/doc/ja/README.md +++ b/StoneIsland/plugins/cordova-plugin-geolocation/doc/ja/README.md @@ -218,7 +218,7 @@ * **coords**: 地ç†çš„座標ã®ã‚»ãƒƒãƒˆã€‚*(座標)* - * **timestamp**: 作æˆã®ã‚¿ã‚¤ãƒ スタンプを `coords` 。*(日)* + * **timestamp**: 作æˆã®ã‚¿ã‚¤ãƒ スタンプを `coords` 。*(DOMTimeStamp)* ## Coordinates diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/doc/ja/index.md b/StoneIsland/plugins/cordova-plugin-geolocation/doc/ja/index.md index 3a8b73a5..3a8b73a5 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-geolocation/doc/ja/index.md +++ b/StoneIsland/plugins/cordova-plugin-geolocation/doc/ja/index.md diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/doc/ko/README.md b/StoneIsland/plugins/cordova-plugin-geolocation/doc/ko/README.md index 1c032293..dab50057 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-geolocation/doc/ko/README.md +++ b/StoneIsland/plugins/cordova-plugin-geolocation/doc/ko/README.md @@ -218,7 +218,7 @@ * **coords**: 지리ì 좌표 ì§‘í•©. *(좌표)* - * **timestamp**: ìƒì„± 타임 ìŠ¤íƒ¬í”„ì— ëŒ€ 한 `coords` . *(ë‚ ì§œ)* + * **timestamp**: ìƒì„± 타임 ìŠ¤íƒ¬í”„ì— ëŒ€ 한 `coords` . *(DOMTimeStamp)* ## Coordinates diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/doc/ko/index.md b/StoneIsland/plugins/cordova-plugin-geolocation/doc/ko/index.md index 2a3e7349..19f47c72 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-geolocation/doc/ko/index.md +++ b/StoneIsland/plugins/cordova-plugin-geolocation/doc/ko/index.md @@ -205,7 +205,7 @@ * **coords**: 지리ì 좌표 ì§‘í•©. *(좌표)* -* **timestamp**: ìƒì„± 타임 ìŠ¤íƒ¬í”„ì— ëŒ€ 한 `coords` . *(ë‚ ì§œ)* +* **timestamp**: ìƒì„± 타임 ìŠ¤íƒ¬í”„ì— ëŒ€ 한 `coords` . *(DOMTimeStamp)* ## Coordinates diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/doc/pl/README.md b/StoneIsland/plugins/cordova-plugin-geolocation/doc/pl/README.md index 8d6717fd..0ef35c4e 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-geolocation/doc/pl/README.md +++ b/StoneIsland/plugins/cordova-plugin-geolocation/doc/pl/README.md @@ -218,7 +218,7 @@ Zawiera współrzÄ™dne `Position` i sygnatury czasowej, stworzony przez geolocat * **coords**: zestaw współrzÄ™dnych geograficznych. *(WspółrzÄ™dne)* - * **timestamp**: Sygnatura czasowa utworzenia dla `coords` . *(Data)* + * **timestamp**: Sygnatura czasowa utworzenia dla `coords` . *(DOMTimeStamp)* ## Coordinates diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/doc/pl/index.md b/StoneIsland/plugins/cordova-plugin-geolocation/doc/pl/index.md index 6d08320e..6d08320e 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-geolocation/doc/pl/index.md +++ b/StoneIsland/plugins/cordova-plugin-geolocation/doc/pl/index.md diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/doc/ru/index.md b/StoneIsland/plugins/cordova-plugin-geolocation/doc/ru/index.md index 3d9c766e..3d9c766e 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-geolocation/doc/ru/index.md +++ b/StoneIsland/plugins/cordova-plugin-geolocation/doc/ru/index.md diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/doc/zh/README.md b/StoneIsland/plugins/cordova-plugin-geolocation/doc/zh/README.md index 1ad9931e..b2afea51 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-geolocation/doc/zh/README.md +++ b/StoneIsland/plugins/cordova-plugin-geolocation/doc/zh/README.md @@ -218,7 +218,7 @@ Android 2.x 模擬器ä¸é™¤éž `enableHighAccuracy` é¸é …è¨ç½®ç‚º `true`ï¼Œå¦ * **coords**: 一組的地ç†åº§æ¨™ã€‚*(座標)* - * **timestamp**: 創建時間戳記為 `coords` 。*(日期)* + * **timestamp**: 創建時間戳記為 `coords` 。*(DOMTimeStamp)* ## Coordinates diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/doc/zh/index.md b/StoneIsland/plugins/cordova-plugin-geolocation/doc/zh/index.md index d6d831e7..c78a9f79 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-geolocation/doc/zh/index.md +++ b/StoneIsland/plugins/cordova-plugin-geolocation/doc/zh/index.md @@ -205,7 +205,7 @@ Android 2.x 模擬器ä¸é™¤éž `enableHighAccuracy` é¸é …è¨ç½®ç‚º `true`ï¼Œå¦ * **coords**: 一組的地ç†åº§æ¨™ã€‚*(座標)* -* **timestamp**: 創建時間戳記為 `coords` 。*(日期)* +* **timestamp**: 創建時間戳記為 `coords` 。*(DOMTimeStamp)* ## Coordinates diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/package.json b/StoneIsland/plugins/cordova-plugin-geolocation/package.json index dee3543b..a043d278 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-geolocation/package.json +++ b/StoneIsland/plugins/cordova-plugin-geolocation/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-geolocation", - "version": "1.0.1", + "version": "2.4.0", "description": "Cordova Geolocation Plugin", "cordova": { "id": "cordova-plugin-geolocation", @@ -36,6 +36,20 @@ "cordova-windows", "cordova-firefoxos" ], + "scripts": { + "test": "npm run jshint", + "jshint": "node node_modules/jshint/bin/jshint www && node node_modules/jshint/bin/jshint src && node node_modules/jshint/bin/jshint tests" + }, "author": "Apache Software Foundation", - "license": "Apache 2.0" + "license": "Apache-2.0", + "engines": { + "cordovaDependencies": { + "3.0.0": { + "cordova": ">100" + } + } + }, + "devDependencies": { + "jshint": "^2.6.0" + } } diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/plugin.xml b/StoneIsland/plugins/cordova-plugin-geolocation/plugin.xml index 4c0a41d1..48abcafc 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-geolocation/plugin.xml +++ b/StoneIsland/plugins/cordova-plugin-geolocation/plugin.xml @@ -22,7 +22,7 @@ xmlns:rim="http://www.blackberry.com/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-geolocation" - version="1.0.1"> + version="2.4.0"> <name>Geolocation</name> <description>Cordova Geolocation Plugin</description> @@ -31,14 +31,34 @@ xmlns:android="http://schemas.android.com/apk/res/android" <repo>https://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation.git</repo> <issue>https://issues.apache.org/jira/browse/CB/component/12320638</issue> + <dependency id="cordova-plugin-compat" version="^1.0.0" /> + <!-- android --> <platform name="android"> <config-file target="AndroidManifest.xml" parent="/*"> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> + <uses-feature android:name="android.hardware.location.gps" /> + </config-file> + + <config-file target="res/xml/config.xml" parent="/*"> + <feature name="Geolocation"> + <param name="android-package" value="org.apache.cordova.geolocation.Geolocation" /> + </feature> </config-file> + <source-file src="src/android/Geolocation.java" target-dir="src/org/apache/cordova/geolocation/" /> + + <js-module src="www/android/geolocation.js" name="geolocation"> + <clobbers target="navigator.geolocation" /> + </js-module> + + <!-- We don't expose PositionError via clobber on Android as we use it internally only --> + <js-module src="www/PositionError.js" name="PositionError"> + <runs /> + </js-module> + </platform> <!-- amazon-fireos --> @@ -48,9 +68,9 @@ xmlns:android="http://schemas.android.com/apk/res/android" <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> </config-file> - + </platform> - + <!-- ios --> <platform name="ios"> @@ -71,18 +91,18 @@ xmlns:android="http://schemas.android.com/apk/res/android" </js-module> <config-file target="config.xml" parent="/*"> - <feature name="Geolocation"> - <param name="ios-package" value="CDVLocation"/> - </feature> + <feature name="Geolocation"> + <param name="ios-package" value="CDVLocation"/> + </feature> </config-file> <header-file src="src/ios/CDVLocation.h" /> <source-file src="src/ios/CDVLocation.m" /> <framework src="CoreLocation.framework" /> - + <config-file target="*-Info.plist" parent="NSLocationWhenInUseUsageDescription"> <string></string> </config-file> - + </platform> <!-- blackberry10 --> @@ -218,7 +238,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" <clobbers target="navigator.geolocation" /> </js-module> </platform> - + <!-- firefoxos --> <platform name="firefoxos"> <config-file target="config.xml" parent="/*"> diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/src/android/Geolocation.java b/StoneIsland/plugins/cordova-plugin-geolocation/src/android/Geolocation.java new file mode 100644 index 00000000..6452170a --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-geolocation/src/android/Geolocation.java @@ -0,0 +1,107 @@ +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + */ + + +package org.apache.cordova.geolocation; + +import android.content.pm.PackageManager; +import android.Manifest; +import android.os.Build; + +import org.apache.cordova.CallbackContext; +import org.apache.cordova.CordovaArgs; +import org.apache.cordova.CordovaPlugin; +import org.apache.cordova.PermissionHelper; +import org.apache.cordova.PluginResult; +import org.apache.cordova.LOG; +import org.json.JSONArray; +import org.json.JSONException; + +import javax.security.auth.callback.Callback; + +public class Geolocation extends CordovaPlugin { + + String TAG = "GeolocationPlugin"; + CallbackContext context; + + String [] permissions = { Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION }; + + + public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { + LOG.d(TAG, "We are entering execute"); + context = callbackContext; + if(action.equals("getPermission")) + { + if(hasPermisssion()) + { + PluginResult r = new PluginResult(PluginResult.Status.OK); + context.sendPluginResult(r); + return true; + } + else { + PermissionHelper.requestPermissions(this, 0, permissions); + } + return true; + } + return false; + } + + + public void onRequestPermissionResult(int requestCode, String[] permissions, + int[] grantResults) throws JSONException + { + PluginResult result; + //This is important if we're using Cordova without using Cordova, but we have the geolocation plugin installed + if(context != null) { + for (int r : grantResults) { + if (r == PackageManager.PERMISSION_DENIED) { + LOG.d(TAG, "Permission Denied!"); + result = new PluginResult(PluginResult.Status.ILLEGAL_ACCESS_EXCEPTION); + context.sendPluginResult(result); + return; + } + + } + result = new PluginResult(PluginResult.Status.OK); + context.sendPluginResult(result); + } + } + + public boolean hasPermisssion() { + for(String p : permissions) + { + if(!PermissionHelper.hasPermission(this, p)) + { + return false; + } + } + return true; + } + + /* + * We override this so that we can access the permissions variable, which no longer exists in + * the parent class, since we can't initialize it reliably in the constructor! + */ + + public void requestPermissions(int requestCode) + { + PermissionHelper.requestPermissions(this, requestCode, permissions); + } + + + +} diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/src/firefoxos/GeolocationProxy.js b/StoneIsland/plugins/cordova-plugin-geolocation/src/firefoxos/GeolocationProxy.js index e4b40529..e4b40529 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-geolocation/src/firefoxos/GeolocationProxy.js +++ b/StoneIsland/plugins/cordova-plugin-geolocation/src/firefoxos/GeolocationProxy.js diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/src/ios/CDVLocation.h b/StoneIsland/plugins/cordova-plugin-geolocation/src/ios/CDVLocation.h index cce2738f..cce2738f 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-geolocation/src/ios/CDVLocation.h +++ b/StoneIsland/plugins/cordova-plugin-geolocation/src/ios/CDVLocation.h diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/src/ios/CDVLocation.m b/StoneIsland/plugins/cordova-plugin-geolocation/src/ios/CDVLocation.m index 8b543c8e..e4b34a11 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-geolocation/src/ios/CDVLocation.m +++ b/StoneIsland/plugins/cordova-plugin-geolocation/src/ios/CDVLocation.m @@ -122,17 +122,17 @@ NSUInteger code = [CLLocationManager authorizationStatus]; if (code == kCLAuthorizationStatusNotDetermined && ([self.locationManager respondsToSelector:@selector(requestAlwaysAuthorization)] || [self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)])) { //iOS8+ __highAccuracyEnabled = enableHighAccuracy; - if([[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationAlwaysUsageDescription"]){ - [self.locationManager requestAlwaysAuthorization]; - } else if([[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationWhenInUseUsageDescription"]) { - [self.locationManager requestWhenInUseAuthorization]; + if([[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationWhenInUseUsageDescription"]){ + [self.locationManager requestWhenInUseAuthorization]; + } else if([[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationAlwaysUsageDescription"]) { + [self.locationManager requestAlwaysAuthorization]; } else { NSLog(@"[Warning] No NSLocationAlwaysUsageDescription or NSLocationWhenInUseUsageDescription key is defined in the Info.plist file."); } return; } #endif - + // Tell the location manager to start notifying us of location updates. We // first stop, and then start the updating to ensure we get at least one // update, even if our location did not change. @@ -148,9 +148,8 @@ self.locationManager.desiredAccuracy = kCLLocationAccuracyBest; } else { __highAccuracyEnabled = NO; - // TODO: Set distance filter to 10 meters? and desired accuracy to nearest ten meters? arbitrary. self.locationManager.distanceFilter = 10; - self.locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters; + self.locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers; } } @@ -193,35 +192,37 @@ - (void)getLocation:(CDVInvokedUrlCommand*)command { - NSString* callbackId = command.callbackId; - BOOL enableHighAccuracy = [[command argumentAtIndex:0] boolValue]; + [self.commandDelegate runInBackground:^{ + NSString* callbackId = command.callbackId; + BOOL enableHighAccuracy = [[command argumentAtIndex:0] boolValue]; - if ([self isLocationServicesEnabled] == NO) { - NSMutableDictionary* posError = [NSMutableDictionary dictionaryWithCapacity:2]; - [posError setObject:[NSNumber numberWithInt:PERMISSIONDENIED] forKey:@"code"]; - [posError setObject:@"Location services are disabled." forKey:@"message"]; - CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:posError]; - [self.commandDelegate sendPluginResult:result callbackId:callbackId]; - } else { - if (!self.locationData) { - self.locationData = [[CDVLocationData alloc] init]; - } - CDVLocationData* lData = self.locationData; - if (!lData.locationCallbacks) { - lData.locationCallbacks = [NSMutableArray arrayWithCapacity:1]; - } + if ([self isLocationServicesEnabled] == NO) { + NSMutableDictionary* posError = [NSMutableDictionary dictionaryWithCapacity:2]; + [posError setObject:[NSNumber numberWithInt:PERMISSIONDENIED] forKey:@"code"]; + [posError setObject:@"Location services are disabled." forKey:@"message"]; + CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:posError]; + [self.commandDelegate sendPluginResult:result callbackId:callbackId]; + } else { + if (!self.locationData) { + self.locationData = [[CDVLocationData alloc] init]; + } + CDVLocationData* lData = self.locationData; + if (!lData.locationCallbacks) { + lData.locationCallbacks = [NSMutableArray arrayWithCapacity:1]; + } - if (!__locationStarted || (__highAccuracyEnabled != enableHighAccuracy)) { - // add the callbackId into the array so we can call back when get data - if (callbackId != nil) { - [lData.locationCallbacks addObject:callbackId]; + if (!__locationStarted || (__highAccuracyEnabled != enableHighAccuracy)) { + // add the callbackId into the array so we can call back when get data + if (callbackId != nil) { + [lData.locationCallbacks addObject:callbackId]; + } + // Tell the location manager to start notifying us of heading updates + [self startLocation:enableHighAccuracy]; + } else { + [self returnLocationInfo:callbackId andKeepCallback:NO]; } - // Tell the location manager to start notifying us of heading updates - [self startLocation:enableHighAccuracy]; - } else { - [self returnLocationInfo:callbackId andKeepCallback:NO]; } - } + }]; } - (void)addWatch:(CDVInvokedUrlCommand*)command diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/src/ubuntu/geolocation.cpp b/StoneIsland/plugins/cordova-plugin-geolocation/src/ubuntu/geolocation.cpp index c820cfef..3d40ab4c 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-geolocation/src/ubuntu/geolocation.cpp +++ b/StoneIsland/plugins/cordova-plugin-geolocation/src/ubuntu/geolocation.cpp @@ -1,6 +1,6 @@ /* * - * Copyright 2013 Canonical Ltd. + * Copyright 2013-2016 Canonical Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,11 +21,19 @@ #include "geolocation.h" -Geolocation::Geolocation(Cordova *cordova): CPlugin(cordova), - _geoPositionInfoSource(QGeoPositionInfoSource::createDefaultSource(this)) { +Geolocation::Geolocation(Cordova *cordova) + : CPlugin(cordova), + _geoPositionInfoSource(QGeoPositionInfoSource::createDefaultSource(this)) { if (_geoPositionInfoSource.data() != 0) { - QObject::connect(_geoPositionInfoSource.data(), SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo))); - QObject::connect(_geoPositionInfoSource.data(), SIGNAL(updateTimeout()), this, SLOT(updateTimeout())); + QObject::connect(_geoPositionInfoSource.data(), + SIGNAL(positionUpdated(QGeoPositionInfo)), + this, + SLOT(positionUpdated(QGeoPositionInfo))); + + QObject::connect(_geoPositionInfoSource.data(), + SIGNAL(updateTimeout()), + this, + SLOT(updateTimeout())); } } @@ -81,16 +89,22 @@ void Geolocation::positionUpdated(const QGeoPositionInfo &update) { p.insert("latitude", coordinate.latitude()); p.insert("longitude", coordinate.longitude()); - p.insert("altitude", coordinate.altitude()); - if (update.hasAttribute(QGeoPositionInfo::VerticalAccuracy)) - p.insert("accuracy", update.attribute(QGeoPositionInfo::VerticalAccuracy)); + if (coordinate.type() == QGeoCoordinate::Coordinate3D) + p.insert("altitude", coordinate.altitude()); + + if (update.hasAttribute(QGeoPositionInfo::HorizontalAccuracy)) + p.insert("accuracy", update.attribute(QGeoPositionInfo::HorizontalAccuracy)); + if (update.hasAttribute(QGeoPositionInfo::Direction)) p.insert("heading", update.attribute(QGeoPositionInfo::Direction)); + if (update.hasAttribute(QGeoPositionInfo::GroundSpeed)) p.insert("velocity", update.attribute(QGeoPositionInfo::GroundSpeed)); - if (update.hasAttribute(QGeoPositionInfo::HorizontalAccuracy)) - p.insert("altitudeAccuracy", update.attribute(QGeoPositionInfo::HorizontalAccuracy)); + + if (update.hasAttribute(QGeoPositionInfo::VerticalAccuracy)) + p.insert("altitudeAccuracy", update.attribute(QGeoPositionInfo::VerticalAccuracy)); + p.insert("timestamp", update.timestamp().toMSecsSinceEpoch()); for (const QString &id: _id2sc.keys()) { diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/src/ubuntu/geolocation.h b/StoneIsland/plugins/cordova-plugin-geolocation/src/ubuntu/geolocation.h index 7345bec9..7345bec9 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-geolocation/src/ubuntu/geolocation.h +++ b/StoneIsland/plugins/cordova-plugin-geolocation/src/ubuntu/geolocation.h diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/src/windows/GeolocationProxy.js b/StoneIsland/plugins/cordova-plugin-geolocation/src/windows/GeolocationProxy.js index 9cab6a4d..03ed4950 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-geolocation/src/windows/GeolocationProxy.js +++ b/StoneIsland/plugins/cordova-plugin-geolocation/src/windows/GeolocationProxy.js @@ -14,27 +14,48 @@ * limitations under the License. */ -var PositionError = require('./PositionError'), - ids = {}, - loc; +/* global Windows, WinJS */ -function ensureLocator() { - if (loc == null) - loc = new Windows.Devices.Geolocation.Geolocator(); +var PositionError = require('./PositionError'); +var callbacks = {}; +var locs = {}; - return loc; +// constants +var FALLBACK_EPSILON = 0.001; + +function ensureAndCreateLocator() { + var deferral; + + var loc = new Windows.Devices.Geolocation.Geolocator(); + + if (typeof Windows.Devices.Geolocation.Geolocator.requestAccessAsync === 'function') { + deferral = Windows.Devices.Geolocation.Geolocator.requestAccessAsync().then(function (result) { + if (result === Windows.Devices.Geolocation.GeolocationAccessStatus.allowed) { + return loc; + } + + return WinJS.Promise.wrapError({ + code: PositionError.PERMISSION_DENIED, + message: 'Geolocation access has not been allowed by user.' + }); + }); + } else { + deferral = WinJS.Promise.wrap(loc); + } + + return deferral; } -function createErrorCode() { +function createErrorCode(loc) { switch (loc.locationStatus) { case Windows.Devices.Geolocation.PositionStatus.initializing: // This status indicates that a location device is still initializing case Windows.Devices.Geolocation.PositionStatus.noData: - // No location data is currently available + // No location data is currently available case Windows.Devices.Geolocation.PositionStatus.notInitialized: // This status indicates that the app has not yet requested - // location data by calling GetGeolocationAsync() or - // registering an event handler for the positionChanged event. + // location data by calling GetGeolocationAsync() or + // registering an event handler for the positionChanged event. case Windows.Devices.Geolocation.PositionStatus.notAvailable: // Location is not available on this version of Windows return PositionError.POSITION_UNAVAILABLE; @@ -55,8 +76,8 @@ function createResult(pos) { velocity: pos.coordinate.speed, altitudeAccuracy: pos.coordinate.altitudeAccuracy, timestamp: pos.coordinate.timestamp - } - + }; + if (pos.coordinate.point) { res.latitude = pos.coordinate.point.position.latitude; res.longitude = pos.coordinate.point.position.longitude; @@ -66,55 +87,54 @@ function createResult(pos) { res.longitude = pos.coordinate.longitude; res.altitude = pos.coordinate.altitude; } - + return res; } module.exports = { getLocation: function (success, fail, args, env) { - ensureLocator(); - if (loc != null) - { - var highAccuracy = args[0], - maxAge = args[1]; + ensureAndCreateLocator().done(function (loc) { + if (loc) { + var highAccuracy = args[0], + maxAge = args[1]; - loc.desiredAccuracy = highAccuracy ? - Windows.Devices.Geolocation.PositionAccuracy.high : - Windows.Devices.Geolocation.PositionAccuracy.default; + loc.desiredAccuracy = highAccuracy ? + Windows.Devices.Geolocation.PositionAccuracy.high : + Windows.Devices.Geolocation.PositionAccuracy.default; - loc.reportInterval = maxAge ? maxAge : 0; + loc.reportInterval = maxAge ? maxAge : 0; - loc.getGeopositionAsync().then( - function (pos) { - success(createResult(pos)); - }, - function (err) { - fail({ - code: createErrorCode(), - message: err.message - }); - } - ); - } - else - { - fail({ - code: PositionError.POSITION_UNAVAILABLE, - message: "You do not have the required location services present on your system." - }); - } + loc.getGeopositionAsync().then( + function (pos) { + success(createResult(pos)); + }, + function (err) { + fail({ + code: createErrorCode(loc), + message: err.message + }); + } + ); + } + else { + fail({ + code: PositionError.POSITION_UNAVAILABLE, + message: "You do not have the required location services present on your system." + }); + } + }, fail); }, addWatch: function (success, fail, args, env) { - ensureLocator(); - var clientId = args[0], - highAccuracy = args[1], + ensureAndCreateLocator().done(function (loc) { + var clientId = args[0]; + var highAccuracy = args[1]; - onPositionChanged = function (e) { - success(createResult(e.position), {keepCallback: true}); - }, + var onPositionChanged = function (e) { + success(createResult(e.position), { keepCallback: true }); + }; - onStatusChanged = function (e) { + var onStatusChanged = function (e) { switch (e.status) { case Windows.Devices.Geolocation.PositionStatus.noData: case Windows.Devices.Geolocation.PositionStatus.notAvailable: @@ -131,44 +151,52 @@ module.exports = { }); break; - case Windows.Devices.Geolocation.PositionStatus.initializing: - case Windows.Devices.Geolocation.PositionStatus.ready: + // case Windows.Devices.Geolocation.PositionStatus.initializing: + // case Windows.Devices.Geolocation.PositionStatus.ready: default: break; } }; - loc.desiredAccuracy = highAccuracy ? - Windows.Devices.Geolocation.PositionAccuracy.high : - Windows.Devices.Geolocation.PositionAccuracy.default; + loc.desiredAccuracy = highAccuracy ? + Windows.Devices.Geolocation.PositionAccuracy.high : + Windows.Devices.Geolocation.PositionAccuracy.default; - if (cordova.platformId == 'windows' && WinJS.Utilities.isPhone) { - // on Windows Phone 8.1 'positionchanged' event fails with error below if movementThreshold is not set - // JavaScript runtime error: Operation aborted - // You must set the MovementThreshold property or the ReportInterval property before adding event handlers. - // WinRT information: You must set the MovementThreshold property or the ReportInterval property before adding event handlers - loc.movementThreshold = loc.movementThreshold || 1; // 1 meter - } + if (cordova.platformId == 'windows') { + // 'positionchanged' event fails with error below if movementThreshold is not set + // JavaScript runtime error: Operation aborted + // You must set the MovementThreshold property or the ReportInterval property before adding event handlers. + // WinRT information: You must set the MovementThreshold property or the ReportInterval property before adding event handlers + if (Number.EPSILON) { + loc.movementThreshold = Number.EPSILON; + } else { + loc.movementThreshold = FALLBACK_EPSILON; + } + } - loc.addEventListener("positionchanged", onPositionChanged); - loc.addEventListener("statuschanged", onStatusChanged); + loc.addEventListener("positionchanged", onPositionChanged); + loc.addEventListener("statuschanged", onStatusChanged); - ids[clientId] = { pos: onPositionChanged, status: onStatusChanged }; + callbacks[clientId] = { pos: onPositionChanged, status: onStatusChanged }; + locs[clientId] = loc; + }, fail); }, clearWatch: function (success, fail, args, env) { - var clientId = args[0], - callbacks = ids[clientId]; + var clientId = args[0]; + var callback = callbacks[clientId]; + var loc = locs[clientId]; - if (callbacks) { - loc.removeEventListener("positionchanged", callbacks.pos); - loc.removeEventListener("statuschanged", callbacks.status); + if (callback && loc) { + loc.removeEventListener("positionchanged", callback.pos); + loc.removeEventListener("statuschanged", callback.status); - delete ids[clientId]; + delete callbacks[clientId]; + delete locs[clientId]; } - success && success(); + success(); } }; -require("cordova/exec/proxy").add("Geolocation", module.exports);
\ No newline at end of file +require("cordova/exec/proxy").add("Geolocation", module.exports); diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/src/wp/GeoLocation.cs b/StoneIsland/plugins/cordova-plugin-geolocation/src/wp/GeoLocation.cs index 42af72de..42af72de 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-geolocation/src/wp/GeoLocation.cs +++ b/StoneIsland/plugins/cordova-plugin-geolocation/src/wp/GeoLocation.cs diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/tests/plugin.xml b/StoneIsland/plugins/cordova-plugin-geolocation/tests/plugin.xml index edeb62e1..cf0f2f6d 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-geolocation/tests/plugin.xml +++ b/StoneIsland/plugins/cordova-plugin-geolocation/tests/plugin.xml @@ -22,10 +22,11 @@ xmlns:rim="http://www.blackberry.com/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-geolocation-tests" - version="1.0.1"> + version="2.4.0"> <name>Cordova Geolocation Plugin Tests</name> <license>Apache 2.0</license> + <dependency id="cordova-plugin-device" url="https://github.com/apache/cordova-plugin-device" /> <js-module src="tests.js" name="tests"> </js-module> </plugin> diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/tests/tests.js b/StoneIsland/plugins/cordova-plugin-geolocation/tests/tests.js index e07caf88..50c5bfb2 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-geolocation/tests/tests.js +++ b/StoneIsland/plugins/cordova-plugin-geolocation/tests/tests.js @@ -18,43 +18,59 @@ * under the License. * */ + +/* jshint jasmine: true */ +/* global WinJS, device */ + exports.defineAutoTests = function () { var fail = function (done, context, message) { - // prevents done() to be called several times - if (context) { - if (context.done) return; - context.done = true; - } + // prevents done() to be called several times + if (context) { + if (context.done) return; + context.done = true; + } - if (message) { - expect(false).toBe(true, message); - } else { - expect(false).toBe(true); - } + if (message) { + expect(false).toBe(true, message); + } else { + expect(false).toBe(true); + } - // watchPosition could call its callback sync (before returning the value) - // so we invoke done async to make sure we know watcher id to .clear in afterEach - setTimeout(function () { - done(); - }); - }, - succeed = function (done, context) { - // prevents done() to be called several times - if (context) { - if (context.done) return; - context.done = true; - } + // watchPosition could call its callback sync (before returning the value) + // so we invoke done async to make sure we know watcher id to .clear in afterEach + setTimeout(function () { + done(); + }); + }; + + var succeed = function (done, context) { + // prevents done() to be called several times + if (context) { + if (context.done) return; + context.done = true; + } - expect(true).toBe(true); + expect(true).toBe(true); + + // watchPosition could call its callback sync (before returning the value) + // so we invoke done async to make sure we know watcher id to .clear in afterEach + setTimeout(function () { + done(); + }); + }; + + // On Windows, some tests prompt user for permission to use geolocation and interrupt autotests run + var isWindowsStore = (cordova.platformId == "windows8") || (cordova.platformId == "windows" && !WinJS.Utilities.isPhone); + var majorDeviceVersion = null; + var versionRegex = /(\d)\..+/.exec(device.version); + if (versionRegex !== null) { + majorDeviceVersion = Number(versionRegex[1]); + } + // Starting from Android 6.0 there are confirmation dialog which prevents us from running auto tests in silent mode (user interaction needed) + // Also, Android emulator doesn't provide geo fix without manual interactions or mocks + var skipAndroid = cordova.platformId == "android" && (device.isVirtual || majorDeviceVersion >= 6); + var isIOSSim = false; // if iOS simulator does not have a location set, it will fail. - // watchPosition could call its callback sync (before returning the value) - // so we invoke done async to make sure we know watcher id to .clear in afterEach - setTimeout(function () { - done(); - }); - }, - isWindowsStore = (cordova.platformId == "windows8") || (cordova.platformId == "windows" && !WinJS.Utilities.isPhone), - isAndroid = cordova.platformId == "android"; describe('Geolocation (navigator.geolocation)', function () { @@ -84,10 +100,7 @@ exports.defineAutoTests = function () { describe('error callback', function () { it("geolocation.spec.5 should be called if we set timeout to 0 and maximumAge to a very small number", function (done) { - // On Windows, this test prompts user for permission to use geolocation and interrupts autotests running. - // On Android geolocation Api is not available on emulator so we pended tests until we found the way to detect - // whether we run on emulator or real device from JavaScript. You can still run the tests on Android manually. - if (isWindowsStore || isAndroid) { + if (isWindowsStore || skipAndroid) { pending(); } @@ -100,15 +113,32 @@ exports.defineAutoTests = function () { }); }); + it("geolocation.spec.9 on failure should return PositionError object with error code constants", function (done) { + if (isWindowsStore || skipAndroid) { + pending(); + } + + navigator.geolocation.getCurrentPosition( + fail.bind(this, done), + function(gpsError) { + // W3C specs: http://dev.w3.org/geo/api/spec-source.html#position_error_interface + expect(gpsError.PERMISSION_DENIED).toBe(1); + expect(gpsError.POSITION_UNAVAILABLE).toBe(2); + expect(gpsError.TIMEOUT).toBe(3); + done(); + }, + { + maximumAge: 0, + timeout: 0 + }); + }); + }); describe('success callback', function () { it("geolocation.spec.6 should be called with a Position object", function (done) { - // On Windows, this test prompts user for permission to use geolocation and interrupts autotests running. - // On Android geolocation Api is not available on emulator so we pended tests until we found the way to detect - // whether we run on emulator or real device from JavaScript. You can still run the tests on Android manually. - if (isWindowsStore || isAndroid) { + if (isWindowsStore || skipAndroid) { pending(); } @@ -116,8 +146,17 @@ exports.defineAutoTests = function () { expect(p.coords).toBeDefined(); expect(p.timestamp).toBeDefined(); done(); + }, function(err){ + if(err.message && err.message.indexOf('kCLErrorDomain') > -1){ + console.log("Error: Location not set in simulator, tests will fail."); + expect(true).toBe(true); + isIOSSim = true; + done(); + } + else { + fail(done); + } }, - fail.bind(null, done), { maximumAge: (5 * 60 * 1000) // 5 minutes maximum age of cached position }); @@ -144,10 +183,7 @@ exports.defineAutoTests = function () { }); it("geolocation.spec.7 should be called if we set timeout to 0 and maximumAge to a very small number", function (done) { - // On Windows, this test prompts user for permission to use geolocation and interrupts autotests running. - // On Android geolocation Api is not available on emulator so we pended tests until we found the way to detect - // whether we run on emulator or real device from JavaScript. You can still run the tests on Android manually. - if (isWindowsStore || isAndroid) { + if (isWindowsStore || skipAndroid) { pending(); } @@ -161,6 +197,31 @@ exports.defineAutoTests = function () { }); }); + it("geolocation.spec.10 on failure should return PositionError object with error code constants", function (done) { + if (isWindowsStore || skipAndroid) { + pending(); + } + + var context = this; + errorWatch = navigator.geolocation.watchPosition( + fail.bind(this, done, context, 'Unexpected win'), + function(gpsError) { + if (context.done) return; + context.done = true; + + // W3C specs: http://dev.w3.org/geo/api/spec-source.html#position_error_interface + expect(gpsError.PERMISSION_DENIED).toBe(1); + expect(gpsError.POSITION_UNAVAILABLE).toBe(2); + expect(gpsError.TIMEOUT).toBe(3); + + done(); + }, + { + maximumAge: 0, + timeout: 0 + }); + }); + }); describe('success callback', function () { @@ -171,10 +232,7 @@ exports.defineAutoTests = function () { }); it("geolocation.spec.8 should be called with a Position object", function (done) { - // On Windows, this test prompts user for permission to use geolocation and interrupts autotests running. - // On Android geolocation Api is not available on emulator so we pended tests until we found the way to detect - // whether we run on emulator or real device from JavaScript. You can still run the tests on Android manually. - if (isWindowsStore || isAndroid) { + if (isWindowsStore || skipAndroid || isIOSSim) { pending(); } @@ -196,6 +254,7 @@ exports.defineAutoTests = function () { { maximumAge: (5 * 60 * 1000) // 5 minutes maximum age of cached position }); + expect(successWatch).toBeDefined(); }); }); @@ -209,23 +268,49 @@ exports.defineAutoTests = function () { /******************************************************************************/ exports.defineManualTests = function (contentEl, createActionButton) { - var newGeolocation = navigator.geolocation; - var origGeolocation = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'); - if (!origGeolocation) { - origGeolocation = newGeolocation; - newGeolocation = null; + var watchLocationId = null; + + /** + * Set location status + */ + function setLocationStatus(status) { + document.getElementById('location_status').innerHTML = status; + } + function setLocationDetails(p) { + var date = (new Date(p.timestamp)); + document.getElementById('latitude').innerHTML = p.coords.latitude; + document.getElementById('longitude').innerHTML = p.coords.longitude; + document.getElementById('altitude').innerHTML = p.coords.altitude; + document.getElementById('accuracy').innerHTML = p.coords.accuracy; + document.getElementById('heading').innerHTML = p.coords.heading; + document.getElementById('speed').innerHTML = p.coords.speed; + document.getElementById('altitude_accuracy').innerHTML = p.coords.altitudeAccuracy; + document.getElementById('timestamp').innerHTML = date.toDateString() + " " + date.toTimeString(); } - var watchLocationId = null; + /** + * Stop watching the location + */ + function stopLocation() { + var geo = navigator.geolocation; + if (!geo) { + alert('navigator.geolocation object is missing.'); + return; + } + setLocationStatus("Stopped"); + if (watchLocationId) { + geo.clearWatch(watchLocationId); + watchLocationId = null; + } + } /** * Start watching location */ - var watchLocation = function (usePlugin) { - console.log("watchLocation()"); - var geo = usePlugin ? newGeolocation : origGeolocation; + var watchLocation = function () { + var geo = navigator.geolocation; if (!geo) { - alert('geolocation object is missing. usePlugin = ' + usePlugin); + alert('navigator.geolocation object is missing.'); return; } @@ -246,30 +331,12 @@ exports.defineManualTests = function (contentEl, createActionButton) { }; /** - * Stop watching the location - */ - var stopLocation = function (usePlugin) { - console.log("stopLocation()"); - var geo = usePlugin ? newGeolocation : origGeolocation; - if (!geo) { - alert('geolocation object is missing. usePlugin = ' + usePlugin); - return; - } - setLocationStatus("Stopped"); - if (watchLocationId) { - geo.clearWatch(watchLocationId); - watchLocationId = null; - } - }; - - /** * Get current location */ - var getLocation = function (usePlugin, opts) { - console.log("getLocation()"); - var geo = usePlugin ? newGeolocation : origGeolocation; + var getLocation = function (opts) { + var geo = navigator.geolocation; if (!geo) { - alert('geolocation object is missing. usePlugin = ' + usePlugin); + alert('navigator.geolocation object is missing.'); return; } @@ -295,24 +362,6 @@ exports.defineManualTests = function (contentEl, createActionButton) { }; - /** - * Set location status - */ - var setLocationStatus = function (status) { - document.getElementById('location_status').innerHTML = status; - }; - var setLocationDetails = function (p) { - var date = (new Date(p.timestamp)); - document.getElementById('latitude').innerHTML = p.coords.latitude; - document.getElementById('longitude').innerHTML = p.coords.longitude; - document.getElementById('altitude').innerHTML = p.coords.altitude; - document.getElementById('accuracy').innerHTML = p.coords.accuracy; - document.getElementById('heading').innerHTML = p.coords.heading; - document.getElementById('speed').innerHTML = p.coords.speed; - document.getElementById('altitude_accuracy').innerHTML = p.coords.altitudeAccuracy; - document.getElementById('timestamp').innerHTML = date.toDateString() + " " + date.toTimeString(); - } - /******************************************************************************/ var location_div = '<div id="info">' + @@ -365,16 +414,6 @@ exports.defineManualTests = function (contentEl, createActionButton) { '</table>' + '</div>', actions = - '<h2>Use Built-in WebView navigator.geolocation</h2>' + - '<div id="built-in-getLocation"></div>' + - 'Expected result: Will update all applicable values in status box for current location. Status will read Retrieving Location (may not see this if location is retrieved immediately) then Done.' + - '<p/> <div id="built-in-watchLocation"></div>' + - 'Expected result: Will update all applicable values in status box for current location and update as location changes. Status will read Running.' + - '<p/> <div id="built-in-stopLocation"></div>' + - 'Expected result: Will stop watching the location so values will not be updated. Status will read Stopped.' + - '<p/> <div id="built-in-getOld"></div>' + - 'Expected result: Will update location values with a cached position that is up to 30 seconds old. Verify with time value. Status will read Done.' + - '<h2>Use Cordova Geolocation Plugin</h2>' + '<div id="cordova-getLocation"></div>' + 'Expected result: Will update all applicable values in status box for current location. Status will read Retrieving Location (may not see this if location is retrieved immediately) then Done.' + '<p/> <div id="cordova-watchLocation"></div>' + @@ -388,38 +427,22 @@ exports.defineManualTests = function (contentEl, createActionButton) { note = '<h3>Allow use of current location, if prompted</h3>'; - contentEl.innerHTML = values_info + location_div + latitude + longitude + altitude + accuracy + heading + speed - + altitude_accuracy + time + note + actions; - - createActionButton('Get Location', function () { - getLocation(false); - }, 'built-in-getLocation'); - - createActionButton('Start Watching Location', function () { - watchLocation(false); - }, 'built-in-watchLocation'); - - createActionButton('Stop Watching Location', function () { - stopLocation(false); - }, 'built-in-stopLocation'); - - createActionButton('Get Location Up to 30 Sec Old', function () { - getLocation(false, { maximumAge: 30000 }); - }, 'built-in-getOld'); + contentEl.innerHTML = values_info + location_div + latitude + longitude + altitude + accuracy + heading + speed + + altitude_accuracy + time + note + actions; createActionButton('Get Location', function () { - getLocation(true); + getLocation(); }, 'cordova-getLocation'); createActionButton('Start Watching Location', function () { - watchLocation(true); + watchLocation(); }, 'cordova-watchLocation'); createActionButton('Stop Watching Location', function () { - stopLocation(true); + stopLocation(); }, 'cordova-stopLocation'); createActionButton('Get Location Up to 30 Sec Old', function () { - getLocation(true, { maximumAge: 30000 }); + getLocation({ maximumAge: 30000 }); }, 'cordova-getOld'); }; diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/www/Coordinates.js b/StoneIsland/plugins/cordova-plugin-geolocation/www/Coordinates.js index 84fdd5b8..84fdd5b8 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-geolocation/www/Coordinates.js +++ b/StoneIsland/plugins/cordova-plugin-geolocation/www/Coordinates.js diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/www/Position.js b/StoneIsland/plugins/cordova-plugin-geolocation/www/Position.js index f0470dea..d6b2c0cc 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-geolocation/www/Position.js +++ b/StoneIsland/plugins/cordova-plugin-geolocation/www/Position.js @@ -27,7 +27,7 @@ var Position = function(coords, timestamp) { } else { this.coords = new Coordinates(); } - this.timestamp = (timestamp !== undefined) ? timestamp : new Date(); + this.timestamp = (timestamp !== undefined) ? timestamp : new Date().getTime(); }; module.exports = Position; diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/www/PositionError.js b/StoneIsland/plugins/cordova-plugin-geolocation/www/PositionError.js index 9403f11f..94562407 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-geolocation/www/PositionError.js +++ b/StoneIsland/plugins/cordova-plugin-geolocation/www/PositionError.js @@ -31,8 +31,8 @@ var PositionError = function(code, message) { this.message = message || ''; }; -PositionError.PERMISSION_DENIED = 1; -PositionError.POSITION_UNAVAILABLE = 2; -PositionError.TIMEOUT = 3; +PositionError.prototype.PERMISSION_DENIED = PositionError.PERMISSION_DENIED = 1; +PositionError.prototype.POSITION_UNAVAILABLE = PositionError.POSITION_UNAVAILABLE = 2; +PositionError.prototype.TIMEOUT = PositionError.TIMEOUT = 3; module.exports = PositionError; diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/www/android/geolocation.js b/StoneIsland/plugins/cordova-plugin-geolocation/www/android/geolocation.js new file mode 100644 index 00000000..7265bec0 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-geolocation/www/android/geolocation.js @@ -0,0 +1,71 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ + +var exec = cordova.require('cordova/exec'); +var utils = require('cordova/utils'); +var PositionError = require('./PositionError'); + +// Native watchPosition method is called async after permissions prompt. +// So we use additional map and own ids to return watch id synchronously. +var pluginToNativeWatchMap = {}; + +module.exports = { + getCurrentPosition: function(success, error, args) { + var win = function() { + var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'); + geo.getCurrentPosition(success, error, args); + }; + var fail = function() { + if (error) { + error(new PositionError (PositionError.PERMISSION_DENIED, 'Illegal Access')); + } + }; + exec(win, fail, "Geolocation", "getPermission", []); + }, + + watchPosition: function(success, error, args) { + var pluginWatchId = utils.createUUID(); + + var win = function() { + var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'); + pluginToNativeWatchMap[pluginWatchId] = geo.watchPosition(success, error, args); + }; + + var fail = function() { + if (error) { + error(new PositionError(PositionError.PERMISSION_DENIED, 'Illegal Access')); + } + }; + exec(win, fail, "Geolocation", "getPermission", []); + + return pluginWatchId; + }, + + clearWatch: function(pluginWatchId) { + var win = function() { + var nativeWatchId = pluginToNativeWatchMap[pluginWatchId]; + var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation'); + geo.clearWatch(nativeWatchId); + }; + + exec(win, null, "Geolocation", "getPermission", []); + } +}; diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/www/blackberry10/GeolocationProxy.js b/StoneIsland/plugins/cordova-plugin-geolocation/www/blackberry10/GeolocationProxy.js index 0bba2263..0bba2263 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-geolocation/www/blackberry10/GeolocationProxy.js +++ b/StoneIsland/plugins/cordova-plugin-geolocation/www/blackberry10/GeolocationProxy.js diff --git a/StoneIsland/plugins/cordova-plugin-geolocation/www/geolocation.js b/StoneIsland/plugins/cordova-plugin-geolocation/www/geolocation.js index 3814919a..f1f64456 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-geolocation/www/geolocation.js +++ b/StoneIsland/plugins/cordova-plugin-geolocation/www/geolocation.js @@ -102,7 +102,7 @@ var geolocation = { velocity:p.velocity, altitudeAccuracy:p.altitudeAccuracy }, - (p.timestamp === undefined ? new Date() : ((p.timestamp instanceof Date) ? p.timestamp : new Date(p.timestamp))) + p.timestamp ); geolocation.lastPosition = pos; successCallback(pos); @@ -118,7 +118,7 @@ var geolocation = { // Check our cached position, if its timestamp difference with current time is less than the maximumAge, then just // fire the success callback with the cached position. - if (geolocation.lastPosition && options.maximumAge && (((new Date()).getTime() - geolocation.lastPosition.timestamp.getTime()) <= options.maximumAge)) { + if (geolocation.lastPosition && options.maximumAge && (((new Date()).getTime() - geolocation.lastPosition.timestamp) <= options.maximumAge)) { successCallback(geolocation.lastPosition); // If the cached position check failed and the timeout was set to 0, error out with a TIMEOUT error object. } else if (options.timeout === 0) { @@ -184,7 +184,7 @@ var geolocation = { velocity:p.velocity, altitudeAccuracy:p.altitudeAccuracy }, - (p.timestamp === undefined ? new Date() : ((p.timestamp instanceof Date) ? p.timestamp : new Date(p.timestamp))) + p.timestamp ); geolocation.lastPosition = pos; successCallback(pos); |
