From 7b7c93aed4b6cfede704cdc4a35b8da082d145df Mon Sep 17 00:00:00 2001 From: jahorton Date: Wed, 25 Sep 2019 14:38:42 +0700 Subject: [PATCH] Improves app stability, delays JS calls past page load --- .../main/java/com/tavultesoft/kmea/KMKeyboard.java | 4 +++- web/source/osk/visualKeyboard.ts | 11 ++++++++++- web/source/utils/version.ts | 3 +++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/android/KMEA/app/src/main/java/com/tavultesoft/kmea/KMKeyboard.java b/android/KMEA/app/src/main/java/com/tavultesoft/kmea/KMKeyboard.java index 3a5d26d555..0ab2c3c632 100644 --- a/android/KMEA/app/src/main/java/com/tavultesoft/kmea/KMKeyboard.java +++ b/android/KMEA/app/src/main/java/com/tavultesoft/kmea/KMKeyboard.java @@ -207,7 +207,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 && this.keyboardSet) callJavascriptAfterLoad(); } } diff --git a/web/source/osk/visualKeyboard.ts b/web/source/osk/visualKeyboard.ts index ca3d4573a5..07972bed78 100644 --- a/web/source/osk/visualKeyboard.ts +++ b/web/source/osk/visualKeyboard.ts @@ -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 = utils.Version.CURRENT; + } layout=Layouts.buildDefaultLayout(PVK, kbdDevVersion, kbdBitmask, formFactor); } diff --git a/web/source/utils/version.ts b/web/source/utils/version.ts index 3d43ee7ea8..48e75cb585 100644 --- a/web/source/utils/version.ts +++ b/web/source/utils/version.ts @@ -9,6 +9,9 @@ namespace com.keyman.utils { // as it results in unexpected, bug-like behavior for keyboard designers when it is unwanted. public static readonly NO_DEFAULT_KEYCAPS = new Version([12, 0]); + // Corresponds to the most recent known version of KMW and Keyman Developer. + public static readonly CURRENT = new Version([12, 0]); + private readonly components: number[] /**