From 91d93deabb864b9d29940cc4ebd212dc0a0238a5 Mon Sep 17 00:00:00 2001 From: Joe Bowser Date: Thu, 18 Dec 2008 15:13:30 -0800 Subject: [PATCH] Removing old code --- src/com/android/droidgap/AccelTuple.java | 7 -- src/com/android/droidgap/DroidGap.java | 89 --------------------- src/com/android/droidgap/GeoTuple.java | 7 -- src/com/android/droidgap/PhoneGap.java | 98 ------------------------ src/com/android/droidgap/R.java | 26 ------- 5 files changed, 227 deletions(-) delete mode 100644 src/com/android/droidgap/AccelTuple.java delete mode 100644 src/com/android/droidgap/DroidGap.java delete mode 100644 src/com/android/droidgap/GeoTuple.java delete mode 100644 src/com/android/droidgap/PhoneGap.java delete mode 100644 src/com/android/droidgap/R.java diff --git a/src/com/android/droidgap/AccelTuple.java b/src/com/android/droidgap/AccelTuple.java deleted file mode 100644 index 5073a236..00000000 --- a/src/com/android/droidgap/AccelTuple.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.android.droidgap; - -public class AccelTuple { - public long accelX; - public long accelY; - public long accelZ; -} diff --git a/src/com/android/droidgap/DroidGap.java b/src/com/android/droidgap/DroidGap.java deleted file mode 100644 index c8c325ae..00000000 --- a/src/com/android/droidgap/DroidGap.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.android.droidgap; - -import java.io.IOException; -import java.io.InputStream; - -import android.app.Activity; -import android.os.Bundle; -import android.os.Handler; -import android.util.Log; -import android.webkit.JsResult; -import android.webkit.WebChromeClient; -import android.webkit.WebView; - -public class DroidGap extends Activity { - - private static final String LOG_TAG = "DroidGap"; - private WebView appView; - - private Handler mHandler = new Handler(); - - /** Called when the activity is first created. */ - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.main); - - appView = (WebView) findViewById(R.id.appView); - - /* This changes the setWebChromeClient to log alerts to LogCat! Important for Javascript Debugging */ - - appView.setWebChromeClient(new MyWebChromeClient()); - appView.getSettings().setJavaScriptEnabled(true); - appView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); - - /* Bind the appView object to the gap class methods */ - bindBrowser(appView); - - /* - * We need to decide whether this is a local or a remote app. For the sake of clarity - * we can use HTML with both local and remote applications, but it means that we have to open the local file - */ - - appView.loadUrl("http://www.infil00p.org/gap/demo/"); - - } - - private void loadFile(WebView appView){ - try { - InputStream is = getAssets().open("index.html"); - - int size = is.available(); - - // Read the entire asset into a local byte buffer. - byte[] buffer = new byte[size]; - is.read(buffer); - is.close(); - - // Convert the buffer into a Java string. - String text = new String(buffer); - - // Load the local file into the webview - appView.loadData(text, "text/html", "UTF-8"); - - } catch (IOException e) { - // Should never happen! - throw new RuntimeException(e); - } - } - - private void bindBrowser(WebView appView) - { - PhoneGap gap = new PhoneGap(this, mHandler, appView); - appView.addJavascriptInterface(gap, "DroidGap"); - } - - /** - * Provides a hook for calling "alert" from javascript. Useful for - * debugging your javascript. - */ - final class MyWebChromeClient extends WebChromeClient { - @Override - public boolean onJsAlert(WebView view, String url, String message, JsResult result) { - Log.d(LOG_TAG, message); - result.confirm(); - return true; - } - } - -} \ No newline at end of file diff --git a/src/com/android/droidgap/GeoTuple.java b/src/com/android/droidgap/GeoTuple.java deleted file mode 100644 index 350ea5f6..00000000 --- a/src/com/android/droidgap/GeoTuple.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.android.droidgap; - -public class GeoTuple { - public double lat; - public double lng; - public double ele; -} diff --git a/src/com/android/droidgap/PhoneGap.java b/src/com/android/droidgap/PhoneGap.java deleted file mode 100644 index 710701a1..00000000 --- a/src/com/android/droidgap/PhoneGap.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.android.droidgap; - -import android.content.Context; -import android.hardware.SensorManager; -import android.location.Location; -import android.location.LocationManager; -import android.os.Handler; -import android.os.Vibrator; -import android.telephony.TelephonyManager; -import android.webkit.WebView; - -public class PhoneGap { - - /* - * UUID, version and availability - */ - public boolean droid = true; - private String version = "0.1"; - private Context mCtx; - private Handler mHandler; - private WebView mAppView; - - public PhoneGap(Context ctx, Handler handler, WebView appView) { - this.mCtx = ctx; - this.mHandler = handler; - this.mAppView = appView; - } - - - public void updateAccel(){ - mHandler.post(new Runnable() { - public void run() { - int accelX = SensorManager.DATA_X; - int accelY = SensorManager.DATA_Y; - int accelZ = SensorManager.DATA_Z; - mAppView.loadUrl("javascript:gotAcceleration(" + accelX + ", " + accelY + "," + accelZ + ")"); - } - }); - - } - - public void takePhoto(){ - // TO-DO: Figure out what this should do - } - - public void playSound(){ - // TO-DO: Figure out what this should do - } - - public void vibrate(long pattern){ - // Start the vibration - Vibrator vibrator = (Vibrator) mCtx.getSystemService(Context.VIBRATOR_SERVICE); - vibrator.vibrate(pattern); - } - - /* - * Android requires a provider, since it can fall back on triangulation and other means as well as GPS - */ - - public void getLocation(final String provider){ - mHandler.post(new Runnable() { - public void run() { - LocationManager locMan = (LocationManager) mCtx.getSystemService(Context.LOCATION_SERVICE); - Location myLoc = (Location) locMan.getLastKnownLocation(provider); - GeoTuple geoloc = new GeoTuple(); - geoloc.lat = myLoc.getLatitude(); - geoloc.lng = myLoc.getLongitude(); - geoloc.ele = myLoc.getAltitude(); - mAppView.loadUrl("javascript:gotLocation(" + geoloc.lat + ", " + geoloc.lng + ")"); - } - }); - } - - public String outputText(){ - String test = "

Test

"; - return test; - } - - - public String getUuid() - { - - TelephonyManager operator = (TelephonyManager) mCtx.getSystemService(Context.TELEPHONY_SERVICE); - String uuid = operator.getDeviceId(); - return uuid; - } - - public String getVersion() - { - return version; - } - - public boolean exists() - { - return true; - } - -} diff --git a/src/com/android/droidgap/R.java b/src/com/android/droidgap/R.java deleted file mode 100644 index 61d94116..00000000 --- a/src/com/android/droidgap/R.java +++ /dev/null @@ -1,26 +0,0 @@ -/* AUTO-GENERATED FILE. DO NOT MODIFY. - * - * This class was automatically generated by the - * aapt tool from the resource data it found. It - * should not be modified by hand. - */ - -package com.android.droidgap; - -public final class R { - public static final class attr { - } - public static final class drawable { - public static final int icon=0x7f020000; - } - public static final class id { - public static final int appView=0x7f050000; - } - public static final class layout { - public static final int main=0x7f030000; - } - public static final class string { - public static final int app_name=0x7f040001; - public static final int hello=0x7f040000; - } -}