mirror of
https://github.com/apache/cordova-android.git
synced 2026-05-11 00:00:05 +08:00
This is an ugly merge commit, because the rebase made even less sense.
This should add the old setProperty methods required for the tests. We decided to not deprecate them. I don't make a habit of doing merge commits, due to their destructive nature, but I think I might have merged too much stuff in. Merge branch 'pluggable_webview' of https://git-wip-us.apache.org/repos/asf/cordova-android into pluggable_webview Conflicts: framework/src/org/apache/cordova/AndroidChromeClient.java framework/src/org/apache/cordova/AndroidWebView.java framework/src/org/apache/cordova/CordovaActivity.java framework/src/org/apache/cordova/CordovaWebView.java
This commit is contained in:
@@ -166,8 +166,11 @@ public class AndroidWebView extends WebView implements CordovaWebView {
|
||||
{
|
||||
Log.d(TAG, "Your activity must implement CordovaInterface to work");
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
this.setWebChromeClient(this.makeChromeClient());
|
||||
this.initWebViewClient(this.cordova);
|
||||
=======
|
||||
>>>>>>> df05f3a3c07c0630c3d598409289db7a8f3c87e3
|
||||
this.loadConfiguration();
|
||||
this.setup();
|
||||
}
|
||||
@@ -190,7 +193,10 @@ public class AndroidWebView extends WebView implements CordovaWebView {
|
||||
{
|
||||
Log.d(TAG, "Your activity must implement CordovaInterface to work");
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
this.setWebChromeClient(this.makeChromeClient());
|
||||
=======
|
||||
>>>>>>> df05f3a3c07c0630c3d598409289db7a8f3c87e3
|
||||
this.loadConfiguration();
|
||||
this.setup();
|
||||
}
|
||||
@@ -214,17 +220,49 @@ public class AndroidWebView extends WebView implements CordovaWebView {
|
||||
{
|
||||
Log.d(TAG, "Your activity must implement CordovaInterface to work");
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
this.setWebChromeClient(this.makeChromeClient());
|
||||
this.initWebViewClient(this.cordova);
|
||||
=======
|
||||
>>>>>>> df05f3a3c07c0630c3d598409289db7a8f3c87e3
|
||||
this.loadConfiguration();
|
||||
this.setup();
|
||||
}
|
||||
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
* set the WebViewClient, but provide special case handling for IceCreamSandwich.
|
||||
*/
|
||||
private void initWebViewClient(CordovaInterface cordova) {
|
||||
this.setWebViewClient(this.makeWebViewClient());
|
||||
=======
|
||||
* Create a default WebViewClient object for this webview. This can be overridden by the
|
||||
* main application's CordovaActivity subclass.
|
||||
*
|
||||
* By default, it creates an AndroidWebViewClient, but we provide special case handling for
|
||||
* IceCreamSandwich.
|
||||
*/
|
||||
@Override
|
||||
public CordovaWebViewClient makeWebViewClient() {
|
||||
if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB ||
|
||||
android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.JELLY_BEAN_MR1)
|
||||
{
|
||||
return (CordovaWebViewClient) new AndroidWebViewClient(this.cordova, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (CordovaWebViewClient) new IceCreamCordovaWebViewClient(this.cordova, this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a default WebViewClient object for this webview. This can be overridden by the
|
||||
* main application's CordovaActivity subclass.
|
||||
*/
|
||||
@Override
|
||||
public CordovaChromeClient makeWebChromeClient() {
|
||||
return (CordovaChromeClient) new AndroidChromeClient(this.cordova);
|
||||
>>>>>>> df05f3a3c07c0630c3d598409289db7a8f3c87e3
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1074,6 +1112,7 @@ public class AndroidWebView extends WebView implements CordovaWebView {
|
||||
public View getView() {
|
||||
return this;
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
|
||||
@Override
|
||||
public CordovaWebViewClient makeWebViewClient() {
|
||||
@@ -1088,4 +1127,6 @@ public class AndroidWebView extends WebView implements CordovaWebView {
|
||||
public CordovaChromeClient makeChromeClient() {
|
||||
return (CordovaChromeClient) new AndroidChromeClient(this.cordova, this);
|
||||
}
|
||||
=======
|
||||
>>>>>>> df05f3a3c07c0630c3d598409289db7a8f3c87e3
|
||||
}
|
||||
|
||||
@@ -219,22 +219,17 @@ public class CordovaActivity extends Activity implements CordovaInterface {
|
||||
try {
|
||||
Class webViewClass = Class.forName(r);
|
||||
Constructor<CordovaWebView> [] webViewConstructors = webViewClass.getConstructors();
|
||||
|
||||
|
||||
if(CordovaWebView.class.isAssignableFrom(webViewClass)) {
|
||||
for (Constructor<CordovaWebView> constructor : webViewConstructors) {
|
||||
try {
|
||||
CordovaWebView webView = (CordovaWebView) constructor.newInstance(this);
|
||||
CordovaWebView webView = (CordovaWebView) constructor.newInstance(this);
|
||||
return webView;
|
||||
} catch (IllegalArgumentException e) {
|
||||
LOG.e(TAG, "Illegal arguments, try next constructor.");
|
||||
LOG.d(TAG, "Illegal arguments; trying next constructor.");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG.e(TAG, "The WebView Engine is NOT a proper WebView, defaulting to system WebView");
|
||||
}
|
||||
LOG.e(TAG, "The WebView Engine is NOT a proper WebView, defaulting to system WebView");
|
||||
} catch (ClassNotFoundException e) {
|
||||
LOG.e(TAG, "The WebView Engine was not found, defaulting to system WebView");
|
||||
} catch (InstantiationException e) {
|
||||
@@ -254,25 +249,27 @@ public class CordovaActivity extends Activity implements CordovaInterface {
|
||||
/**
|
||||
* Construct the client for the default web view object.
|
||||
*
|
||||
* This is intended to be overridable by subclasses of CordovaIntent which
|
||||
* require a more specialized web view.
|
||||
* This is intended to be overridable by subclasses of CordovaActivity which
|
||||
* require a more specialized web view. By default, it allows the webView
|
||||
* to create its own client objects.
|
||||
*
|
||||
* @param webView the default constructed web view object
|
||||
*/
|
||||
protected CordovaWebViewClient makeWebViewClient(CordovaWebView webView) {
|
||||
return webView.makeWebViewClient();
|
||||
return webView.makeWebViewClient();
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the chrome client for the default web view object.
|
||||
*
|
||||
* This is intended to be overridable by subclasses of CordovaIntent which
|
||||
* require a more specialized web view.
|
||||
* This is intended to be overridable by subclasses of CordovaActivity which
|
||||
* require a more specialized web view. By default, it allows the webView
|
||||
* to create its own client objects.
|
||||
*
|
||||
* @param webView the default constructed web view object
|
||||
*/
|
||||
protected CordovaChromeClient makeChromeClient(CordovaWebView webView) {
|
||||
return webView.makeChromeClient();
|
||||
return webView.makeWebChromeClient();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -45,6 +45,27 @@ import java.net.URL;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* What this class provides:
|
||||
* 1. Helpers for reading & writing to URLs.
|
||||
* - E.g. handles assets, resources, content providers, files, data URIs, http[s]
|
||||
* - E.g. Can be used to query for mime-type & content length.
|
||||
*
|
||||
* 2. To allow plugins to redirect URLs (via remapUrl).
|
||||
* - All plugins should call remapUrl() on URLs they receive from JS *before*
|
||||
* passing the URL onto other utility functions in this class.
|
||||
* - For an example usage of this, refer to the org.apache.cordova.file plugin.
|
||||
*
|
||||
* 3. It exposes a way to use the OkHttp library that ships with Cordova.
|
||||
* - Through createHttpConnection().
|
||||
*
|
||||
* Future Work:
|
||||
* - Consider using a Cursor to query content URLs for their size (like the file plugin does).
|
||||
* - Allow plugins to remapUri to "cdv-plugin://plugin-name/$ID", which CordovaResourceApi
|
||||
* would then delegate to pluginManager.getPlugin(plugin-name).openForRead($ID)
|
||||
* - Currently, plugins *can* do this by remapping to a data: URL, but it's inefficient
|
||||
* for large payloads.
|
||||
*/
|
||||
public class CordovaResourceApi {
|
||||
@SuppressWarnings("unused")
|
||||
private static final String LOG_TAG = "CordovaResourceApi";
|
||||
|
||||
@@ -18,10 +18,10 @@ public interface CordovaWebView {
|
||||
Object jsMessageQueue = null;
|
||||
|
||||
View getView();
|
||||
|
||||
|
||||
CordovaWebViewClient makeWebViewClient();
|
||||
|
||||
CordovaChromeClient makeChromeClient();
|
||||
|
||||
CordovaChromeClient makeWebChromeClient();
|
||||
|
||||
void setWebViewClient(CordovaWebViewClient webViewClient);
|
||||
|
||||
|
||||
@@ -494,9 +494,22 @@ public class NativeToJsMessageQueue {
|
||||
.append(success)
|
||||
.append(",")
|
||||
.append(status)
|
||||
.append(",[")
|
||||
.append(pluginResult.getMessage())
|
||||
.append("],")
|
||||
.append(",[");
|
||||
switch (pluginResult.getMessageType()) {
|
||||
case PluginResult.MESSAGE_TYPE_BINARYSTRING:
|
||||
sb.append("atob('")
|
||||
.append(pluginResult.getMessage())
|
||||
.append("')");
|
||||
break;
|
||||
case PluginResult.MESSAGE_TYPE_ARRAYBUFFER:
|
||||
sb.append("cordova.require('cordova/base64').toArrayBuffer('")
|
||||
.append(pluginResult.getMessage())
|
||||
.append("')");
|
||||
break;
|
||||
default:
|
||||
sb.append(pluginResult.getMessage());
|
||||
}
|
||||
sb.append("],")
|
||||
.append(pluginResult.getKeepCallback())
|
||||
.append(");");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user