Latest PhoneGap Source

This commit is contained in:
Joe Bowser 2008-10-22 13:07:33 -07:00
parent 2337509c15
commit 782310849f
2 changed files with 28 additions and 4 deletions

View File

@ -5,12 +5,19 @@ 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) {
@ -18,6 +25,10 @@ public class DroidGap extends Activity {
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);
@ -29,7 +40,7 @@ public class DroidGap extends Activity {
* 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/");
appView.loadUrl("http://www.infil00p.org/gap/demo/");
}
@ -58,8 +69,21 @@ public class DroidGap extends Activity {
private void bindBrowser(WebView appView)
{
PhoneGap gap = new PhoneGap(this);
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;
}
}
}

View File

@ -27,7 +27,7 @@ public class PhoneGap {
this.mAppView = appView;
}
public void updateAccel(AccelTuple accel){
public void updateAccel(){
mHandler.post(new Runnable() {
public void run() {
int accelX = SensorManager.DATA_X;