Merge branch 'develop' into dla/feature/custom_room_notification_settings_list

This commit is contained in:
David Langley 2023-10-19 16:36:30 +01:00 committed by GitHub
commit e2adecbcf4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 306 additions and 39 deletions

View file

@ -18,4 +18,10 @@ package io.element.android.libraries.di
import javax.inject.Qualifier
@Qualifier annotation class ApplicationContext
/**
* Qualifies a [Context] object that represents the application context.
*/
@Retention(AnnotationRetention.RUNTIME)
@MustBeDocumented
@Qualifier
annotation class ApplicationContext

View file

@ -0,0 +1,27 @@
/*
* Copyright (c) 2022 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.element.android.libraries.di
import javax.inject.Qualifier
/**
* Qualifies a [File] object which represents the application cache directory.
*/
@Retention(AnnotationRetention.RUNTIME)
@MustBeDocumented
@Qualifier
annotation class CacheDirectory

View file

@ -161,7 +161,7 @@ class DefaultRoomLastMessageFormatterTest {
val sharedContentMessagesTypes = arrayOf(
TextMessageType(body, null),
VideoMessageType(body, MediaSource("url"), null),
AudioMessageType(body, MediaSource("url"), null),
AudioMessageType(body, MediaSource("url"), null, null, false),
ImageMessageType(body, MediaSource("url"), null),
FileMessageType(body, MediaSource("url"), null),
LocationMessageType(body, "geo:1,2", null),

View file

@ -0,0 +1,24 @@
/*
* Copyright (c) 2023 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.element.android.libraries.matrix.api.media
import java.time.Duration
data class AudioDetails(
val duration: Duration,
val waveform: List<Int>,
)

View file

@ -16,6 +16,7 @@
package io.element.android.libraries.matrix.api.timeline.item.event
import io.element.android.libraries.matrix.api.media.AudioDetails
import io.element.android.libraries.matrix.api.media.AudioInfo
import io.element.android.libraries.matrix.api.media.FileInfo
import io.element.android.libraries.matrix.api.media.ImageInfo
@ -46,7 +47,9 @@ data class LocationMessageType(
data class AudioMessageType(
val body: String,
val source: MediaSource,
val info: AudioInfo?
val info: AudioInfo?,
val details: AudioDetails?,
val isVoiceMessage: Boolean,
) : MessageType
data class VideoMessageType(

View file

@ -16,9 +16,8 @@
package io.element.android.libraries.matrix.impl
import android.content.Context
import io.element.android.libraries.core.coroutine.CoroutineDispatchers
import io.element.android.libraries.di.ApplicationContext
import io.element.android.libraries.di.CacheDirectory
import io.element.android.libraries.network.useragent.UserAgentProvider
import io.element.android.libraries.sessionstorage.api.SessionData
import io.element.android.libraries.sessionstorage.api.SessionStore
@ -32,8 +31,8 @@ import java.io.File
import javax.inject.Inject
class RustMatrixClientFactory @Inject constructor(
@ApplicationContext private val context: Context,
private val baseDirectory: File,
@CacheDirectory private val cacheDirectory: File,
private val appCoroutineScope: CoroutineScope,
private val coroutineDispatchers: CoroutineDispatchers,
private val sessionStore: SessionStore,
@ -63,7 +62,7 @@ class RustMatrixClientFactory @Inject constructor(
appCoroutineScope = appCoroutineScope,
dispatchers = coroutineDispatchers,
baseDirectory = baseDirectory,
baseCacheDirectory = context.cacheDir,
baseCacheDirectory = cacheDirectory,
clock = clock,
)
}

View file

@ -0,0 +1,30 @@
/*
* Copyright (c) 2023 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.element.android.libraries.matrix.impl.media
import io.element.android.libraries.matrix.api.media.AudioDetails
import org.matrix.rustcomponents.sdk.UnstableAudioDetailsContent as RustAudioDetails
fun RustAudioDetails.map(): AudioDetails = AudioDetails(
duration = duration,
waveform = waveform.map { it.toInt() },
)
fun AudioDetails.map(): RustAudioDetails = RustAudioDetails(
duration = duration,
waveform = waveform.map { it.toUShort() }
)

View file

@ -75,7 +75,13 @@ class EventMessageMapper {
fun mapMessageType(type: RustMessageType?) = when (type) {
is RustMessageType.Audio -> {
AudioMessageType(type.content.body, type.content.source.map(), type.content.info?.map())
AudioMessageType(
body = type.content.body,
source = type.content.source.map(),
info = type.content.info?.map(),
details = type.content.audio?.map(),
isVoiceMessage = type.content.voice != null,
)
}
is RustMessageType.File -> {
FileMessageType(type.content.body, type.content.source.map(), type.content.info?.map())

View file

@ -55,6 +55,4 @@ dependencies {
androidTestImplementation(libs.test.truth)
androidTestImplementation(libs.test.runner)
androidTestImplementation(projects.libraries.sessionStorage.test)
coreLibraryDesugaring(libs.android.desugar)
}

View file

@ -45,8 +45,6 @@ dependencies {
testImplementation(libs.test.turbine)
testImplementation(libs.coroutines.test)
testImplementation(libs.sqldelight.driver.jvm)
coreLibraryDesugaring(libs.android.desugar)
}
sqldelight {