mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-23 01:45:52 +03:00
Merge pull request #3816 from vector-im/feature/ons/fix_voice_message_ui
Voice Message - UI Improvements
This commit is contained in:
commit
ec093e78b0
4 changed files with 26 additions and 3 deletions
1
changelog.d/3798.bugfix
Normal file
1
changelog.d/3798.bugfix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Voice Message - UI Improvements
|
|
@ -1044,6 +1044,9 @@ class RoomDetailFragment @Inject constructor(
|
||||||
notificationDrawerManager.setCurrentRoom(roomDetailArgs.roomId)
|
notificationDrawerManager.setCurrentRoom(roomDetailArgs.roomId)
|
||||||
roomDetailPendingActionStore.data?.let { handlePendingAction(it) }
|
roomDetailPendingActionStore.data?.let { handlePendingAction(it) }
|
||||||
roomDetailPendingActionStore.data = null
|
roomDetailPendingActionStore.data = null
|
||||||
|
|
||||||
|
// Removed listeners should be set again
|
||||||
|
setupVoiceMessageView()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handlePendingAction(roomDetailPendingAction: RoomDetailPendingAction) {
|
private fun handlePendingAction(roomDetailPendingAction: RoomDetailPendingAction) {
|
||||||
|
@ -1318,7 +1321,6 @@ class RoomDetailFragment @Inject constructor(
|
||||||
if (text.isNotBlank()) {
|
if (text.isNotBlank()) {
|
||||||
// We collapse ASAP, if not there will be a slight annoying delay
|
// We collapse ASAP, if not there will be a slight annoying delay
|
||||||
views.composerLayout.collapse(true)
|
views.composerLayout.collapse(true)
|
||||||
views.voiceMessageRecorderView.isVisible = vectorPreferences.labsUseVoiceMessage()
|
|
||||||
lockSendButton = true
|
lockSendButton = true
|
||||||
roomDetailViewModel.handle(RoomDetailAction.SendMessage(text, vectorPreferences.isMarkdownEnabled()))
|
roomDetailViewModel.handle(RoomDetailAction.SendMessage(text, vectorPreferences.isMarkdownEnabled()))
|
||||||
emojiPopup.dismiss()
|
emojiPopup.dismiss()
|
||||||
|
|
|
@ -20,6 +20,7 @@ import android.content.Context
|
||||||
import android.text.format.DateUtils
|
import android.text.format.DateUtils
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
|
import android.view.View
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
import androidx.core.view.isInvisible
|
import androidx.core.view.isInvisible
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
|
@ -87,6 +88,15 @@ class VoiceMessageRecorderView @JvmOverloads constructor(
|
||||||
initListeners()
|
initListeners()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onVisibilityChanged(changedView: View, visibility: Int) {
|
||||||
|
super.onVisibilityChanged(changedView, visibility)
|
||||||
|
if (changedView == this && visibility == VISIBLE) {
|
||||||
|
views.voiceMessageMicButton.contentDescription = context.getString(R.string.a11y_start_voice_message)
|
||||||
|
} else {
|
||||||
|
views.voiceMessageMicButton.contentDescription = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun initVoiceRecordingViews() {
|
fun initVoiceRecordingViews() {
|
||||||
recordingState = RecordingState.NONE
|
recordingState = RecordingState.NONE
|
||||||
|
|
||||||
|
@ -209,6 +219,7 @@ class VoiceMessageRecorderView @JvmOverloads constructor(
|
||||||
}
|
}
|
||||||
RecordingState.CANCELLED -> {
|
RecordingState.CANCELLED -> {
|
||||||
hideRecordingViews(isCancelled = true)
|
hideRecordingViews(isCancelled = true)
|
||||||
|
vibrate(context)
|
||||||
}
|
}
|
||||||
RecordingState.LOCKED -> {
|
RecordingState.LOCKED -> {
|
||||||
if (isRecordingStateChanged) { // Do not update views if it was already in locked state.
|
if (isRecordingStateChanged) { // Do not update views if it was already in locked state.
|
||||||
|
@ -220,6 +231,9 @@ class VoiceMessageRecorderView @JvmOverloads constructor(
|
||||||
}
|
}
|
||||||
RecordingState.STARTED -> {
|
RecordingState.STARTED -> {
|
||||||
showRecordingViews()
|
showRecordingViews()
|
||||||
|
val translationAmount = distanceX.coerceAtMost(distanceToCancel)
|
||||||
|
views.voiceMessageMicButton.translationX = -translationAmount * rtlXMultiplier
|
||||||
|
views.voiceMessageSlideToCancel.translationX = -translationAmount / 2 * rtlXMultiplier
|
||||||
}
|
}
|
||||||
RecordingState.NONE -> Timber.d("VoiceMessageRecorderView shouldn't be in NONE state while moving.")
|
RecordingState.NONE -> Timber.d("VoiceMessageRecorderView shouldn't be in NONE state while moving.")
|
||||||
RecordingState.PLAYBACK -> Timber.d("VoiceMessageRecorderView shouldn't be in PLAYBACK state while moving.")
|
RecordingState.PLAYBACK -> Timber.d("VoiceMessageRecorderView shouldn't be in PLAYBACK state while moving.")
|
||||||
|
@ -235,9 +249,9 @@ class VoiceMessageRecorderView @JvmOverloads constructor(
|
||||||
if (recordingState == RecordingState.STARTED) {
|
if (recordingState == RecordingState.STARTED) {
|
||||||
// Determine if cancelling or locking for the first move action.
|
// Determine if cancelling or locking for the first move action.
|
||||||
if (((currentX < firstX && rtlXMultiplier == 1) || (currentX > firstX && rtlXMultiplier == -1))
|
if (((currentX < firstX && rtlXMultiplier == 1) || (currentX > firstX && rtlXMultiplier == -1))
|
||||||
&& distanceX > distanceY) {
|
&& distanceX > distanceY && distanceX > lastDistanceX) {
|
||||||
recordingState = RecordingState.CANCELLING
|
recordingState = RecordingState.CANCELLING
|
||||||
} else if (currentY < firstY && distanceY > distanceX) {
|
} else if (currentY < firstY && distanceY > distanceX && distanceY > lastDistanceY) {
|
||||||
recordingState = RecordingState.LOCKING
|
recordingState = RecordingState.LOCKING
|
||||||
}
|
}
|
||||||
} else if (recordingState == RecordingState.CANCELLING) {
|
} else if (recordingState == RecordingState.CANCELLING) {
|
||||||
|
@ -507,12 +521,14 @@ class VoiceMessageRecorderView @JvmOverloads constructor(
|
||||||
}
|
}
|
||||||
is VoiceMessagePlaybackTracker.Listener.State.Playing -> {
|
is VoiceMessagePlaybackTracker.Listener.State.Playing -> {
|
||||||
views.voicePlaybackControlButton.setImageResource(R.drawable.ic_play_pause_pause)
|
views.voicePlaybackControlButton.setImageResource(R.drawable.ic_play_pause_pause)
|
||||||
|
views.voicePlaybackControlButton.contentDescription = context.getString(R.string.a11y_pause_voice_message)
|
||||||
val formattedTimerText = DateUtils.formatElapsedTime((state.playbackTime / 1000).toLong())
|
val formattedTimerText = DateUtils.formatElapsedTime((state.playbackTime / 1000).toLong())
|
||||||
views.voicePlaybackTime.text = formattedTimerText
|
views.voicePlaybackTime.text = formattedTimerText
|
||||||
}
|
}
|
||||||
is VoiceMessagePlaybackTracker.Listener.State.Paused,
|
is VoiceMessagePlaybackTracker.Listener.State.Paused,
|
||||||
is VoiceMessagePlaybackTracker.Listener.State.Idle -> {
|
is VoiceMessagePlaybackTracker.Listener.State.Idle -> {
|
||||||
views.voicePlaybackControlButton.setImageResource(R.drawable.ic_play_pause_play)
|
views.voicePlaybackControlButton.setImageResource(R.drawable.ic_play_pause_play)
|
||||||
|
views.voicePlaybackControlButton.contentDescription = context.getString(R.string.a11y_play_voice_message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,6 +71,7 @@ abstract class MessageVoiceItem : AbsMessageItem<MessageVoiceItem.Holder>() {
|
||||||
contentUploadStateTrackerBinder.bind(attributes.informationData.eventId, izLocalFile, holder.progressLayout)
|
contentUploadStateTrackerBinder.bind(attributes.informationData.eventId, izLocalFile, holder.progressLayout)
|
||||||
} else {
|
} else {
|
||||||
holder.voicePlaybackControlButton.setImageResource(R.drawable.ic_cross)
|
holder.voicePlaybackControlButton.setImageResource(R.drawable.ic_cross)
|
||||||
|
holder.voicePlaybackControlButton.contentDescription = holder.view.context.getString(R.string.error_voice_message_unable_to_play)
|
||||||
holder.progressLayout.isVisible = false
|
holder.progressLayout.isVisible = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,16 +99,19 @@ abstract class MessageVoiceItem : AbsMessageItem<MessageVoiceItem.Holder>() {
|
||||||
|
|
||||||
private fun renderIdleState(holder: Holder) {
|
private fun renderIdleState(holder: Holder) {
|
||||||
holder.voicePlaybackControlButton.setImageResource(R.drawable.ic_play_pause_play)
|
holder.voicePlaybackControlButton.setImageResource(R.drawable.ic_play_pause_play)
|
||||||
|
holder.voicePlaybackControlButton.contentDescription = holder.view.context.getString(R.string.a11y_play_voice_message)
|
||||||
holder.voicePlaybackTime.text = formatPlaybackTime(duration)
|
holder.voicePlaybackTime.text = formatPlaybackTime(duration)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun renderPlayingState(holder: Holder, state: VoiceMessagePlaybackTracker.Listener.State.Playing) {
|
private fun renderPlayingState(holder: Holder, state: VoiceMessagePlaybackTracker.Listener.State.Playing) {
|
||||||
holder.voicePlaybackControlButton.setImageResource(R.drawable.ic_play_pause_pause)
|
holder.voicePlaybackControlButton.setImageResource(R.drawable.ic_play_pause_pause)
|
||||||
|
holder.voicePlaybackControlButton.contentDescription = holder.view.context.getString(R.string.a11y_pause_voice_message)
|
||||||
holder.voicePlaybackTime.text = formatPlaybackTime(state.playbackTime)
|
holder.voicePlaybackTime.text = formatPlaybackTime(state.playbackTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun renderPausedState(holder: Holder, state: VoiceMessagePlaybackTracker.Listener.State.Paused) {
|
private fun renderPausedState(holder: Holder, state: VoiceMessagePlaybackTracker.Listener.State.Paused) {
|
||||||
holder.voicePlaybackControlButton.setImageResource(R.drawable.ic_play_pause_play)
|
holder.voicePlaybackControlButton.setImageResource(R.drawable.ic_play_pause_play)
|
||||||
|
holder.voicePlaybackControlButton.contentDescription = holder.view.context.getString(R.string.a11y_play_voice_message)
|
||||||
holder.voicePlaybackTime.text = formatPlaybackTime(state.playbackTime)
|
holder.voicePlaybackTime.text = formatPlaybackTime(state.playbackTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue