From adc5d16297f2ce752df50f0642e7dfecc98bad82 Mon Sep 17 00:00:00 2001 From: Philipp Schaefer Date: Fri, 24 Jan 2014 00:16:43 +0100 Subject: [PATCH] workaround: always enable JS if webview has focus. fixes select box spinner close behavior on Android 4.4 --- code/smartphone.js | 3 --- mobile/src/com/cradle/iitc_mobile/IITC_JSInterface.java | 1 - mobile/src/com/cradle/iitc_mobile/IITC_WebView.java | 2 ++ 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/code/smartphone.js b/code/smartphone.js index d01d2545..c9133aab 100644 --- a/code/smartphone.js +++ b/code/smartphone.js @@ -144,9 +144,6 @@ window.runOnSmartphonesAfterBoot = function() { $("body").on("click", "select", function() { android.spinnerEnabled(true); }); - $("body").on("focus", "select", function() { - android.spinnerEnabled(false); - }); } // add event to portals that allows long press to switch to sidebar diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_JSInterface.java b/mobile/src/com/cradle/iitc_mobile/IITC_JSInterface.java index cd7aee85..78080700 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_JSInterface.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_JSInterface.java @@ -46,7 +46,6 @@ public class IITC_JSInterface { // prevent the spinner from closing automatically @JavascriptInterface public void spinnerEnabled(boolean en) { - Log.d("disableJS? " + en); mIitc.getWebView().disableJS(en); } diff --git a/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java b/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java index 19781705..9963e432 100644 --- a/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java +++ b/mobile/src/com/cradle/iitc_mobile/IITC_WebView.java @@ -171,6 +171,8 @@ public class IITC_WebView extends WebView { public void onWindowFocusChanged(final boolean hasWindowFocus) { if (hasWindowFocus) { getHandler().postDelayed(mNavHider, 3000); + // if the webView has focus, JS should always be enabled + mDisableJs = false; } else { getHandler().removeCallbacks(mNavHider); }