You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bo...@apache.org on 2012/03/30 22:28:43 UTC

android commit: Move the callback server into the View, preparing to start CordovaWebView testing

Updated Branches:
  refs/heads/CordovaWebView 49b50ce66 -> 2818e05e7


Move the callback server into the View, preparing to start CordovaWebView testing


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

Branch: refs/heads/CordovaWebView
Commit: 2818e05e71e6774427692ca60a4ab7cf655b5c53
Parents: 49b50ce
Author: Joe Bowser <bo...@apache.org>
Authored: Fri Mar 30 13:28:19 2012 -0700
Committer: Joe Bowser <bo...@apache.org>
Committed: Fri Mar 30 13:28:19 2012 -0700

----------------------------------------------------------------------
 .../src/org/apache/cordova/CordovaWebView.java     |   31 ++++++++++++++-
 framework/src/org/apache/cordova/DroidGap.java     |   13 +++---
 2 files changed, 36 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/2818e05e/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 461bbe4..fad4ffe 100644
--- a/framework/src/org/apache/cordova/CordovaWebView.java
+++ b/framework/src/org/apache/cordova/CordovaWebView.java
@@ -15,9 +15,11 @@ import org.xmlpull.v1.XmlPullParserException;
 import android.content.Context;
 import android.content.res.XmlResourceParser;
 import android.util.AttributeSet;
+import android.webkit.WebChromeClient;
 import android.webkit.WebSettings;
 import android.webkit.WebView;
 import android.webkit.WebSettings.LayoutAlgorithm;
+import android.webkit.WebViewClient;
 
 public class CordovaWebView extends WebView {
   
@@ -30,9 +32,12 @@ public class CordovaWebView extends WebView {
   private ArrayList<Pattern> whiteList = new ArrayList<Pattern>();
   private HashMap<String, Boolean> whiteListCache = new HashMap<String,Boolean>();
   protected PluginManager pluginManager;
-  
+  public CallbackServer callbackServer;
+
   /** Actvities and other important classes **/
   private Context mCtx;
+  private CordovaWebViewClient viewClient;
+  private CordovaChromeClient chromeClient;
 
   public CordovaWebView(Context context) {
     super(context);
@@ -241,4 +246,28 @@ public class CordovaWebView extends WebView {
       return false;
   }
   
+  @Override
+  public void setWebViewClient(WebViewClient client) {
+    if(client.getClass().equals(CordovaWebView.class)) {
+      viewClient = (CordovaWebViewClient) client;
+      super.setWebViewClient(viewClient);
+    }
+    else
+    {
+      //This should throw an exception!
+    }
+  }
+  
+  @Override
+  public void setWebChromeClient(WebChromeClient client) {
+    if(client.getClass().equals(CordovaWebView.class)) {
+      chromeClient = (CordovaChromeClient) client;
+      super.setWebChromeClient(chromeClient);
+    }
+    else
+    {
+      //This should throw an exception!
+    }
+  }
+  
 }

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/2818e05e/framework/src/org/apache/cordova/DroidGap.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/DroidGap.java b/framework/src/org/apache/cordova/DroidGap.java
index 35d31b3..d6e64cd 100755
--- a/framework/src/org/apache/cordova/DroidGap.java
+++ b/framework/src/org/apache/cordova/DroidGap.java
@@ -155,7 +155,6 @@ public class DroidGap extends Activity implements CordovaInterface {
 
     protected LinearLayout root;
     public boolean bound = false;
-    public CallbackServer callbackServer;
     protected boolean cancelLoadUrl = false;
     protected ProgressDialog spinnerDialog = null;
 
@@ -380,12 +379,12 @@ public class DroidGap extends Activity implements CordovaInterface {
                 me.appView.clearHistory();
             
                 // Create callback server and plugin manager
-                if (me.callbackServer == null) {
-                    me.callbackServer = new CallbackServer();
-                    me.callbackServer.init(url);
+                if (me.appView.callbackServer == null) {
+                    me.appView.callbackServer = new CallbackServer();
+                    me.appView.callbackServer.init(url);
                 }
                 else {
-                    me.callbackServer.reinit(url);
+                    me.appView.callbackServer.reinit(url);
                 }
                 appView.pluginManager.init();
                 
@@ -833,8 +832,8 @@ public class DroidGap extends Activity implements CordovaInterface {
      */
     public void sendJavascript(String statement) {
         //We need to check for the null case on the Kindle Fire beacuse it changes the width and height on load
-        if(this.callbackServer != null)
-          this.callbackServer.sendJavascript(statement);
+        if(this.appView.callbackServer != null)
+          this.appView.callbackServer.sendJavascript(statement);
     }
 
     /**