Media: some code clean-up

This commit is contained in:
ganfra 2023-05-24 22:23:38 +02:00
parent 92e19c3dd9
commit 3e01a2f317
7 changed files with 18 additions and 16 deletions

View file

@ -22,7 +22,7 @@ import io.element.android.libraries.matrix.api.media.MediaFile
interface LocalMediaFactory {
/**
* This method will create a [LocalMedia] with the given [MediaFile] and [mimeType]
* This method will create a [LocalMedia] with the given [MediaFile] and [mimeType].
*
*/
fun createFromMediaFile(mediaFile: MediaFile, mimeType: String?): LocalMedia

View file

@ -74,17 +74,18 @@ private fun MediaImageView(
modifier = modifier.fillMaxSize(),
contentDescription = null,
)
} else {
val zoomableState = rememberZoomableState(
zoomSpec = ZoomSpec(maxZoomFactor = 3f)
)
ZoomableAsyncImage(
modifier = modifier.fillMaxSize(),
state = rememberZoomableImageState(zoomableState),
model = localMedia.model,
contentDescription = "Image",
contentScale = ContentScale.Fit,
)
}
val zoomableState = rememberZoomableState(
zoomSpec = ZoomSpec(maxZoomFactor = 3f)
)
ZoomableAsyncImage(
modifier = modifier.fillMaxSize(),
state = rememberZoomableImageState(zoomableState),
model = localMedia.model,
contentDescription = "Image",
contentScale = ContentScale.Fit,
)
}
@UnstableApi

View file

@ -84,7 +84,7 @@ class AttachmentsPreviewPresenterTest {
}
private fun anAttachmentsPreviewPresenter(
localMedia: LocalMedia = aLocalMedia(MimeTypes.IMAGE_JPEG),
localMedia: LocalMedia = aLocalMedia(mimeType = MimeTypes.IMAGE_JPEG),
room: MatrixRoom = FakeMatrixRoom()
): AttachmentsPreviewPresenter {
return AttachmentsPreviewPresenter(

View file

@ -17,13 +17,14 @@
package io.element.android.features.messages.fixtures
import android.net.Uri
import androidx.media3.common.MimeTypes
import io.element.android.features.messages.impl.attachments.Attachment
import io.element.android.features.messages.impl.media.local.LocalMedia
import io.mockk.mockk
fun aLocalMedia(
mimeType: String,
uri: Uri = mockk("localMediaUri"),
mimeType: String = MimeTypes.IMAGE_JPEG,
name: String = "a media",
size: Long = 1000,
) = LocalMedia(

View file

@ -23,7 +23,7 @@ import io.element.android.features.messages.impl.media.local.LocalMediaFactory
import io.element.android.libraries.core.mimetype.MimeTypes
import io.element.android.libraries.matrix.api.media.MediaFile
class FakeLocalMediaFactory() : LocalMediaFactory {
class FakeLocalMediaFactory : LocalMediaFactory {
var fallbackMimeType: String = MimeTypes.OctetStream

View file

@ -22,11 +22,11 @@ import kotlinx.parcelize.Parcelize
@Parcelize
data class MediaSource(
/**
* Url of the media
* Url of the media.
*/
val url: String,
/**
* This is used to hold data for encrypted media
* This is used to hold data for encrypted media.
*/
val json: String? = null,
) : Parcelable