Merge branch 'develop' into feature/fga/fix_media_pre_processing
This commit is contained in:
commit
e7ad8f6e07
10 changed files with 31 additions and 20 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),
|
||||||
|
|
|
||||||
|
|
@ -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"
|
android_desugar = "com.android.tools:desugar_jdk_libs:2.0.3"
|
||||||
kotlin_gradle_plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
|
kotlin_gradle_plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
|
||||||
# https://firebase.google.com/docs/android/setup#available-libraries
|
# 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
|
||||||
androidx_material = { module = "com.google.android.material:material", version.ref = "material" }
|
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" }
|
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.21"
|
||||||
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,
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ import org.matrix.rustcomponents.sdk.SlidingSync
|
||||||
import org.matrix.rustcomponents.sdk.SlidingSyncList
|
import org.matrix.rustcomponents.sdk.SlidingSyncList
|
||||||
import org.matrix.rustcomponents.sdk.SlidingSyncListRoomsListDiff
|
import org.matrix.rustcomponents.sdk.SlidingSyncListRoomsListDiff
|
||||||
import org.matrix.rustcomponents.sdk.SlidingSyncSelectiveModeBuilder
|
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 org.matrix.rustcomponents.sdk.UpdateSummary
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.io.Closeable
|
import java.io.Closeable
|
||||||
|
|
@ -56,7 +56,7 @@ internal class RustRoomSummaryDataSource(
|
||||||
private val coroutineScope = CoroutineScope(SupervisorJob() + coroutineDispatchers.io)
|
private val coroutineScope = CoroutineScope(SupervisorJob() + coroutineDispatchers.io)
|
||||||
|
|
||||||
private val roomSummaries = MutableStateFlow<List<RoomSummary>>(emptyList())
|
private val roomSummaries = MutableStateFlow<List<RoomSummary>>(emptyList())
|
||||||
private val state = MutableStateFlow(SlidingSyncState.NOT_LOADED)
|
private val state = MutableStateFlow(SlidingSyncListLoadingState.NOT_LOADED)
|
||||||
|
|
||||||
fun init() {
|
fun init() {
|
||||||
coroutineScope.launch {
|
coroutineScope.launch {
|
||||||
|
|
@ -107,7 +107,7 @@ internal class RustRoomSummaryDataSource(
|
||||||
|
|
||||||
private suspend fun didReceiveSyncUpdate(summary: UpdateSummary) {
|
private suspend fun didReceiveSyncUpdate(summary: UpdateSummary) {
|
||||||
Timber.v("UpdateRooms with identifiers: ${summary.rooms}")
|
Timber.v("UpdateRooms with identifiers: ${summary.rooms}")
|
||||||
if (state.value != SlidingSyncState.FULLY_LOADED) {
|
if (state.value != SlidingSyncListLoadingState.FULLY_LOADED) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
updateRoomSummaries {
|
updateRoomSummaries {
|
||||||
|
|
|
||||||
|
|
@ -21,11 +21,11 @@ import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.matrix.rustcomponents.sdk.SlidingSyncList
|
import org.matrix.rustcomponents.sdk.SlidingSyncList
|
||||||
|
import org.matrix.rustcomponents.sdk.SlidingSyncListLoadingState
|
||||||
import org.matrix.rustcomponents.sdk.SlidingSyncListRoomListObserver
|
import org.matrix.rustcomponents.sdk.SlidingSyncListRoomListObserver
|
||||||
import org.matrix.rustcomponents.sdk.SlidingSyncListRoomsCountObserver
|
import org.matrix.rustcomponents.sdk.SlidingSyncListRoomsCountObserver
|
||||||
import org.matrix.rustcomponents.sdk.SlidingSyncListRoomsListDiff
|
import org.matrix.rustcomponents.sdk.SlidingSyncListRoomsListDiff
|
||||||
import org.matrix.rustcomponents.sdk.SlidingSyncListStateObserver
|
import org.matrix.rustcomponents.sdk.SlidingSyncListStateObserver
|
||||||
import org.matrix.rustcomponents.sdk.SlidingSyncState
|
|
||||||
|
|
||||||
fun SlidingSyncList.roomListDiff(scope: CoroutineScope): Flow<SlidingSyncListRoomsListDiff> =
|
fun SlidingSyncList.roomListDiff(scope: CoroutineScope): Flow<SlidingSyncListRoomsListDiff> =
|
||||||
mxCallbackFlow {
|
mxCallbackFlow {
|
||||||
|
|
@ -39,9 +39,9 @@ fun SlidingSyncList.roomListDiff(scope: CoroutineScope): Flow<SlidingSyncListRoo
|
||||||
observeRoomList(observer)
|
observeRoomList(observer)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun SlidingSyncList.state(scope: CoroutineScope): Flow<SlidingSyncState> = mxCallbackFlow {
|
fun SlidingSyncList.state(scope: CoroutineScope): Flow<SlidingSyncListLoadingState> = mxCallbackFlow {
|
||||||
val observer = object : SlidingSyncListStateObserver {
|
val observer = object : SlidingSyncListStateObserver {
|
||||||
override fun didReceiveUpdate(newState: SlidingSyncState) {
|
override fun didReceiveUpdate(newState: SlidingSyncListLoadingState) {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
send(newState)
|
send(newState)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ import kotlinx.coroutines.flow.onEach
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
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
|
||||||
|
|
||||||
@ContributesBinding(AppScope::class)
|
@ContributesBinding(AppScope::class)
|
||||||
|
|
@ -192,7 +193,7 @@ class AndroidMediaPreProcessor @Inject constructor(
|
||||||
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,
|
||||||
)
|
)
|
||||||
|
|
@ -225,7 +226,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,
|
||||||
|
|
@ -253,3 +254,9 @@ fun ImageCompressionResult.toImageInfo(mimeType: String, thumbnailResult: Thumbn
|
||||||
thumbnailSource = null,
|
thumbnailSource = null,
|
||||||
blurhash = thumbnailResult.blurhash,
|
blurhash = thumbnailResult.blurhash,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
private fun MediaMetadataRetriever.extractDuration(): Duration {
|
||||||
|
val durationInMs = extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION)?.toLong() ?: 0L
|
||||||
|
return Duration.ofMillis(durationInMs)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue