-
-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
change(android): smoother keyboard initialization ✨ #10022
Conversation
User Test ResultsTest specification and instructions
Test Artifacts
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got curious about if this approach is even possible these days for iOS as well; figured I'd document what I could find in that regard.
@@ -62,6 +64,21 @@ public int getKeyboardWidth() { | |||
return kbWidth; | |||
} | |||
|
|||
@JavascriptInterface | |||
public String initialKeyboard() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we wanted to adopt something kinda similar for iOS:
https://developer.apple.com/documentation/webkit/wkscriptmessagehandlerwithreply
We could then reply
with a stub string like the one this method builds, passing it through that Swift function's 'reply' callback for use and interpretation. (See the other comment in this batch.)
But... this is only available with iOS 14.0+.
@@ -31,6 +31,10 @@ function init() { | |||
keyman.getOskHeight = getOskHeight; | |||
keyman.getOskWidth = getOskWidth; | |||
keyman.beepKeyboard = beepKeyboard; | |||
|
|||
// Readies the keyboard stub for instant loading during the init process. | |||
KeymanWeb.registerStub(JSON.parse(jsInterface.initialKeyboard())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uses the function defined within this PR within the Java KMKeyboardJSHandler
class. See other comment (re https://developer.apple.com/documentation/webkit/wkscriptmessagehandlerwithreply) on how this could look for iOS if we wanted to go that route.
That said, I don't see the problem this PR addresses on my personal iOS device. So, adopting this code for use on iOS can probably be low-priority for now.
Changes in this pull request will be available for download in Keyman version 17.0.221-alpha |
Continuing from #10017, this PR adds a few more tweaks to further smooth certain aspects of keyboard use.
One thing I happened upon while investigating the keyboard-load process:
That tidbit above surfaces as a keyboard-initialization flash whenever the host-page is loaded - be it the first time or a reset. It's what happens when Web loads on touch without an available keyboard stub... corresponding to an old warning about how "no keyboard stubs exist". It seems that the flash has become slower / more prominent recently... possibly due to side effects from the Web modularization work?
One way to resolve that issue: make sure that a valid keyboard stub is available before the embedded version of KMW initializes. In essence, "get it right the first time." It turns out there were a few complications to resolve on the way, but they're nothing a little elbow grease can't fix.
So, for many of those complications... the best way forward involved replicating a lot of the keyboard-stub building code for use within the
Keyboard
class, unbound from the standardsetKeyboard
methods. This is obviously a bit WET to do, but unavoidable due to entangling side-effects in the originals. The new methods are better modularized; I'd advise refactoring the old methods to rely on the new methods at some point.User Testing
TEST_SIMPLE_LOAD: