From 170c74113001ecb9a05413762b1e0b5f84b0aced Mon Sep 17 00:00:00 2001 From: ganfra Date: Thu, 15 Jun 2023 15:26:53 +0200 Subject: [PATCH 1/3] Matrix rust sdk: update to 0.1.20 (and fix compilation issues) --- .../event/TimelineItemContentMessageFactory.kt | 4 ++-- gradle/libs.versions.toml | 2 +- .../android/libraries/matrix/api/media/AudioInfo.kt | 4 +++- .../android/libraries/matrix/api/media/VideoInfo.kt | 4 +++- .../android/libraries/matrix/impl/media/AudioInfo.kt | 4 ++-- .../android/libraries/matrix/impl/media/VideoInfo.kt | 4 ++-- .../impl/timeline/item/event/EventMessageMapper.kt | 4 ++-- .../libraries/mediaupload/AndroidMediaPreProcessor.kt | 11 ++++++++--- 8 files changed, 23 insertions(+), 14 deletions(-) diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/factories/event/TimelineItemContentMessageFactory.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/factories/event/TimelineItemContentMessageFactory.kt index 0e407003e8..d20560d53a 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/factories/event/TimelineItemContentMessageFactory.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/factories/event/TimelineItemContentMessageFactory.kt @@ -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), diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 434d39e743..a225832eda 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -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" } diff --git a/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/media/AudioInfo.kt b/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/media/AudioInfo.kt index 6ed6e474b6..e9708a6926 100644 --- a/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/media/AudioInfo.kt +++ b/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/media/AudioInfo.kt @@ -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?, ) diff --git a/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/media/VideoInfo.kt b/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/media/VideoInfo.kt index aa291bd653..b7af54c6b2 100644 --- a/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/media/VideoInfo.kt +++ b/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/media/VideoInfo.kt @@ -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?, diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/media/AudioInfo.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/media/AudioInfo.kt index 7c35c14fb7..2f0d6879a4 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/media/AudioInfo.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/media/AudioInfo.kt @@ -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, ) diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/media/VideoInfo.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/media/VideoInfo.kt index b474c2ab2e..661d1b9b33 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/media/VideoInfo.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/media/VideoInfo.kt @@ -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, diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/item/event/EventMessageMapper.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/item/event/EventMessageMapper.kt index 8a052d1a3a..7fdbe06e8a 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/item/event/EventMessageMapper.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/item/event/EventMessageMapper.kt @@ -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 } } diff --git a/libraries/mediaupload/impl/src/main/kotlin/io/element/android/libraries/mediaupload/AndroidMediaPreProcessor.kt b/libraries/mediaupload/impl/src/main/kotlin/io/element/android/libraries/mediaupload/AndroidMediaPreProcessor.kt index 4882000307..0f8ebab21a 100644 --- a/libraries/mediaupload/impl/src/main/kotlin/io/element/android/libraries/mediaupload/AndroidMediaPreProcessor.kt +++ b/libraries/mediaupload/impl/src/main/kotlin/io/element/android/libraries/mediaupload/AndroidMediaPreProcessor.kt @@ -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(), From b71b4615b88f9aa232ebee71977eac286662270b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 15 Jun 2023 21:57:50 +0000 Subject: [PATCH 2/3] Update dependency com.google.firebase:firebase-bom to v32.1.1 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a225832eda..b7573db2e3 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -64,7 +64,7 @@ android_gradle_plugin = { module = "com.android.tools.build:gradle", version.ref android_desugar = "com.android.tools:desugar_jdk_libs:2.0.3" kotlin_gradle_plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } # https://firebase.google.com/docs/android/setup#available-libraries -google_firebase_bom = "com.google.firebase:firebase-bom:32.1.0" +google_firebase_bom = "com.google.firebase:firebase-bom:32.1.1" # AndroidX androidx_material = { module = "com.google.android.material:material", version.ref = "material" } From 1fea2fa255aa30a733661b2d5e5064408003aaa7 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 16 Jun 2023 09:57:47 +0200 Subject: [PATCH 3/3] Update dependency org.matrix.rustcomponents:sdk-android to v0.1.21 (#610) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update dependency org.matrix.rustcomponents:sdk-android to v0.1.21 * Fix `SlidingSyncState` being renamed to `SlidingSyncListLoadingState` --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Jorge Martín --- gradle/libs.versions.toml | 2 +- .../libraries/matrix/impl/room/RustRoomSummaryDataSource.kt | 6 +++--- .../libraries/matrix/impl/sync/SlidingSyncListFlows.kt | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a225832eda..4cbbe5dcdf 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -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.20" +matrix_sdk = "org.matrix.rustcomponents:sdk-android:0.1.21" 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" } diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RustRoomSummaryDataSource.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RustRoomSummaryDataSource.kt index ab94298418..34c0a9cb48 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RustRoomSummaryDataSource.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RustRoomSummaryDataSource.kt @@ -39,7 +39,7 @@ import org.matrix.rustcomponents.sdk.SlidingSync import org.matrix.rustcomponents.sdk.SlidingSyncList import org.matrix.rustcomponents.sdk.SlidingSyncListRoomsListDiff import org.matrix.rustcomponents.sdk.SlidingSyncSelectiveModeBuilder -import org.matrix.rustcomponents.sdk.SlidingSyncState +import org.matrix.rustcomponents.sdk.SlidingSyncListLoadingState import org.matrix.rustcomponents.sdk.UpdateSummary import timber.log.Timber import java.io.Closeable @@ -56,7 +56,7 @@ internal class RustRoomSummaryDataSource( private val coroutineScope = CoroutineScope(SupervisorJob() + coroutineDispatchers.io) private val roomSummaries = MutableStateFlow>(emptyList()) - private val state = MutableStateFlow(SlidingSyncState.NOT_LOADED) + private val state = MutableStateFlow(SlidingSyncListLoadingState.NOT_LOADED) fun init() { coroutineScope.launch { @@ -107,7 +107,7 @@ internal class RustRoomSummaryDataSource( private suspend fun didReceiveSyncUpdate(summary: UpdateSummary) { Timber.v("UpdateRooms with identifiers: ${summary.rooms}") - if (state.value != SlidingSyncState.FULLY_LOADED) { + if (state.value != SlidingSyncListLoadingState.FULLY_LOADED) { return } updateRoomSummaries { diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/sync/SlidingSyncListFlows.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/sync/SlidingSyncListFlows.kt index 2aa0c59330..eb8019a79d 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/sync/SlidingSyncListFlows.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/sync/SlidingSyncListFlows.kt @@ -21,11 +21,11 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.launch import org.matrix.rustcomponents.sdk.SlidingSyncList +import org.matrix.rustcomponents.sdk.SlidingSyncListLoadingState import org.matrix.rustcomponents.sdk.SlidingSyncListRoomListObserver import org.matrix.rustcomponents.sdk.SlidingSyncListRoomsCountObserver import org.matrix.rustcomponents.sdk.SlidingSyncListRoomsListDiff import org.matrix.rustcomponents.sdk.SlidingSyncListStateObserver -import org.matrix.rustcomponents.sdk.SlidingSyncState fun SlidingSyncList.roomListDiff(scope: CoroutineScope): Flow = mxCallbackFlow { @@ -39,9 +39,9 @@ fun SlidingSyncList.roomListDiff(scope: CoroutineScope): Flow = mxCallbackFlow { +fun SlidingSyncList.state(scope: CoroutineScope): Flow = mxCallbackFlow { val observer = object : SlidingSyncListStateObserver { - override fun didReceiveUpdate(newState: SlidingSyncState) { + override fun didReceiveUpdate(newState: SlidingSyncListLoadingState) { scope.launch { send(newState) }