fix: do not use KeyboardUtils to listen for ime state

This commit is contained in:
Akash Yadav
2024-05-19 19:02:08 +05:30
parent cfc0aed74e
commit 3b43ef4b35
2 changed files with 9 additions and 1 deletions
@@ -187,6 +187,7 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele
}
}
private var isImeVisible = false
private var contentCardRealHeight: Int? = null
private val editorSurfaceContainerBackground by lazy {
resolveAttr(R.attr.colorSurfaceDim)
@@ -268,10 +269,17 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele
super.onApplyWindowInsets(insets)
val height = contentCardRealHeight ?: return
val imeInsets = insets.getInsets(WindowInsetsCompat.Type.ime())
_binding?.content?.bottomSheet?.setImeVisible(imeInsets.bottom > 0)
_binding?.contentCard?.updateLayoutParams<ViewGroup.LayoutParams> {
this.height = height - imeInsets.bottom
}
val isImeVisible = imeInsets.bottom > 0
if (this.isImeVisible != isImeVisible) {
this.isImeVisible = isImeVisible
onSoftInputChanged()
}
}
override fun onApplySystemBarInsets(insets: Insets) {
@@ -333,7 +341,6 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele
setupViews()
KeyboardUtils.registerSoftInputChangedListener(this) { onSoftInputChanged() }
setupContainers()
setupDiagnosticInfo()
@@ -303,6 +303,7 @@ constructor(
fun onSoftInputChanged() {
if (context !is Activity) {
log.error("Bottom sheet is not attached to an activity!")
return
}