cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject git commit: CB-5756: Android: Use WebView.evaluateJavascript for script injection on Android 4.4+
Date Mon, 20 Jan 2014 02:22:35 GMT
Updated Branches:
  refs/heads/dev 0ce0eed58 -> e807bc3dc


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/e807bc3d
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/tree/e807bc3d
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/diff/e807bc3d

Branch: refs/heads/dev
Commit: e807bc3dc0f684212e43610a18f61e837a685c38
Parents: 0ce0eed
Author: Ian Clelland <iclelland@chromium.org>
Authored: Mon Jan 13 14:32:57 2014 -0500
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Sun Jan 19 21:22:02 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/e807bc3d/src/android/InAppBrowser.java
----------------------------------------------------------------------
diff --git a/src/android/InAppBrowser.java b/src/android/InAppBrowser.java
index 4efd99b..1a77c57 100644
--- a/src/android/InAppBrowser.java
+++ b/src/android/InAppBrowser.java
@@ -253,11 +253,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