change (media preview config) : introduce new apis from sdk

This commit is contained in:
ganfra 2025-06-25 20:38:39 +02:00
parent 03fded9ae7
commit 416f4f2215
8 changed files with 227 additions and 0 deletions

View file

@ -8,6 +8,7 @@
package io.element.android.libraries.matrix.api
import io.element.android.libraries.core.data.tryOrNull
import io.element.android.libraries.core.extensions.runCatchingExceptions
import io.element.android.libraries.matrix.api.core.DeviceId
import io.element.android.libraries.matrix.api.core.MatrixPatterns
import io.element.android.libraries.matrix.api.core.ProgressCallback
@ -19,6 +20,9 @@ import io.element.android.libraries.matrix.api.core.UserId
import io.element.android.libraries.matrix.api.createroom.CreateRoomParameters
import io.element.android.libraries.matrix.api.encryption.EncryptionService
import io.element.android.libraries.matrix.api.media.MatrixMediaLoader
import io.element.android.libraries.matrix.api.media.MediaPreviewConfig
import io.element.android.libraries.matrix.api.media.MediaPreviewService
import io.element.android.libraries.matrix.api.media.MediaPreviewValue
import io.element.android.libraries.matrix.api.notification.NotificationService
import io.element.android.libraries.matrix.api.notificationsettings.NotificationSettingsService
import io.element.android.libraries.matrix.api.oidc.AccountManagementAction
@ -40,6 +44,7 @@ import kotlinx.collections.immutable.ImmutableList
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.withContext
import java.util.Optional
interface MatrixClient {
@ -72,6 +77,7 @@ interface MatrixClient {
fun notificationSettingsService(): NotificationSettingsService
fun encryptionService(): EncryptionService
fun roomDirectoryService(): RoomDirectoryService
fun mediaPreviewService(): MediaPreviewService
suspend fun getCacheSize(): Long
/**
@ -169,6 +175,7 @@ interface MatrixClient {
* Return true if Livekit Rtc is supported, i.e. if Element Call is available.
*/
suspend fun isLivekitRtcSupported(): Boolean
}
/**

View file

@ -0,0 +1,16 @@
/*
* Copyright 2025 New Vector Ltd.
*
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
* Please see LICENSE files in the repository root for full details.
*/
package io.element.android.libraries.matrix.api.media
/**
* Configuration for media preview ie. invite avatars and timeline media.
*/
data class MediaPreviewConfig(
val mediaPreviewValue: MediaPreviewValue,
val hideInviteAvatar: Boolean,
)

View file

@ -0,0 +1,42 @@
/*
* Copyright 2025 New Vector Ltd.
*
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
* Please see LICENSE files in the repository root for full details.
*/
package io.element.android.libraries.matrix.api.media
import kotlinx.coroutines.flow.Flow
interface MediaPreviewService {
/**
* Will fetch the media preview config from the server.
*/
suspend fun fetchMediaPreviewConfig(): Result<MediaPreviewConfig?>
/**
* Will emit the media preview config known by the client.
* This will emit a new value when received from sync.
*/
fun getMediaPreviewConfigFlow(): Flow<MediaPreviewConfig?>
/**
* Get the media preview display policy from the cache. This value is updated through sync.
*/
suspend fun getMediaPreviewValue(): MediaPreviewValue?
/**
* Get the invite avatars display policy from the cache. This value is updated through sync.
*/
suspend fun getHideInviteAvatars(): Boolean
/**
* Set the media preview display policy. This will update the value on the server and update the local value when successful.
*/
suspend fun setMediaPreviewValue(mediaPreviewValue: MediaPreviewValue): Result<Unit>
/**
* Set the invite avatars display policy. This will update the value on the server and update the local value when successful.
*/
suspend fun setHideInviteAvatars(hide: Boolean): Result<Unit>
}