Allow caption for audio and file.
Need to preview all the attachments now, to be able to type a caption.
This commit is contained in:
parent
7217cc108b
commit
ece62b7978
13 changed files with 112 additions and 102 deletions
|
|
@ -12,7 +12,6 @@ import io.element.android.features.messages.impl.actionlist.ActionListState
|
||||||
import io.element.android.features.messages.impl.actionlist.anActionListState
|
import io.element.android.features.messages.impl.actionlist.anActionListState
|
||||||
import io.element.android.features.messages.impl.crypto.identity.IdentityChangeState
|
import io.element.android.features.messages.impl.crypto.identity.IdentityChangeState
|
||||||
import io.element.android.features.messages.impl.crypto.identity.anIdentityChangeState
|
import io.element.android.features.messages.impl.crypto.identity.anIdentityChangeState
|
||||||
import io.element.android.features.messages.impl.messagecomposer.AttachmentsState
|
|
||||||
import io.element.android.features.messages.impl.messagecomposer.MessageComposerState
|
import io.element.android.features.messages.impl.messagecomposer.MessageComposerState
|
||||||
import io.element.android.features.messages.impl.messagecomposer.aMessageComposerState
|
import io.element.android.features.messages.impl.messagecomposer.aMessageComposerState
|
||||||
import io.element.android.features.messages.impl.pinned.banner.PinnedMessagesBannerState
|
import io.element.android.features.messages.impl.pinned.banner.PinnedMessagesBannerState
|
||||||
|
|
@ -62,16 +61,6 @@ open class MessagesStateProvider : PreviewParameterProvider<MessagesState> {
|
||||||
enableVoiceMessages = true,
|
enableVoiceMessages = true,
|
||||||
voiceMessageComposerState = aVoiceMessageComposerState(showPermissionRationaleDialog = true),
|
voiceMessageComposerState = aVoiceMessageComposerState(showPermissionRationaleDialog = true),
|
||||||
),
|
),
|
||||||
aMessagesState(
|
|
||||||
composerState = aMessageComposerState(
|
|
||||||
attachmentsState = AttachmentsState.Sending.Processing(persistentListOf())
|
|
||||||
),
|
|
||||||
),
|
|
||||||
aMessagesState(
|
|
||||||
composerState = aMessageComposerState(
|
|
||||||
attachmentsState = AttachmentsState.Sending.Uploading(0.33f)
|
|
||||||
),
|
|
||||||
),
|
|
||||||
aMessagesState(
|
aMessagesState(
|
||||||
roomCallState = anOngoingCallState(),
|
roomCallState = anOngoingCallState(),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -83,8 +83,6 @@ import io.element.android.features.networkmonitor.api.ui.ConnectivityIndicatorVi
|
||||||
import io.element.android.features.roomcall.api.RoomCallState
|
import io.element.android.features.roomcall.api.RoomCallState
|
||||||
import io.element.android.libraries.androidutils.ui.hideKeyboard
|
import io.element.android.libraries.androidutils.ui.hideKeyboard
|
||||||
import io.element.android.libraries.designsystem.atomic.molecules.IconTitlePlaceholdersRowMolecule
|
import io.element.android.libraries.designsystem.atomic.molecules.IconTitlePlaceholdersRowMolecule
|
||||||
import io.element.android.libraries.designsystem.components.ProgressDialog
|
|
||||||
import io.element.android.libraries.designsystem.components.ProgressDialogType
|
|
||||||
import io.element.android.libraries.designsystem.components.avatar.AvatarData
|
import io.element.android.libraries.designsystem.components.avatar.AvatarData
|
||||||
import io.element.android.libraries.designsystem.components.avatar.AvatarSize
|
import io.element.android.libraries.designsystem.components.avatar.AvatarSize
|
||||||
import io.element.android.libraries.designsystem.components.avatar.CompositeAvatar
|
import io.element.android.libraries.designsystem.components.avatar.CompositeAvatar
|
||||||
|
|
@ -134,7 +132,6 @@ fun MessagesView(
|
||||||
AttachmentStateView(
|
AttachmentStateView(
|
||||||
state = state.composerState.attachmentsState,
|
state = state.composerState.attachmentsState,
|
||||||
onPreviewAttachments = onPreviewAttachments,
|
onPreviewAttachments = onPreviewAttachments,
|
||||||
onCancel = { state.composerState.eventSink(MessageComposerEvents.CancelSendAttachment) },
|
|
||||||
)
|
)
|
||||||
|
|
||||||
val snackbarHostState = rememberSnackbarHostState(snackbarMessage = state.snackbarMessage)
|
val snackbarHostState = rememberSnackbarHostState(snackbarMessage = state.snackbarMessage)
|
||||||
|
|
@ -280,7 +277,6 @@ private fun ReinviteDialog(state: MessagesState) {
|
||||||
private fun AttachmentStateView(
|
private fun AttachmentStateView(
|
||||||
state: AttachmentsState,
|
state: AttachmentsState,
|
||||||
onPreviewAttachments: (ImmutableList<Attachment>) -> Unit,
|
onPreviewAttachments: (ImmutableList<Attachment>) -> Unit,
|
||||||
onCancel: () -> Unit,
|
|
||||||
) {
|
) {
|
||||||
when (state) {
|
when (state) {
|
||||||
AttachmentsState.None -> Unit
|
AttachmentsState.None -> Unit
|
||||||
|
|
@ -290,17 +286,6 @@ private fun AttachmentStateView(
|
||||||
latestOnPreviewAttachments(state.attachments)
|
latestOnPreviewAttachments(state.attachments)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is AttachmentsState.Sending -> {
|
|
||||||
ProgressDialog(
|
|
||||||
type = when (state) {
|
|
||||||
is AttachmentsState.Sending.Uploading -> ProgressDialogType.Determinate(state.progress)
|
|
||||||
is AttachmentsState.Sending.Processing -> ProgressDialogType.Indeterminate
|
|
||||||
},
|
|
||||||
text = stringResource(id = CommonStrings.common_sending),
|
|
||||||
showCancelButton = true,
|
|
||||||
onDismissRequest = onCancel,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,6 @@ package io.element.android.features.messages.impl.attachments.preview
|
||||||
|
|
||||||
import androidx.compose.runtime.Immutable
|
import androidx.compose.runtime.Immutable
|
||||||
import io.element.android.features.messages.impl.attachments.Attachment
|
import io.element.android.features.messages.impl.attachments.Attachment
|
||||||
import io.element.android.libraries.core.bool.orFalse
|
|
||||||
import io.element.android.libraries.core.mimetype.MimeTypes.isMimeTypeImage
|
|
||||||
import io.element.android.libraries.core.mimetype.MimeTypes.isMimeTypeVideo
|
|
||||||
import io.element.android.libraries.textcomposer.model.TextEditorState
|
import io.element.android.libraries.textcomposer.model.TextEditorState
|
||||||
|
|
||||||
data class AttachmentsPreviewState(
|
data class AttachmentsPreviewState(
|
||||||
|
|
@ -20,9 +17,8 @@ data class AttachmentsPreviewState(
|
||||||
val textEditorState: TextEditorState,
|
val textEditorState: TextEditorState,
|
||||||
val eventSink: (AttachmentsPreviewEvents) -> Unit
|
val eventSink: (AttachmentsPreviewEvents) -> Unit
|
||||||
) {
|
) {
|
||||||
val allowCaption: Boolean = (attachment as? Attachment.Media)?.localMedia?.info?.mimeType?.let {
|
// Keep the val to eventually set to false for some mimetypes.
|
||||||
it.isMimeTypeImage() || it.isMimeTypeVideo()
|
val allowCaption: Boolean = true
|
||||||
}.orFalse()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,6 @@ sealed interface MessageComposerEvents {
|
||||||
data object Poll : PickAttachmentSource
|
data object Poll : PickAttachmentSource
|
||||||
}
|
}
|
||||||
data class ToggleTextFormatting(val enabled: Boolean) : MessageComposerEvents
|
data class ToggleTextFormatting(val enabled: Boolean) : MessageComposerEvents
|
||||||
data object CancelSendAttachment : MessageComposerEvents
|
|
||||||
data class Error(val error: Throwable) : MessageComposerEvents
|
data class Error(val error: Throwable) : MessageComposerEvents
|
||||||
data class TypingNotice(val isTyping: Boolean) : MessageComposerEvents
|
data class TypingNotice(val isTyping: Boolean) : MessageComposerEvents
|
||||||
data class SuggestionReceived(val suggestion: Suggestion?) : MessageComposerEvents
|
data class SuggestionReceived(val suggestion: Suggestion?) : MessageComposerEvents
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,6 @@ import io.element.android.libraries.di.RoomScope
|
||||||
import io.element.android.libraries.di.SingleIn
|
import io.element.android.libraries.di.SingleIn
|
||||||
import io.element.android.libraries.featureflag.api.FeatureFlagService
|
import io.element.android.libraries.featureflag.api.FeatureFlagService
|
||||||
import io.element.android.libraries.featureflag.api.FeatureFlags
|
import io.element.android.libraries.featureflag.api.FeatureFlags
|
||||||
import io.element.android.libraries.matrix.api.core.ProgressCallback
|
|
||||||
import io.element.android.libraries.matrix.api.core.UserId
|
import io.element.android.libraries.matrix.api.core.UserId
|
||||||
import io.element.android.libraries.matrix.api.permalink.PermalinkBuilder
|
import io.element.android.libraries.matrix.api.permalink.PermalinkBuilder
|
||||||
import io.element.android.libraries.matrix.api.permalink.PermalinkData
|
import io.element.android.libraries.matrix.api.permalink.PermalinkData
|
||||||
|
|
@ -81,7 +80,6 @@ import kotlinx.collections.immutable.toPersistentList
|
||||||
import kotlinx.coroutines.CancellationException
|
import kotlinx.coroutines.CancellationException
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.FlowPreview
|
import kotlinx.coroutines.FlowPreview
|
||||||
import kotlinx.coroutines.Job
|
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.collect
|
import kotlinx.coroutines.flow.collect
|
||||||
|
|
@ -89,11 +87,9 @@ import kotlinx.coroutines.flow.combine
|
||||||
import kotlinx.coroutines.flow.debounce
|
import kotlinx.coroutines.flow.debounce
|
||||||
import kotlinx.coroutines.flow.filter
|
import kotlinx.coroutines.flow.filter
|
||||||
import kotlinx.coroutines.flow.merge
|
import kotlinx.coroutines.flow.merge
|
||||||
import kotlinx.coroutines.isActive
|
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import kotlin.coroutines.coroutineContext
|
|
||||||
import kotlin.time.Duration.Companion.seconds
|
import kotlin.time.Duration.Companion.seconds
|
||||||
import io.element.android.libraries.core.mimetype.MimeTypes.Any as AnyMimeTypes
|
import io.element.android.libraries.core.mimetype.MimeTypes.Any as AnyMimeTypes
|
||||||
|
|
||||||
|
|
@ -180,26 +176,12 @@ class MessageComposerPresenter @Inject constructor(
|
||||||
val isFullScreen = rememberSaveable {
|
val isFullScreen = rememberSaveable {
|
||||||
mutableStateOf(false)
|
mutableStateOf(false)
|
||||||
}
|
}
|
||||||
val ongoingSendAttachmentJob = remember { mutableStateOf<Job?>(null) }
|
|
||||||
|
|
||||||
var showAttachmentSourcePicker: Boolean by remember { mutableStateOf(false) }
|
var showAttachmentSourcePicker: Boolean by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
val sendTypingNotifications by sessionPreferencesStore.isSendTypingNotificationsEnabled().collectAsState(initial = true)
|
val sendTypingNotifications by sessionPreferencesStore.isSendTypingNotificationsEnabled().collectAsState(initial = true)
|
||||||
|
|
||||||
val roomAliasSuggestions by roomAliasSuggestionsDataSource.getAllRoomAliasSuggestions().collectAsState(initial = emptyList())
|
val roomAliasSuggestions by roomAliasSuggestionsDataSource.getAllRoomAliasSuggestions().collectAsState(initial = emptyList())
|
||||||
|
|
||||||
LaunchedEffect(attachmentsState.value) {
|
|
||||||
when (val attachmentStateValue = attachmentsState.value) {
|
|
||||||
is AttachmentsState.Sending.Processing -> {
|
|
||||||
ongoingSendAttachmentJob.value = localCoroutineScope.sendAttachment(
|
|
||||||
attachmentStateValue.attachments.first(),
|
|
||||||
attachmentsState,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
else -> Unit
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LaunchedEffect(cameraPermissionState.permissionGranted) {
|
LaunchedEffect(cameraPermissionState.permissionGranted) {
|
||||||
if (cameraPermissionState.permissionGranted) {
|
if (cameraPermissionState.permissionGranted) {
|
||||||
when (pendingEvent) {
|
when (pendingEvent) {
|
||||||
|
|
@ -338,12 +320,6 @@ class MessageComposerPresenter @Inject constructor(
|
||||||
showAttachmentSourcePicker = false
|
showAttachmentSourcePicker = false
|
||||||
// Navigation to the create poll screen is done at the view layer
|
// Navigation to the create poll screen is done at the view layer
|
||||||
}
|
}
|
||||||
is MessageComposerEvents.CancelSendAttachment -> {
|
|
||||||
ongoingSendAttachmentJob.value?.let {
|
|
||||||
it.cancel()
|
|
||||||
ongoingSendAttachmentJob.value == null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
is MessageComposerEvents.ToggleTextFormatting -> {
|
is MessageComposerEvents.ToggleTextFormatting -> {
|
||||||
showAttachmentSourcePicker = false
|
showAttachmentSourcePicker = false
|
||||||
localCoroutineScope.toggleTextFormatting(event.enabled, markdownTextEditorState, richTextEditorState)
|
localCoroutineScope.toggleTextFormatting(event.enabled, markdownTextEditorState, richTextEditorState)
|
||||||
|
|
@ -505,17 +481,7 @@ class MessageComposerPresenter @Inject constructor(
|
||||||
formattedFileSize = null
|
formattedFileSize = null
|
||||||
)
|
)
|
||||||
val mediaAttachment = Attachment.Media(localMedia)
|
val mediaAttachment = Attachment.Media(localMedia)
|
||||||
val isPreviewable = when {
|
attachmentsState.value = AttachmentsState.Previewing(persistentListOf(mediaAttachment))
|
||||||
MimeTypes.isImage(localMedia.info.mimeType) -> true
|
|
||||||
MimeTypes.isVideo(localMedia.info.mimeType) -> true
|
|
||||||
MimeTypes.isAudio(localMedia.info.mimeType) -> true
|
|
||||||
else -> false
|
|
||||||
}
|
|
||||||
attachmentsState.value = if (isPreviewable) {
|
|
||||||
AttachmentsState.Previewing(persistentListOf(mediaAttachment))
|
|
||||||
} else {
|
|
||||||
AttachmentsState.Sending.Processing(persistentListOf(mediaAttachment))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun sendMedia(
|
private suspend fun sendMedia(
|
||||||
|
|
@ -523,18 +489,10 @@ class MessageComposerPresenter @Inject constructor(
|
||||||
mimeType: String,
|
mimeType: String,
|
||||||
attachmentState: MutableState<AttachmentsState>,
|
attachmentState: MutableState<AttachmentsState>,
|
||||||
) = runCatching {
|
) = runCatching {
|
||||||
val context = coroutineContext
|
|
||||||
val progressCallback = object : ProgressCallback {
|
|
||||||
override fun onProgress(current: Long, total: Long) {
|
|
||||||
if (context.isActive) {
|
|
||||||
attachmentState.value = AttachmentsState.Sending.Uploading(current.toFloat() / total.toFloat())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mediaSender.sendMedia(
|
mediaSender.sendMedia(
|
||||||
uri = uri,
|
uri = uri,
|
||||||
mimeType = mimeType,
|
mimeType = mimeType,
|
||||||
progressCallback = progressCallback
|
progressCallback = null,
|
||||||
).getOrThrow()
|
).getOrThrow()
|
||||||
}
|
}
|
||||||
.onSuccess {
|
.onSuccess {
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,4 @@ data class MessageComposerState(
|
||||||
sealed interface AttachmentsState {
|
sealed interface AttachmentsState {
|
||||||
data object None : AttachmentsState
|
data object None : AttachmentsState
|
||||||
data class Previewing(val attachments: ImmutableList<Attachment>) : AttachmentsState
|
data class Previewing(val attachments: ImmutableList<Attachment>) : AttachmentsState
|
||||||
sealed interface Sending : AttachmentsState {
|
|
||||||
data class Processing(val attachments: ImmutableList<Attachment>) : Sending
|
|
||||||
data class Uploading(val progress: Float) : Sending
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -147,9 +147,21 @@ interface MatrixRoom : Closeable {
|
||||||
progressCallback: ProgressCallback?
|
progressCallback: ProgressCallback?
|
||||||
): Result<MediaUploadHandler>
|
): Result<MediaUploadHandler>
|
||||||
|
|
||||||
suspend fun sendAudio(file: File, audioInfo: AudioInfo, progressCallback: ProgressCallback?): Result<MediaUploadHandler>
|
suspend fun sendAudio(
|
||||||
|
file: File,
|
||||||
|
audioInfo: AudioInfo,
|
||||||
|
caption: String?,
|
||||||
|
formattedCaption: String?,
|
||||||
|
progressCallback: ProgressCallback?,
|
||||||
|
): Result<MediaUploadHandler>
|
||||||
|
|
||||||
suspend fun sendFile(file: File, fileInfo: FileInfo, progressCallback: ProgressCallback?): Result<MediaUploadHandler>
|
suspend fun sendFile(
|
||||||
|
file: File,
|
||||||
|
fileInfo: FileInfo,
|
||||||
|
caption: String?,
|
||||||
|
formattedCaption: String?,
|
||||||
|
progressCallback: ProgressCallback?,
|
||||||
|
): Result<MediaUploadHandler>
|
||||||
|
|
||||||
suspend fun toggleReaction(emoji: String, eventOrTransactionId: EventOrTransactionId): Result<Unit>
|
suspend fun toggleReaction(emoji: String, eventOrTransactionId: EventOrTransactionId): Result<Unit>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -91,9 +91,21 @@ interface Timeline : AutoCloseable {
|
||||||
|
|
||||||
suspend fun redactEvent(eventOrTransactionId: EventOrTransactionId, reason: String?): Result<Unit>
|
suspend fun redactEvent(eventOrTransactionId: EventOrTransactionId, reason: String?): Result<Unit>
|
||||||
|
|
||||||
suspend fun sendAudio(file: File, audioInfo: AudioInfo, progressCallback: ProgressCallback?): Result<MediaUploadHandler>
|
suspend fun sendAudio(
|
||||||
|
file: File,
|
||||||
|
audioInfo: AudioInfo,
|
||||||
|
caption: String?,
|
||||||
|
formattedCaption: String?,
|
||||||
|
progressCallback: ProgressCallback?,
|
||||||
|
): Result<MediaUploadHandler>
|
||||||
|
|
||||||
suspend fun sendFile(file: File, fileInfo: FileInfo, progressCallback: ProgressCallback?): Result<MediaUploadHandler>
|
suspend fun sendFile(
|
||||||
|
file: File,
|
||||||
|
fileInfo: FileInfo,
|
||||||
|
caption: String?,
|
||||||
|
formattedCaption: String?,
|
||||||
|
progressCallback: ProgressCallback?,
|
||||||
|
): Result<MediaUploadHandler>
|
||||||
|
|
||||||
suspend fun toggleReaction(emoji: String, eventOrTransactionId: EventOrTransactionId): Result<Unit>
|
suspend fun toggleReaction(emoji: String, eventOrTransactionId: EventOrTransactionId): Result<Unit>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -467,12 +467,36 @@ class RustMatrixRoom(
|
||||||
return liveTimeline.sendVideo(file, thumbnailFile, videoInfo, caption, formattedCaption, progressCallback)
|
return liveTimeline.sendVideo(file, thumbnailFile, videoInfo, caption, formattedCaption, progressCallback)
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun sendAudio(file: File, audioInfo: AudioInfo, progressCallback: ProgressCallback?): Result<MediaUploadHandler> {
|
override suspend fun sendAudio(
|
||||||
return liveTimeline.sendAudio(file, audioInfo, progressCallback)
|
file: File,
|
||||||
|
audioInfo: AudioInfo,
|
||||||
|
caption: String?,
|
||||||
|
formattedCaption: String?,
|
||||||
|
progressCallback: ProgressCallback?,
|
||||||
|
): Result<MediaUploadHandler> {
|
||||||
|
return liveTimeline.sendAudio(
|
||||||
|
file = file,
|
||||||
|
audioInfo = audioInfo,
|
||||||
|
caption = caption,
|
||||||
|
formattedCaption = formattedCaption,
|
||||||
|
progressCallback = progressCallback,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun sendFile(file: File, fileInfo: FileInfo, progressCallback: ProgressCallback?): Result<MediaUploadHandler> {
|
override suspend fun sendFile(
|
||||||
return liveTimeline.sendFile(file, fileInfo, progressCallback)
|
file: File,
|
||||||
|
fileInfo: FileInfo,
|
||||||
|
caption: String?,
|
||||||
|
formattedCaption: String?,
|
||||||
|
progressCallback: ProgressCallback?,
|
||||||
|
): Result<MediaUploadHandler> {
|
||||||
|
return liveTimeline.sendFile(
|
||||||
|
file,
|
||||||
|
fileInfo,
|
||||||
|
caption,
|
||||||
|
formattedCaption,
|
||||||
|
progressCallback,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun toggleReaction(emoji: String, eventOrTransactionId: EventOrTransactionId): Result<Unit> {
|
override suspend fun toggleReaction(emoji: String, eventOrTransactionId: EventOrTransactionId): Result<Unit> {
|
||||||
|
|
|
||||||
|
|
@ -373,29 +373,44 @@ class RustTimeline(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun sendAudio(file: File, audioInfo: AudioInfo, progressCallback: ProgressCallback?): Result<MediaUploadHandler> {
|
override suspend fun sendAudio(
|
||||||
|
file: File,
|
||||||
|
audioInfo: AudioInfo,
|
||||||
|
caption: String?,
|
||||||
|
formattedCaption: String?,
|
||||||
|
progressCallback: ProgressCallback?,
|
||||||
|
): Result<MediaUploadHandler> {
|
||||||
val useSendQueue = featureFlagsService.isFeatureEnabled(FeatureFlags.MediaUploadOnSendQueue)
|
val useSendQueue = featureFlagsService.isFeatureEnabled(FeatureFlags.MediaUploadOnSendQueue)
|
||||||
return sendAttachment(listOf(file)) {
|
return sendAttachment(listOf(file)) {
|
||||||
inner.sendAudio(
|
inner.sendAudio(
|
||||||
url = file.path,
|
url = file.path,
|
||||||
audioInfo = audioInfo.map(),
|
audioInfo = audioInfo.map(),
|
||||||
// Maybe allow a caption in the future?
|
caption = caption,
|
||||||
caption = null,
|
formattedCaption = formattedCaption?.let {
|
||||||
formattedCaption = null,
|
FormattedBody(body = it, format = MessageFormat.Html)
|
||||||
|
},
|
||||||
useSendQueue = useSendQueue,
|
useSendQueue = useSendQueue,
|
||||||
progressWatcher = progressCallback?.toProgressWatcher()
|
progressWatcher = progressCallback?.toProgressWatcher()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun sendFile(file: File, fileInfo: FileInfo, progressCallback: ProgressCallback?): Result<MediaUploadHandler> {
|
override suspend fun sendFile(
|
||||||
|
file: File,
|
||||||
|
fileInfo: FileInfo,
|
||||||
|
caption: String?,
|
||||||
|
formattedCaption: String?,
|
||||||
|
progressCallback: ProgressCallback?,
|
||||||
|
): Result<MediaUploadHandler> {
|
||||||
val useSendQueue = featureFlagsService.isFeatureEnabled(FeatureFlags.MediaUploadOnSendQueue)
|
val useSendQueue = featureFlagsService.isFeatureEnabled(FeatureFlags.MediaUploadOnSendQueue)
|
||||||
return sendAttachment(listOf(file)) {
|
return sendAttachment(listOf(file)) {
|
||||||
inner.sendFile(
|
inner.sendFile(
|
||||||
url = file.path,
|
url = file.path,
|
||||||
fileInfo = fileInfo.map(),
|
fileInfo = fileInfo.map(),
|
||||||
caption = null,
|
caption = caption,
|
||||||
formattedCaption = null,
|
formattedCaption = formattedCaption?.let {
|
||||||
|
FormattedBody(body = it, format = MessageFormat.Html)
|
||||||
|
},
|
||||||
useSendQueue = useSendQueue,
|
useSendQueue = useSendQueue,
|
||||||
progressWatcher = progressCallback?.toProgressWatcher(),
|
progressWatcher = progressCallback?.toProgressWatcher(),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -92,10 +92,10 @@ class FakeMatrixRoom(
|
||||||
{ _, _, _, _, _, _ -> lambdaError() },
|
{ _, _, _, _, _, _ -> lambdaError() },
|
||||||
private val sendVideoResult: (File, File?, VideoInfo, String?, String?, ProgressCallback?) -> Result<FakeMediaUploadHandler> =
|
private val sendVideoResult: (File, File?, VideoInfo, String?, String?, ProgressCallback?) -> Result<FakeMediaUploadHandler> =
|
||||||
{ _, _, _, _, _, _ -> lambdaError() },
|
{ _, _, _, _, _, _ -> lambdaError() },
|
||||||
private val sendFileResult: (File, FileInfo, ProgressCallback?) -> Result<FakeMediaUploadHandler> =
|
private val sendFileResult: (File, FileInfo, String?, String?, ProgressCallback?) -> Result<FakeMediaUploadHandler> =
|
||||||
{ _, _, _ -> lambdaError() },
|
{ _, _, _, _, _ -> lambdaError() },
|
||||||
private val sendAudioResult: (File, AudioInfo, ProgressCallback?) -> Result<FakeMediaUploadHandler> =
|
private val sendAudioResult: (File, AudioInfo, String?, String?, ProgressCallback?) -> Result<FakeMediaUploadHandler> =
|
||||||
{ _, _, _ -> lambdaError() },
|
{ _, _, _, _, _ -> lambdaError() },
|
||||||
private val sendVoiceMessageResult: (File, AudioInfo, List<Float>, ProgressCallback?) -> Result<FakeMediaUploadHandler> =
|
private val sendVoiceMessageResult: (File, AudioInfo, List<Float>, ProgressCallback?) -> Result<FakeMediaUploadHandler> =
|
||||||
{ _, _, _, _ -> lambdaError() },
|
{ _, _, _, _ -> lambdaError() },
|
||||||
private val setNameResult: (String) -> Result<Unit> = { lambdaError() },
|
private val setNameResult: (String) -> Result<Unit> = { lambdaError() },
|
||||||
|
|
@ -354,12 +354,16 @@ class FakeMatrixRoom(
|
||||||
override suspend fun sendAudio(
|
override suspend fun sendAudio(
|
||||||
file: File,
|
file: File,
|
||||||
audioInfo: AudioInfo,
|
audioInfo: AudioInfo,
|
||||||
|
caption: String?,
|
||||||
|
formattedCaption: String?,
|
||||||
progressCallback: ProgressCallback?
|
progressCallback: ProgressCallback?
|
||||||
): Result<MediaUploadHandler> = simulateLongTask {
|
): Result<MediaUploadHandler> = simulateLongTask {
|
||||||
simulateSendMediaProgress(progressCallback)
|
simulateSendMediaProgress(progressCallback)
|
||||||
sendAudioResult(
|
sendAudioResult(
|
||||||
file,
|
file,
|
||||||
audioInfo,
|
audioInfo,
|
||||||
|
caption,
|
||||||
|
formattedCaption,
|
||||||
progressCallback,
|
progressCallback,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -367,12 +371,16 @@ class FakeMatrixRoom(
|
||||||
override suspend fun sendFile(
|
override suspend fun sendFile(
|
||||||
file: File,
|
file: File,
|
||||||
fileInfo: FileInfo,
|
fileInfo: FileInfo,
|
||||||
|
caption: String?,
|
||||||
|
formattedCaption: String?,
|
||||||
progressCallback: ProgressCallback?
|
progressCallback: ProgressCallback?
|
||||||
): Result<MediaUploadHandler> = simulateLongTask {
|
): Result<MediaUploadHandler> = simulateLongTask {
|
||||||
simulateSendMediaProgress(progressCallback)
|
simulateSendMediaProgress(progressCallback)
|
||||||
sendFileResult(
|
sendFileResult(
|
||||||
file,
|
file,
|
||||||
fileInfo,
|
fileInfo,
|
||||||
|
caption,
|
||||||
|
formattedCaption,
|
||||||
progressCallback,
|
progressCallback,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -173,36 +173,48 @@ class FakeTimeline(
|
||||||
var sendAudioLambda: (
|
var sendAudioLambda: (
|
||||||
file: File,
|
file: File,
|
||||||
audioInfo: AudioInfo,
|
audioInfo: AudioInfo,
|
||||||
|
caption: String?,
|
||||||
|
formattedCaption: String?,
|
||||||
progressCallback: ProgressCallback?,
|
progressCallback: ProgressCallback?,
|
||||||
) -> Result<MediaUploadHandler> = { _, _, _ ->
|
) -> Result<MediaUploadHandler> = { _, _, _, _, _ ->
|
||||||
Result.success(FakeMediaUploadHandler())
|
Result.success(FakeMediaUploadHandler())
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun sendAudio(
|
override suspend fun sendAudio(
|
||||||
file: File,
|
file: File,
|
||||||
audioInfo: AudioInfo,
|
audioInfo: AudioInfo,
|
||||||
|
caption: String?,
|
||||||
|
formattedCaption: String?,
|
||||||
progressCallback: ProgressCallback?,
|
progressCallback: ProgressCallback?,
|
||||||
): Result<MediaUploadHandler> = sendAudioLambda(
|
): Result<MediaUploadHandler> = sendAudioLambda(
|
||||||
file,
|
file,
|
||||||
audioInfo,
|
audioInfo,
|
||||||
|
caption,
|
||||||
|
formattedCaption,
|
||||||
progressCallback
|
progressCallback
|
||||||
)
|
)
|
||||||
|
|
||||||
var sendFileLambda: (
|
var sendFileLambda: (
|
||||||
file: File,
|
file: File,
|
||||||
fileInfo: FileInfo,
|
fileInfo: FileInfo,
|
||||||
|
caption: String?,
|
||||||
|
formattedCaption: String?,
|
||||||
progressCallback: ProgressCallback?,
|
progressCallback: ProgressCallback?,
|
||||||
) -> Result<MediaUploadHandler> = { _, _, _ ->
|
) -> Result<MediaUploadHandler> = { _, _, _, _, _ ->
|
||||||
Result.success(FakeMediaUploadHandler())
|
Result.success(FakeMediaUploadHandler())
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun sendFile(
|
override suspend fun sendFile(
|
||||||
file: File,
|
file: File,
|
||||||
fileInfo: FileInfo,
|
fileInfo: FileInfo,
|
||||||
|
caption: String?,
|
||||||
|
formattedCaption: String?,
|
||||||
progressCallback: ProgressCallback?,
|
progressCallback: ProgressCallback?,
|
||||||
): Result<MediaUploadHandler> = sendFileLambda(
|
): Result<MediaUploadHandler> = sendFileLambda(
|
||||||
file,
|
file,
|
||||||
fileInfo,
|
fileInfo,
|
||||||
|
caption,
|
||||||
|
formattedCaption,
|
||||||
progressCallback
|
progressCallback
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -125,6 +125,8 @@ class MediaSender @Inject constructor(
|
||||||
sendAudio(
|
sendAudio(
|
||||||
file = uploadInfo.file,
|
file = uploadInfo.file,
|
||||||
audioInfo = uploadInfo.audioInfo,
|
audioInfo = uploadInfo.audioInfo,
|
||||||
|
caption = caption,
|
||||||
|
formattedCaption = formattedCaption,
|
||||||
progressCallback = progressCallback
|
progressCallback = progressCallback
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -140,6 +142,8 @@ class MediaSender @Inject constructor(
|
||||||
sendFile(
|
sendFile(
|
||||||
file = uploadInfo.file,
|
file = uploadInfo.file,
|
||||||
fileInfo = uploadInfo.fileInfo,
|
fileInfo = uploadInfo.fileInfo,
|
||||||
|
caption = caption,
|
||||||
|
formattedCaption = formattedCaption,
|
||||||
progressCallback = progressCallback
|
progressCallback = progressCallback
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue