From ce5c09ad6a0ce46745124b3060ae0517e495d976 Mon Sep 17 00:00:00 2001 From: Andy Gup Date: Wed, 13 Jul 2016 12:44:59 -0600 Subject: [PATCH 1/3] Added project build shell script --- cordova_create2.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100755 cordova_create2.sh diff --git a/cordova_create2.sh b/cordova_create2.sh new file mode 100755 index 0000000..3c782c5 --- /dev/null +++ b/cordova_create2.sh @@ -0,0 +1,10 @@ +#!/bin/bash + + +mkdir -p assets/www/plugins/cordova-plugin-advanced-geolocation/www +cp www/AdvancedGeolocation.js assets/www/plugins/cordova-plugin-advanced-geolocation/www/ +cp sample/map.js assets/www/js/ +cp sample/blue-pin.png assets/www/img/ +cp sample/green-pin.png assets/www/img/ +cp sample/sample-map.html assets/www/ +cp -r src/ java/ \ No newline at end of file From cc04263bed2570538808a2d4f10f1770f5c832e2 Mon Sep 17 00:00:00 2001 From: Andy Gup Date: Wed, 13 Jul 2016 12:46:19 -0600 Subject: [PATCH 2/3] v0.5.0 Closes #15 --- CHANGELOG.md | 8 +++++++ README.md | 14 +++++++---- api_reference.md | 4 +++- package.json | 2 +- .../geolocation/AdvancedGeolocation.java | 23 +++++++++++++++---- .../controllers/CellLocationController.java | 5 ++++ .../controllers/GPSController.java | 3 +++ 7 files changed, 48 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee9a377..79b5cba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # cordova-plugin-advanced-geolocation - Changelog +## Version 0.5.0 - July 13, 2016 + +No breaking changes. + +**Enhancements** +* Disable cellular data configuration option if Android API Level is less than v17. This functionality is not available on those phones and could cause app to crash. +* Updates docs. Added notices that Android N will have breaking changes in terms of how GPS is implemented. + ## Version 0.4.0 - May 6, 2016 No breaking changes. diff --git a/README.md b/README.md index 118872c..2db5144 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,11 @@ This plugin is available via [npm](https://www.npmjs.com/package/cordova-plugin- ##Supported Platforms -**Android-only.** This plugin is designed for Android API 5.0.0 (Lollipop / API Level 21) and greater. Cordova supports the following android [releases](https://github.com/apache/cordova-android/releases). +**Android-only.** This plugin is designed for Android versions between Android 5.0.0 (Lollipop / API Level 21) and Android 6.x (Marshmallow / API Level 23). + +**IMPORTANT** At Android N (OS version 7) there have been many changes to how GPS is implemented that are not compatible with the current version of this library. See the [issues](https://github.com/Esri/cordova-plugin-advanced-geolocation/issues) list for the most current information. + +Cordova supports the following android [releases](https://github.com/apache/cordova-android/releases). ##Quick Start! @@ -46,6 +50,10 @@ If your requirements specifically call for less than 3 meter accuracy then consi **PRIVACY WARNING** Keep in mind the [W3C security and privacy considerations](http://dev.w3.org/geo/api/spec-source.html#security). This plugin uses native geolocation functionality only. Users will not automatically see a W3C Geolocation prompt, they will only get native Android prompts. The plugin requires the following Android User Permissions: [ACCESS_COARSE_LOCATION](http://developer.android.com/reference/android/Manifest.permission.html#ACCESS_COARSE_LOCATION), [ACCESS_FINE_LOCATION](http://developer.android.com/reference/android/Manifest.permission.html#ACCESS_FINE_LOCATION), [ACCESS_NETWORK_STATE](http://developer.android.com/reference/android/Manifest.permission.html#ACCESS_NETWORK_STATE), [ACCESS_WIFI_STATE](http://developer.android.com/reference/android/Manifest.permission.html#ACCESS_WIFI_STATE) and [INTERNET](http://developer.android.com/reference/android/Manifest.permission.html#INTERNET). +#API Reference + +Click [here](api_reference.md) to read all about it. + ##Example Usage @@ -128,10 +136,6 @@ The following geolocation data may be exposed and accessible by this API if the * Cached Network location * Cell tower information (type of information varies by device, OS version and cell service provider) -#API Reference - -Click [here](api_reference.md) to read all about it. - ## FAQ * **Which location providers does this plugin use?** The plugin can be configured to use both [GPS](http://developer.android.com/reference/android/location/LocationManager.html#GPS_PROVIDER) and [NETWORK](http://developer.android.com/reference/android/location/LocationManager.html#NETWORK_PROVIDER) location providers. NETWORK location providers require access to the internet whether it's via cellular or WiFi connection. The plugin does not use [PASSIVE](http://developer.android.com/reference/android/location/LocationManager.html#PASSIVE_PROVIDER) location providers because you have no direct control over those. diff --git a/api_reference.md b/api_reference.md index 0a8de25..11e06e9 100644 --- a/api_reference.md +++ b/api_reference.md @@ -2,6 +2,8 @@ This geolocation API is multi-threaded for maximum efficiency and reduced impact on user experience. +**Reminder** This project currently only supports API Level 21 to API Level 23. Android N (API 24) brings breaking changes in terms of how GPS is implemented. Be sure to set the `minSdkVersion` in the AndroidManifest, for example: `` + **IMPORTANT - READ THIS FIRST!** There are important differences between GPS Provider data, Network Provider data and Cellular data. It can be confusing. * GPS Provider data is focused on providing a device location using latitude and longitude information via a GPS. @@ -142,7 +144,7 @@ A full set of detailed information is available via the [`android.telephony`](ht **IMPORTANT** Please make note of the following: -* There are minimum device SDK requirements. API level 17 is the current minimum to take advantage of this specific functionality. Plus, this project requires a minimum of SDK 21 or greater. Be aware of how you set the `minSdkVersion` in the AndroidManifest, for example: `` +* There are minimum device SDK requirements. API level 17 is the current minimum to take advantage of this specific functionality. The plugin will turn of this functionality if the API level is less than 17. * Activating cellular data may result in additional network charges for the user. * This information is not gauranteed. * The `TelephonyManager` API may not work correctly on all devices. diff --git a/package.json b/package.json index 5900dda..1300c50 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-advanced-geolocation", - "version": "0.4.0", + "version": “0.5.0”, "description": "Android geolocation plugin for both GPS or NETWORK-based location providers.", "cordova": { "id": "cordova-plugin-advanced-geolocation", diff --git a/src/com/esri/cordova/geolocation/AdvancedGeolocation.java b/src/com/esri/cordova/geolocation/AdvancedGeolocation.java index f0ba74d..854d7a6 100644 --- a/src/com/esri/cordova/geolocation/AdvancedGeolocation.java +++ b/src/com/esri/cordova/geolocation/AdvancedGeolocation.java @@ -27,6 +27,7 @@ import android.location.LocationManager; import android.net.ConnectivityManager; import android.net.NetworkInfo; +import android.os.Build; import android.util.Log; import org.apache.cordova.CallbackContext; @@ -140,8 +141,14 @@ private void startLocation(){ _cordova, _callbackContext, _minDistance, _minTime, _useCache, _buffer, _bufferSize); cordova.getThreadPool().execute(_networkLocationController); - _cellLocationController = new CellLocationController(networkEnabled,_cordova,_callbackContext); - cordova.getThreadPool().execute(_cellLocationController); + // Reference: https://developer.android.com/reference/android/telephony/TelephonyManager.html#getAllCellInfo() + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP){ + Log.e(TAG, "Cell Data option is not available on Android API versions < 17"); + } + else { + _cellLocationController = new CellLocationController(networkEnabled,_cordova,_callbackContext); + cordova.getThreadPool().execute(_cellLocationController); + } } if(_providers.equalsIgnoreCase(PROVIDERS_SOME)){ _gpsController = new GPSController( @@ -164,8 +171,16 @@ private void startLocation(){ cordova.getThreadPool().execute(_networkLocationController); } if(_providers.equalsIgnoreCase(PROVIDERS_CELL)){ - _cellLocationController = new CellLocationController(networkEnabled,_cordova,_callbackContext); - cordova.getThreadPool().execute(_cellLocationController); + + // Reference: https://developer.android.com/reference/android/telephony/TelephonyManager.html#getAllCellInfo() + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP){ + Log.e(TAG, "Cell Data option is not available on Android API versions < 17"); + sendCallback(PluginResult.Status.ERROR, "Cell Data option is not available on Android API versions < 17"); + } + else { + _cellLocationController = new CellLocationController(networkEnabled,_cordova,_callbackContext); + cordova.getThreadPool().execute(_cellLocationController); + } } } diff --git a/src/com/esri/cordova/geolocation/controllers/CellLocationController.java b/src/com/esri/cordova/geolocation/controllers/CellLocationController.java index 4773f94..adca919 100644 --- a/src/com/esri/cordova/geolocation/controllers/CellLocationController.java +++ b/src/com/esri/cordova/geolocation/controllers/CellLocationController.java @@ -16,6 +16,11 @@ */ package com.esri.cordova.geolocation.controllers; +/** + * IMPORTANT: This Class is only compatible with API Level 17 or greater + * Reference: https://developer.android.com/reference/android/telephony/CellInfo.html + */ + import android.content.Context; import android.os.Build; import android.os.Looper; diff --git a/src/com/esri/cordova/geolocation/controllers/GPSController.java b/src/com/esri/cordova/geolocation/controllers/GPSController.java index 7436ee6..8a06590 100644 --- a/src/com/esri/cordova/geolocation/controllers/GPSController.java +++ b/src/com/esri/cordova/geolocation/controllers/GPSController.java @@ -180,6 +180,9 @@ private static void sendCallback(PluginResult.Status status, String message){ } private static InitStatus setGPSStatusListener(){ + + // IMPORTANT: The GpsStatus.Listener Interface is deprecated at API 24. + // Reference: https://developer.android.com/reference/android/location/package-summary.html _gpsStatusListener = new GpsStatus.Listener() { @Override From cc7f15c16e842bbd4f2bfc825405eecc18caadf6 Mon Sep 17 00:00:00 2001 From: Andy Gup Date: Wed, 13 Jul 2016 12:49:20 -0600 Subject: [PATCH 3/3] replace invalid qoutes --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1300c50..2e74d8a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-advanced-geolocation", - "version": “0.5.0”, + "version": "0.5.0", "description": "Android geolocation plugin for both GPS or NETWORK-based location providers.", "cordova": { "id": "cordova-plugin-advanced-geolocation",