From 61be302f9202b6e1b4c63aad637ec599b0f078db Mon Sep 17 00:00:00 2001 From: syphyr Date: Mon, 6 May 2024 22:54:54 +0200 Subject: [PATCH] Do not hide keyboard when SearchEditText is inactive view This fixes regression from #2280 which may cause the menu of search result items to be cut off after long pressing the item. The problem is that after the keyboard becomes hidden after a long press, the resulting menu may then be moved down which can cause it to be cut off. The solution is to only hide keyboard when SearchEditText is the active view. --- app/src/main/java/fr/neamar/kiss/MainActivity.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/fr/neamar/kiss/MainActivity.java b/app/src/main/java/fr/neamar/kiss/MainActivity.java index 2886ac4ff..b19d6c2a1 100644 --- a/app/src/main/java/fr/neamar/kiss/MainActivity.java +++ b/app/src/main/java/fr/neamar/kiss/MainActivity.java @@ -621,7 +621,9 @@ public boolean dispatchTouchEvent(MotionEvent ev) { if (isKeyboardOpen) { edit.clearFocus(); InputMethodManager imm = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(edit.getWindowToken(), 0); + if (imm.isActive(edit)) { + imm.hideSoftInputFromWindow(edit.getWindowToken(), 0); + } } edit.setCursorVisible(!isKeyboardOpen); }