mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-23 12:38:33 +00:00
Avoid sending blank replies and do not clear input when sending reactions.
This commit is contained in:
@@ -92,15 +92,22 @@ class StoryReplyComposer @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
input.doAfterTextChanged {
|
||||
val notEmpty = !it.isNullOrEmpty()
|
||||
reply.isEnabled = notEmpty
|
||||
if (notEmpty && reply.visibility != View.VISIBLE) {
|
||||
val transition = AutoTransition().setDuration(200L).setInterpolator(OvershootInterpolator(1f))
|
||||
if (it == null) return@doAfterTextChanged
|
||||
val isEmpty = it.isBlank()
|
||||
reply.isEnabled = !isEmpty
|
||||
val transition = AutoTransition().setDuration(200L).setInterpolator(OvershootInterpolator(1f))
|
||||
if (!isEmpty && reply.visibility != View.VISIBLE) {
|
||||
TransitionManager.beginDelayedTransition(bubbleView, transition)
|
||||
reply.visibility = View.VISIBLE
|
||||
reply.scaleX = 0f
|
||||
reply.scaleY = 0f
|
||||
reply.animate().setDuration(150).scaleX(1f).scaleY(1f).setInterpolator(OvershootInterpolator(1f)).start()
|
||||
} else if (isEmpty) {
|
||||
TransitionManager.beginDelayedTransition(bubbleView, transition)
|
||||
reply.visibility = View.GONE
|
||||
reply.scaleX = 1f
|
||||
reply.scaleY = 1f
|
||||
reply.animate().setDuration(150).scaleX(0f).scaleY(0f).setInterpolator(OvershootInterpolator(1f)).start()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ class StoryDirectReplyDialogFragment :
|
||||
}
|
||||
|
||||
override fun onReactionClicked(emoji: String) {
|
||||
sendReaction(emoji)
|
||||
sendReaction(emoji, composer.input.text.isNullOrBlank())
|
||||
}
|
||||
|
||||
override fun onPickAnyReactionClicked() {
|
||||
@@ -176,11 +176,11 @@ class StoryDirectReplyDialogFragment :
|
||||
}
|
||||
|
||||
override fun onReactWithAnyEmojiSelected(emoji: String) {
|
||||
sendReaction(emoji)
|
||||
sendReaction(emoji, composer.input.text.isNullOrBlank())
|
||||
isReactClosingAfterSend = true
|
||||
}
|
||||
|
||||
private fun sendReaction(emoji: String) {
|
||||
private fun sendReaction(emoji: String, shouldClose: Boolean) {
|
||||
lifecycleDisposable += viewModel.sendReaction(emoji)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe {
|
||||
@@ -190,7 +190,9 @@ class StoryDirectReplyDialogFragment :
|
||||
putString(REQUEST_EMOJI, emoji)
|
||||
}
|
||||
)
|
||||
dismissAllowingStateLoss()
|
||||
if (shouldClose) {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user