Skip to content

Commit

Permalink
Merge pull request #35793 from CleverRaven/android-2019-12-01
Browse files Browse the repository at this point in the history
Updated Android SDL activity
  • Loading branch information
ZhilkinSerg committed Nov 30, 2019
2 parents 7845cd8 + b20eb0d commit 246e5f9
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions android/app/src/main/java/org/libsdl/app/SDLActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2124,17 +2124,24 @@ public boolean onKey(View v, int keyCode, KeyEvent event) {
//
@Override
public boolean onKeyPreIme (int keyCode, KeyEvent event) {
// HACK: Make sure the SDL activity receives native events for back button, even if DummyEdit is in focus
if (keyCode == KeyEvent.KEYCODE_BACK) {
if (event.getAction()==KeyEvent.ACTION_DOWN)
SDLActivity.onNativeKeyDown(keyCode);
else if (event.getAction()==KeyEvent.ACTION_UP)
SDLActivity.onNativeKeyUp(keyCode);
}
// As seen on StackOverflow: http://stackoverflow.com/questions/7634346/keyboard-hide-event
// FIXME: Discussion at http://bugzilla.libsdl.org/show_bug.cgi?id=1639
// FIXME: This is not a 100% effective solution to the problem of detecting if the keyboard is showing or not
// FIXME: A more effective solution would be to assume our Layout to be RelativeLayout or LinearLayout
// FIXME: And determine the keyboard presence doing this: http://stackoverflow.com/questions/2150078/how-to-check-visibility-of-software-keyboard-in-android
// FIXME: An even more effective way would be if Android provided this out of the box, but where would the fun be in that :)
if (event.getAction()==KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {
if (SDLActivity.mTextEdit != null && SDLActivity.mTextEdit.getVisibility() == View.VISIBLE) {
SDLActivity.onNativeKeyboardFocusLost();
}
}
//if (event.getAction()==KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {
// if (SDLActivity.mTextEdit != null && SDLActivity.mTextEdit.getVisibility() == View.VISIBLE) {
// SDLActivity.onNativeKeyboardFocusLost();
// }
//}
return super.onKeyPreIme(keyCode, event);
}

Expand Down

0 comments on commit 246e5f9

Please sign in to comment.