Reshow IME keyboard if it was showing prior to opening attachment keyboard.

This commit is contained in:
Cody Henthorne
2023-08-18 13:00:54 -04:00
parent 8b2a535f19
commit e7d0b575bb

View File

@@ -25,6 +25,7 @@ class InputAwareConstraintLayout @JvmOverloads constructor(
private var inputId: Int? = null
private var input: Fragment? = null
private var wasKeyboardVisibleBeforeToggle: Boolean = false
val isInputShowing: Boolean
get() = input != null
@@ -38,11 +39,12 @@ class InputAwareConstraintLayout @JvmOverloads constructor(
}
fun hideAll(imeTarget: EditText) {
wasKeyboardVisibleBeforeToggle = false
ViewUtil.hideKeyboard(context, imeTarget)
hideInput(resetKeyboardGuideline = true)
}
fun toggleInput(fragmentCreator: FragmentCreator, imeTarget: EditText, showSoftKeyOnHide: Boolean = false) {
fun toggleInput(fragmentCreator: FragmentCreator, imeTarget: EditText, showSoftKeyOnHide: Boolean = wasKeyboardVisibleBeforeToggle) {
if (fragmentCreator.id == inputId) {
if (showSoftKeyOnHide) {
showSoftkey(imeTarget)
@@ -50,6 +52,7 @@ class InputAwareConstraintLayout @JvmOverloads constructor(
hideInput(resetKeyboardGuideline = true)
}
} else {
wasKeyboardVisibleBeforeToggle = isKeyboardShowing
hideInput(resetKeyboardGuideline = false)
showInput(fragmentCreator, imeTarget)
}
@@ -57,6 +60,7 @@ class InputAwareConstraintLayout @JvmOverloads constructor(
fun hideInput() {
hideInput(resetKeyboardGuideline = true)
wasKeyboardVisibleBeforeToggle = false
}
private fun showInput(fragmentCreator: FragmentCreator, imeTarget: EditText) {