Send voice message should not be allowed during a voice broadcast recording
This commit is contained in:
parent
0cdbceaa00
commit
ba9720416a
1
changelog.d/7895.bugfix
Normal file
1
changelog.d/7895.bugfix
Normal file
@ -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_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_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_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="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 -->
|
<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) {
|
return when (throwable) {
|
||||||
is VoiceFailure.UnableToPlay -> stringProvider.getString(R.string.error_voice_message_unable_to_play)
|
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.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 -> {
|
is MessageComposerViewEvents.VoicePlaybackOrRecordingFailure -> {
|
||||||
if (it.throwable is VoiceFailure.UnableToRecord) {
|
if (it.throwable is VoiceFailure.UnableToRecord) {
|
||||||
onCannotRecord()
|
onCannotRecord()
|
||||||
|
} else if (it.throwable is VoiceFailure.VoiceBroadcastInProgress) {
|
||||||
|
displayErrorVoiceBroadcastInProgress()
|
||||||
}
|
}
|
||||||
showErrorInSnackbar(it.throwable)
|
showErrorInSnackbar(it.throwable)
|
||||||
}
|
}
|
||||||
@ -526,6 +528,14 @@ class MessageComposerFragment : VectorBaseFragment<FragmentComposerBinding>(), A
|
|||||||
messageComposerViewModel.handle(MessageComposerAction.OnVoiceRecordingUiStateChanged(VoiceMessageRecorderView.RecordingUiState.Idle))
|
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) {
|
private fun handleJoinedToAnotherRoom(action: MessageComposerViewEvents.JoinRoomCommandSuccess) {
|
||||||
composer.setTextIfDifferent("")
|
composer.setTextIfDifferent("")
|
||||||
lockSendButton = false
|
lockSendButton = false
|
||||||
|
@ -19,6 +19,7 @@ package im.vector.app.features.home.room.detail.composer
|
|||||||
import android.text.SpannableString
|
import android.text.SpannableString
|
||||||
import androidx.lifecycle.asFlow
|
import androidx.lifecycle.asFlow
|
||||||
import com.airbnb.mvrx.MavericksViewModelFactory
|
import com.airbnb.mvrx.MavericksViewModelFactory
|
||||||
|
import com.airbnb.mvrx.withState
|
||||||
import dagger.assisted.Assisted
|
import dagger.assisted.Assisted
|
||||||
import dagger.assisted.AssistedFactory
|
import dagger.assisted.AssistedFactory
|
||||||
import dagger.assisted.AssistedInject
|
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.powerlevel.PowerLevelsFlowFactory
|
||||||
import im.vector.app.features.session.coroutineScope
|
import im.vector.app.features.session.coroutineScope
|
||||||
import im.vector.app.features.settings.VectorPreferences
|
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.VoiceBroadcastConstants
|
||||||
import im.vector.app.features.voicebroadcast.VoiceBroadcastHelper
|
import im.vector.app.features.voicebroadcast.VoiceBroadcastHelper
|
||||||
import im.vector.app.features.voicebroadcast.model.asVoiceBroadcastEvent
|
import im.vector.app.features.voicebroadcast.model.asVoiceBroadcastEvent
|
||||||
@ -916,10 +918,15 @@ class MessageComposerViewModel @AssistedInject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun handleStartRecordingVoiceMessage(room: Room) {
|
private fun handleStartRecordingVoiceMessage(room: Room) {
|
||||||
try {
|
val isRecordingVoiceBroadcast = withState(this) { it.isRecordingVoiceBroadcast }
|
||||||
audioMessageHelper.startRecording(room.roomId)
|
if (isRecordingVoiceBroadcast) {
|
||||||
} catch (failure: Throwable) {
|
_viewEvents.post(MessageComposerViewEvents.VoicePlaybackOrRecordingFailure(VoiceFailure.VoiceBroadcastInProgress))
|
||||||
_viewEvents.post(MessageComposerViewEvents.VoicePlaybackOrRecordingFailure(failure))
|
} else {
|
||||||
|
try {
|
||||||
|
audioMessageHelper.startRecording(room.roomId)
|
||||||
|
} catch (failure: Throwable) {
|
||||||
|
_viewEvents.post(MessageComposerViewEvents.VoicePlaybackOrRecordingFailure(failure))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,4 +19,5 @@ package im.vector.app.features.voice
|
|||||||
sealed class VoiceFailure(cause: Throwable? = null) : Throwable(cause = cause) {
|
sealed class VoiceFailure(cause: Throwable? = null) : Throwable(cause = cause) {
|
||||||
data class UnableToPlay(val throwable: Throwable) : VoiceFailure(throwable)
|
data class UnableToPlay(val throwable: Throwable) : VoiceFailure(throwable)
|
||||||
data class UnableToRecord(val throwable: Throwable) : VoiceFailure(throwable)
|
data class UnableToRecord(val throwable: Throwable) : VoiceFailure(throwable)
|
||||||
|
object VoiceBroadcastInProgress : VoiceFailure()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user