From 34d4c3eff93ac5f9d71a6f9394cc6c5925effe0e Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Sun, 17 Nov 2024 23:04:33 +0100 Subject: [PATCH] Twelve: Show and hide keyboard in search fragment automatically * After switching to search fragment, show keyboard if input text is empty. * After switching from search fragment, hide keyboard unconditionally. Change-Id: I7178c08bd79250b42d682a5246f5d645bf327597 --- .../lineageos/twelve/fragments/SearchFragment.kt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/src/main/java/org/lineageos/twelve/fragments/SearchFragment.kt b/app/src/main/java/org/lineageos/twelve/fragments/SearchFragment.kt index c4359bf3..c4608cdb 100644 --- a/app/src/main/java/org/lineageos/twelve/fragments/SearchFragment.kt +++ b/app/src/main/java/org/lineageos/twelve/fragments/SearchFragment.kt @@ -160,6 +160,21 @@ class SearchFragment : Fragment(R.layout.fragment_search) { } } + override fun onResume() { + super.onResume() + + if (searchView.editText.text.isEmpty()) { + searchView.show() + searchView.requestFocusAndShowKeyboard() + } + } + + override fun onPause() { + searchView.clearFocusAndHideKeyboard() + + super.onPause() + } + override fun onDestroyView() { recyclerView.adapter = null