mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-26 00:06:02 +00:00
fix(input): B on a controller hides the on-screen keyboard before going back (#2498)
* fix(input): B on a controller hides the on-screen keyboard before going back * fix(input): B sees the on-screen keyboard on Android 8 to 10 too
This commit is contained in:
1 parent
3230ccdc73
commit
afd2d91662
1 file changed
+12
@@ -454,6 +454,18 @@ internal fun AdbTextField(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
showSoftInputOnFocus = !bottomTyping
|
showSoftInputOnFocus = !bottomTyping
|
||||||
|
// B on a controller puts the keyboard away first; with no keyboard up it goes back as usual.
|
||||||
|
var hidingKeyboard = false
|
||||||
|
setOnKeyListener { view, keyCode, event ->
|
||||||
|
if (keyCode != android.view.KeyEvent.KEYCODE_BUTTON_B) return@setOnKeyListener false
|
||||||
|
if (event.action == android.view.KeyEvent.ACTION_DOWN && event.repeatCount == 0) {
|
||||||
|
hidingKeyboard = androidx.core.view.ViewCompat.getRootWindowInsets(view)
|
||||||
|
?.isVisible(androidx.core.view.WindowInsetsCompat.Type.ime()) == true
|
||||||
|
if (hidingKeyboard) (view.context.getSystemService(android.content.Context.INPUT_METHOD_SERVICE) as? android.view.inputmethod.InputMethodManager)
|
||||||
|
?.hideSoftInputFromWindow(view.windowToken, 0)
|
||||||
|
}
|
||||||
|
hidingKeyboard
|
||||||
|
}
|
||||||
setOnClickListener { if (hasFocus() && !typeOnBottom(this) && bottomTypingLatest.value) showKeyboardHere(this) }
|
setOnClickListener { if (hasFocus() && !typeOnBottom(this) && bottomTypingLatest.value) showKeyboardHere(this) }
|
||||||
setOnFocusChangeListener { _, hasFocus ->
|
setOnFocusChangeListener { _, hasFocus ->
|
||||||
focused = hasFocus
|
focused = hasFocus
|
||||||
|
|||||||
Reference in new issue
Block a user