From 13aee7d162d5284bcff91a282b847a26b2c35523 Mon Sep 17 00:00:00 2001 From: Onuray Sahin Date: Mon, 11 Oct 2021 16:49:15 +0300 Subject: [PATCH 1/2] Do not delete voice message file to be able to resend. --- changelog.d/4006.bugfix | 1 + .../sdk/internal/session/content/UploadContentWorker.kt | 5 +++++ .../app/features/home/room/detail/RoomDetailFragment.kt | 2 -- 3 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 changelog.d/4006.bugfix diff --git a/changelog.d/4006.bugfix b/changelog.d/4006.bugfix new file mode 100644 index 0000000000..61ac98ccb8 --- /dev/null +++ b/changelog.d/4006.bugfix @@ -0,0 +1 @@ +Voice Message not sendable if recorded while flight mode was on \ No newline at end of file diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/content/UploadContentWorker.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/content/UploadContentWorker.kt index 11c200c54b..6fd92047b3 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/content/UploadContentWorker.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/content/UploadContentWorker.kt @@ -291,6 +291,11 @@ internal class UploadContentWorker(val context: Context, params: WorkerParameter filesToDelete.forEach { tryOrNull { it.delete() } } + + // Delete the temporary voice message file + if (params.attachment.type == ContentAttachmentData.Type.AUDIO && params.attachment.mimeType == MimeTypes.Ogg) { + context.contentResolver.delete(params.attachment.queryUri, null, null) + } } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt index b3fe6fcbf4..2066bf9d08 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt @@ -1095,8 +1095,6 @@ class RoomDetailFragment @Inject constructor( textComposerViewModel.handle(TextComposerAction.SaveDraft(views.composerLayout.text.toString())) - // We should improve the UX to support going into playback mode when paused and delete the media when the view is destroyed. - roomDetailViewModel.handle(RoomDetailAction.EndAllVoiceActions) views.voiceMessageRecorderView.initVoiceRecordingViews() } From 39d92d855980f76b25050e282d2bd6ac9bf3b903 Mon Sep 17 00:00:00 2001 From: Onuray Sahin Date: Tue, 12 Oct 2021 17:53:56 +0300 Subject: [PATCH 2/2] To be able to resend, stop all voice actions without deleting. --- .../app/features/home/room/detail/RoomDetailAction.kt | 2 +- .../app/features/home/room/detail/RoomDetailFragment.kt | 2 ++ .../app/features/home/room/detail/RoomDetailViewModel.kt | 6 +++--- .../home/room/detail/composer/VoiceMessageHelper.kt | 6 ++++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailAction.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailAction.kt index 9c5f436728..a9b9f8000b 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailAction.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailAction.kt @@ -115,5 +115,5 @@ sealed class RoomDetailAction : VectorViewModelAction { object PauseRecordingVoiceMessage : RoomDetailAction() data class PlayOrPauseVoicePlayback(val eventId: String, val messageAudioContent: MessageAudioContent) : RoomDetailAction() object PlayOrPauseRecordingPlayback : RoomDetailAction() - object EndAllVoiceActions : RoomDetailAction() + data class EndAllVoiceActions(val deleteRecord: Boolean = true) : RoomDetailAction() } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt index 2066bf9d08..a144715aa2 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt @@ -1095,6 +1095,8 @@ class RoomDetailFragment @Inject constructor( textComposerViewModel.handle(TextComposerAction.SaveDraft(views.composerLayout.text.toString())) + // We should improve the UX to support going into playback mode when paused and delete the media when the view is destroyed. + roomDetailViewModel.handle(RoomDetailAction.EndAllVoiceActions(deleteRecord = false)) views.voiceMessageRecorderView.initVoiceRecordingViews() } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewModel.kt index bd11ec6718..7971b5123a 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewModel.kt @@ -343,7 +343,7 @@ class RoomDetailViewModel @AssistedInject constructor( is RoomDetailAction.PlayOrPauseVoicePlayback -> handlePlayOrPauseVoicePlayback(action) RoomDetailAction.PauseRecordingVoiceMessage -> handlePauseRecordingVoiceMessage() RoomDetailAction.PlayOrPauseRecordingPlayback -> handlePlayOrPauseRecordingPlayback() - RoomDetailAction.EndAllVoiceActions -> handleEndAllVoiceActions() + is RoomDetailAction.EndAllVoiceActions -> handleEndAllVoiceActions(action.deleteRecord) is RoomDetailAction.RoomUpgradeSuccess -> { setState { copy(joinUpgradedRoomAsync = Success(action.replacementRoomId)) @@ -649,8 +649,8 @@ class RoomDetailViewModel @AssistedInject constructor( voiceMessageHelper.startOrPauseRecordingPlayback() } - private fun handleEndAllVoiceActions() { - voiceMessageHelper.stopAllVoiceActions() + private fun handleEndAllVoiceActions(deleteRecord: Boolean) { + voiceMessageHelper.stopAllVoiceActions(deleteRecord) } private fun handlePauseRecordingVoiceMessage() { diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/VoiceMessageHelper.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/VoiceMessageHelper.kt index b0880623de..adcd6a3008 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/VoiceMessageHelper.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/VoiceMessageHelper.kt @@ -217,10 +217,12 @@ class VoiceMessageHelper @Inject constructor( playbackTicker = null } - fun stopAllVoiceActions() { + fun stopAllVoiceActions(deleteRecord: Boolean = true) { stopRecording() stopPlayback() - deleteRecording() + if (deleteRecord) { + deleteRecording() + } playbackTracker.clear() } }