mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-19 21:09:20 +01:00
Hide soft keyboard after submitting search query throughout app (#5837)
* Clear focus from SearchView when submitting a search query in BrowseSourceController * Revert "Clear focus from SearchView when submitting a search query" * Implement SearchView focus clearing in Tachiyomi's subclass to enable feature throughout app * Add support for keyboard Enter key Pressing enter on a keyboard (when using the emulator for example) now also submits the query
This commit is contained in:
parent
b284384f0a
commit
82f14a7d59
@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import androidx.appcompat.widget.SearchView
|
||||
import androidx.core.view.inputmethod.EditorInfoCompat
|
||||
import eu.kanade.tachiyomi.R
|
||||
@ -39,6 +40,18 @@ class TachiyomiSearchView @JvmOverloads constructor(
|
||||
}.launchIn(scope!!)
|
||||
}
|
||||
|
||||
override fun setOnQueryTextListener(listener: OnQueryTextListener?) {
|
||||
super.setOnQueryTextListener(listener)
|
||||
val searchAutoComplete: SearchAutoComplete = findViewById(R.id.search_src_text)
|
||||
searchAutoComplete.setOnEditorActionListener { _, actionID, _ ->
|
||||
if (actionID == EditorInfo.IME_ACTION_SEARCH || actionID == EditorInfo.IME_NULL) {
|
||||
clearFocus()
|
||||
listener?.onQueryTextSubmit(query.toString())
|
||||
true
|
||||
} else false
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
scope?.cancel()
|
||||
|
Loading…
Reference in New Issue
Block a user