chore(developer): Merge branch 'master' into test/developer/kmcmplib-compiler-unit-tests-2

# Keyman Conventional Commit suggestions:
#
# - Link to a Sentry issue with git trailer:
#     Fixes: _MODULE_-_ID_
# - Give credit to co-authors:
#     Co-authored-by: _Name_ <_email_>
# - Use imperative, present tense ('attach' not 'attaches', 'attached' etc)
# - Don't include a period at the end of the title
# - Always include a blank line before trailers
# - More: https://github.com/keymanapp/keyman/wiki/Pull-Request-and-Commit-workflow-notes
This commit is contained in:
Dr Mark C. Sinclair 2024-06-10 11:45:08 +01:00
commit 0bf8c6bbd6
5 changed files with 49 additions and 26 deletions

View file

@ -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)

View file

@ -1 +1 @@
18.0.52
18.0.53

View file

@ -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);

View file

@ -145,7 +145,7 @@ function setOskHeight(h) {
function setOskWidth(w) {
if(w > 0) {
oskWidth = w;
oskWidth = w / window.devicePixelRatio;
}
}

View file

@ -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()) {