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): use main looper to dispatch key events when OSK is hidden #12871

Merged
merged 1 commit into from
Jan 16, 2025
Merged
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
@@ -31,6 +31,7 @@
import android.content.res.Configuration;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.GestureDetector;
@@ -70,6 +71,10 @@ final class KMKeyboard extends WebView {
protected KeyboardType keyboardType = KeyboardType.KEYBOARD_TYPE_UNDEFINED;
protected ArrayList<String> javascriptAfterLoad = new ArrayList<>();

// .getMainLooper() returns the looper associated with the main UI thread.
// https://stackoverflow.com/questions/13974661/runonuithread-vs-looper-getmainlooper-post-in-android
private Handler jsQueuer = new Handler(Looper.getMainLooper());

private static String currentKeyboard = null;

/**
@@ -368,7 +373,7 @@ 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() {
jsQueuer.postDelayed(new Runnable() {
@Override
public void run() {
StringBuilder allCalls = new StringBuilder();