Add emoji search to CFv2.

This commit is contained in:
Cody Henthorne
2023-06-27 11:03:03 -04:00
committed by Nicholas
parent 2ee2d2883a
commit b6589637fa
8 changed files with 148 additions and 67 deletions

View File

@@ -26,6 +26,9 @@ class InputAwareConstraintLayout @JvmOverloads constructor(
private var inputId: Int? = null
private var input: Fragment? = null
val isInputShowing: Boolean
get() = input != null
lateinit var fragmentManager: FragmentManager
var listener: Listener? = null

View File

@@ -55,9 +55,11 @@ open class InsetAwareConstraintLayout @JvmOverloads constructor(
private val parentEndGuideline: Guideline? by lazy { findViewById(R.id.parent_end_guideline) }
private val keyboardGuideline: Guideline? by lazy { findViewById(R.id.keyboard_guideline) }
private val listeners: MutableList<KeyboardStateListener> = mutableListOf()
private val keyboardAnimator = KeyboardInsetAnimator()
private val displayMetrics = DisplayMetrics()
private var overridingKeyboard: Boolean = false
private var previousKeyboardHeight: Int = 0
init {
ViewCompat.setOnApplyWindowInsetsListener(this) { _, windowInsetsCompat ->
@@ -74,6 +76,14 @@ open class InsetAwareConstraintLayout @JvmOverloads constructor(
}
}
fun addKeyboardStateListener(listener: KeyboardStateListener) {
listeners += listener
}
fun removeKeyboardStateListener(listener: KeyboardStateListener) {
listeners.remove(listener)
}
private fun applyInsets(windowInsets: Insets, keyboardInsets: Insets) {
val isLtr = ViewUtil.isLtr(this)
@@ -96,6 +106,18 @@ open class InsetAwareConstraintLayout @JvmOverloads constructor(
keyboardAnimator.endingGuidelineEnd = windowInsets.bottom
}
}
if (previousKeyboardHeight != keyboardInsets.bottom) {
listeners.forEach {
if (previousKeyboardHeight <= 0) {
it.onKeyboardShown()
} else {
it.onKeyboardHidden()
}
}
}
previousKeyboardHeight = keyboardInsets.bottom
}
protected fun overrideKeyboardGuidelineWithPreviousHeight() {
@@ -157,6 +179,11 @@ open class InsetAwareConstraintLayout @JvmOverloads constructor(
private val Guideline?.guidelineEnd: Int
get() = if (this == null) 0 else (layoutParams as LayoutParams).guideEnd
interface KeyboardStateListener {
fun onKeyboardShown()
fun onKeyboardHidden()
}
/**
* Adjusts the [keyboardGuideline] to move with the IME keyboard opening or closing.
*/