diff --git a/HISTORY.md b/HISTORY.md index 3f6bdeda65..30e4c59a51 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,12 @@ # Keyman Version History +## 18.0.52 alpha 2024-06-08 + +* fix(developer): prevent two touch layout editors opening for the same file (#11717) +* chore(common): cleanup meson deprecations and warnings (#11523) +* feat(developer): support language reference in context help (#11737) +* test(developer): kmcmplib compiler unit tests (#11378) + ## 18.0.51 alpha 2024-06-07 * fix(web): fix osk touch-focus tracking (#11705) diff --git a/VERSION.md b/VERSION.md index 7f0a827856..ff065a7a5f 100644 --- a/VERSION.md +++ b/VERSION.md @@ -1 +1 @@ -18.0.52 \ No newline at end of file +18.0.53 \ No newline at end of file diff --git a/android/KMAPro/kMAPro/src/main/java/com/keyman/android/SystemKeyboard.java b/android/KMAPro/kMAPro/src/main/java/com/keyman/android/SystemKeyboard.java index cf32ba0c00..c6885b2b56 100644 --- a/android/KMAPro/kMAPro/src/main/java/com/keyman/android/SystemKeyboard.java +++ b/android/KMAPro/kMAPro/src/main/java/com/keyman/android/SystemKeyboard.java @@ -147,6 +147,16 @@ public class SystemKeyboard extends InputMethodService implements OnKeyboardEven KMManager.onStartInput(attribute, restarting); KMManager.resetContext(KeyboardType.KEYBOARD_TYPE_SYSTEM); + // This method (likely) includes the IME equivalent to `onResume` for `Activity`-based classes, + // making it an important time to detect orientation changes. + Context appContext = getApplicationContext(); + int newOrientation = KMManager.getOrientation(appContext); + if(newOrientation != lastOrientation) { + lastOrientation = newOrientation; + Configuration newConfig = this.getResources().getConfiguration(); + KMManager.onConfigurationChanged(newConfig); + } + // Temporarily disable predictions on certain fields (e.g. hidden password field or numeric) int inputType = attribute.inputType; KMManager.setMayPredictOverride(inputType); @@ -154,7 +164,6 @@ public class SystemKeyboard extends InputMethodService implements OnKeyboardEven KMManager.setBannerOptions(false); } else if (KMManager.isKeyboardLoaded(KeyboardType.KEYBOARD_TYPE_SYSTEM)){ // Check if predictions needs to be re-enabled per Settings preference - Context appContext = getApplicationContext(); Keyboard kbInfo = KMManager.getCurrentKeyboardInfo(appContext); if (kbInfo != null) { String langId = kbInfo.getLanguageID(); @@ -171,7 +180,7 @@ public class SystemKeyboard extends InputMethodService implements OnKeyboardEven ExtractedText icText = ic.getExtractedText(new ExtractedTextRequest(), 0); /* We do sometimes receive null `icText.text`, even though - getExtractedText() docs does not list this as a possible + getExtractedText() docs does not list this as a possible return value, so we test for that as well (#11479) */ if (icText != null && icText.text != null) { @@ -199,15 +208,6 @@ public class SystemKeyboard extends InputMethodService implements OnKeyboardEven super.onUpdateExtractingVisibility(ei); } - @Override - public void onConfigurationChanged(Configuration newConfig) { - super.onConfigurationChanged(newConfig); - if (newConfig.orientation != lastOrientation) { - lastOrientation = newConfig.orientation; - KMManager.onConfigurationChanged(newConfig); - } - } - @Override public void onConfigureWindow(Window win, boolean isFullscreen, boolean isCandidatesOnly) { super.onConfigureWindow(win, isFullscreen, isCandidatesOnly); diff --git a/android/KMEA/app/src/main/assets/android-host.js b/android/KMEA/app/src/main/assets/android-host.js index 1582c970f8..39ce3a5f30 100644 --- a/android/KMEA/app/src/main/assets/android-host.js +++ b/android/KMEA/app/src/main/assets/android-host.js @@ -145,7 +145,7 @@ function setOskHeight(h) { function setOskWidth(w) { if(w > 0) { - oskWidth = w; + oskWidth = w / window.devicePixelRatio; } } diff --git a/android/KMEA/app/src/main/java/com/keyman/engine/KMKeyboard.java b/android/KMEA/app/src/main/java/com/keyman/engine/KMKeyboard.java index d45937fe73..6788c8f90e 100644 --- a/android/KMEA/app/src/main/java/com/keyman/engine/KMKeyboard.java +++ b/android/KMEA/app/src/main/java/com/keyman/engine/KMKeyboard.java @@ -195,13 +195,13 @@ final class KMKeyboard extends WebView { int selMin = icText.selectionStart, selMax = icText.selectionEnd; int textLength = rawText.length(); - + if (selMin < 0 || selMax < 0) { // There is no selection or cursor // Reference https://developer.android.com/reference/android/text/Selection#getSelectionEnd(java.lang.CharSequence) return false; } else if (selMin > textLength || selMax > textLength) { - // Selection is past end of existing text -- should not be possible but we + // Selection is past end of existing text -- should not be possible but we // are seeing it happen; #11506 return false; } @@ -231,7 +231,7 @@ final class KMKeyboard extends WebView { selMin -= pairsAtStart; selMax -= (pairsAtStart + pairsSelected); this.loadJavascript(KMString.format("updateKMSelectionRange(%d,%d)", selMin, selMax)); - + return true; } @@ -262,7 +262,7 @@ final class KMKeyboard extends WebView { // When `.isTestMode() == true`, the setWebContentsDebuggingEnabled method is not available // and thus will trigger unit-test failures. if (!KMManager.isTestMode() && ( - (context.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0 || + (context.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0 || KMManager.getTier(null) != KMManager.Tier.STABLE )) { // Enable debugging of WebView via adb. Not used during unit tests @@ -443,20 +443,15 @@ final class KMKeyboard extends WebView { dismissHelpBubble(); } + @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); RelativeLayout.LayoutParams params = KMManager.getKeyboardLayoutParams(); + // I suspect this is the part we should actually be calling directly... this.setLayoutParams(params); - - int bannerHeight = KMManager.getBannerHeight(context); - int oskHeight = KMManager.getKeyboardHeight(context); - if (this.htmlBannerString != null && !this.htmlBannerString.isEmpty()) { - setHTMLBanner(this.htmlBannerString); - } - loadJavascript(KMString.format("setBannerHeight(%d)", bannerHeight)); - loadJavascript(KMString.format("setOskWidth(%d)", newConfig.screenWidthDp)); - loadJavascript(KMString.format("setOskHeight(%d)", oskHeight)); + this.invalidate(); + this.requestLayout(); this.dismissHelpBubble(); @@ -465,6 +460,27 @@ final class KMKeyboard extends WebView { } } + @Override + public void onSizeChanged(int width, int height, int oldWidth, int oldHeight) { + super.onSizeChanged(width, height, oldWidth, oldHeight); + int bannerHeight = KMManager.getBannerHeight(context); + int oskHeight = KMManager.getKeyboardHeight(context); + + if(bannerHeight + oskHeight != height) { + // We'll proceed, but cautiously and with logging. + KMLog.LogInfo(TAG, "Height mismatch: onSizeChanged = " + height + ", our version = " + (bannerHeight + oskHeight)); + } + + if (this.htmlBannerString != null && !this.htmlBannerString.isEmpty()) { + setHTMLBanner(this.htmlBannerString); + } + + loadJavascript(KMString.format("setBannerHeight(%d)", bannerHeight)); + loadJavascript(KMString.format("setOskWidth(%d)", width)); + // Must be last - it's the one that triggers a Web-engine layout refresh. + loadJavascript(KMString.format("setOskHeight(%d)", oskHeight)); + } + public void dismissSuggestionMenuWindow() { try { if (suggestionMenuWindow != null && suggestionMenuWindow.isShowing()) {