Merge pull request #2136 from keymanapp/android-js-stability

[Android] Improves keyboard swap stability
This commit is contained in:
Joshua Horton 2019-09-26 09:05:57 +07:00 • committed by GitHub
commit dac0f15adc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 4 deletions

View file

@ -190,6 +190,7 @@ final class KMKeyboard extends WebView {
public void loadKeyboard() {
keyboardSet = false;
this.javascriptAfterLoad.clear();
if(keyboardType == KeyboardType.KEYBOARD_TYPE_INAPP)
KMManager.InAppKeyboardLoaded = false;
@ -207,7 +208,9 @@ final class KMKeyboard extends WebView {
if((keyboardType == KeyboardType.KEYBOARD_TYPE_INAPP && KMManager.InAppKeyboardLoaded) ||
(keyboardType == KeyboardType.KEYBOARD_TYPE_SYSTEM && KMManager.SystemKeyboardLoaded)) {
if(this.javascriptAfterLoad.size() == 1)
// If !this.keyboardSet, then pageLoaded hasn't fired yet.
// When pageLoaded fires, it'll call `callJavascriptAfterLoad` safely.
if(this.javascriptAfterLoad.size() == 1 && keyboardSet)
callJavascriptAfterLoad();
}
}
@ -221,8 +224,11 @@ final class KMKeyboard extends WebView {
if(javascriptAfterLoad.size() > 0) {
loadUrl("javascript:" + javascriptAfterLoad.get(0));
javascriptAfterLoad.remove(0);
if (javascriptAfterLoad.size() > 0) {
callJavascriptAfterLoad();
// Make sure we didn't reset the page in the middle of the queue!
if(keyboardSet) {
if (javascriptAfterLoad.size() > 0) {
callJavascriptAfterLoad();
}
}
}
}

View file

@ -592,7 +592,16 @@ namespace com.keyman.osk {
// Build a layout using the default for the device
if(typeof layout != 'object' || layout == null) {
let kbdDevVersion = new utils.Version(activeKeyboard['KVER']);
var kbdDevVersion: utils.Version;
// This CAN be called with no backing keyboard; KMW will try to force-show
// the OSK even without a backing keyboard on mobile, using the default
// layout as the OSK's base.
if(activeKeyboard) {
kbdDevVersion = new utils.Version(activeKeyboard['KVER']);
} else {
kbdDevVersion = new utils.Version(keyman['version']);
}
layout=Layouts.buildDefaultLayout(PVK, kbdDevVersion, kbdBitmask, formFactor);
}