From 745e5508152cf33b27743d2843019df0f086a0dd Mon Sep 17 00:00:00 2001 From: Joe Bowser Date: Fri, 27 Mar 2009 14:27:49 -0700 Subject: [PATCH] Moving to new computer, committing what I have in the branch --- src/com/nitobi/phonegap/DroidGap.java | 4 ++- src/com/nitobi/phonegap/GeoBroker.java | 19 ++++++++++ src/com/nitobi/phonegap/GeoListener.java | 37 ++++++++++++++++++++ src/com/nitobi/phonegap/GpsListener.java | 6 ++-- src/com/nitobi/phonegap/NetworkListener.java | 6 ++-- src/com/nitobi/phonegap/PhoneGap.java | 12 +------ 6 files changed, 68 insertions(+), 16 deletions(-) create mode 100644 src/com/nitobi/phonegap/GeoBroker.java create mode 100644 src/com/nitobi/phonegap/GeoListener.java diff --git a/src/com/nitobi/phonegap/DroidGap.java b/src/com/nitobi/phonegap/DroidGap.java index 5b925f45..b1b7cdee 100644 --- a/src/com/nitobi/phonegap/DroidGap.java +++ b/src/com/nitobi/phonegap/DroidGap.java @@ -89,8 +89,10 @@ public class DroidGap extends Activity { private void bindBrowser(WebView appView) { + // The PhoneGap class handles the Notification and Android Specific crap PhoneGap gap = new PhoneGap(this, mHandler, appView); - appView.addJavascriptInterface(gap, "DroidGap"); + appView.addJavascriptInterface(gap, "Droid"); + } /** diff --git a/src/com/nitobi/phonegap/GeoBroker.java b/src/com/nitobi/phonegap/GeoBroker.java new file mode 100644 index 00000000..56817baf --- /dev/null +++ b/src/com/nitobi/phonegap/GeoBroker.java @@ -0,0 +1,19 @@ +package com.nitobi.phonegap; + +import android.webkit.WebView; + +public class GeoBroker { + private WebView mAppView; + + + public String start(int freq, String success, String failure) + { + + return null; + } + + public void stop(String key) + { + + } +} diff --git a/src/com/nitobi/phonegap/GeoListener.java b/src/com/nitobi/phonegap/GeoListener.java new file mode 100644 index 00000000..a36a262b --- /dev/null +++ b/src/com/nitobi/phonegap/GeoListener.java @@ -0,0 +1,37 @@ +package com.nitobi.phonegap; + +import android.content.Context; +import android.webkit.WebView; + +public class GeoListener { + String id; + String successCallback; + String failCallback; + GpsListener mGps; + NetworkListener mNetwork; + Context mCtx; + private WebView mAppView; + + int interval; + + GeoListener(String key, Context ctx, int time, String succ, String fail) + { + id = key; + interval = time; + mCtx = ctx; + mGps = new GpsListener(mCtx, interval, this); + mNetwork = new NetworkListener(mCtx, interval, this); + } + + void success() + { + /* + * We only need to figure out what we do when we succeed! + */ + mAppView.loadUrl("javascript:geoLocation.success(" + ")"); + } + + void fail() + { + } +} diff --git a/src/com/nitobi/phonegap/GpsListener.java b/src/com/nitobi/phonegap/GpsListener.java index 7e2afae4..b38aafe4 100644 --- a/src/com/nitobi/phonegap/GpsListener.java +++ b/src/com/nitobi/phonegap/GpsListener.java @@ -34,12 +34,14 @@ public class GpsListener implements LocationListener { private Location cLoc; private LocationManager mLocMan; private static final String LOG_TAG = "PhoneGap"; + private GeoListener owner; - public GpsListener(Context ctx) + public GpsListener(Context ctx, int interval, GeoListener m) { + owner = m; mCtx = ctx; mLocMan = (LocationManager) mCtx.getSystemService(Context.LOCATION_SERVICE); - mLocMan.requestLocationUpdates(LocationManager.GPS_PROVIDER, 60000, 0, this); + mLocMan.requestLocationUpdates(LocationManager.GPS_PROVIDER, interval, 0, this); cLoc = mLocMan.getLastKnownLocation(LocationManager.GPS_PROVIDER); } diff --git a/src/com/nitobi/phonegap/NetworkListener.java b/src/com/nitobi/phonegap/NetworkListener.java index 952922f6..8c4bd9c4 100644 --- a/src/com/nitobi/phonegap/NetworkListener.java +++ b/src/com/nitobi/phonegap/NetworkListener.java @@ -34,12 +34,14 @@ public class NetworkListener implements LocationListener { private Location cLoc; private LocationManager mLocMan; private static final String LOG_TAG = "PhoneGap"; + GeoListener owner; - public NetworkListener(Context ctx) + public NetworkListener(Context ctx, int interval, GeoListener m) { + owner = m; mCtx = ctx; mLocMan = (LocationManager) mCtx.getSystemService(Context.LOCATION_SERVICE); - mLocMan.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 60000, 0, this); + mLocMan.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, interval, 0, this); cLoc = mLocMan.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); } diff --git a/src/com/nitobi/phonegap/PhoneGap.java b/src/com/nitobi/phonegap/PhoneGap.java index e55ce9f7..249e03eb 100644 --- a/src/com/nitobi/phonegap/PhoneGap.java +++ b/src/com/nitobi/phonegap/PhoneGap.java @@ -57,8 +57,7 @@ public class PhoneGap{ this.mCtx = ctx; this.mHandler = handler; this.mAppView = appView; - mGps = new GpsListener(ctx); - mNetwork = new NetworkListener(ctx); + mSmsListener = new SmsListener(ctx,mAppView); fileManager = new DirectoryManager(); audio = new AudioHandler("/sdcard/tmprecording.mp3", ctx); @@ -90,8 +89,6 @@ public class PhoneGap{ vibrator.vibrate(pattern); } - - public void getLocation( ){ mHandler.post(new Runnable() { public void run() { @@ -113,13 +110,6 @@ public class PhoneGap{ } }); } - - - public String outputText(){ - String test = "

Test

"; - return test; - } - public String getUuid() {