Focus the drawer's search and raise the keyboard when the drawer opens

Swiping down to the app drawer puts the cursor in its search box. A WebView
won't show the keyboard for a script focus(), so the shell does it through
new Android.showKeyboard/hideKeyboard bridge calls; closing the drawer hides
it again. Pick mode (adding apps) stays keyboard-free.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0169wSWnZqnXBsJKMPAiCCNG
This commit is contained in:
Claude committed 2026-10-21 23:54:41 +00:00
1 parent ce815d72c2
commit be2371deb0
3 files changed
+39 -1

No files matched your search

@@ -35,6 +35,7 @@ import android.view.View;
import android.view.ViewConfiguration;
import android.view.Window;
import android.view.WindowInsets;
import android.view.inputmethod.InputMethodManager;
import android.webkit.JavascriptInterface;
import android.webkit.RenderProcessGoneDetail;
import android.webkit.WebResourceRequest;
@@ -751,6 +752,22 @@ public class MainActivity extends Activity {
HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING));
}
/** The page focused the drawer's search box; show the keyboard for it. */
@JavascriptInterface public void showKeyboard() {
main.postDelayed(() -> {
web.requestFocus();
InputMethodManager imm = getSystemService(InputMethodManager.class);
if (imm != null) imm.showSoftInput(web, InputMethodManager.SHOW_IMPLICIT);
}, 50);
}
@JavascriptInterface public void hideKeyboard() {
main.post(() -> {
InputMethodManager imm = getSystemService(InputMethodManager.class);
if (imm != null) imm.hideSoftInputFromWindow(web.getWindowToken(), 0);
});
}
@JavascriptInterface public void openSettings() {
main.post(() -> startIntent(new Intent(Settings.ACTION_SETTINGS)));
}