Browse Source

Merge branch 'develop' into feature/fga/fix_media_pre_processing

feature/julioromano/geocoding_api
ganfra 1 year ago
parent
commit
15ef9abed6
  1. 4
      features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/factories/event/TimelineItemContentMessageFactory.kt
  2. 4
      gradle/libs.versions.toml
  3. 4
      libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/media/AudioInfo.kt
  4. 4
      libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/media/VideoInfo.kt
  5. 4
      libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/media/AudioInfo.kt
  6. 4
      libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/media/VideoInfo.kt
  7. 6
      libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RustRoomSummaryDataSource.kt
  8. 6
      libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/sync/SlidingSyncListFlows.kt
  9. 4
      libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/item/event/EventMessageMapper.kt
  10. 11
      libraries/mediaupload/impl/src/main/kotlin/io/element/android/libraries/mediaupload/AndroidMediaPreProcessor.kt

4
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( @@ -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( @@ -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),

4
gradle/libs.versions.toml

@ -64,7 +64,7 @@ android_gradle_plugin = { module = "com.android.tools.build:gradle", version.ref @@ -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" }
@ -142,7 +142,7 @@ jsoup = { module = "org.jsoup:jsoup", version.ref = "jsoup" } @@ -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.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" }

4
libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/media/AudioInfo.kt

@ -16,8 +16,10 @@ @@ -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?,
)

4
libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/media/VideoInfo.kt

@ -16,8 +16,10 @@ @@ -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?,

4
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 @@ -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,
)

4
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 @@ -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( @@ -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,

6
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 @@ -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( @@ -56,7 +56,7 @@ internal class RustRoomSummaryDataSource(
private val coroutineScope = CoroutineScope(SupervisorJob() + coroutineDispatchers.io)
private val roomSummaries = MutableStateFlow<List<RoomSummary>>(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( @@ -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 {

6
libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/sync/SlidingSyncListFlows.kt

@ -21,11 +21,11 @@ import kotlinx.coroutines.CoroutineScope @@ -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<SlidingSyncListRoomsListDiff> =
mxCallbackFlow {
@ -39,9 +39,9 @@ fun SlidingSyncList.roomListDiff(scope: CoroutineScope): Flow<SlidingSyncListRoo @@ -39,9 +39,9 @@ fun SlidingSyncList.roomListDiff(scope: CoroutineScope): Flow<SlidingSyncListRoo
observeRoomList(observer)
}
fun SlidingSyncList.state(scope: CoroutineScope): Flow<SlidingSyncState> = mxCallbackFlow {
fun SlidingSyncList.state(scope: CoroutineScope): Flow<SlidingSyncListLoadingState> = mxCallbackFlow {
val observer = object : SlidingSyncListStateObserver {
override fun didReceiveUpdate(newState: SlidingSyncState) {
override fun didReceiveUpdate(newState: SlidingSyncListLoadingState) {
scope.launch {
send(newState)
}

4
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( @@ -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
}
}

11
libraries/mediaupload/impl/src/main/kotlin/io/element/android/libraries/mediaupload/AndroidMediaPreProcessor.kt

@ -46,6 +46,7 @@ import kotlinx.coroutines.flow.onEach @@ -46,6 +46,7 @@ import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.withContext
import java.io.File
import java.io.InputStream
import java.time.Duration
import javax.inject.Inject
@ContributesBinding(AppScope::class)
@ -192,7 +193,7 @@ class AndroidMediaPreProcessor @Inject constructor( @@ -192,7 +193,7 @@ class AndroidMediaPreProcessor @Inject constructor(
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,
)
@ -225,7 +226,7 @@ class AndroidMediaPreProcessor @Inject constructor( @@ -225,7 +226,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,
@ -253,3 +254,9 @@ fun ImageCompressionResult.toImageInfo(mimeType: String, thumbnailResult: Thumbn @@ -253,3 +254,9 @@ fun ImageCompressionResult.toImageInfo(mimeType: String, thumbnailResult: Thumbn
thumbnailSource = null,
blurhash = thumbnailResult.blurhash,
)
private fun MediaMetadataRetriever.extractDuration(): Duration {
val durationInMs = extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION)?.toLong() ?: 0L
return Duration.ofMillis(durationInMs)
}

Loading…
Cancel
Save