fix(android): Back button to dismiss system keyboard

Cherry-pick  #2950 and #3093 to stable-13.0

This allows the back button to dismiss the system keyboard if shown. Additional back-presses revert to default UI behavior.

As a throw-in, I made the same change to KMSample2
This commit is contained in:
Darcy Wong 2020-05-07 09:43:57 +07:00
parent 841afb9f53
commit 91c2e4a5a3
3 changed files with 28 additions and 0 deletions

View file

@ -209,6 +209,18 @@ public class SystemKeyboard extends InputMethodService implements OnKeyboardEven
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
// Dismiss the keyboard if currently shown
if (isInputViewShown()) {
KMManager.hideSystemKeyboard();
return true;
}
break;
}
}
return interpreter.onKeyDown(keyCode, event); // if false, will revert to default handling.
}

View file

@ -184,6 +184,18 @@ public class SystemKeyboard extends InputMethodService implements OnKeyboardEven
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
// Dismiss the keyboard if currently shown
if (isInputViewShown()) {
KMManager.hideSystemKeyboard();
return true;
}
break;
}
}
return interpreter.onKeyDown(keyCode, event); // if false, will revert to default handling.
}

View file

@ -1,5 +1,9 @@
# Keyman for Android Version History
## 2020-05-07 13.0.6210 stable
* Bug fix:
* Back button dismisses system keyboard ()
## 2020-04-20 13.0.6209 stable
* Bug fix:
* Fix crash involving system keyboard update notifications (#3007)