Fix other API change: body renamed to filename
This commit is contained in:
parent
3f58f4b793
commit
2724815d79
13 changed files with 28 additions and 28 deletions
|
|
@ -35,12 +35,12 @@ interface VoiceMessageMediaRepo {
|
||||||
*
|
*
|
||||||
* @param mediaSource the media source of the voice message.
|
* @param mediaSource the media source of the voice message.
|
||||||
* @param mimeType the mime type of the voice message.
|
* @param mimeType the mime type of the voice message.
|
||||||
* @param body the body of the voice message.
|
* @param filename the filename of the voice message.
|
||||||
*/
|
*/
|
||||||
fun create(
|
fun create(
|
||||||
mediaSource: MediaSource,
|
mediaSource: MediaSource,
|
||||||
mimeType: String?,
|
mimeType: String?,
|
||||||
body: String?,
|
filename: String?,
|
||||||
): VoiceMessageMediaRepo
|
): VoiceMessageMediaRepo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -61,7 +61,7 @@ class DefaultVoiceMessageMediaRepo @AssistedInject constructor(
|
||||||
private val matrixMediaLoader: MatrixMediaLoader,
|
private val matrixMediaLoader: MatrixMediaLoader,
|
||||||
@Assisted private val mediaSource: MediaSource,
|
@Assisted private val mediaSource: MediaSource,
|
||||||
@Assisted("mimeType") private val mimeType: String?,
|
@Assisted("mimeType") private val mimeType: String?,
|
||||||
@Assisted("body") private val body: String?,
|
@Assisted("filename") private val filename: String?,
|
||||||
) : VoiceMessageMediaRepo {
|
) : VoiceMessageMediaRepo {
|
||||||
@ContributesBinding(RoomScope::class)
|
@ContributesBinding(RoomScope::class)
|
||||||
@AssistedFactory
|
@AssistedFactory
|
||||||
|
|
@ -69,7 +69,7 @@ class DefaultVoiceMessageMediaRepo @AssistedInject constructor(
|
||||||
override fun create(
|
override fun create(
|
||||||
mediaSource: MediaSource,
|
mediaSource: MediaSource,
|
||||||
@Assisted("mimeType") mimeType: String?,
|
@Assisted("mimeType") mimeType: String?,
|
||||||
@Assisted("body") body: String?,
|
@Assisted("filename") filename: String?,
|
||||||
): DefaultVoiceMessageMediaRepo
|
): DefaultVoiceMessageMediaRepo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -79,7 +79,7 @@ class DefaultVoiceMessageMediaRepo @AssistedInject constructor(
|
||||||
else -> matrixMediaLoader.downloadMediaFile(
|
else -> matrixMediaLoader.downloadMediaFile(
|
||||||
source = mediaSource,
|
source = mediaSource,
|
||||||
mimeType = mimeType,
|
mimeType = mimeType,
|
||||||
body = body,
|
filename = filename,
|
||||||
).mapCatching {
|
).mapCatching {
|
||||||
it.use { mediaFile ->
|
it.use { mediaFile ->
|
||||||
val dest = cachedFile.apply { parentFile?.mkdirs() }
|
val dest = cachedFile.apply { parentFile?.mkdirs() }
|
||||||
|
|
|
||||||
|
|
@ -37,13 +37,13 @@ interface VoiceMessagePlayer {
|
||||||
* @param eventId The eventId of the voice message event.
|
* @param eventId The eventId of the voice message event.
|
||||||
* @param mediaSource The media source of the voice message.
|
* @param mediaSource The media source of the voice message.
|
||||||
* @param mimeType The mime type of the voice message.
|
* @param mimeType The mime type of the voice message.
|
||||||
* @param body The body of the voice message.
|
* @param filename The filename of the voice message.
|
||||||
*/
|
*/
|
||||||
fun create(
|
fun create(
|
||||||
eventId: EventId?,
|
eventId: EventId?,
|
||||||
mediaSource: MediaSource,
|
mediaSource: MediaSource,
|
||||||
mimeType: String?,
|
mimeType: String?,
|
||||||
body: String?,
|
filename: String?,
|
||||||
): VoiceMessagePlayer
|
): VoiceMessagePlayer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -113,7 +113,7 @@ class DefaultVoiceMessagePlayer(
|
||||||
private val eventId: EventId?,
|
private val eventId: EventId?,
|
||||||
mediaSource: MediaSource,
|
mediaSource: MediaSource,
|
||||||
mimeType: String?,
|
mimeType: String?,
|
||||||
body: String?,
|
filename: String?,
|
||||||
) : VoiceMessagePlayer {
|
) : VoiceMessagePlayer {
|
||||||
@ContributesBinding(RoomScope::class) // Scoped types can't use @AssistedInject.
|
@ContributesBinding(RoomScope::class) // Scoped types can't use @AssistedInject.
|
||||||
class Factory @Inject constructor(
|
class Factory @Inject constructor(
|
||||||
|
|
@ -124,21 +124,21 @@ class DefaultVoiceMessagePlayer(
|
||||||
eventId: EventId?,
|
eventId: EventId?,
|
||||||
mediaSource: MediaSource,
|
mediaSource: MediaSource,
|
||||||
mimeType: String?,
|
mimeType: String?,
|
||||||
body: String?,
|
filename: String?,
|
||||||
): DefaultVoiceMessagePlayer = DefaultVoiceMessagePlayer(
|
): DefaultVoiceMessagePlayer = DefaultVoiceMessagePlayer(
|
||||||
mediaPlayer = mediaPlayer,
|
mediaPlayer = mediaPlayer,
|
||||||
voiceMessageMediaRepoFactory = voiceMessageMediaRepoFactory,
|
voiceMessageMediaRepoFactory = voiceMessageMediaRepoFactory,
|
||||||
eventId = eventId,
|
eventId = eventId,
|
||||||
mediaSource = mediaSource,
|
mediaSource = mediaSource,
|
||||||
mimeType = mimeType,
|
mimeType = mimeType,
|
||||||
body = body,
|
filename = filename,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val repo = voiceMessageMediaRepoFactory.create(
|
private val repo = voiceMessageMediaRepoFactory.create(
|
||||||
mediaSource = mediaSource,
|
mediaSource = mediaSource,
|
||||||
mimeType = mimeType,
|
mimeType = mimeType,
|
||||||
body = body
|
filename = filename,
|
||||||
)
|
)
|
||||||
|
|
||||||
private var internalState = MutableStateFlow(
|
private var internalState = MutableStateFlow(
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ class VoiceMessagePresenter @AssistedInject constructor(
|
||||||
eventId = content.eventId,
|
eventId = content.eventId,
|
||||||
mediaSource = content.mediaSource,
|
mediaSource = content.mediaSource,
|
||||||
mimeType = content.mimeType,
|
mimeType = content.mimeType,
|
||||||
body = content.caption,
|
filename = content.caption,
|
||||||
)
|
)
|
||||||
|
|
||||||
private val play = mutableStateOf<AsyncData<Unit>>(AsyncData.Uninitialized)
|
private val play = mutableStateOf<AsyncData<Unit>>(AsyncData.Uninitialized)
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,7 @@ private fun createDefaultVoiceMessageMediaRepo(
|
||||||
json = null
|
json = null
|
||||||
),
|
),
|
||||||
mimeType = MimeTypes.Ogg,
|
mimeType = MimeTypes.Ogg,
|
||||||
body = "someBody.ogg"
|
filename = "someBody.ogg"
|
||||||
)
|
)
|
||||||
|
|
||||||
private const val MXC_URI = "mxc://matrix.org/1234567890abcdefg"
|
private const val MXC_URI = "mxc://matrix.org/1234567890abcdefg"
|
||||||
|
|
|
||||||
|
|
@ -279,7 +279,7 @@ private fun createDefaultVoiceMessagePlayer(
|
||||||
json = null
|
json = null
|
||||||
),
|
),
|
||||||
mimeType = MimeTypes.Ogg,
|
mimeType = MimeTypes.Ogg,
|
||||||
body = "someBody.ogg"
|
filename = "someBody.ogg"
|
||||||
)
|
)
|
||||||
|
|
||||||
private const val MXC_URI = "mxc://matrix.org/1234567890abcdefg"
|
private const val MXC_URI = "mxc://matrix.org/1234567890abcdefg"
|
||||||
|
|
|
||||||
|
|
@ -226,14 +226,14 @@ fun TestScope.createVoiceMessagePresenter(
|
||||||
analyticsService: AnalyticsService = FakeAnalyticsService(),
|
analyticsService: AnalyticsService = FakeAnalyticsService(),
|
||||||
content: TimelineItemVoiceContent = aTimelineItemVoiceContent(),
|
content: TimelineItemVoiceContent = aTimelineItemVoiceContent(),
|
||||||
) = VoiceMessagePresenter(
|
) = VoiceMessagePresenter(
|
||||||
voiceMessagePlayerFactory = { eventId, mediaSource, mimeType, body ->
|
voiceMessagePlayerFactory = { eventId, mediaSource, mimeType, filename ->
|
||||||
DefaultVoiceMessagePlayer(
|
DefaultVoiceMessagePlayer(
|
||||||
mediaPlayer = mediaPlayer,
|
mediaPlayer = mediaPlayer,
|
||||||
voiceMessageMediaRepoFactory = { _, _, _ -> voiceMessageMediaRepo },
|
voiceMessageMediaRepoFactory = { _, _, _ -> voiceMessageMediaRepo },
|
||||||
eventId = eventId,
|
eventId = eventId,
|
||||||
mediaSource = mediaSource,
|
mediaSource = mediaSource,
|
||||||
mimeType = mimeType,
|
mimeType = mimeType,
|
||||||
body = body
|
filename = filename
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
analyticsService = analyticsService,
|
analyticsService = analyticsService,
|
||||||
|
|
|
||||||
|
|
@ -25,14 +25,14 @@ interface MatrixMediaLoader {
|
||||||
/**
|
/**
|
||||||
* @param source to fetch the data for.
|
* @param source to fetch the data for.
|
||||||
* @param mimeType: optional mime type.
|
* @param mimeType: optional mime type.
|
||||||
* @param body: optional body which will be used to name the file.
|
* @param filename: optional String which will be used to name the file.
|
||||||
* @param useCache: if true, the rust sdk will cache the media in its store.
|
* @param useCache: if true, the rust sdk will cache the media in its store.
|
||||||
* @return a [Result] of [MediaFile]
|
* @return a [Result] of [MediaFile]
|
||||||
*/
|
*/
|
||||||
suspend fun downloadMediaFile(
|
suspend fun downloadMediaFile(
|
||||||
source: MediaSource,
|
source: MediaSource,
|
||||||
mimeType: String?,
|
mimeType: String?,
|
||||||
body: String?,
|
filename: String?,
|
||||||
useCache: Boolean = true,
|
useCache: Boolean = true,
|
||||||
): Result<MediaFile>
|
): Result<MediaFile>
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ class RustMediaLoader(
|
||||||
override suspend fun downloadMediaFile(
|
override suspend fun downloadMediaFile(
|
||||||
source: MediaSource,
|
source: MediaSource,
|
||||||
mimeType: String?,
|
mimeType: String?,
|
||||||
body: String?,
|
filename: String?,
|
||||||
useCache: Boolean,
|
useCache: Boolean,
|
||||||
): Result<MediaFile> =
|
): Result<MediaFile> =
|
||||||
withContext(mediaDispatcher) {
|
withContext(mediaDispatcher) {
|
||||||
|
|
@ -71,7 +71,7 @@ class RustMediaLoader(
|
||||||
source.toRustMediaSource().use { mediaSource ->
|
source.toRustMediaSource().use { mediaSource ->
|
||||||
val mediaFile = innerClient.getMediaFile(
|
val mediaFile = innerClient.getMediaFile(
|
||||||
mediaSource = mediaSource,
|
mediaSource = mediaSource,
|
||||||
body = body,
|
filename = filename,
|
||||||
mimeType = mimeType?.takeIf { MimeTypes.hasSubtype(it) } ?: MimeTypes.OctetStream,
|
mimeType = mimeType?.takeIf { MimeTypes.hasSubtype(it) } ?: MimeTypes.OctetStream,
|
||||||
useCache = useCache,
|
useCache = useCache,
|
||||||
tempDir = cacheDirectory.path,
|
tempDir = cacheDirectory.path,
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ class FakeMatrixMediaLoader : MatrixMediaLoader {
|
||||||
override suspend fun downloadMediaFile(
|
override suspend fun downloadMediaFile(
|
||||||
source: MediaSource,
|
source: MediaSource,
|
||||||
mimeType: String?,
|
mimeType: String?,
|
||||||
body: String?,
|
filename: String?,
|
||||||
useCache: Boolean,
|
useCache: Boolean,
|
||||||
): Result<MediaFile> = simulateLongTask {
|
): Result<MediaFile> = simulateLongTask {
|
||||||
if (shouldFail) {
|
if (shouldFail) {
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ class MediaViewerPresenter @AssistedInject constructor(
|
||||||
mediaLoader.downloadMediaFile(
|
mediaLoader.downloadMediaFile(
|
||||||
source = inputs.mediaSource,
|
source = inputs.mediaSource,
|
||||||
mimeType = inputs.mediaInfo.mimeType,
|
mimeType = inputs.mediaInfo.mimeType,
|
||||||
body = inputs.mediaInfo.filename
|
filename = inputs.mediaInfo.filename
|
||||||
)
|
)
|
||||||
.onSuccess {
|
.onSuccess {
|
||||||
mediaFile.value = it
|
mediaFile.value = it
|
||||||
|
|
|
||||||
|
|
@ -299,7 +299,7 @@ class DefaultNotifiableEventResolver @Inject constructor(
|
||||||
.getMediaFile(
|
.getMediaFile(
|
||||||
mediaSource = messageType.source,
|
mediaSource = messageType.source,
|
||||||
mimeType = messageType.info?.mimetype,
|
mimeType = messageType.info?.mimetype,
|
||||||
body = messageType.filename,
|
filename = messageType.filename,
|
||||||
)
|
)
|
||||||
is VideoMessageType -> null // Use the thumbnail here?
|
is VideoMessageType -> null // Use the thumbnail here?
|
||||||
else -> null
|
else -> null
|
||||||
|
|
|
||||||
|
|
@ -47,13 +47,13 @@ interface NotificationMediaRepo {
|
||||||
*
|
*
|
||||||
* @param mediaSource the media source of the media.
|
* @param mediaSource the media source of the media.
|
||||||
* @param mimeType the mime type of the media.
|
* @param mimeType the mime type of the media.
|
||||||
* @param body optional body which will be used to name the file.
|
* @param filename optional String which will be used to name the file.
|
||||||
* @return A [Result] holding either the media [File] from the cache directory or an [Exception].
|
* @return A [Result] holding either the media [File] from the cache directory or an [Exception].
|
||||||
*/
|
*/
|
||||||
suspend fun getMediaFile(
|
suspend fun getMediaFile(
|
||||||
mediaSource: MediaSource,
|
mediaSource: MediaSource,
|
||||||
mimeType: String?,
|
mimeType: String?,
|
||||||
body: String?,
|
filename: String?,
|
||||||
): Result<File>
|
): Result<File>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -75,7 +75,7 @@ class DefaultNotificationMediaRepo @AssistedInject constructor(
|
||||||
override suspend fun getMediaFile(
|
override suspend fun getMediaFile(
|
||||||
mediaSource: MediaSource,
|
mediaSource: MediaSource,
|
||||||
mimeType: String?,
|
mimeType: String?,
|
||||||
body: String?,
|
filename: String?,
|
||||||
): Result<File> {
|
): Result<File> {
|
||||||
val cachedFile = mediaSource.cachedFile()
|
val cachedFile = mediaSource.cachedFile()
|
||||||
return when {
|
return when {
|
||||||
|
|
@ -84,7 +84,7 @@ class DefaultNotificationMediaRepo @AssistedInject constructor(
|
||||||
else -> matrixMediaLoader.downloadMediaFile(
|
else -> matrixMediaLoader.downloadMediaFile(
|
||||||
source = mediaSource,
|
source = mediaSource,
|
||||||
mimeType = mimeType,
|
mimeType = mimeType,
|
||||||
body = body,
|
filename = filename,
|
||||||
).mapCatching {
|
).mapCatching {
|
||||||
it.use { mediaFile ->
|
it.use { mediaFile ->
|
||||||
val dest = cachedFile.apply { parentFile?.mkdirs() }
|
val dest = cachedFile.apply { parentFile?.mkdirs() }
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ class FakeNotificationMediaRepo : NotificationMediaRepo {
|
||||||
override suspend fun getMediaFile(
|
override suspend fun getMediaFile(
|
||||||
mediaSource: MediaSource,
|
mediaSource: MediaSource,
|
||||||
mimeType: String?,
|
mimeType: String?,
|
||||||
body: String?,
|
filename: String?,
|
||||||
): Result<File> {
|
): Result<File> {
|
||||||
return Result.failure(IllegalStateException("Fake class"))
|
return Result.failure(IllegalStateException("Fake class"))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue