diff --git a/android/KMEA/app/src/main/assets/android-host.js b/android/KMEA/app/src/main/assets/android-host.js index 1582c970f80..39ce3a5f307 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 d45937fe730..6788c8f90e0 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 @@ protected boolean updateSelectionRange() { 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 @@ protected boolean updateSelectionRange() { selMin -= pairsAtStart; selMax -= (pairsAtStart + pairsSelected); this.loadJavascript(KMString.format("updateKMSelectionRange(%d,%d)", selMin, selMax)); - + return true; } @@ -262,7 +262,7 @@ public void initKMKeyboard(final Context context) { // 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,26 +443,42 @@ public void onDestroy() { 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); + this.invalidate(); + this.requestLayout(); + this.dismissHelpBubble(); + + if(this.getShouldShowHelpBubble()) { + this.showHelpBubbleAfterDelay(2000); + } + } + + @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)", newConfig.screenWidthDp)); + 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)); - - this.dismissHelpBubble(); - - if(this.getShouldShowHelpBubble()) { - this.showHelpBubbleAfterDelay(2000); - } } public void dismissSuggestionMenuWindow() {