From 72fd058b9edc365ba5d770244784245864452dbe Mon Sep 17 00:00:00 2001 From: Joe Bowser Date: Mon, 29 Mar 2010 16:56:07 -0700 Subject: [PATCH] Turning off the Native WebKit Geolcation --- framework/src/com/phonegap/DroidGap.java | 3 ++ .../src/com/phonegap/WebViewReflect.java | 29 +++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/framework/src/com/phonegap/DroidGap.java b/framework/src/com/phonegap/DroidGap.java index 5a8bc47d..8f8eb0bd 100644 --- a/framework/src/com/phonegap/DroidGap.java +++ b/framework/src/com/phonegap/DroidGap.java @@ -111,6 +111,9 @@ public class DroidGap extends Activity { // Turn on DOM storage! WebViewReflect.setDomStorage(settings); + // Turn OFF Native Geolocation + WebViewReflect.setGeolocation(settings); + /* Bind the appView object to the gap class methods */ bindBrowser(appView); if(cupcakeStorage != null) diff --git a/framework/src/com/phonegap/WebViewReflect.java b/framework/src/com/phonegap/WebViewReflect.java index ed611a2b..9e69acdd 100644 --- a/framework/src/com/phonegap/WebViewReflect.java +++ b/framework/src/com/phonegap/WebViewReflect.java @@ -10,6 +10,7 @@ public class WebViewReflect { private static Method mWebSettings_setDatabaseEnabled; private static Method mWebSettings_setDatabasePath; private static Method mWebSettings_setDomStorageEnabled; + private static Method mWebSettings_setGeolocationEnabled; static { @@ -48,6 +49,8 @@ public class WebViewReflect { "setDatabasePath", new Class[] { String.class }); mWebSettings_setDomStorageEnabled = WebSettings.class.getMethod( "setDomStorageEnabled", new Class[] { boolean.class }); + mWebSettings_setGeolocationEnabled = WebSettings.class.getMethod( + "setGeolocationEnabled", new Class[] { boolean.class }); /* success, this is a newer device */ } catch (NoSuchMethodException nsme) { /* failure, must be older device */ @@ -72,7 +75,6 @@ public class WebViewReflect { } } else { /* feature not supported, do something else */ - System.out.println("Database not supported"); } } @@ -95,9 +97,32 @@ public class WebViewReflect { } } else { /* feature not supported, do something else */ - System.out.println("DOM Storage not supported"); } } + public static void setGeolocation(WebSettings setting) + { + if(mWebSettings_setGeolocationEnabled != null) + { + /* feature is supported */ + try { + mWebSettings_setGeolocationEnabled.invoke(setting, false); + } catch (IllegalArgumentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InvocationTargetException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } else { + /* feature not supported, do something else */ + + } + + } + }