diff --git a/framework/src/com/phonegap/CompassListener.java b/framework/src/com/phonegap/CompassListener.java index 7b37bba9..b504528c 100644 --- a/framework/src/com/phonegap/CompassListener.java +++ b/framework/src/com/phonegap/CompassListener.java @@ -49,6 +49,6 @@ public class CompassListener implements SensorEventListener{ public void onSensorChanged(SensorEvent event) { // We only care about the orientation as far as it refers to Magnetic North float heading = event.values[0]; - mAppView.loadUrl("javascript:gotBearing(" + heading + ")"); + mAppView.loadUrl("javascript:navigator.compass.setHeading(" + heading + ")"); } } diff --git a/framework/src/com/phonegap/DroidGap.java b/framework/src/com/phonegap/DroidGap.java index 4dc9c1cf..358e1ec4 100644 --- a/framework/src/com/phonegap/DroidGap.java +++ b/framework/src/com/phonegap/DroidGap.java @@ -26,6 +26,7 @@ package com.phonegap; import android.app.Activity; import android.app.AlertDialog; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.content.res.Configuration; import android.graphics.Color; @@ -172,13 +173,39 @@ public class DroidGap extends Activity { Log.d(LOG_TAG, message); // This shows the dialog box. This can be commented out for dev AlertDialog.Builder alertBldr = new AlertDialog.Builder(mCtx); + GapOKDialog okHook = new GapOKDialog(); + GapCancelDialog cancelHook = new GapCancelDialog(); alertBldr.setMessage(message); alertBldr.setTitle("Alert"); + alertBldr.setCancelable(true); + alertBldr.setPositiveButton("OK", okHook); + alertBldr.setNegativeButton("Cancel", cancelHook); alertBldr.show(); result.confirm(); return true; } + /* + * This is the Code for the OK Button + */ + + public class GapOKDialog implements DialogInterface.OnClickListener { + + public void onClick(DialogInterface dialog, int which) { + // TODO Auto-generated method stub + dialog.dismiss(); + } + + } + + public class GapCancelDialog implements DialogInterface.OnClickListener { + + public void onClick(DialogInterface dialog, int which) { + // TODO Auto-generated method stub + dialog.dismiss(); + } + + } } diff --git a/framework/src/com/phonegap/GeoBroker.java b/framework/src/com/phonegap/GeoBroker.java index c8f896ef..d7cb5473 100644 --- a/framework/src/com/phonegap/GeoBroker.java +++ b/framework/src/com/phonegap/GeoBroker.java @@ -3,6 +3,7 @@ package com.phonegap; import java.util.HashMap; import android.content.Context; +import android.location.Location; import android.webkit.WebView; /* @@ -15,7 +16,6 @@ public class GeoBroker { private WebView mAppView; private Context mCtx; private HashMap geoListeners; - private GeoListener listener; public GeoBroker(WebView view, Context ctx) { @@ -24,9 +24,13 @@ public class GeoBroker { } public void getCurrentLocation() - { - if (listener == null) - listener = new GeoListener("global", mCtx, 10000, mAppView); + { + GeoListener listener = new GeoListener("global", mCtx, 10000, mAppView); + Location loc = listener.getCurrentLocation(); + String params = loc.getLatitude() + "," + loc.getLongitude() + ", " + loc.getAltitude() + "," + loc.getAccuracy() + "," + loc.getBearing(); + params += "," + loc.getSpeed() + "," + loc.getTime(); + mAppView.loadUrl("javascript:navigator.geolocation.gotCurrentPosition(" + params + ")"); + listener.stop(); } public String start(int freq, String key) diff --git a/framework/src/com/phonegap/GeoListener.java b/framework/src/com/phonegap/GeoListener.java index a65efa3c..98dc3001 100644 --- a/framework/src/com/phonegap/GeoListener.java +++ b/framework/src/com/phonegap/GeoListener.java @@ -40,12 +40,7 @@ public class GeoListener { if(id != "global") { mAppView.loadUrl("javascript:navigator.geolocation.success(" + id + "," + params + ")"); - } - else - { - mAppView.loadUrl("javascript:navigator.geolocation.gotCurrentPosition(" + params + ")"); - this.stop(); - } + } } void fail()