Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
fix: do not use KeyboardUtils to listen for ime state
Browse files Browse the repository at this point in the history
  • Loading branch information
itsaky committed May 19, 2024
1 parent cfc0aed commit 3b43ef4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -333,7 +341,6 @@ abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSele

setupViews()

KeyboardUtils.registerSoftInputChangedListener(this) { onSoftInputChanged() }
setupContainers()
setupDiagnosticInfo()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ constructor(

fun onSoftInputChanged() {
if (context !is Activity) {
log.error("Bottom sheet is not attached to an activity!")
return
}

Expand Down

0 comments on commit 3b43ef4

Please sign in to comment.