cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [07/17] git commit: Added amazon-fireos platform + some of the fixes in android code.
Date Thu, 05 Dec 2013 00:58:39 GMT
Added amazon-fireos platform + some of the fixes in android code.


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/commit/9eb9efb6
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/tree/9eb9efb6
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/diff/9eb9efb6

Branch: refs/heads/master
Commit: 9eb9efb6eec18e6ea3b3c531f2916b015198ed79
Parents: a2f73ef
Author: Archana Naik <naika@lab126.com>
Authored: Fri Oct 18 14:59:29 2013 -0700
Committer: Archana Naik <naika@lab126.com>
Committed: Wed Oct 30 13:24:20 2013 -0700

----------------------------------------------------------------------
 plugin.xml                               | 37 +++++++++++++++++++++++++++
 src/android/CordovaLocationListener.java |  3 ++-
 src/android/GPSListener.java             |  4 +--
 src/android/GeoBroker.java               |  7 ++---
 test/cordova-incl.js                     |  4 ++-
 5 files changed, 48 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/9eb9efb6/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index 777a9cc..56f1e97 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -50,6 +50,43 @@ xmlns:android="http://schemas.android.com/apk/res/android"
 
     </platform>
 
+     <!-- amazon-fireos -->
+    <platform name="amazon-fireos">
+
+        <js-module src="www/Coordinates.js" name="Coordinates">
+            <clobbers target="Coordinates" />
+        </js-module>
+
+        <js-module src="www/PositionError.js" name="PositionError">
+            <clobbers target="PositionError" />
+        </js-module>
+
+        <js-module src="www/Position.js" name="Position">
+            <clobbers target="Position" />
+        </js-module>
+
+        <js-module src="www/geolocation.js" name="geolocation">
+            <clobbers target="navigator.geolocation" />
+        </js-module>
+
+        <config-file target="res/xml/config.xml" parent="/*">
+            <feature name="Geolocation">
+	            <param name="android-package" value="org.apache.cordova.geolocation.GeoBroker"/>
+	        </feature>
+        </config-file>
+
+        <config-file target="AndroidManifest.xml" parent="/*">
+            <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"
/>
+            <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+        </config-file>
+
+        <source-file src="src/android/GeoBroker.java" target-dir="src/org/apache/cordova/geolocation"
/>
+        <source-file src="src/android/GPSListener.java" target-dir="src/org/apache/cordova/geolocation"
/>
+        <source-file src="src/android/NetworkListener.java" target-dir="src/org/apache/cordova/geolocation"
/>
+        <source-file src="src/android/CordovaLocationListener.java" target-dir="src/org/apache/cordova/geolocation"
/>
+
+    </platform>
+    
     <!-- ios -->
     <platform name="ios">
 

http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/9eb9efb6/src/android/CordovaLocationListener.java
----------------------------------------------------------------------
diff --git a/src/android/CordovaLocationListener.java b/src/android/CordovaLocationListener.java
index f0f70fe..b60bf59 100755
--- a/src/android/CordovaLocationListener.java
+++ b/src/android/CordovaLocationListener.java
@@ -31,6 +31,7 @@ import android.location.Location;
 import android.location.LocationListener;
 import android.location.LocationManager;
 import android.os.Bundle;
+import android.os.Looper;
 import android.util.Log;
 
 public class CordovaLocationListener implements LocationListener {
@@ -198,7 +199,7 @@ public class CordovaLocationListener implements LocationListener {
         if (!this.running) {
             if (this.locationManager.getProvider(LocationManager.NETWORK_PROVIDER) != null)
{
                 this.running = true;
-                this.locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
60000, 10, this);
+                this.locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
60000, 10, Looper.getMainLooper());
             } else {
                 this.fail(CordovaLocationListener.POSITION_UNAVAILABLE, "Network provider
is not available.");
             }

http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/9eb9efb6/src/android/GPSListener.java
----------------------------------------------------------------------
diff --git a/src/android/GPSListener.java b/src/android/GPSListener.java
index 8c41b2e..1b156d5 100755
--- a/src/android/GPSListener.java
+++ b/src/android/GPSListener.java
@@ -19,7 +19,7 @@
 
 package org.apache.cordova.geolocation;
 
-
+import android.os.Looper;
 import android.location.LocationManager;
 
 /**
@@ -42,7 +42,7 @@ public class GPSListener extends CordovaLocationListener {
         if (!this.running) {
             if (this.locationManager.getProvider(LocationManager.GPS_PROVIDER) != null) {
                 this.running = true;
-                this.locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
60000, 0, this);
+                this.locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
60000, 0, Looper.getMainLooper());
             } else {
                 this.fail(CordovaLocationListener.POSITION_UNAVAILABLE, "GPS provider is
not available.");
             }

http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/9eb9efb6/src/android/GeoBroker.java
----------------------------------------------------------------------
diff --git a/src/android/GeoBroker.java b/src/android/GeoBroker.java
index ea0ad1c..bd88d38 100755
--- a/src/android/GeoBroker.java
+++ b/src/android/GeoBroker.java
@@ -65,7 +65,8 @@ public class GeoBroker extends CordovaPlugin {
             if (action.equals("getLocation")) {
                 boolean enableHighAccuracy = args.getBoolean(0);
                 int maximumAge = args.getInt(1);
-                Location last = this.locationManager.getLastKnownLocation((enableHighAccuracy
? LocationManager.GPS_PROVIDER : LocationManager.NETWORK_PROVIDER));
+                String provider = (enableHighAccuracy && locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER))
? LocationManager.GPS_PROVIDER : LocationManager.NETWORK_PROVIDER;
+                Location last = this.locationManager.getLastKnownLocation(provider);
                 // Check if we can use lastKnownLocation to get a quick reading and use less
battery
                 if (last != null && (System.currentTimeMillis() - last.getTime())
<= maximumAge) {
                     PluginResult result = new PluginResult(PluginResult.Status.OK, this.returnLocationJSON(last));
@@ -101,7 +102,7 @@ public class GeoBroker extends CordovaPlugin {
     }
 
     private void getCurrentLocation(CallbackContext callbackContext, boolean enableHighAccuracy,
int timeout) {
-        if (enableHighAccuracy) {
+        if (enableHighAccuracy && locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER))
{
             this.gpsListener.addCallback(callbackContext, timeout);
         } else {
             this.networkListener.addCallback(callbackContext, timeout);
@@ -109,7 +110,7 @@ public class GeoBroker extends CordovaPlugin {
     }
 
     private void addWatch(String timerId, CallbackContext callbackContext, boolean enableHighAccuracy)
{
-        if (enableHighAccuracy) {
+        if (enableHighAccuracy && locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER))
{
             this.gpsListener.addWatch(timerId, callbackContext);
         } else {
             this.networkListener.addWatch(timerId, callbackContext);

http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/9eb9efb6/test/cordova-incl.js
----------------------------------------------------------------------
diff --git a/test/cordova-incl.js b/test/cordova-incl.js
index dbcd1a6..86c82e3 100644
--- a/test/cordova-incl.js
+++ b/test/cordova-incl.js
@@ -20,7 +20,9 @@
 */
 
 var PLAT;
-if (/Android/.exec(navigator.userAgent)) {
+if (/Chrome/.exec(navigator.userAgent)) {
+    PLAT = 'amazon-fireos';
+} else if (/Android/.exec(navigator.userAgent)) {
     PLAT = 'android';
 } else if (/(iPad)|(iPhone)|(iPod)/.exec(navigator.userAgent)) {
     PLAT = 'ios';


Mime
View raw message