Working on the API, doing a 5 PM build to try to get this rolling along

- Got Vibrate to work
- 411 works out of the box
This commit is contained in:
unknown
2009-03-30 17:06:27 -07:00
parent 0514195d94
commit c78a0b876a
7 changed files with 815 additions and 495 deletions
+4 -2
View File
@@ -91,8 +91,10 @@ public class DroidGap extends Activity {
{
// The PhoneGap class handles the Notification and Android Specific crap
PhoneGap gap = new PhoneGap(this, mHandler, appView);
appView.addJavascriptInterface(gap, "Droid");
GeoBroker geo = new GeoBroker(appView, this);
// This creates the new javascript interfaces for PhoneGap
appView.addJavascriptInterface(gap, "Device");
appView.addJavascriptInterface(geo, "Geo");
}
/**
+2 -18
View File
@@ -23,25 +23,9 @@ public class GeoBroker {
mAppView = view;
}
public GeoTuple getCurrentLocation()
public void getCurrentLocation()
{
GeoListener listener = new GeoListener("0", mCtx, 60000, mAppView);
Location loc = listener.getCurrentLocation();
GeoTuple geo = new GeoTuple();
if (loc == null)
{
geo.lat = 0;
geo.lng = 0;
geo.ele = 0;
}
else
{
geo.lng = loc.getLongitude();
geo.lat = loc.getLatitude();
geo.ele = 0;
}
listener.stop();
return geo;
GeoListener listener = new GeoListener("global", mCtx, 10000, mAppView);
}
public String start(int freq, String key)
+9 -1
View File
@@ -30,7 +30,15 @@ public class GeoListener {
/*
* We only need to figure out what we do when we succeed!
*/
mAppView.loadUrl("javascript:GeoLocation.success(" + id + ", " + loc.getLatitude() + ", " + loc.getLongitude() + ")");
if(id != "global")
{
mAppView.loadUrl("javascript:Geolocation.success(" + id + ", " + loc.getLatitude() + ", " + loc.getLongitude() + ")");
}
else
{
mAppView.loadUrl("javascript:Geolocation.gotCurrentPosition(" + loc.getLatitude() + ", " + loc.getLongitude() + ")");
this.stop();
}
}
void fail()
+17 -37
View File
@@ -42,13 +42,12 @@ public class PhoneGap{
* UUID, version and availability
*/
public boolean droid = true;
private String version = "0.1";
private Context mCtx;
public static String version = "0.2";
public static String platform = "Android";
public static String uuid;
private Context mCtx;
private Handler mHandler;
private WebView mAppView;
private GpsListener mGps;
private NetworkListener mNetwork;
protected LocationProvider provider;
private WebView mAppView;
SmsListener mSmsListener;
DirectoryManager fileManager;
AudioHandler audio;
@@ -61,6 +60,7 @@ public class PhoneGap{
mSmsListener = new SmsListener(ctx,mAppView);
fileManager = new DirectoryManager();
audio = new AudioHandler("/sdcard/tmprecording.mp3", ctx);
uuid = getUuid();
}
public void updateAccel(){
@@ -75,42 +75,14 @@ public class PhoneGap{
}
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
// Start the vibration, 0 defaults to half a second.
if (pattern == 0)
pattern = 500;
Vibrator vibrator = (Vibrator) mCtx.getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(pattern);
}
public void getLocation( ){
mHandler.post(new Runnable() {
public void run() {
GeoTuple geoloc = new GeoTuple();
Location loc = mGps.hasLocation() ? mGps.getLocation() : mNetwork.getLocation();
if (loc != null)
{
geoloc.lat = loc.getLatitude();
geoloc.lng = loc.getLongitude();
geoloc.ele = loc.getAltitude();
}
else
{
geoloc.lat = 0;
geoloc.lng = 0;
geoloc.ele = 0;
}
mAppView.loadUrl("javascript:gotLocation(" + geoloc.lat + ", " + geoloc.lng + ")");
}
});
}
public String getUuid()
{
@@ -119,6 +91,11 @@ public class PhoneGap{
return uuid;
}
public void init()
{
mAppView.loadUrl("javascript:Device.setData('Android','" + version + "','" + this.getUuid() + "')");
}
public String getModel()
{
String model = android.os.Build.MODEL;
@@ -145,6 +122,9 @@ public class PhoneGap{
return version;
}
// Old SMS code, figure out what to do with this!
// BTW: This is awesome!
public void notificationWatchPosition(String filter)
/**
* Starts the listener for incoming notifications of type filter