mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-03-23 22:39:02 +03:00
[merge-fixup] Fix our send button behaviour
Change-Id: I119132f0423bf4884e37e4b9f9e5cd204949b269
This commit is contained in:
parent
dffc0c1d65
commit
ba2ed623c2
4 changed files with 19 additions and 9 deletions
vector/src/main/java/im/vector/app/features/home/room/detail
|
@ -19,6 +19,7 @@ package im.vector.app.features.home.room.detail
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.content.res.ColorStateList
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.graphics.Typeface
|
import android.graphics.Typeface
|
||||||
|
@ -474,11 +475,17 @@ class RoomDetailFragment @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleSendButtonVisibilityChanged(event: TextComposerViewEvents.AnimateSendButtonVisibility) {
|
private fun handleSendButtonVisibilityChanged(event: TextComposerViewEvents.AnimateSendButtonVisibility) {
|
||||||
|
val sendButtonColor = ThemeUtils.getColor(views.composerLayout.context, if (event.isActive) R.attr.colorAccent else R.attr.vctr_content_tertiary)
|
||||||
|
views.composerLayout.views.sendButton.imageTintList = ColorStateList.valueOf(sendButtonColor)
|
||||||
if (event.isVisible) {
|
if (event.isVisible) {
|
||||||
views.voiceMessageRecorderView.isVisible = false
|
views.voiceMessageRecorderView.isVisible = false
|
||||||
views.composerLayout.views.sendButton.alpha = 0f
|
if (views.composerLayout.views.sendButton.isVisible) {
|
||||||
views.composerLayout.views.sendButton.isVisible = true
|
views.composerLayout.views.sendButton.alpha = 1f
|
||||||
views.composerLayout.views.sendButton.animate().alpha(1f).setDuration(150).start()
|
} else {
|
||||||
|
views.composerLayout.views.sendButton.alpha = 0f
|
||||||
|
views.composerLayout.views.sendButton.isVisible = true
|
||||||
|
views.composerLayout.views.sendButton.animate().alpha(1f).setDuration(150).start()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
views.composerLayout.views.sendButton.isInvisible = true
|
views.composerLayout.views.sendButton.isInvisible = true
|
||||||
views.voiceMessageRecorderView.alpha = 0f
|
views.voiceMessageRecorderView.alpha = 0f
|
||||||
|
@ -1426,7 +1433,7 @@ class RoomDetailFragment @Inject constructor(
|
||||||
lazyLoadedViews.inviteView(false)?.isVisible = false
|
lazyLoadedViews.inviteView(false)?.isVisible = false
|
||||||
if (mainState.tombstoneEvent == null) {
|
if (mainState.tombstoneEvent == null) {
|
||||||
views.composerLayout.isInvisible = !textComposerState.isComposerVisible
|
views.composerLayout.isInvisible = !textComposerState.isComposerVisible
|
||||||
views.voiceMessageRecorderView.isVisible = !textComposerState.isSendButtonVisible && vectorPreferences.useVoiceMessage()
|
views.voiceMessageRecorderView.isVisible = !textComposerState.isSendButtonVisible
|
||||||
views.composerLayout.views.sendButton.isInvisible = !textComposerState.isSendButtonVisible
|
views.composerLayout.views.sendButton.isInvisible = !textComposerState.isSendButtonVisible
|
||||||
views.composerLayout.setRoomEncrypted(summary.isEncrypted)
|
views.composerLayout.setRoomEncrypted(summary.isEncrypted)
|
||||||
// views.composerLayout.alwaysShowSendButton = !vectorPreferences.useVoiceMessage()
|
// views.composerLayout.alwaysShowSendButton = !vectorPreferences.useVoiceMessage()
|
||||||
|
|
|
@ -22,7 +22,7 @@ import im.vector.app.features.command.Command
|
||||||
|
|
||||||
sealed class TextComposerViewEvents : VectorViewEvents {
|
sealed class TextComposerViewEvents : VectorViewEvents {
|
||||||
|
|
||||||
data class AnimateSendButtonVisibility(val isVisible: Boolean) : TextComposerViewEvents()
|
data class AnimateSendButtonVisibility(val isVisible: Boolean, val isActive: Boolean) : TextComposerViewEvents()
|
||||||
|
|
||||||
data class ShowMessage(val message: String) : TextComposerViewEvents()
|
data class ShowMessage(val message: String) : TextComposerViewEvents()
|
||||||
|
|
||||||
|
|
|
@ -112,11 +112,13 @@ class TextComposerViewModel @AssistedInject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateIsSendButtonVisibility(triggerAnimation: Boolean) = setState {
|
private fun updateIsSendButtonVisibility(triggerAnimation: Boolean) = setState {
|
||||||
val isSendButtonVisible = isComposerVisible && (sendMode !is SendMode.REGULAR || currentComposerText.isNotBlank())
|
val upstreamShowsSendButton = (isComposerVisible && (sendMode !is SendMode.REGULAR || currentComposerText.isNotBlank()))
|
||||||
if (this.isSendButtonVisible != isSendButtonVisible && triggerAnimation) {
|
val isSendButtonVisible = upstreamShowsSendButton || !vectorPreferences.useVoiceMessage()
|
||||||
_viewEvents.post(TextComposerViewEvents.AnimateSendButtonVisibility(isSendButtonVisible))
|
val isSendButtonActive = currentComposerText.isNotBlank()
|
||||||
|
if ((this.isSendButtonVisible != isSendButtonVisible || this.isSendButtonActive != isSendButtonActive) && triggerAnimation) {
|
||||||
|
_viewEvents.post(TextComposerViewEvents.AnimateSendButtonVisibility(isSendButtonVisible, isSendButtonActive))
|
||||||
}
|
}
|
||||||
copy(isSendButtonVisible = isSendButtonVisible)
|
copy(isSendButtonVisible = isSendButtonVisible, isSendButtonActive = isSendButtonActive)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleEnterRegularMode(action: TextComposerAction.EnterRegularMode) = setState {
|
private fun handleEnterRegularMode(action: TextComposerAction.EnterRegularMode) = setState {
|
||||||
|
|
|
@ -45,6 +45,7 @@ data class TextComposerViewState(
|
||||||
val roomId: String,
|
val roomId: String,
|
||||||
val canSendMessage: Boolean = true,
|
val canSendMessage: Boolean = true,
|
||||||
val isVoiceRecording: Boolean = false,
|
val isVoiceRecording: Boolean = false,
|
||||||
|
val isSendButtonActive: Boolean = false,
|
||||||
val isSendButtonVisible: Boolean = false,
|
val isSendButtonVisible: Boolean = false,
|
||||||
val sendMode: SendMode = SendMode.REGULAR("", false)
|
val sendMode: SendMode = SendMode.REGULAR("", false)
|
||||||
) : MvRxState {
|
) : MvRxState {
|
||||||
|
|
Loading…
Add table
Reference in a new issue