Tweaking DroidGap so it compiles into a JAR, starting testing

This commit is contained in:
Joe Bowser 2012-04-10 14:39:01 -07:00
parent f34da8a96f
commit 9a2eb04054
4 changed files with 23 additions and 17 deletions

View File

@ -10,5 +10,5 @@
# Indicates whether an apk should be generated for each density. # Indicates whether an apk should be generated for each density.
split.density=false split.density=false
# Project target. # Project target.
target=android-14 target=android-15
apk-configurations= apk-configurations=

View File

@ -44,7 +44,7 @@ public class CordovaChromeClient extends WebChromeClient {
private String TAG = "CordovaLog"; private String TAG = "CordovaLog";
private long MAX_QUOTA = 100 * 1024 * 1024; private long MAX_QUOTA = 100 * 1024 * 1024;
private DroidGap ctx; private Context ctx;
private CordovaWebView appView; private CordovaWebView appView;
/** /**
@ -53,8 +53,7 @@ public class CordovaChromeClient extends WebChromeClient {
* @param ctx * @param ctx
*/ */
public CordovaChromeClient(Context ctx) { public CordovaChromeClient(Context ctx) {
this.ctx = (DroidGap) ctx; this.ctx = ctx;
appView = this.ctx.appView;
} }
public CordovaChromeClient(Context ctx, CordovaWebView app) public CordovaChromeClient(Context ctx, CordovaWebView app)
@ -173,10 +172,15 @@ public class CordovaChromeClient extends WebChromeClient {
@Override @Override
public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, JsPromptResult result) { public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, JsPromptResult result) {
if(appView == null)
{
appView = (CordovaWebView) view;
}
// Security check to make sure any requests are coming from the page initially // Security check to make sure any requests are coming from the page initially
// loaded in webview and not another loaded in an iframe. // loaded in webview and not another loaded in an iframe.
boolean reqOk = false; boolean reqOk = false;
if (url.startsWith("file://") || url.indexOf(this.ctx.baseUrl) == 0 || ctx.isUrlWhiteListed(url)) { if (url.startsWith("file://") || appView.isUrlWhiteListed(url)) {
reqOk = true; reqOk = true;
} }
@ -199,7 +203,9 @@ public class CordovaChromeClient extends WebChromeClient {
// Polling for JavaScript messages // Polling for JavaScript messages
else if (reqOk && defaultValue != null && defaultValue.equals("gap_poll:")) { else if (reqOk && defaultValue != null && defaultValue.equals("gap_poll:")) {
String r = ctx.callbackServer.getJavascript();
String r = appView.callbackServer.getJavascript();
result.confirm(r); result.confirm(r);
} }
@ -207,16 +213,16 @@ public class CordovaChromeClient extends WebChromeClient {
else if (reqOk && defaultValue != null && defaultValue.equals("gap_callbackServer:")) { else if (reqOk && defaultValue != null && defaultValue.equals("gap_callbackServer:")) {
String r = ""; String r = "";
if (message.equals("usePolling")) { if (message.equals("usePolling")) {
r = ""+ ctx.callbackServer.usePolling(); r = ""+ appView.callbackServer.usePolling();
} }
else if (message.equals("restartServer")) { else if (message.equals("restartServer")) {
ctx.callbackServer.restartServer(); appView.callbackServer.restartServer();
} }
else if (message.equals("getPort")) { else if (message.equals("getPort")) {
r = Integer.toString(ctx.callbackServer.getPort()); r = Integer.toString(appView.callbackServer.getPort());
} }
else if (message.equals("getToken")) { else if (message.equals("getToken")) {
r = ctx.callbackServer.getToken(); r = appView.callbackServer.getToken();
} }
result.confirm(r); result.confirm(r);
} }
@ -224,11 +230,11 @@ public class CordovaChromeClient extends WebChromeClient {
// Cordova JS has initialized, so show webview // Cordova JS has initialized, so show webview
// (This solves white flash seen when rendering HTML) // (This solves white flash seen when rendering HTML)
else if (reqOk && defaultValue != null && defaultValue.equals("gap_init:")) { else if (reqOk && defaultValue != null && defaultValue.equals("gap_init:")) {
if (ctx.splashscreen != 0) { if (ctx.getClass().equals(DroidGap.class) && ((DroidGap) ctx).splashscreen != 0) {
ctx.root.setBackgroundResource(0); ((DroidGap) ctx).root.setBackgroundResource(0);
((DroidGap) ctx).spinnerStop();
} }
ctx.appView.setVisibility(View.VISIBLE); appView.setVisibility(View.VISIBLE);
ctx.spinnerStop();
result.confirm("OK"); result.confirm("OK");
} }

View File

@ -256,8 +256,8 @@ public class CordovaWebViewClient extends WebViewClient {
// Shutdown if blank loaded // Shutdown if blank loaded
if (url.equals("about:blank")) { if (url.equals("about:blank")) {
if (this.ctx.callbackServer != null) { if (appView.callbackServer != null) {
this.ctx.callbackServer.destroy(); appView.callbackServer.destroy();
} }
this.ctx.endActivity(); this.ctx.endActivity();
} }

View File

@ -1,5 +1,5 @@
/* /*
Licensed to the Apache Software Foundation (ASF) under one f Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file or more contributor license agreements. See the NOTICE file
distributed with this work for additional information distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file regarding copyright ownership. The ASF licenses this file