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