From 4be84fbf124639525f4d1308e29619e28096e620 Mon Sep 17 00:00:00 2001 From: denis Date: Mon, 1 Jul 2013 16:28:22 +0800 Subject: [PATCH] Let subclasses override focus behavior Signed-off-by: Joe Bowser (cherry picked from commit 55865a4f1dcd0f24df5292e3621b77080939e6e1) --- .../org/apache/cordova/CordovaWebView.java | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/framework/src/org/apache/cordova/CordovaWebView.java b/framework/src/org/apache/cordova/CordovaWebView.java index 278bfa44..648b1f88 100755 --- a/framework/src/org/apache/cordova/CordovaWebView.java +++ b/framework/src/org/apache/cordova/CordovaWebView.java @@ -228,9 +228,10 @@ public class CordovaWebView extends WebView { private void setup() { this.setInitialScale(0); this.setVerticalScrollBarEnabled(false); - this.requestFocusFromTouch(); - - // Enable JavaScript + if (shouldRequestFocusOnInit()) { + this.requestFocusFromTouch(); + } + // Enable JavaScript WebSettings settings = this.getSettings(); settings.setJavaScriptEnabled(true); settings.setJavaScriptCanOpenWindowsAutomatically(true); @@ -308,8 +309,18 @@ public class CordovaWebView extends WebView { exposedJsApi = new ExposedJsApi(pluginManager, jsMessageQueue); exposeJsInterface(); } - - private void updateUserAgentString() { + + /** + * Override this method to decide wether or not you need to request the + * focus when your application start + * + * @return + */ + protected boolean shouldRequestFocusOnInit() { + return true; + } + + private void updateUserAgentString() { this.getSettings().getUserAgentString(); }