You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2014/07/07 22:39:14 UTC

[2/3] android commit: Make setWebViewClient an override instead of an overload. Delete Location-change JS->Native bridge mode (missed some of it).

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


Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/caeb8684
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/caeb8684
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/caeb8684

Branch: refs/heads/master
Commit: caeb86843ddca712b5bf1dfbdac9005edce98100
Parents: 0f15608
Author: Andrew Grieve <ag...@chromium.org>
Authored: Mon Jul 7 16:31:29 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Mon Jul 7 16:31:29 2014 -0400

----------------------------------------------------------------------
 .../src/org/apache/cordova/CordovaActivity.java |  2 +-
 .../src/org/apache/cordova/CordovaWebView.java  | 31 +++++++-------------
 .../apache/cordova/CordovaWebViewClient.java    | 21 -------------
 3 files changed, 12 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/caeb8684/framework/src/org/apache/cordova/CordovaActivity.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaActivity.java b/framework/src/org/apache/cordova/CordovaActivity.java
index a3b6314..ff96667 100755
--- a/framework/src/org/apache/cordova/CordovaActivity.java
+++ b/framework/src/org/apache/cordova/CordovaActivity.java
@@ -319,7 +319,7 @@ public class CordovaActivity extends Activity implements CordovaInterface {
      * @param webView the default constructed web view object
      */
     protected CordovaChromeClient makeChromeClient(CordovaWebView webView) {
-        return webView.makeChromeClient(this);
+        return webView.makeWebChromeClient(this);
     }
 
     @Deprecated // No need to call init() anymore.

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/caeb8684/framework/src/org/apache/cordova/CordovaWebView.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaWebView.java b/framework/src/org/apache/cordova/CordovaWebView.java
index 8d0b4a9..8eae350 100755
--- a/framework/src/org/apache/cordova/CordovaWebView.java
+++ b/framework/src/org/apache/cordova/CordovaWebView.java
@@ -21,12 +21,10 @@ package org.apache.cordova;
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Locale;
-import java.util.Map;
 
 import org.apache.cordova.Config;
 import org.apache.cordova.CordovaInterface;
@@ -41,8 +39,6 @@ import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.PackageManager.NameNotFoundException;
 import android.net.Uri;
 import android.os.Build;
 import android.os.Bundle;
@@ -59,6 +55,7 @@ import android.webkit.WebChromeClient;
 import android.webkit.WebSettings;
 import android.webkit.WebView;
 import android.webkit.WebSettings.LayoutAlgorithm;
+import android.webkit.WebViewClient;
 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.
-    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) {
             throw new IllegalStateException();
         }
         this.cordova = cordova;
         this.viewClient = webViewClient;
-        this.chromeClient = chromeClient;
-        super.setWebChromeClient(chromeClient);
+        this.chromeClient = webChromeClient;
+        super.setWebChromeClient(webChromeClient);
         super.setWebViewClient(webViewClient);
 
         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);
     }
 
@@ -296,21 +293,15 @@ public class CordovaWebView extends WebView {
         this.addJavascriptInterface(exposedJsApi, "_cordovaNative");
     }
 
-    /**
-     * Set the WebViewClient.
-     */
-    @Deprecated // Set this in init() instead.
-    public void setWebViewClient(CordovaWebViewClient client) {
-        this.viewClient = client;
+    @Override
+    public void setWebViewClient(WebViewClient client) {
+        this.viewClient = (CordovaWebViewClient)client;
         super.setWebViewClient(client);
     }
 
-    /**
-     * Set the WebChromeClient.
-     */
-    @Deprecated // Set this in init() instead.
-    public void setWebChromeClient(CordovaChromeClient client) {
-        this.chromeClient = client;
+    @Override
+    public void setWebChromeClient(WebChromeClient client) {
+        this.chromeClient = (CordovaChromeClient)client;
         super.setWebChromeClient(client);
     }
     

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/caeb8684/framework/src/org/apache/cordova/CordovaWebViewClient.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaWebViewClient.java b/framework/src/org/apache/cordova/CordovaWebViewClient.java
index 65d8ff6..35dbea1 100755
--- a/framework/src/org/apache/cordova/CordovaWebViewClient.java
+++ b/framework/src/org/apache/cordova/CordovaWebViewClient.java
@@ -32,7 +32,6 @@ import android.content.pm.PackageManager;
 import android.content.pm.PackageManager.NameNotFoundException;
 import android.graphics.Bitmap;
 import android.net.http.SslError;
-import android.util.Log;
 import android.view.View;
 import android.webkit.HttpAuthHandler;
 import android.webkit.SslErrorHandler;
@@ -54,7 +53,6 @@ import android.webkit.WebViewClient;
 public class CordovaWebViewClient extends WebViewClient {
 
 	private static final String TAG = "CordovaWebViewClient";
-	private static final String CORDOVA_EXEC_URL_PREFIX = "http://cdv_exec/";
     CordovaInterface cordova;
     CordovaWebView appView;
     CordovaUriHelper helper;
@@ -92,25 +90,6 @@ public class CordovaWebViewClient extends WebViewClient {
         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
      * is about to be loaded in the current WebView.