Matrix rust sdk: update to 0.1.20 (and fix compilation issues)
This commit is contained in:
@@ -54,7 +54,7 @@ class TimelineItemContentMessageFactory @Inject constructor(
|
||||
TimelineItemImageContent(
|
||||
body = messageType.body,
|
||||
mediaSource = messageType.source,
|
||||
thumbnailSource = messageType.info?.thumbnailSource,
|
||||
thumbnailSource = messageType.info?.thumbnailSource,
|
||||
mimeType = messageType.info?.mimetype ?: MimeTypes.OctetStream,
|
||||
blurhash = messageType.info?.blurhash,
|
||||
width = messageType.info?.width?.toInt(),
|
||||
@@ -73,7 +73,7 @@ class TimelineItemContentMessageFactory @Inject constructor(
|
||||
mimeType = messageType.info?.mimetype ?: MimeTypes.OctetStream,
|
||||
width = messageType.info?.width?.toInt(),
|
||||
height = messageType.info?.height?.toInt(),
|
||||
duration = messageType.info?.duration ?: 0L,
|
||||
duration = messageType.info?.duration?.toMillis() ?: 0L,
|
||||
blurHash = messageType.info?.blurhash,
|
||||
aspectRatio = aspectRatio,
|
||||
formattedFileSize = fileSizeFormatter.format(messageType.info?.size ?: 0),
|
||||
|
||||
@@ -142,7 +142,7 @@ jsoup = { module = "org.jsoup:jsoup", version.ref = "jsoup" }
|
||||
appyx_core = { module = "com.bumble.appyx:core", version.ref = "appyx" }
|
||||
molecule-runtime = { module = "app.cash.molecule:molecule-runtime", version.ref = "molecule" }
|
||||
timber = "com.jakewharton.timber:timber:5.0.1"
|
||||
matrix_sdk = "org.matrix.rustcomponents:sdk-android:0.1.19"
|
||||
matrix_sdk = "org.matrix.rustcomponents:sdk-android:0.1.20"
|
||||
sqldelight-driver-android = { module = "com.squareup.sqldelight:android-driver", version.ref = "sqldelight" }
|
||||
sqldelight-driver-jvm = { module = "com.squareup.sqldelight:sqlite-driver", version.ref = "sqldelight" }
|
||||
sqldelight-coroutines = { module = "com.squareup.sqldelight:coroutines-extensions", version.ref = "sqldelight" }
|
||||
|
||||
@@ -16,8 +16,10 @@
|
||||
|
||||
package io.element.android.libraries.matrix.api.media
|
||||
|
||||
import java.time.Duration
|
||||
|
||||
data class AudioInfo(
|
||||
val duration: Long?,
|
||||
val duration: Duration?,
|
||||
val size: Long?,
|
||||
val mimeType: String?,
|
||||
)
|
||||
|
||||
@@ -16,8 +16,10 @@
|
||||
|
||||
package io.element.android.libraries.matrix.api.media
|
||||
|
||||
import java.time.Duration
|
||||
|
||||
data class VideoInfo(
|
||||
val duration: Long?,
|
||||
val duration: Duration?,
|
||||
val height: Long?,
|
||||
val width: Long?,
|
||||
val mimetype: String?,
|
||||
|
||||
@@ -20,13 +20,13 @@ import io.element.android.libraries.matrix.api.media.AudioInfo
|
||||
import org.matrix.rustcomponents.sdk.AudioInfo as RustAudioInfo
|
||||
|
||||
fun RustAudioInfo.map(): AudioInfo = AudioInfo(
|
||||
duration = duration?.toLong(),
|
||||
duration = duration,
|
||||
size = size?.toLong(),
|
||||
mimeType = mimetype
|
||||
)
|
||||
|
||||
fun AudioInfo.map(): RustAudioInfo = RustAudioInfo(
|
||||
duration = duration?.toULong(),
|
||||
duration = duration,
|
||||
size = size?.toULong(),
|
||||
mimetype = mimeType,
|
||||
)
|
||||
|
||||
@@ -20,7 +20,7 @@ import io.element.android.libraries.matrix.api.media.VideoInfo
|
||||
import org.matrix.rustcomponents.sdk.VideoInfo as RustVideoInfo
|
||||
|
||||
fun RustVideoInfo.map(): VideoInfo = VideoInfo(
|
||||
duration = duration?.toLong(),
|
||||
duration = duration,
|
||||
height = height?.toLong(),
|
||||
width = width?.toLong(),
|
||||
mimetype = mimetype,
|
||||
@@ -31,7 +31,7 @@ fun RustVideoInfo.map(): VideoInfo = VideoInfo(
|
||||
)
|
||||
|
||||
fun VideoInfo.map(): RustVideoInfo = RustVideoInfo(
|
||||
duration = duration?.toULong(),
|
||||
duration = duration,
|
||||
height = height?.toULong(),
|
||||
width = width?.toULong(),
|
||||
mimetype = mimetype,
|
||||
|
||||
@@ -103,7 +103,7 @@ private fun RustFormattedBody.map(): FormattedBody = FormattedBody(
|
||||
|
||||
private fun RustMessageFormat.map(): MessageFormat {
|
||||
return when (this) {
|
||||
RustMessageFormat.HTML -> MessageFormat.HTML
|
||||
RustMessageFormat.UNKNOWN -> MessageFormat.UNKNOWN
|
||||
RustMessageFormat.Html -> MessageFormat.HTML
|
||||
is RustMessageFormat.Unknown -> MessageFormat.UNKNOWN
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ import java.io.ByteArrayInputStream
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.File
|
||||
import java.io.InputStream
|
||||
import java.time.Duration
|
||||
import javax.inject.Inject
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
@@ -175,9 +176,8 @@ class AndroidMediaPreProcessor @Inject constructor(
|
||||
val file = copyToTmpFile(uri)
|
||||
return MediaMetadataRetriever().runAndRelease {
|
||||
setDataSource(context, Uri.fromFile(file))
|
||||
|
||||
val info = AudioInfo(
|
||||
duration = extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION)?.toLong() ?: 0L,
|
||||
duration = extractDuration(),
|
||||
size = file.length(),
|
||||
mimeType = mimeType,
|
||||
)
|
||||
@@ -219,7 +219,7 @@ class AndroidMediaPreProcessor @Inject constructor(
|
||||
MediaMetadataRetriever().runAndRelease {
|
||||
setDataSource(context, Uri.fromFile(file))
|
||||
VideoInfo(
|
||||
duration = extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION)?.toLong() ?: 0L,
|
||||
duration = extractDuration(),
|
||||
width = extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH)?.toLong() ?: 0L,
|
||||
height = extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT)?.toLong() ?: 0L,
|
||||
mimetype = mimeType,
|
||||
@@ -252,6 +252,11 @@ class AndroidMediaPreProcessor @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun MediaMetadataRetriever.extractDuration(): Duration {
|
||||
val durationInMs = extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION)?.toLong() ?: 0L
|
||||
return Duration.ofMillis(durationInMs)
|
||||
}
|
||||
|
||||
fun ImageCompressionResult.toImageInfo(mimeType: String, thumbnailUrl: String?, thumbnailInfo: ThumbnailInfo?) = ImageInfo(
|
||||
width = width.toLong(),
|
||||
height = height.toLong(),
|
||||
|
||||
Reference in New Issue
Block a user