Merge pull request #4547 from vector-im/feature/adm/voice-files
Timeline editing and offline voice message fixes
This commit is contained in:
commit
b3d1c4fbdb
1
changelog.d/3833.bugfix
Normal file
1
changelog.d/3833.bugfix
Normal file
@ -0,0 +1 @@
|
|||||||
|
Fixing queued voice message failing to send or retry
|
@ -279,6 +279,11 @@ internal class UploadContentWorker(val context: Context, params: WorkerParameter
|
|||||||
Timber.e(failure, "## Failed to update file cache")
|
Timber.e(failure, "## Failed to update file cache")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
}
|
||||||
|
|
||||||
val uploadThumbnailResult = dealWithThumbnail(params)
|
val uploadThumbnailResult = dealWithThumbnail(params)
|
||||||
|
|
||||||
handleSuccess(params,
|
handleSuccess(params,
|
||||||
@ -299,11 +304,6 @@ internal class UploadContentWorker(val context: Context, params: WorkerParameter
|
|||||||
filesToDelete.forEach {
|
filesToDelete.forEach {
|
||||||
tryOrNull { it.delete() }
|
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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,10 +58,7 @@ data class MessageComposerViewState(
|
|||||||
VoiceMessageRecorderView.RecordingUiState.Started -> true
|
VoiceMessageRecorderView.RecordingUiState.Started -> true
|
||||||
}
|
}
|
||||||
|
|
||||||
val isVoiceMessageIdle = when (voiceRecordingUiState) {
|
val isVoiceMessageIdle = !isVoiceRecording
|
||||||
VoiceMessageRecorderView.RecordingUiState.None, VoiceMessageRecorderView.RecordingUiState.Cancelled -> false
|
|
||||||
else -> true
|
|
||||||
}
|
|
||||||
|
|
||||||
val isComposerVisible = canSendMessage && !isVoiceRecording
|
val isComposerVisible = canSendMessage && !isVoiceRecording
|
||||||
val isVoiceMessageRecorderVisible = canSendMessage && !isSendButtonVisible
|
val isVoiceMessageRecorderVisible = canSendMessage && !isSendButtonVisible
|
||||||
|
@ -76,9 +76,8 @@ class VoiceMessageHelper @Inject constructor(
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
voiceMessageFile?.let {
|
voiceMessageFile?.let {
|
||||||
val outputFileUri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".fileProvider", it)
|
val outputFileUri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".fileProvider", it, "Voice message.${it.extension}")
|
||||||
return outputFileUri
|
return outputFileUri.toMultiPickerAudioType(context)
|
||||||
?.toMultiPickerAudioType(context)
|
|
||||||
?.apply {
|
?.apply {
|
||||||
waveform = if (amplitudeList.size < 50) {
|
waveform = if (amplitudeList.size < 50) {
|
||||||
amplitudeList
|
amplitudeList
|
||||||
|
@ -18,9 +18,12 @@ package im.vector.app.features.voice
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.media.MediaRecorder
|
import android.media.MediaRecorder
|
||||||
|
import android.net.Uri
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
|
import org.matrix.android.sdk.api.session.content.ContentAttachmentData
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileOutputStream
|
import java.io.FileOutputStream
|
||||||
|
import java.util.UUID
|
||||||
|
|
||||||
abstract class AbstractVoiceRecorder(
|
abstract class AbstractVoiceRecorder(
|
||||||
private val context: Context,
|
private val context: Context,
|
||||||
@ -59,7 +62,7 @@ abstract class AbstractVoiceRecorder(
|
|||||||
|
|
||||||
override fun startRecord() {
|
override fun startRecord() {
|
||||||
init()
|
init()
|
||||||
outputFile = File(outputDirectory, "Voice message.$filenameExt")
|
outputFile = File(outputDirectory, "${UUID.randomUUID()}$filenameExt")
|
||||||
|
|
||||||
val mr = mediaRecorder ?: return
|
val mr = mediaRecorder ?: return
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
@ -100,3 +103,12 @@ abstract class AbstractVoiceRecorder(
|
|||||||
return convertFile(outputFile)
|
return convertFile(outputFile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("UNUSED") // preemptively added for https://github.com/vector-im/element-android/pull/4527
|
||||||
|
private fun ContentAttachmentData.findVoiceFile(baseDirectory: File): File {
|
||||||
|
return File(baseDirectory, queryUri.takePathAfter(baseDirectory.name))
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun Uri.takePathAfter(after: String): String {
|
||||||
|
return pathSegments.takeLastWhile { it != after }.joinToString(separator = "/") { it }
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user