mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-23 10:20:25 +01:00
Add emoji search to CFv2.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user