Address TODO: Move requestFocusFromTouch() to CordovaActivity rather than AndroidWebView

This commit is contained in:
Andrew Grieve 2015-02-19 10:32:29 -05:00
parent fb0987b824
commit 804dcac12f
2 changed files with 2 additions and 20 deletions

View File

@ -163,16 +163,6 @@ public class AndroidWebView extends WebView implements CordovaWebView {
private void initWebViewSettings() {
this.setInitialScale(0);
this.setVerticalScrollBarEnabled(false);
// TODO: The Activity is the one that should call requestFocus().
if (shouldRequestFocusOnInit()) {
this.requestFocusFromTouch();
}
this.setInitialScale(0);
this.setVerticalScrollBarEnabled(false);
if (shouldRequestFocusOnInit()) {
this.requestFocusFromTouch();
}
// Enable JavaScript
final WebSettings settings = this.getSettings();
settings.setJavaScriptEnabled(true);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
@ -267,16 +257,6 @@ public class AndroidWebView extends WebView implements CordovaWebView {
}
}
/**
* Override this method to decide whether or not you need to request the
* focus when your application start
*
* @return true unless this method is overriden to return a different value
*/
protected boolean shouldRequestFocusOnInit() {
return true;
}
private void exposeJsInterface() {
if ((Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1)) {
Log.i(TAG, "Disabled addJavascriptInterface() bridge since Android version is old.");

View File

@ -147,6 +147,8 @@ public class CordovaActivity extends Activity {
if ("media".equals(volumePref.toLowerCase(Locale.ENGLISH))) {
setVolumeControlStream(AudioManager.STREAM_MUSIC);
}
appView.getView().requestFocusFromTouch();
}
@SuppressWarnings("deprecation")