android: proper hiding keyboard when entering passcode (#4066)

This commit is contained in:
Stanislav Dmitrenko
2024-04-22 22:13:14 +01:00
committed by GitHub
parent 2b6764fc36
commit f80ac6dc50
4 changed files with 8 additions and 3 deletions
@@ -67,10 +67,13 @@ actual fun getKeyboardState(): State<KeyboardState> {
return keyboardState
}
actual fun hideKeyboard(view: Any?) {
actual fun hideKeyboard(view: Any?, clearFocus: Boolean) {
// LALAL
// LocalSoftwareKeyboardController.current?.hide()
if (view is View) {
if (clearFocus) {
view.clearFocus()
}
(androidAppContext.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager).hideSoftInputFromWindow(view.windowToken, 0)
}
}
@@ -13,7 +13,7 @@ expect fun LocalMultiplatformView(): Any?
@Composable
expect fun getKeyboardState(): State<KeyboardState>
expect fun hideKeyboard(view: Any?)
expect fun hideKeyboard(view: Any?, clearFocus: Boolean = false)
expect fun androidIsFinishingMainActivity(): Boolean
@@ -135,7 +135,9 @@ fun PasscodeView(
if (!buttonsEnabled.value) {
ProgressIndicator()
}
val view = LocalMultiplatformView()
LaunchedEffect(Unit) {
hideKeyboard(view, true)
focusRequester.requestFocus()
// Disallow to steal a focus by clicking on buttons or using Tab
focusRequester.captureFocus()
@@ -16,7 +16,7 @@ actual fun LocalMultiplatformView(): Any? = null
@Composable
actual fun getKeyboardState(): State<KeyboardState> = remember { mutableStateOf(KeyboardState.Opened) }
actual fun hideKeyboard(view: Any?) {}
actual fun hideKeyboard(view: Any?, clearFocus: Boolean) {}
actual fun androidIsFinishingMainActivity(): Boolean = false