Skip to content
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

fix(android): Allow external keyboard to work when OSK hidden #12381

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,8 @@ public void loadJavascript(String func) {

public void callJavascriptAfterLoad() {
if(this.javascriptAfterLoad.size() > 0) {
// Don't call this WebView method on just ANY thread - run it on the main UI thread.
// https://stackoverflow.com/a/22611010
this.postDelayed(new Runnable() {
Handler handler = new Handler();
Copy link
Contributor

@jahorton jahorton Jan 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On this constructor's deprecation

(from https://developer.android.com/reference/android/os/Handler)

The docs strongly suggest making this, at least, new Handler(Looper.getMainLooper()).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After a bit more searching, I found this: https://stackoverflow.com/questions/13974661/runonuithread-vs-looper-getmainlooper-post-in-android

The big takeaway from that link: Looper.getMainLooper() will return the Looper instance associated with the primary UI thread, which is what we want.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've now authored #12871 as an alternative. It'll essentially be a middle-ground of sorts between the two approaches, and it does appear to be enough to unblock these keystrokes as well.

handler.postDelayed(new Runnable() {
@Override
public void run() {
StringBuilder allCalls = new StringBuilder();
Expand Down
Loading