mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-20 23:56:20 +08:00
Tweaking DroidGap so it compiles into a JAR, starting testing
This commit is contained in:
parent
f34da8a96f
commit
9a2eb04054
@ -10,5 +10,5 @@
|
||||
# Indicates whether an apk should be generated for each density.
|
||||
split.density=false
|
||||
# Project target.
|
||||
target=android-14
|
||||
target=android-15
|
||||
apk-configurations=
|
||||
|
@ -44,7 +44,7 @@ public class CordovaChromeClient extends WebChromeClient {
|
||||
|
||||
private String TAG = "CordovaLog";
|
||||
private long MAX_QUOTA = 100 * 1024 * 1024;
|
||||
private DroidGap ctx;
|
||||
private Context ctx;
|
||||
private CordovaWebView appView;
|
||||
|
||||
/**
|
||||
@ -53,8 +53,7 @@ public class CordovaChromeClient extends WebChromeClient {
|
||||
* @param ctx
|
||||
*/
|
||||
public CordovaChromeClient(Context ctx) {
|
||||
this.ctx = (DroidGap) ctx;
|
||||
appView = this.ctx.appView;
|
||||
this.ctx = ctx;
|
||||
}
|
||||
|
||||
public CordovaChromeClient(Context ctx, CordovaWebView app)
|
||||
@ -173,10 +172,15 @@ public class CordovaChromeClient extends WebChromeClient {
|
||||
@Override
|
||||
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
|
||||
// loaded in webview and not another loaded in an iframe.
|
||||
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;
|
||||
}
|
||||
|
||||
@ -199,7 +203,9 @@ public class CordovaChromeClient extends WebChromeClient {
|
||||
|
||||
// Polling for JavaScript messages
|
||||
else if (reqOk && defaultValue != null && defaultValue.equals("gap_poll:")) {
|
||||
String r = ctx.callbackServer.getJavascript();
|
||||
|
||||
|
||||
String r = appView.callbackServer.getJavascript();
|
||||
result.confirm(r);
|
||||
}
|
||||
|
||||
@ -207,16 +213,16 @@ public class CordovaChromeClient extends WebChromeClient {
|
||||
else if (reqOk && defaultValue != null && defaultValue.equals("gap_callbackServer:")) {
|
||||
String r = "";
|
||||
if (message.equals("usePolling")) {
|
||||
r = ""+ ctx.callbackServer.usePolling();
|
||||
r = ""+ appView.callbackServer.usePolling();
|
||||
}
|
||||
else if (message.equals("restartServer")) {
|
||||
ctx.callbackServer.restartServer();
|
||||
appView.callbackServer.restartServer();
|
||||
}
|
||||
else if (message.equals("getPort")) {
|
||||
r = Integer.toString(ctx.callbackServer.getPort());
|
||||
r = Integer.toString(appView.callbackServer.getPort());
|
||||
}
|
||||
else if (message.equals("getToken")) {
|
||||
r = ctx.callbackServer.getToken();
|
||||
r = appView.callbackServer.getToken();
|
||||
}
|
||||
result.confirm(r);
|
||||
}
|
||||
@ -224,11 +230,11 @@ public class CordovaChromeClient extends WebChromeClient {
|
||||
// Cordova JS has initialized, so show webview
|
||||
// (This solves white flash seen when rendering HTML)
|
||||
else if (reqOk && defaultValue != null && defaultValue.equals("gap_init:")) {
|
||||
if (ctx.splashscreen != 0) {
|
||||
ctx.root.setBackgroundResource(0);
|
||||
if (ctx.getClass().equals(DroidGap.class) && ((DroidGap) ctx).splashscreen != 0) {
|
||||
((DroidGap) ctx).root.setBackgroundResource(0);
|
||||
((DroidGap) ctx).spinnerStop();
|
||||
}
|
||||
ctx.appView.setVisibility(View.VISIBLE);
|
||||
ctx.spinnerStop();
|
||||
appView.setVisibility(View.VISIBLE);
|
||||
result.confirm("OK");
|
||||
}
|
||||
|
||||
|
@ -256,8 +256,8 @@ public class CordovaWebViewClient extends WebViewClient {
|
||||
|
||||
// Shutdown if blank loaded
|
||||
if (url.equals("about:blank")) {
|
||||
if (this.ctx.callbackServer != null) {
|
||||
this.ctx.callbackServer.destroy();
|
||||
if (appView.callbackServer != null) {
|
||||
appView.callbackServer.destroy();
|
||||
}
|
||||
this.ctx.endActivity();
|
||||
}
|
||||
|
@ -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
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
|
Loading…
Reference in New Issue
Block a user