From 1c3415172c4c1dc68a9df09df15d73317d358c10 Mon Sep 17 00:00:00 2001 From: Brock Whitten Date: Mon, 16 Nov 2009 13:38:49 -0800 Subject: [PATCH 1/6] added gitignore for android. moved project specific ignores into respective directories --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..90eca753 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +default.properties +bin +gen +assets/www/phonegap.js \ No newline at end of file From 1991daee722d82afa78a425471574dc2f9899238 Mon Sep 17 00:00:00 2001 From: Joe Bowser Date: Wed, 18 Nov 2009 10:05:11 -0800 Subject: [PATCH 2/6] Removing the GeoTuple.java class --- src/com/phonegap/GeoTuple.java | 32 -------------------------------- 1 file changed, 32 deletions(-) delete mode 100644 src/com/phonegap/GeoTuple.java diff --git a/src/com/phonegap/GeoTuple.java b/src/com/phonegap/GeoTuple.java deleted file mode 100644 index 4795b606..00000000 --- a/src/com/phonegap/GeoTuple.java +++ /dev/null @@ -1,32 +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. - */ - - -public class GeoTuple { - - public double lat; - public double lng; - public double ele; - -} From 3ee7589bb83252a851c5849806af46cd319bc121 Mon Sep 17 00:00:00 2001 From: Joe Bowser Date: Wed, 18 Nov 2009 10:13:11 -0800 Subject: [PATCH 3/6] Removing another stupid Tuple class --- src/com/phonegap/AccelTuple.java | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 src/com/phonegap/AccelTuple.java diff --git a/src/com/phonegap/AccelTuple.java b/src/com/phonegap/AccelTuple.java deleted file mode 100644 index 152c2201..00000000 --- a/src/com/phonegap/AccelTuple.java +++ /dev/null @@ -1,29 +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. - */ - -public class AccelTuple { - public long accelX; - public long accelY; - public long accelZ; -} From 2d52f941c960e5b05af0825da9e2cc0112e78dcd Mon Sep 17 00:00:00 2001 From: Joe Bowser Date: Wed, 18 Nov 2009 11:09:20 -0800 Subject: [PATCH 4/6] Updating the Accelerometer to the latest version of Android --- src/com/phonegap/AccelListener.java | 55 +++++++++++++++++------------ 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/src/com/phonegap/AccelListener.java b/src/com/phonegap/AccelListener.java index 629bcbf2..25cbc489 100644 --- a/src/com/phonegap/AccelListener.java +++ b/src/com/phonegap/AccelListener.java @@ -1,19 +1,21 @@ package com.phonegap; -import static android.hardware.SensorManager.DATA_X; -import static android.hardware.SensorManager.DATA_Y; -import static android.hardware.SensorManager.DATA_Z; + +import java.util.List; + +import android.hardware.Sensor; +import android.hardware.SensorEvent; +import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.content.Context; -import android.hardware.SensorListener; import android.webkit.WebView; -@SuppressWarnings("deprecation") -public class AccelListener implements SensorListener{ +public class AccelListener implements SensorEventListener{ WebView mAppView; Context mCtx; String mKey; + Sensor mSensor; int mTime = 10000; boolean started = false; @@ -26,16 +28,21 @@ public class AccelListener implements SensorListener{ mCtx = ctx; mAppView = appView; sensorManager = (SensorManager) mCtx.getSystemService(Context.SENSOR_SERVICE); + } public void start(int time) { mTime = time; - if (!started) + List list = this.sensorManager.getSensorList(Sensor.TYPE_ACCELEROMETER); + if (list.size() > 0) { - sensorManager.registerListener(this, - SensorManager.SENSOR_ACCELEROMETER, - SensorManager.SENSOR_DELAY_GAME); + this.mSensor = list.get(0); + this.sensorManager.registerListener(this, this.mSensor, SensorManager.SENSOR_DELAY_NORMAL); + } + else + { + // Call fail } } @@ -45,23 +52,25 @@ public class AccelListener implements SensorListener{ sensorManager.unregisterListener(this); } - public void onAccuracyChanged(int sensor, int accuracy) { - // This should call the FAIL method - } - public void onSensorChanged(int sensor, float[] values) { - if (sensor != SensorManager.SENSOR_ACCELEROMETER || values.length < 3) - return; + + public void onAccuracyChanged(Sensor sensor, int accuracy) { + // TODO Auto-generated method stub + + } + + public void onSensorChanged(SensorEvent event) { + if (event.sensor.getType() != Sensor.TYPE_ACCELEROMETER) + return; long curTime = System.currentTimeMillis(); - if (lastUpdate == -1 || (curTime - lastUpdate) > mTime) { - + if (lastUpdate == -1 || (curTime - lastUpdate) > mTime) { lastUpdate = curTime; - - float x = values[DATA_X]; - float y = values[DATA_Y]; - float z = values[DATA_Z]; + + float x = event.values[0]; + float y = event.values[1]; + float z = event.values[2]; mAppView.loadUrl("javascript:gotAccel(" + x + ", " + y + "," + z + " )"); - } + } } From 9e391d082338c2467a2418362168825fd191fb79 Mon Sep 17 00:00:00 2001 From: Joe Bowser Date: Wed, 18 Nov 2009 11:11:05 -0800 Subject: [PATCH 5/6] Wiring up CompassHook --- src/com/phonegap/DroidGap.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/com/phonegap/DroidGap.java b/src/com/phonegap/DroidGap.java index 9f0bb099..2ac4988f 100644 --- a/src/com/phonegap/DroidGap.java +++ b/src/com/phonegap/DroidGap.java @@ -51,6 +51,7 @@ public class DroidGap extends Activity { private ContactManager mContacts; private FileUtils fs; private NetworkManager netMan; + private CompassListener mCompass; /** Called when the activity is first created. */ @Override @@ -109,6 +110,7 @@ public class DroidGap extends Activity { mContacts = new ContactManager(this, appView); fs = new FileUtils(appView); netMan = new NetworkManager(this, appView); + mCompass = new CompassListener(this, appView); // This creates the new javascript interfaces for PhoneGap appView.addJavascriptInterface(gap, "DroidGap"); @@ -118,6 +120,7 @@ public class DroidGap extends Activity { appView.addJavascriptInterface(mContacts, "ContactHook"); appView.addJavascriptInterface(fs, "FileUtil"); appView.addJavascriptInterface(netMan, "NetworkManager"); + appView.addJavascriptInterface(mCompass, "CompassHook"); } /** From e7f4a3ac11a5f9c8bf0267f71633063d82c44ffc Mon Sep 17 00:00:00 2001 From: Joe Bowser Date: Wed, 18 Nov 2009 11:32:18 -0800 Subject: [PATCH 6/6] Removing useless class --- src/com/phonegap/VideoPreview.java | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 src/com/phonegap/VideoPreview.java diff --git a/src/com/phonegap/VideoPreview.java b/src/com/phonegap/VideoPreview.java deleted file mode 100644 index e263ab6c..00000000 --- a/src/com/phonegap/VideoPreview.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.phonegap; - -import android.app.Activity; - - -public class VideoPreview extends Activity { - -}