Update: Fix search bar initial setup [new UI]

This commit is contained in:
machiav3lli 2021-12-23 01:41:26 +01:00
parent ea80e658cf
commit 1dab4dfe3d

View File

@ -4,6 +4,7 @@ import android.content.Context
import android.util.AttributeSet import android.util.AttributeSet
import android.view.KeyEvent import android.view.KeyEvent
import androidx.appcompat.widget.SearchView import androidx.appcompat.widget.SearchView
import com.looker.droidify.R
class FocusSearchView : SearchView { class FocusSearchView : SearchView {
constructor(context: Context) : super(context) constructor(context: Context) : super(context)
@ -16,6 +17,11 @@ class FocusSearchView : SearchView {
var allowFocus = true var allowFocus = true
init {
maxWidth = Int.MAX_VALUE
queryHint = context.getString(R.string.search)
}
override fun dispatchKeyEventPreIme(event: KeyEvent): Boolean { override fun dispatchKeyEventPreIme(event: KeyEvent): Boolean {
// Always clear focus on back press // Always clear focus on back press
return if (hasFocus() && event.keyCode == KeyEvent.KEYCODE_BACK) { return if (hasFocus() && event.keyCode == KeyEvent.KEYCODE_BACK) {