Send voice message should not be allowed during a voice broadcast recording
This commit is contained in:
parent
0cdbceaa00
commit
ba9720416a
|
@ -0,0 +1 @@
|
|||
Send voice message should not be allowed during a voice broadcast recording
|
|
@ -3097,6 +3097,8 @@
|
|||
<string name="error_voice_message_unable_to_play">Cannot play this voice message</string>
|
||||
<string name="error_voice_message_unable_to_record">Cannot record a voice message</string>
|
||||
<string name="error_voice_message_cannot_reply_or_edit">Cannot reply or edit while voice message is active</string>
|
||||
<string name="error_voice_message_broadcast_in_progress">Cannot start voice message</string>
|
||||
<string name="error_voice_message_broadcast_in_progress_message">You can’t start a voice message as you are currently recording a live broadcast. Please end your live broadcast in order to start recording a voice message</string>
|
||||
<string name="voice_message_reply_content">Voice Message (%1$s)</string>
|
||||
|
||||
<string name="a11y_audio_message_item">%1$s, %2$s, %3$s</string> <!-- filename, duration, file size -->
|
||||
|
|
|
@ -151,6 +151,7 @@ class DefaultErrorFormatter @Inject constructor(
|
|||
return when (throwable) {
|
||||
is VoiceFailure.UnableToPlay -> stringProvider.getString(R.string.error_voice_message_unable_to_play)
|
||||
is VoiceFailure.UnableToRecord -> stringProvider.getString(R.string.error_voice_message_unable_to_record)
|
||||
is VoiceFailure.VoiceBroadcastInProgress -> stringProvider.getString(R.string.error_voice_message_broadcast_in_progress)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -191,6 +191,8 @@ class MessageComposerFragment : VectorBaseFragment<FragmentComposerBinding>(), A
|
|||
is MessageComposerViewEvents.VoicePlaybackOrRecordingFailure -> {
|
||||
if (it.throwable is VoiceFailure.UnableToRecord) {
|
||||
onCannotRecord()
|
||||
} else if (it.throwable is VoiceFailure.VoiceBroadcastInProgress) {
|
||||
displayErrorVoiceBroadcastInProgress()
|
||||
}
|
||||
showErrorInSnackbar(it.throwable)
|
||||
}
|
||||
|
@ -526,6 +528,14 @@ class MessageComposerFragment : VectorBaseFragment<FragmentComposerBinding>(), A
|
|||
messageComposerViewModel.handle(MessageComposerAction.OnVoiceRecordingUiStateChanged(VoiceMessageRecorderView.RecordingUiState.Idle))
|
||||
}
|
||||
|
||||
private fun displayErrorVoiceBroadcastInProgress() {
|
||||
MaterialAlertDialogBuilder(requireActivity())
|
||||
.setTitle(R.string.error_voice_message_broadcast_in_progress)
|
||||
.setMessage(getString(R.string.error_voice_message_broadcast_in_progress_message))
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.show()
|
||||
}
|
||||
|
||||
private fun handleJoinedToAnotherRoom(action: MessageComposerViewEvents.JoinRoomCommandSuccess) {
|
||||
composer.setTextIfDifferent("")
|
||||
lockSendButton = false
|
||||
|
|
|
@ -19,6 +19,7 @@ package im.vector.app.features.home.room.detail.composer
|
|||
import android.text.SpannableString
|
||||
import androidx.lifecycle.asFlow
|
||||
import com.airbnb.mvrx.MavericksViewModelFactory
|
||||
import com.airbnb.mvrx.withState
|
||||
import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedFactory
|
||||
import dagger.assisted.AssistedInject
|
||||
|
@ -42,6 +43,7 @@ import im.vector.app.features.home.room.detail.toMessageType
|
|||
import im.vector.app.features.powerlevel.PowerLevelsFlowFactory
|
||||
import im.vector.app.features.session.coroutineScope
|
||||
import im.vector.app.features.settings.VectorPreferences
|
||||
import im.vector.app.features.voice.VoiceFailure
|
||||
import im.vector.app.features.voicebroadcast.VoiceBroadcastConstants
|
||||
import im.vector.app.features.voicebroadcast.VoiceBroadcastHelper
|
||||
import im.vector.app.features.voicebroadcast.model.asVoiceBroadcastEvent
|
||||
|
@ -916,12 +918,17 @@ class MessageComposerViewModel @AssistedInject constructor(
|
|||
}
|
||||
|
||||
private fun handleStartRecordingVoiceMessage(room: Room) {
|
||||
val isRecordingVoiceBroadcast = withState(this) { it.isRecordingVoiceBroadcast }
|
||||
if (isRecordingVoiceBroadcast) {
|
||||
_viewEvents.post(MessageComposerViewEvents.VoicePlaybackOrRecordingFailure(VoiceFailure.VoiceBroadcastInProgress))
|
||||
} else {
|
||||
try {
|
||||
audioMessageHelper.startRecording(room.roomId)
|
||||
} catch (failure: Throwable) {
|
||||
_viewEvents.post(MessageComposerViewEvents.VoicePlaybackOrRecordingFailure(failure))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleEndRecordingVoiceMessage(room: Room, isCancelled: Boolean, rootThreadEventId: String? = null) {
|
||||
audioMessageHelper.stopPlayback()
|
||||
|
|
|
@ -19,4 +19,5 @@ package im.vector.app.features.voice
|
|||
sealed class VoiceFailure(cause: Throwable? = null) : Throwable(cause = cause) {
|
||||
data class UnableToPlay(val throwable: Throwable) : VoiceFailure(throwable)
|
||||
data class UnableToRecord(val throwable: Throwable) : VoiceFailure(throwable)
|
||||
object VoiceBroadcastInProgress : VoiceFailure()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue