From f76957a5086a5a45d3305d8aba7c7a1b929c34af Mon Sep 17 00:00:00 2001 From: syphyr Date: Sun, 12 Mar 2023 19:30:27 +0100 Subject: [PATCH] Make cursor in Search bar invisible when keyboard is hidden Hide blinking cursor when keyboard is hidden and show blinking cursor when keyboard is visible. --- app/src/main/java/fr/neamar/kiss/MainActivity.java | 3 +++ app/src/main/res/layout/main.xml | 1 + 2 files changed, 4 insertions(+) diff --git a/app/src/main/java/fr/neamar/kiss/MainActivity.java b/app/src/main/java/fr/neamar/kiss/MainActivity.java index a0b96ac46..c3cd84776 100644 --- a/app/src/main/java/fr/neamar/kiss/MainActivity.java +++ b/app/src/main/java/fr/neamar/kiss/MainActivity.java @@ -498,6 +498,7 @@ public void onBackPressed() { // (which means pressing back in minimalistic mode with history displayed // will hide history again) searchEditText.setText(""); + searchEditText.setCursorVisible(false); } // Calling super.onBackPressed() will quit the launcher, only do this if KISS is not the user's default home. @@ -890,6 +891,7 @@ public void onWindowFocusChanged(boolean hasFocus) { public void showKeyboard() { searchEditText.requestFocus(); + searchEditText.setCursorVisible(true); InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); assert mgr != null; mgr.showSoftInput(searchEditText, InputMethodManager.SHOW_IMPLICIT); @@ -910,6 +912,7 @@ public void hideKeyboard() { systemUiVisibilityHelper.onKeyboardVisibilityChanged(false); dismissPopup(); + searchEditText.setCursorVisible(false); searchEditText.clearFocus(); } diff --git a/app/src/main/res/layout/main.xml b/app/src/main/res/layout/main.xml index 8dded0288..7d74f0372 100644 --- a/app/src/main/res/layout/main.xml +++ b/app/src/main/res/layout/main.xml @@ -145,6 +145,7 @@ android:layout_toEndOf="@id/leftHandSideButtonsWrapper" android:layout_toRightOf="@id/leftHandSideButtonsWrapper" android:background="@android:color/transparent" + android:cursorVisible="false" android:hint="@string/ui_search_hint" android:imeOptions="flagNoExtractUi|actionSearch" android:importantForAutofill="no"