Skip to content

Commit

Permalink
Reshow IME keyboard if it was showing prior to opening attachment key…
Browse files Browse the repository at this point in the history
…board.
  • Loading branch information
cody-signal committed Aug 18, 2023
1 parent 8b2a535 commit e7d0b57
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -38,25 +39,28 @@ 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)
} else {
hideInput(resetKeyboardGuideline = true)
}
} else {
wasKeyboardVisibleBeforeToggle = isKeyboardShowing
hideInput(resetKeyboardGuideline = false)
showInput(fragmentCreator, imeTarget)
}
}

fun hideInput() {
hideInput(resetKeyboardGuideline = true)
wasKeyboardVisibleBeforeToggle = false
}

private fun showInput(fragmentCreator: FragmentCreator, imeTarget: EditText) {
Expand Down

0 comments on commit e7d0b57

Please sign in to comment.