Skip to content

Commit

Permalink
Merge pull request #16 from andygup/compat
Browse files Browse the repository at this point in the history
v0.5.0
  • Loading branch information
andygup authored Jul 13, 2016
2 parents b8c66f3 + cc7f15c commit db16fb9
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 11 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion api_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: `<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="22" />`

**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.
Expand Down Expand Up @@ -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: `<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="22" />`
* 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.
Expand Down
10 changes: 10 additions & 0 deletions cordova_create2.sh
Original file line number Diff line number Diff line change
@@ -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/
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
23 changes: 19 additions & 4 deletions src/com/esri/cordova/geolocation/AdvancedGeolocation.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand All @@ -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);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit db16fb9

Please sign in to comment.