mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-23 20:48:43 +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 {
|
input.doAfterTextChanged {
|
||||||
val notEmpty = !it.isNullOrEmpty()
|
if (it == null) return@doAfterTextChanged
|
||||||
reply.isEnabled = notEmpty
|
val isEmpty = it.isBlank()
|
||||||
if (notEmpty && reply.visibility != View.VISIBLE) {
|
reply.isEnabled = !isEmpty
|
||||||
val transition = AutoTransition().setDuration(200L).setInterpolator(OvershootInterpolator(1f))
|
val transition = AutoTransition().setDuration(200L).setInterpolator(OvershootInterpolator(1f))
|
||||||
|
if (!isEmpty && reply.visibility != View.VISIBLE) {
|
||||||
TransitionManager.beginDelayedTransition(bubbleView, transition)
|
TransitionManager.beginDelayedTransition(bubbleView, transition)
|
||||||
reply.visibility = View.VISIBLE
|
reply.visibility = View.VISIBLE
|
||||||
reply.scaleX = 0f
|
reply.scaleX = 0f
|
||||||
reply.scaleY = 0f
|
reply.scaleY = 0f
|
||||||
reply.animate().setDuration(150).scaleX(1f).scaleY(1f).setInterpolator(OvershootInterpolator(1f)).start()
|
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) {
|
override fun onReactionClicked(emoji: String) {
|
||||||
sendReaction(emoji)
|
sendReaction(emoji, composer.input.text.isNullOrBlank())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPickAnyReactionClicked() {
|
override fun onPickAnyReactionClicked() {
|
||||||
@@ -176,11 +176,11 @@ class StoryDirectReplyDialogFragment :
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onReactWithAnyEmojiSelected(emoji: String) {
|
override fun onReactWithAnyEmojiSelected(emoji: String) {
|
||||||
sendReaction(emoji)
|
sendReaction(emoji, composer.input.text.isNullOrBlank())
|
||||||
isReactClosingAfterSend = true
|
isReactClosingAfterSend = true
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun sendReaction(emoji: String) {
|
private fun sendReaction(emoji: String, shouldClose: Boolean) {
|
||||||
lifecycleDisposable += viewModel.sendReaction(emoji)
|
lifecycleDisposable += viewModel.sendReaction(emoji)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe {
|
.subscribe {
|
||||||
@@ -190,7 +190,9 @@ class StoryDirectReplyDialogFragment :
|
|||||||
putString(REQUEST_EMOJI, emoji)
|
putString(REQUEST_EMOJI, emoji)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
if (shouldClose) {
|
||||||
dismissAllowingStateLoss()
|
dismissAllowingStateLoss()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user