From 678edfa2281e70f7bfdc996c209ff5b17e786b8a Mon Sep 17 00:00:00 2001 From: "Joshua A. Horton" Date: Wed, 29 May 2024 12:33:03 +0700 Subject: [PATCH 1/5] fix(android): check current orientation when redisplaying system keyboard --- .../main/java/com/keyman/android/SystemKeyboard.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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..ad7e5e9ed3 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(); From 5c59512e95daf0385a15300c9919a7419ba91739 Mon Sep 17 00:00:00 2001 From: "Joshua A. Horton" Date: Thu, 30 May 2024 12:46:28 +0700 Subject: [PATCH 2/5] change(android): removes sys-keyboard config-change handler in favor of onStartInput version --- .../main/java/com/keyman/android/SystemKeyboard.java | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) 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 ad7e5e9ed3..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 @@ -180,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) { @@ -208,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); From d86833783d5bfdf0333f1a4d3365edbc1b8dd0dd Mon Sep 17 00:00:00 2001 From: "Joshua A. Horton" Date: Thu, 6 Jun 2024 14:02:18 +0700 Subject: [PATCH 3/5] fix(android): fix keyboard size after rotation and restore via onSizeChanged, after layout Fixes: #10054 --- .../KMEA/app/src/main/assets/android-host.js | 2 +- .../java/com/keyman/engine/KMKeyboard.java | 42 +++++++++++++------ 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/android/KMEA/app/src/main/assets/android-host.js b/android/KMEA/app/src/main/assets/android-host.js index 0c9af9a784..0fe1fc70a8 100644 --- a/android/KMEA/app/src/main/assets/android-host.js +++ b/android/KMEA/app/src/main/assets/android-host.js @@ -129,7 +129,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()) { From 288c0a52860818a5d12ef1bbbc7689a0250f33ec Mon Sep 17 00:00:00 2001 From: Keyman Build Agent Date: Sat, 8 Jun 2024 14:05:30 -0400 Subject: [PATCH 4/5] auto: increment master version to 18.0.53 --- HISTORY.md | 7 +++++++ VERSION.md | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) 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 From fb67d1ddf584e9750247e24fe997f50cb263c7d2 Mon Sep 17 00:00:00 2001 From: "Joshua A. Horton" Date: Mon, 10 Jun 2024 13:58:17 +0700 Subject: [PATCH 5/5] fix(developer): fix include paths Backslashes in paths are Windows-only, may have caused recent *nix CI-build failures. --- .../kmcmplib/tests/gtest-compiler-test.cpp | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp index 7d9dd97245..61d6c03aa9 100644 --- a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp +++ b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp @@ -1,12 +1,12 @@ #include -#include "..\include\kmcompx.h" -#include "..\include\kmcmplibapi.h" -#include "..\src\kmx_u16.h" -#include "..\src\compfile.h" -#include "..\src\CompMsg.h" -#include "..\..\common\include\kmn_compiler_errors.h" -#include "..\..\..\..\common\include\km_types.h" -#include "..\..\..\..\common\include\kmx_file.h" +#include "../include/kmcompx.h" +#include "../include/kmcmplibapi.h" +#include "../src/kmx_u16.h" +#include "../src/compfile.h" +#include "../src/CompMsg.h" +#include "../../common/include/kmn_compiler_errors.h" +#include "../../../../common/include/km_types.h" +#include "../../../../common/include/kmx_file.h" PKMX_WCHAR strtowstr(PKMX_STR in); PKMX_STR wstrtostr(PKMX_WCHAR in); @@ -45,7 +45,7 @@ class CompilerTest : public testing::Test { void TearDown() override { deleteFileKeyboard(fileKeyboard); } - + void initGlobals() { msgproc = NULL; szText_stub[0] = '\0'; @@ -175,7 +175,7 @@ TEST_F(CompilerTest, AddCompileError_test) { EXPECT_EQ(0, strcmp(expected, szText_stub)); ErrExtraLIB[0] = '\0'; EXPECT_EQ(5, kmcmp::nErrors); - + // msgproc returns FALSE msgproc = msgproc_false_stub; EXPECT_EQ(CERR_ERROR, CERR_InvalidLayoutLine & CERR_ERROR); @@ -249,7 +249,7 @@ TEST_F(CompilerTest, IsValidKeyboardVersion_test) { EXPECT_FALSE(IsValidKeyboardVersion((KMX_WCHAR *)u"")); EXPECT_FALSE(IsValidKeyboardVersion((KMX_WCHAR *)u" ")); EXPECT_FALSE(IsValidKeyboardVersion((KMX_WCHAR *)u"\t")); - EXPECT_FALSE(IsValidKeyboardVersion((KMX_WCHAR *)u" 1.1")); + EXPECT_FALSE(IsValidKeyboardVersion((KMX_WCHAR *)u" 1.1")); EXPECT_TRUE(IsValidKeyboardVersion((KMX_WCHAR *)u"1.1")); EXPECT_TRUE(IsValidKeyboardVersion((KMX_WCHAR *)u"1.0")); EXPECT_FALSE(IsValidKeyboardVersion((KMX_WCHAR *)u"1.")); @@ -310,7 +310,7 @@ TEST_F(CompilerTest, GetXStringImpl_type_xd_test) { u16cpy(str, u"x10330"); // Gothic A EXPECT_EQ(CERR_None, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); const KMX_WCHAR tstr_GothicA[] = { 0xD800, 0xDF30, 0 }; // see UTF32ToUTF16 - EXPECT_EQ(0, u16cmp(tstr_GothicA, tstr)); + EXPECT_EQ(0, u16cmp(tstr_GothicA, tstr)); // decimal 8-bit u16cpy(str, u"d18"); @@ -370,10 +370,10 @@ TEST_F(CompilerTest, GetXStringImpl_type_double_quote_test) { // CERR_UnterminatedString u16cpy(str, u"\"abc"); EXPECT_EQ(CERR_UnterminatedString, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); - + // CERR_ExtendedStringTooLong u16cpy(str, u"\"abc\""); - EXPECT_EQ(CERR_ExtendedStringTooLong, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 2, 0, &newp, FALSE)); // max reduced to force error + EXPECT_EQ(CERR_ExtendedStringTooLong, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 2, 0, &newp, FALSE)); // max reduced to force error // CERR_StringInVirtualKeySection *** TODO *** } @@ -393,10 +393,10 @@ TEST_F(CompilerTest, GetXStringImpl_type_single_quote_test) { // CERR_UnterminatedString u16cpy(str, u"\'abc"); EXPECT_EQ(CERR_UnterminatedString, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 80, 0, &newp, FALSE)); - + // CERR_ExtendedStringTooLong u16cpy(str, u"\'abc\'"); - EXPECT_EQ(CERR_ExtendedStringTooLong, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 2, 0, &newp, FALSE)); // max reduced to force error + EXPECT_EQ(CERR_ExtendedStringTooLong, GetXStringImpl(tstr, &fileKeyboard, str, u"", output, 2, 0, &newp, FALSE)); // max reduced to force error // CERR_StringInVirtualKeySection *** TODO *** }