Make setWebViewClient an override instead of an overload. Delete Location-change JS->Native bridge mode (missed some of it).

This commit is contained in:
Andrew Grieve 2014-07-07 16:31:29 -04:00
parent 0f15608175
commit caeb86843d
3 changed files with 12 additions and 42 deletions

View File

@ -319,7 +319,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
* @param webView the default constructed web view object * @param webView the default constructed web view object
*/ */
protected CordovaChromeClient makeChromeClient(CordovaWebView webView) { protected CordovaChromeClient makeChromeClient(CordovaWebView webView) {
return webView.makeChromeClient(this); return webView.makeWebChromeClient(this);
} }
@Deprecated // No need to call init() anymore. @Deprecated // No need to call init() anymore.

View File

@ -21,12 +21,10 @@ package org.apache.cordova;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map;
import org.apache.cordova.Config; import org.apache.cordova.Config;
import org.apache.cordova.CordovaInterface; import org.apache.cordova.CordovaInterface;
@ -41,8 +39,6 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
@ -59,6 +55,7 @@ import android.webkit.WebChromeClient;
import android.webkit.WebSettings; import android.webkit.WebSettings;
import android.webkit.WebView; import android.webkit.WebView;
import android.webkit.WebSettings.LayoutAlgorithm; import android.webkit.WebSettings.LayoutAlgorithm;
import android.webkit.WebViewClient;
import android.widget.FrameLayout; import android.widget.FrameLayout;
/* /*
@ -145,14 +142,14 @@ public class CordovaWebView extends WebView {
} }
// Use two-phase init so that the control will work with XML layouts. // Use two-phase init so that the control will work with XML layouts.
public void init(CordovaInterface cordova, CordovaWebViewClient webViewClient, CordovaChromeClient chromeClient, List<PluginEntry> pluginEntries) { public void init(CordovaInterface cordova, CordovaWebViewClient webViewClient, CordovaChromeClient webChromeClient, List<PluginEntry> pluginEntries) {
if (this.cordova != null) { if (this.cordova != null) {
throw new IllegalStateException(); throw new IllegalStateException();
} }
this.cordova = cordova; this.cordova = cordova;
this.viewClient = webViewClient; this.viewClient = webViewClient;
this.chromeClient = chromeClient; this.chromeClient = webChromeClient;
super.setWebChromeClient(chromeClient); super.setWebChromeClient(webChromeClient);
super.setWebViewClient(webViewClient); super.setWebViewClient(webViewClient);
pluginManager = new PluginManager(this, this.cordova, pluginEntries); pluginManager = new PluginManager(this, this.cordova, pluginEntries);
@ -264,7 +261,7 @@ public class CordovaWebView extends WebView {
} }
} }
public CordovaChromeClient makeChromeClient(CordovaInterface cordova) { public CordovaChromeClient makeWebChromeClient(CordovaInterface cordova) {
return new CordovaChromeClient(cordova, this); return new CordovaChromeClient(cordova, this);
} }
@ -296,21 +293,15 @@ public class CordovaWebView extends WebView {
this.addJavascriptInterface(exposedJsApi, "_cordovaNative"); this.addJavascriptInterface(exposedJsApi, "_cordovaNative");
} }
/** @Override
* Set the WebViewClient. public void setWebViewClient(WebViewClient client) {
*/ this.viewClient = (CordovaWebViewClient)client;
@Deprecated // Set this in init() instead.
public void setWebViewClient(CordovaWebViewClient client) {
this.viewClient = client;
super.setWebViewClient(client); super.setWebViewClient(client);
} }
/** @Override
* Set the WebChromeClient. public void setWebChromeClient(WebChromeClient client) {
*/ this.chromeClient = (CordovaChromeClient)client;
@Deprecated // Set this in init() instead.
public void setWebChromeClient(CordovaChromeClient client) {
this.chromeClient = client;
super.setWebChromeClient(client); super.setWebChromeClient(client);
} }

View File

@ -32,7 +32,6 @@ import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.PackageManager.NameNotFoundException;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.net.http.SslError; import android.net.http.SslError;
import android.util.Log;
import android.view.View; import android.view.View;
import android.webkit.HttpAuthHandler; import android.webkit.HttpAuthHandler;
import android.webkit.SslErrorHandler; import android.webkit.SslErrorHandler;
@ -54,7 +53,6 @@ import android.webkit.WebViewClient;
public class CordovaWebViewClient extends WebViewClient { public class CordovaWebViewClient extends WebViewClient {
private static final String TAG = "CordovaWebViewClient"; private static final String TAG = "CordovaWebViewClient";
private static final String CORDOVA_EXEC_URL_PREFIX = "http://cdv_exec/";
CordovaInterface cordova; CordovaInterface cordova;
CordovaWebView appView; CordovaWebView appView;
CordovaUriHelper helper; CordovaUriHelper helper;
@ -92,25 +90,6 @@ public class CordovaWebViewClient extends WebViewClient {
helper = new CordovaUriHelper(cordova, view); helper = new CordovaUriHelper(cordova, view);
} }
// Parses commands sent by setting the webView's URL to:
// cdvbrg:service/action/callbackId#jsonArgs
private void handleExecUrl(String url) {
int idx1 = CORDOVA_EXEC_URL_PREFIX.length();
int idx2 = url.indexOf('#', idx1 + 1);
int idx3 = url.indexOf('#', idx2 + 1);
int idx4 = url.indexOf('#', idx3 + 1);
if (idx1 == -1 || idx2 == -1 || idx3 == -1 || idx4 == -1) {
Log.e(TAG, "Could not decode URL command: " + url);
return;
}
String service = url.substring(idx1, idx2);
String action = url.substring(idx2 + 1, idx3);
String callbackId = url.substring(idx3 + 1, idx4);
String jsonArgs = url.substring(idx4 + 1);
appView.pluginManager.exec(service, action, callbackId, jsonArgs);
}
/** /**
* Give the host application a chance to take over the control when a new url * Give the host application a chance to take over the control when a new url
* is about to be loaded in the current WebView. * is about to be loaded in the current WebView.