cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From i..@apache.org
Subject git commit: CB-5756: Android: Use WebView.evaluateJavascript for script injection on Android 4.4+
Date Mon, 13 Jan 2014 19:34:50 GMT
Updated Branches:
  refs/heads/dev 21fe13e80 -> 255c5269c


CB-5756: Android: Use WebView.evaluateJavascript for script injection on Android 4.4+


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/commit/255c5269
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/tree/255c5269
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/diff/255c5269

Branch: refs/heads/dev
Commit: 255c5269c37430c3bddfbbf5f116f57c5c174507
Parents: 21fe13e
Author: Ian Clelland <iclelland@chromium.org>
Authored: Mon Jan 13 14:32:57 2014 -0500
Committer: Ian Clelland <iclelland@chromium.org>
Committed: Mon Jan 13 14:34:32 2014 -0500

----------------------------------------------------------------------
 src/android/InAppBrowser.java | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/255c5269/src/android/InAppBrowser.java
----------------------------------------------------------------------
diff --git a/src/android/InAppBrowser.java b/src/android/InAppBrowser.java
index 34e96d9..1c6a859 100644
--- a/src/android/InAppBrowser.java
+++ b/src/android/InAppBrowser.java
@@ -251,11 +251,16 @@ public class InAppBrowser extends CordovaPlugin {
             scriptToInject = source;
         }
         final String finalScriptToInject = scriptToInject;
-        // This action will have the side-effect of blurring the currently focused element
         this.cordova.getActivity().runOnUiThread(new Runnable() {
+            @SuppressLint("NewApi")
             @Override
             public void run() {
-                inAppWebView.loadUrl("javascript:" + finalScriptToInject);
+                if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
+                    // This action will have the side-effect of blurring the currently focused
element
+                    inAppWebView.loadUrl("javascript:" + finalScriptToInject);
+                } else {
+                    inAppWebView.evaluateJavascript(finalScriptToInject, null);
+                }
             }
         });
     }


Mime
View raw message