From 32ef2aed33e993a7de3f592ca4165c1e1d44ec0e Mon Sep 17 00:00:00 2001 From: Toni Barzic Date: Tue, 1 Oct 2024 23:25:58 +0000 Subject: [PATCH] Handle enter key as editor action in search bar Handles IME_NULL action in AllAppSearchBarController, which is generated in response to the enter key (with no modifiers) keyboard event in multiline text view. The action triggers search in the same way as ACTION_SEARCH and ACTION_GO. Without this, enter key gets treated as new line in the app list search box. Test: Open all apps, and enter a search query using physical keyboard. Pressing ENTER triggers search. Pressing Shift + ENTER adds a new line to search query. Bug: 370780257 Flag: com.android.launcher3.multiline_search_bar Change-Id: I6aef5e120210f4efc216e03d24974b04ab5f1d16 --- .../allapps/search/AllAppsSearchBarController.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java b/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java index de3bb9efe1..7e3e392a87 100644 --- a/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java +++ b/src/com/android/launcher3/allapps/search/AllAppsSearchBarController.java @@ -118,8 +118,14 @@ public class AllAppsSearchBarController @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { - if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_GO) { - Log.i(TAG, "User tapped ime search button"); + if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_GO || ( + actionId == EditorInfo.IME_NULL && event != null + && event.getAction() == KeyEvent.ACTION_DOWN)) { + if (actionId == EditorInfo.IME_NULL) { + Log.i(TAG, "User pressed ENTER key"); + } else { + Log.i(TAG, "User tapped ime search button"); + } // selectFocusedView should return SearchTargetEvent that is passed onto onClick return mLauncher.getAppsView().getMainAdapterProvider().launchHighlightedItem(); }