Merge pull request #2571 from element-hq/renovate/org.matrix.rustcomponents-sdk-android-0.x
Update dependency org.matrix.rustcomponents:sdk-android to v0.2.10
This commit is contained in:
commit
ba564bbe9c
6 changed files with 85 additions and 10 deletions
|
|
@ -463,7 +463,12 @@ class MessageComposerPresenter @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mediaSender.sendMedia(uri, mimeType, compressIfPossible = false, progressCallback).getOrThrow()
|
mediaSender.sendMedia(
|
||||||
|
uri = uri,
|
||||||
|
mimeType = mimeType,
|
||||||
|
compressIfPossible = false,
|
||||||
|
progressCallback = progressCallback
|
||||||
|
).getOrThrow()
|
||||||
}
|
}
|
||||||
.onSuccess {
|
.onSuccess {
|
||||||
attachmentState.value = AttachmentsState.None
|
attachmentState.value = AttachmentsState.None
|
||||||
|
|
|
||||||
|
|
@ -153,7 +153,7 @@ jsoup = "org.jsoup:jsoup:1.17.2"
|
||||||
appyx_core = { module = "com.bumble.appyx:core", version.ref = "appyx" }
|
appyx_core = { module = "com.bumble.appyx:core", version.ref = "appyx" }
|
||||||
molecule-runtime = "app.cash.molecule:molecule-runtime:1.4.1"
|
molecule-runtime = "app.cash.molecule:molecule-runtime:1.4.1"
|
||||||
timber = "com.jakewharton.timber:timber:5.0.1"
|
timber = "com.jakewharton.timber:timber:5.0.1"
|
||||||
matrix_sdk = "org.matrix.rustcomponents:sdk-android:0.2.9"
|
matrix_sdk = "org.matrix.rustcomponents:sdk-android:0.2.10"
|
||||||
matrix_richtexteditor = { module = "io.element.android:wysiwyg", version.ref = "wysiwyg" }
|
matrix_richtexteditor = { module = "io.element.android:wysiwyg", version.ref = "wysiwyg" }
|
||||||
matrix_richtexteditor_compose = { module = "io.element.android:wysiwyg-compose", version.ref = "wysiwyg" }
|
matrix_richtexteditor_compose = { module = "io.element.android:wysiwyg-compose", version.ref = "wysiwyg" }
|
||||||
sqldelight-driver-android = { module = "app.cash.sqldelight:android-driver", version.ref = "sqldelight" }
|
sqldelight-driver-android = { module = "app.cash.sqldelight:android-driver", version.ref = "sqldelight" }
|
||||||
|
|
|
||||||
|
|
@ -127,9 +127,23 @@ interface MatrixRoom : Closeable {
|
||||||
|
|
||||||
suspend fun redactEvent(eventId: EventId, reason: String? = null): Result<Unit>
|
suspend fun redactEvent(eventId: EventId, reason: String? = null): Result<Unit>
|
||||||
|
|
||||||
suspend fun sendImage(file: File, thumbnailFile: File?, imageInfo: ImageInfo, progressCallback: ProgressCallback?): Result<MediaUploadHandler>
|
suspend fun sendImage(
|
||||||
|
file: File,
|
||||||
|
thumbnailFile: File?,
|
||||||
|
imageInfo: ImageInfo,
|
||||||
|
body: String?,
|
||||||
|
formattedBody: String?,
|
||||||
|
progressCallback: ProgressCallback?
|
||||||
|
): Result<MediaUploadHandler>
|
||||||
|
|
||||||
suspend fun sendVideo(file: File, thumbnailFile: File?, videoInfo: VideoInfo, progressCallback: ProgressCallback?): Result<MediaUploadHandler>
|
suspend fun sendVideo(
|
||||||
|
file: File,
|
||||||
|
thumbnailFile: File?,
|
||||||
|
videoInfo: VideoInfo,
|
||||||
|
body: String?,
|
||||||
|
formattedBody: String?,
|
||||||
|
progressCallback: ProgressCallback?
|
||||||
|
): Result<MediaUploadHandler>
|
||||||
|
|
||||||
suspend fun sendAudio(file: File, audioInfo: AudioInfo, progressCallback: ProgressCallback?): Result<MediaUploadHandler>
|
suspend fun sendAudio(file: File, audioInfo: AudioInfo, progressCallback: ProgressCallback?): Result<MediaUploadHandler>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,7 @@ import kotlinx.coroutines.flow.onEach
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import org.matrix.rustcomponents.sdk.EventTimelineItem
|
import org.matrix.rustcomponents.sdk.EventTimelineItem
|
||||||
|
import org.matrix.rustcomponents.sdk.MessageFormat
|
||||||
import org.matrix.rustcomponents.sdk.RoomInfo
|
import org.matrix.rustcomponents.sdk.RoomInfo
|
||||||
import org.matrix.rustcomponents.sdk.RoomInfoListener
|
import org.matrix.rustcomponents.sdk.RoomInfoListener
|
||||||
import org.matrix.rustcomponents.sdk.RoomListItem
|
import org.matrix.rustcomponents.sdk.RoomListItem
|
||||||
|
|
@ -90,6 +91,7 @@ import org.matrix.rustcomponents.sdk.use
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import uniffi.matrix_sdk.RoomPowerLevelChanges
|
import uniffi.matrix_sdk.RoomPowerLevelChanges
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import org.matrix.rustcomponents.sdk.FormattedBody as RustFormattedBody
|
||||||
import org.matrix.rustcomponents.sdk.Room as InnerRoom
|
import org.matrix.rustcomponents.sdk.Room as InnerRoom
|
||||||
import org.matrix.rustcomponents.sdk.Timeline as InnerTimeline
|
import org.matrix.rustcomponents.sdk.Timeline as InnerTimeline
|
||||||
|
|
||||||
|
|
@ -436,10 +438,21 @@ class RustMatrixRoom(
|
||||||
file: File,
|
file: File,
|
||||||
thumbnailFile: File?,
|
thumbnailFile: File?,
|
||||||
imageInfo: ImageInfo,
|
imageInfo: ImageInfo,
|
||||||
|
body: String?,
|
||||||
|
formattedBody: String?,
|
||||||
progressCallback: ProgressCallback?,
|
progressCallback: ProgressCallback?,
|
||||||
): Result<MediaUploadHandler> {
|
): Result<MediaUploadHandler> {
|
||||||
return sendAttachment(listOfNotNull(file, thumbnailFile)) {
|
return sendAttachment(listOfNotNull(file, thumbnailFile)) {
|
||||||
innerTimeline.sendImage(file.path, thumbnailFile?.path, imageInfo.map(), progressCallback?.toProgressWatcher())
|
innerTimeline.sendImage(
|
||||||
|
url = file.path,
|
||||||
|
thumbnailUrl = thumbnailFile?.path,
|
||||||
|
imageInfo = imageInfo.map(),
|
||||||
|
caption = body,
|
||||||
|
formattedCaption = formattedBody?.let {
|
||||||
|
RustFormattedBody(body = it, format = MessageFormat.Html)
|
||||||
|
},
|
||||||
|
progressWatcher = progressCallback?.toProgressWatcher()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -447,16 +460,34 @@ class RustMatrixRoom(
|
||||||
file: File,
|
file: File,
|
||||||
thumbnailFile: File?,
|
thumbnailFile: File?,
|
||||||
videoInfo: VideoInfo,
|
videoInfo: VideoInfo,
|
||||||
|
body: String?,
|
||||||
|
formattedBody: String?,
|
||||||
progressCallback: ProgressCallback?,
|
progressCallback: ProgressCallback?,
|
||||||
): Result<MediaUploadHandler> {
|
): Result<MediaUploadHandler> {
|
||||||
return sendAttachment(listOfNotNull(file, thumbnailFile)) {
|
return sendAttachment(listOfNotNull(file, thumbnailFile)) {
|
||||||
innerTimeline.sendVideo(file.path, thumbnailFile?.path, videoInfo.map(), progressCallback?.toProgressWatcher())
|
innerTimeline.sendVideo(
|
||||||
|
url = file.path,
|
||||||
|
thumbnailUrl = thumbnailFile?.path,
|
||||||
|
videoInfo = videoInfo.map(),
|
||||||
|
caption = body,
|
||||||
|
formattedCaption = formattedBody?.let {
|
||||||
|
RustFormattedBody(body = it, format = MessageFormat.Html)
|
||||||
|
},
|
||||||
|
progressWatcher = progressCallback?.toProgressWatcher()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun sendAudio(file: File, audioInfo: AudioInfo, progressCallback: ProgressCallback?): Result<MediaUploadHandler> {
|
override suspend fun sendAudio(file: File, audioInfo: AudioInfo, progressCallback: ProgressCallback?): Result<MediaUploadHandler> {
|
||||||
return sendAttachment(listOf(file)) {
|
return sendAttachment(listOf(file)) {
|
||||||
innerTimeline.sendAudio(file.path, audioInfo.map(), progressCallback?.toProgressWatcher())
|
innerTimeline.sendAudio(
|
||||||
|
url = file.path,
|
||||||
|
audioInfo = audioInfo.map(),
|
||||||
|
// Maybe allow a caption in the future?
|
||||||
|
caption = null,
|
||||||
|
formattedCaption = null,
|
||||||
|
progressWatcher = progressCallback?.toProgressWatcher()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -653,6 +684,9 @@ class RustMatrixRoom(
|
||||||
url = file.path,
|
url = file.path,
|
||||||
audioInfo = audioInfo.map(),
|
audioInfo = audioInfo.map(),
|
||||||
waveform = waveform.toMSC3246range(),
|
waveform = waveform.toMSC3246range(),
|
||||||
|
// Maybe allow a caption in the future?
|
||||||
|
caption = null,
|
||||||
|
formattedCaption = null,
|
||||||
progressWatcher = progressCallback?.toProgressWatcher(),
|
progressWatcher = progressCallback?.toProgressWatcher(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -357,6 +357,8 @@ class FakeMatrixRoom(
|
||||||
file: File,
|
file: File,
|
||||||
thumbnailFile: File?,
|
thumbnailFile: File?,
|
||||||
imageInfo: ImageInfo,
|
imageInfo: ImageInfo,
|
||||||
|
body: String?,
|
||||||
|
formattedBody: String?,
|
||||||
progressCallback: ProgressCallback?
|
progressCallback: ProgressCallback?
|
||||||
): Result<MediaUploadHandler> = fakeSendMedia(progressCallback)
|
): Result<MediaUploadHandler> = fakeSendMedia(progressCallback)
|
||||||
|
|
||||||
|
|
@ -364,6 +366,8 @@ class FakeMatrixRoom(
|
||||||
file: File,
|
file: File,
|
||||||
thumbnailFile: File?,
|
thumbnailFile: File?,
|
||||||
videoInfo: VideoInfo,
|
videoInfo: VideoInfo,
|
||||||
|
body: String?,
|
||||||
|
formattedBody: String?,
|
||||||
progressCallback: ProgressCallback?
|
progressCallback: ProgressCallback?
|
||||||
): Result<MediaUploadHandler> = fakeSendMedia(
|
): Result<MediaUploadHandler> = fakeSendMedia(
|
||||||
progressCallback
|
progressCallback
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,8 @@ class MediaSender @Inject constructor(
|
||||||
uri: Uri,
|
uri: Uri,
|
||||||
mimeType: String,
|
mimeType: String,
|
||||||
compressIfPossible: Boolean,
|
compressIfPossible: Boolean,
|
||||||
|
caption: String? = null,
|
||||||
|
formattedCaption: String? = null,
|
||||||
progressCallback: ProgressCallback? = null
|
progressCallback: ProgressCallback? = null
|
||||||
): Result<Unit> {
|
): Result<Unit> {
|
||||||
return preProcessor
|
return preProcessor
|
||||||
|
|
@ -44,10 +46,15 @@ class MediaSender @Inject constructor(
|
||||||
uri = uri,
|
uri = uri,
|
||||||
mimeType = mimeType,
|
mimeType = mimeType,
|
||||||
deleteOriginal = true,
|
deleteOriginal = true,
|
||||||
compressIfPossible = compressIfPossible
|
compressIfPossible = compressIfPossible,
|
||||||
)
|
)
|
||||||
.flatMapCatching { info ->
|
.flatMapCatching { info ->
|
||||||
room.sendMedia(info, progressCallback)
|
room.sendMedia(
|
||||||
|
uploadInfo = info,
|
||||||
|
progressCallback = progressCallback,
|
||||||
|
caption = caption,
|
||||||
|
formattedCaption = formattedCaption
|
||||||
|
)
|
||||||
}
|
}
|
||||||
.handleSendResult()
|
.handleSendResult()
|
||||||
}
|
}
|
||||||
|
|
@ -71,7 +78,12 @@ class MediaSender @Inject constructor(
|
||||||
audioInfo = audioInfo,
|
audioInfo = audioInfo,
|
||||||
waveform = waveForm,
|
waveform = waveForm,
|
||||||
)
|
)
|
||||||
room.sendMedia(newInfo, progressCallback)
|
room.sendMedia(
|
||||||
|
uploadInfo = newInfo,
|
||||||
|
progressCallback = progressCallback,
|
||||||
|
caption = null,
|
||||||
|
formattedCaption = null
|
||||||
|
)
|
||||||
}
|
}
|
||||||
.handleSendResult()
|
.handleSendResult()
|
||||||
}
|
}
|
||||||
|
|
@ -90,6 +102,8 @@ class MediaSender @Inject constructor(
|
||||||
private suspend fun MatrixRoom.sendMedia(
|
private suspend fun MatrixRoom.sendMedia(
|
||||||
uploadInfo: MediaUploadInfo,
|
uploadInfo: MediaUploadInfo,
|
||||||
progressCallback: ProgressCallback?,
|
progressCallback: ProgressCallback?,
|
||||||
|
caption: String?,
|
||||||
|
formattedCaption: String?,
|
||||||
): Result<Unit> {
|
): Result<Unit> {
|
||||||
val handler = when (uploadInfo) {
|
val handler = when (uploadInfo) {
|
||||||
is MediaUploadInfo.Image -> {
|
is MediaUploadInfo.Image -> {
|
||||||
|
|
@ -97,6 +111,8 @@ class MediaSender @Inject constructor(
|
||||||
file = uploadInfo.file,
|
file = uploadInfo.file,
|
||||||
thumbnailFile = uploadInfo.thumbnailFile,
|
thumbnailFile = uploadInfo.thumbnailFile,
|
||||||
imageInfo = uploadInfo.imageInfo,
|
imageInfo = uploadInfo.imageInfo,
|
||||||
|
body = caption,
|
||||||
|
formattedBody = formattedCaption,
|
||||||
progressCallback = progressCallback
|
progressCallback = progressCallback
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -105,6 +121,8 @@ class MediaSender @Inject constructor(
|
||||||
file = uploadInfo.file,
|
file = uploadInfo.file,
|
||||||
thumbnailFile = uploadInfo.thumbnailFile,
|
thumbnailFile = uploadInfo.thumbnailFile,
|
||||||
videoInfo = uploadInfo.videoInfo,
|
videoInfo = uploadInfo.videoInfo,
|
||||||
|
body = caption,
|
||||||
|
formattedBody = formattedCaption,
|
||||||
progressCallback = progressCallback
|
progressCallback = progressCallback
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue