Skip to content

Commit

Permalink
Merge pull request #20 from andygup/permissions
Browse files Browse the repository at this point in the history
v1.0.0
  • Loading branch information
andygup authored Aug 17, 2016
2 parents 5e9d8f6 + 880f1b5 commit cd7ca9b
Show file tree
Hide file tree
Showing 19 changed files with 895 additions and 191 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ gen
out
# Gradle builds
/build
WhitelistPlugin.java
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# cordova-plugin-advanced-geolocation - Changelog

## Version 1.0.0 - August 17, 2016

Has breaking changes. This is a v1 implementation so any improvements and suggestions are welcome!

**Enhancements**
* Handles Android 6 permissions with native system prompts. Continues to handle previous Android versions exactly the same as before.
* Improved incompatible version protection. If using this library on an unsupported platform it should protect against incompatibility errors where functionality is not available on a specific Android version. If you come across something that fails please open an issue.
* Significantly improved error handling. Errors are now reported as JSON Objects that include an error number and message. Errors messages are now pervasively collected where possible.
* Improved sample app and fixed various bugs.

**Known Issues**
* Does not provide a rationale message explaining why the library requires location information. There is a GPSPermsDeniedDialogFragment in the project and other stubs reserved for either custom implementation or as inclusion for future functionality.


## Version 0.5.1 - July 13, 2016

No breaking changes.
Expand Down
1 change: 1 addition & 0 deletions api_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ A full set of detailed information is available via the [`android.telephony`](ht
* There are minimum device SDK requirements. API level 18 is the current minimum to take advantage of this specific functionality. The plugin will turn off this functionality if the API level is less than 18.
* Activating cellular data may result in additional network charges for the user.
* This information is not gauranteed.
* This information may still be provided by the device even if Location is turned off.
* The `TelephonyManager` API may not work correctly on all devices.
* To make use of this data you'll need access to a cell tower database. We don't provide cell tower location data, however there are databases and services available. One example provider is the [OpenCellId organization](http://wiki.opencellid.org/wiki/View_the_data).
* Take extra steps to protect the input data when using this API. Check for `null` or `Integer.MAX_VALUE`.
Expand Down
89 changes: 89 additions & 0 deletions cordova_create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/bin/bash

set -e # Exit script on any error

# "This is a shell script for manually creating a cordova repo"
# "for the purpose of making changes or updating the github repo"

read -p "Press [Enter] to create Cordova project…"

cordova create cordova-geo com.esri.cordova.geolocation AdvancedGeolocation "$1" || exit 1

read -p "Press [Enter] to continue…"

echo "cd to new project directory"
cd cordova-geo/

echo "add android platform to project"
cordova platform add android

echo "cd to android platform directory"
cd platforms/android/

echo "clone github repo to temp dir"
git clone https://github.com/andygup/cordova-plugin-advanced-geolocation.git temp

echo "moving temp dir into android dir"
mv temp/.gitignore .
mv temp/.git .

echo "creating www directory and copy contents over"
mkdir -p assets/www/plugins/cordova-plugin-advanced-geolocation/www
cp temp/www/AdvancedGeolocation.js assets/www/plugins/cordova-plugin-advanced-geolocation/www/
cp temp/sample/map.js assets/www/js/
cp temp/sample/blue-pin.png assets/www/img/
cp temp/sample/green-pin.png assets/www/img/
cp temp/sample/sample-map.html assets/www/
cp -r src/ java/

echo "deleting temp directory"
rm -rf temp

echo "reset git"
git reset --hard HEAD # git will think you deleted all the important files
git status # most likely there will be a MainActivity.java untracked

echo "DONE! Please see shell script for additional manual tasks."

<<COMMENT
# Added permissions in AndroidManifest.xml
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
# Added plugin to config.xml
<feature name="AdvancedGeolocation">
<param name="android-package" value="com.esri.cordova.geolocation.AdvancedGeolocation" />
</feature>
# Add reference to cordova_plugins.js
module.exports = [
{
"file": "plugins/cordova-plugin-advanced-geolocation/www/AdvancedGeolocation.js",
"id": "cordova-plugin-advanced-geolocation.AdvancedGeolocation",
"clobbers": [
"AdvancedGeolocation"
]
}
];
Wrap AdvancedGeolocation.js in
cordova.define("cordova-plugin-advanced-geolocation.AdvancedGeolocation", function(require, exports, module) {
});
AndroidManifest.xml
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="22" />
# In config.xml switch out index.html to sample-map.html
# Debug the app and see if everything works!
COMMENT
10 changes: 0 additions & 10 deletions cordova_create2.sh

This file was deleted.

19 changes: 15 additions & 4 deletions sample/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ var app = {

var count = 0;
var satDiv = document.getElementById("satData");
var locationDiv = document.getElementById("locationData");

// Displays GPS-derived locations
var greenGPSSymbol = new PictureMarkerSymbol({
Expand Down Expand Up @@ -88,7 +89,12 @@ var app = {
var satellites = "<br /><span style='font-weight:bold;'>Satellite Data:</span> " + date.toUTCString() + "<br /><br />";

for( var key in json){
if(json.hasOwnProperty(key) && key.toLowerCase() != "provider" && key.toLowerCase() != "timestamp"){

if(json.hasOwnProperty(key)
&& key.toLowerCase() != "provider"
&& key.toLowerCase() != "timestamp"
&& key.toLowerCase() != "error"){

satellites +=
"PRN: " + json[key].PRN +
", fix: " + json[key].usedInFix +
Expand All @@ -97,7 +103,7 @@ var app = {
}
}

satData.innerHTML = satellites;
satDiv.innerHTML = satellites;
}

// Initialize the geolocation plugin
Expand All @@ -122,6 +128,8 @@ var app = {
switch(jsonObject.provider){
case "gps":
if(jsonObject.latitude != "0.0"){
console.log("GPS location detected - lat:" +
jsonObject.latitude + ", lon: " + jsonObject.longitude);
var point = new Point(jsonObject.longitude, jsonObject.latitude);
map.centerAt(point);
addGraphic( greenGPSSymbol, point);
Expand All @@ -130,6 +138,8 @@ var app = {

case "network":
if(jsonObject.latitude != "0.0"){
console.log("Network location detected - lat:" +
jsonObject.latitude + ", lon: " + jsonObject.longitude);
var point = new Point(jsonObject.longitude, jsonObject.latitude);
map.centerAt(point);
addGraphic( blueNetworkSymbol, point);
Expand All @@ -144,7 +154,6 @@ var app = {

case "cell_info":
console.log("cell_info JSON: " + data);
satDiv.innerHTML = data;
break;

case "cell_location":
Expand All @@ -158,7 +167,9 @@ var app = {
}
},
function(error){
console.log("ERROR! " + JSON.stringify(error));
console.log("Error JSON: " + JSON.stringify(error));
var e = JSON.parse(error);
console.log("Error no.: " + e.error + ", Message: " + e.msg + ", Provider: " + e.provider);
},
/////////////////////////////////////////
//
Expand Down
9 changes: 5 additions & 4 deletions sample/sample-map.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no"/>
<title>Hello World Map</title>
<link rel="stylesheet" href="https://js.arcgis.com/3.16/esri/css/esri.css">
<link rel="stylesheet" href="https://js.arcgis.com/3.17/esri/css/esri.css">
<style>
html, body, #map {
height: 75%;
Expand All @@ -54,16 +54,17 @@
font-family: "Trebuchet MS";
}
</style>
<script src="https://js.arcgis.com/3.16/"></script>
<script src="https://js.arcgis.com/3.17/"></script>
</head>
<body>
<div id="map"></div>
<hr>
<div>
GPS&nbsp; <img src="img/blue-pin.png">
&nbsp;NETWORK&nbsp; <img src="img/green-pin.png">
GPS&nbsp; <img src="img/green-pin.png">
&nbsp;NETWORK&nbsp; <img src="img/blue-pin.png">
</div>
<hr>
<div id='locationData'></div>
<div id="satData"></div>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/map.js"></script>
Expand Down
Loading

0 comments on commit cd7ca9b

Please sign in to comment.