Let subclasses override focus behavior

Signed-off-by: Joe Bowser <bowserj@apache.org>
(cherry picked from commit 55865a4f1d)
This commit is contained in:
denis 2013-07-01 16:28:22 +08:00 committed by Andrew Grieve
parent e9b46e5cf6
commit 4be84fbf12

View File

@ -228,8 +228,9 @@ public class CordovaWebView extends WebView {
private void setup() {
this.setInitialScale(0);
this.setVerticalScrollBarEnabled(false);
if (shouldRequestFocusOnInit()) {
this.requestFocusFromTouch();
}
// Enable JavaScript
WebSettings settings = this.getSettings();
settings.setJavaScriptEnabled(true);
@ -309,6 +310,16 @@ public class CordovaWebView extends WebView {
exposeJsInterface();
}
/**
* 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();
}