Merge branch 'develop' into feature/fga/fix_media_pre_processing
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),
|
||||
|
||||
@@ -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" }
|
||||
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" }
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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<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(
|
||||
|
||||
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 {
|
||||
|
||||
@@ -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
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
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(
|
||||
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
|
||||
thumbnailSource = null,
|
||||
blurhash = thumbnailResult.blurhash,
|
||||
)
|
||||
|
||||
private fun MediaMetadataRetriever.extractDuration(): Duration {
|
||||
val durationInMs = extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION)?.toLong() ?: 0L
|
||||
return Duration.ofMillis(durationInMs)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user