Merge pull request #8770 from element-hq/feature/fga/fix_send_button_blinking
Fix send button blinking with RTE
This commit is contained in:
commit
b4b11a5767
|
@ -0,0 +1 @@
|
||||||
|
Fix send button blinking once for each character you are typing in RTE.
|
|
@ -45,7 +45,9 @@ import com.google.android.material.shape.MaterialShapeDrawable
|
||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
import im.vector.app.core.extensions.setTextIfDifferent
|
import im.vector.app.core.extensions.setTextIfDifferent
|
||||||
import im.vector.app.core.extensions.showKeyboard
|
import im.vector.app.core.extensions.showKeyboard
|
||||||
|
import im.vector.app.core.utils.Debouncer
|
||||||
import im.vector.app.core.utils.DimensionConverter
|
import im.vector.app.core.utils.DimensionConverter
|
||||||
|
import im.vector.app.core.utils.createUIHandler
|
||||||
import im.vector.app.databinding.ComposerRichTextLayoutBinding
|
import im.vector.app.databinding.ComposerRichTextLayoutBinding
|
||||||
import im.vector.app.databinding.ViewRichTextMenuButtonBinding
|
import im.vector.app.databinding.ViewRichTextMenuButtonBinding
|
||||||
import im.vector.app.features.home.room.detail.composer.images.UriContentListener
|
import im.vector.app.features.home.room.detail.composer.images.UriContentListener
|
||||||
|
@ -195,10 +197,16 @@ internal class RichTextComposerLayout @JvmOverloads constructor(
|
||||||
renderComposerMode(MessageComposerMode.Normal(null))
|
renderComposerMode(MessageComposerMode.Normal(null))
|
||||||
|
|
||||||
views.richTextComposerEditText.addTextChangedListener(
|
views.richTextComposerEditText.addTextChangedListener(
|
||||||
TextChangeListener({ callback?.onTextChanged(it) }, { updateTextFieldBorder(isFullScreen) })
|
TextChangeListener(
|
||||||
|
onTextChanged = {
|
||||||
|
callback?.onTextChanged(it)
|
||||||
|
},
|
||||||
|
onExpandedChanged = { updateTextFieldBorder(isFullScreen) })
|
||||||
)
|
)
|
||||||
views.plainTextComposerEditText.addTextChangedListener(
|
views.plainTextComposerEditText.addTextChangedListener(
|
||||||
TextChangeListener({ callback?.onTextChanged(it) }, { updateTextFieldBorder(isFullScreen) })
|
TextChangeListener({
|
||||||
|
callback?.onTextChanged(it)
|
||||||
|
}, { updateTextFieldBorder(isFullScreen) })
|
||||||
)
|
)
|
||||||
ViewCompat.setOnReceiveContentListener(
|
ViewCompat.setOnReceiveContentListener(
|
||||||
views.richTextComposerEditText,
|
views.richTextComposerEditText,
|
||||||
|
@ -516,13 +524,15 @@ internal class RichTextComposerLayout @JvmOverloads constructor(
|
||||||
private val onTextChanged: (s: Editable) -> Unit,
|
private val onTextChanged: (s: Editable) -> Unit,
|
||||||
private val onExpandedChanged: (isExpanded: Boolean) -> Unit,
|
private val onExpandedChanged: (isExpanded: Boolean) -> Unit,
|
||||||
) : TextWatcher {
|
) : TextWatcher {
|
||||||
|
|
||||||
|
private val debouncer = Debouncer(createUIHandler())
|
||||||
private var previousTextWasExpanded = false
|
private var previousTextWasExpanded = false
|
||||||
|
|
||||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
|
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
|
||||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {}
|
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {}
|
||||||
override fun afterTextChanged(s: Editable) {
|
override fun afterTextChanged(s: Editable) {
|
||||||
|
debouncer.debounce("afterTextChanged", 50L) {
|
||||||
onTextChanged.invoke(s)
|
onTextChanged.invoke(s)
|
||||||
|
|
||||||
val isExpanded = s.lines().count() > 1
|
val isExpanded = s.lines().count() > 1
|
||||||
if (previousTextWasExpanded != isExpanded) {
|
if (previousTextWasExpanded != isExpanded) {
|
||||||
onExpandedChanged(isExpanded)
|
onExpandedChanged(isExpanded)
|
||||||
|
@ -531,3 +541,4 @@ internal class RichTextComposerLayout @JvmOverloads constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue