Skip to content

Commit

Permalink
Don't request focus explicitly if not needed
Browse files Browse the repository at this point in the history
Requesting the focus explicitly actually makes the child WebView to move the focus to the first visible focusable element on the page. This makes it impossible to simply let the WebView restore the focus to the last focused element, before the activity was paused. To prevent this problem on devices other that the Samsung Galaxy Note 3, only request the focus if necessary (it might as well be possible that the original fix is not needed anymore on newer versions of Android and/or WebView).
  • Loading branch information
goffioul authored Jun 20, 2019
1 parent 4cf3dcf commit 01ab116
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions framework/src/org/apache/cordova/CordovaActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,11 @@ protected void onResume() {
if (this.appView == null) {
return;
}
// Force window to have focus, so application always
// receive user input. Workaround for some devices (Samsung Galaxy Note 3 at least)
this.getWindow().getDecorView().requestFocus();
if (! this.getWindow().getDecorView().hasFocus()) {
// Force window to have focus, so application always
// receive user input. Workaround for some devices (Samsung Galaxy Note 3 at least)
this.getWindow().getDecorView().requestFocus();
}

this.appView.handleResume(this.keepRunning);
}
Expand Down

0 comments on commit 01ab116

Please sign in to comment.