diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/TachiyomiSearchView.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/TachiyomiSearchView.kt index 80e7850c6..6a971ce82 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/TachiyomiSearchView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/TachiyomiSearchView.kt @@ -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()