From 827c0ec81f9ca8bda8b387814c7e7cf13df789ea Mon Sep 17 00:00:00 2001 From: Joe Bowser <bowserj@shapley.(none)> Date: Fri, 26 Mar 2010 15:34:29 -0700 Subject: [PATCH 1/3] Removing junk Orientation class --- framework/src/com/phonegap/Orientation.java | 69 --------------------- 1 file changed, 69 deletions(-) delete mode 100644 framework/src/com/phonegap/Orientation.java diff --git a/framework/src/com/phonegap/Orientation.java b/framework/src/com/phonegap/Orientation.java deleted file mode 100644 index b49787b9..00000000 --- a/framework/src/com/phonegap/Orientation.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.phonegap; -/* License (MIT) - * Copyright (c) 2008 Nitobi - * website: http://phonegap.com - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * “Software”), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -import android.content.Context; -import android.hardware.SensorManager; -import android.hardware.SensorListener; -import android.webkit.WebView; - -public class Orientation implements SensorListener{ - - private WebView mAppView; - private SensorManager sensorManager; - private Context mCtx; - - Orientation(WebView kit, Context ctx) { - mAppView = kit; - mCtx = ctx; - sensorManager = (SensorManager) mCtx.getSystemService(Context.SENSOR_SERVICE); - this.resumeAccel(); - } - - public void onSensorChanged(int sensor, final float[] values) { - if (sensor != SensorManager.SENSOR_ACCELEROMETER || values.length < 3) - return; - float x = values[0]; - float y = values[1]; - float z = values[2]; - mAppView.loadUrl("javascript:gotAcceleration(" + x + ", " + y + "," + z + ")"); - } - - public void onAccuracyChanged(int arg0, int arg1) { - // This is a stub method. - - } - - public void pauseAccel() - { - sensorManager.unregisterListener(this); - } - - public void resumeAccel() - { - sensorManager.registerListener(this, - SensorManager.SENSOR_ACCELEROMETER, - SensorManager.SENSOR_DELAY_GAME); - } - -} From 72fd058b9edc365ba5d770244784245864452dbe Mon Sep 17 00:00:00 2001 From: Joe Bowser <bowserj@shapley.(none)> Date: Mon, 29 Mar 2010 16:56:07 -0700 Subject: [PATCH 2/3] 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 */ + + } + + } + } From 69e580136a06a7be239ae48c3321266cb57508e3 Mon Sep 17 00:00:00 2001 From: Joe Bowser <bowserj@shapley.(none)> Date: Tue, 30 Mar 2010 12:02:08 -0700 Subject: [PATCH 3/3] Forgot the min SDK is 2, not 3 --- framework/AndroidManifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/AndroidManifest.xml b/framework/AndroidManifest.xml index 3bedc80a..c3ecca13 100644 --- a/framework/AndroidManifest.xml +++ b/framework/AndroidManifest.xml @@ -38,6 +38,6 @@ <action android:name="android.intent.action.PICK" /> </activity> </application> - <uses-sdk android:minSdkVersion="3" /> + <uses-sdk android:minSdkVersion="2" /> </manifest>