forked from GitHub-Mirror/riotX-android
Download file - typo
This commit is contained in:
parent
a07f8b615e
commit
b0c939866f
@ -51,4 +51,4 @@ data class MessageAudioContent(
|
|||||||
* Required if the file is encrypted. Information on the encrypted file, as specified in End-to-end encryption.
|
* Required if the file is encrypted. Information on the encrypted file, as specified in End-to-end encryption.
|
||||||
*/
|
*/
|
||||||
@Json(name = "file") override val encryptedFileInfo: EncryptedFileInfo? = null
|
@Json(name = "file") override val encryptedFileInfo: EncryptedFileInfo? = null
|
||||||
) : MessageEncyptedContent
|
) : MessageEncryptedContent
|
||||||
|
@ -22,6 +22,6 @@ import im.vector.matrix.android.internal.crypto.model.rest.EncryptedFileInfo
|
|||||||
/**
|
/**
|
||||||
* Interface for message which can contains encrypted data
|
* Interface for message which can contains encrypted data
|
||||||
*/
|
*/
|
||||||
interface MessageEncyptedContent : MessageContent {
|
interface MessageEncryptedContent : MessageContent {
|
||||||
val encryptedFileInfo: EncryptedFileInfo?
|
val encryptedFileInfo: EncryptedFileInfo?
|
||||||
}
|
}
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package im.vector.matrix.android.api.session.room.model.message
|
package im.vector.matrix.android.api.session.room.model.message
|
||||||
|
|
||||||
|
import android.content.ClipDescription
|
||||||
import com.squareup.moshi.Json
|
import com.squareup.moshi.Json
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
||||||
import im.vector.matrix.android.api.session.events.model.Content
|
import im.vector.matrix.android.api.session.events.model.Content
|
||||||
@ -53,4 +54,16 @@ data class MessageFileContent(
|
|||||||
@Json(name = "m.new_content") override val newContent: Content? = null,
|
@Json(name = "m.new_content") override val newContent: Content? = null,
|
||||||
|
|
||||||
@Json(name = "file") override val encryptedFileInfo: EncryptedFileInfo? = null
|
@Json(name = "file") override val encryptedFileInfo: EncryptedFileInfo? = null
|
||||||
) : MessageEncyptedContent
|
) : MessageEncryptedContent {
|
||||||
|
|
||||||
|
fun getMimeType(): String {
|
||||||
|
// Mimetype default to plain text, should not be used
|
||||||
|
return encryptedFileInfo?.mimetype
|
||||||
|
?: info?.mimeType
|
||||||
|
?: ClipDescription.MIMETYPE_TEXT_PLAIN
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getFileName(): String {
|
||||||
|
return filename ?: body
|
||||||
|
}
|
||||||
|
}
|
@ -52,4 +52,4 @@ data class MessageImageContent(
|
|||||||
* Required if the file is encrypted. Information on the encrypted file, as specified in End-to-end encryption.
|
* Required if the file is encrypted. Information on the encrypted file, as specified in End-to-end encryption.
|
||||||
*/
|
*/
|
||||||
@Json(name = "file") override val encryptedFileInfo: EncryptedFileInfo? = null
|
@Json(name = "file") override val encryptedFileInfo: EncryptedFileInfo? = null
|
||||||
) : MessageEncyptedContent
|
) : MessageEncryptedContent
|
@ -51,4 +51,4 @@ data class MessageVideoContent(
|
|||||||
* Required if the file is encrypted. Information on the encrypted file, as specified in End-to-end encryption.
|
* Required if the file is encrypted. Information on the encrypted file, as specified in End-to-end encryption.
|
||||||
*/
|
*/
|
||||||
@Json(name = "file") override val encryptedFileInfo: EncryptedFileInfo? = null
|
@Json(name = "file") override val encryptedFileInfo: EncryptedFileInfo? = null
|
||||||
) : MessageEncyptedContent
|
) : MessageEncryptedContent
|
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package im.vector.riotx.features.home.room.detail
|
package im.vector.riotx.features.home.room.detail
|
||||||
|
|
||||||
import android.content.ClipDescription
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
import androidx.lifecycle.LiveData
|
import androidx.lifecycle.LiveData
|
||||||
@ -452,16 +451,13 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||||||
session.downloadFile(
|
session.downloadFile(
|
||||||
FileService.DownloadMode.TO_EXPORT,
|
FileService.DownloadMode.TO_EXPORT,
|
||||||
action.eventId,
|
action.eventId,
|
||||||
action.messageFileContent.filename ?: "file.dat",
|
action.messageFileContent.getFileName(),
|
||||||
action.messageFileContent.url,
|
action.messageFileContent.url,
|
||||||
action.messageFileContent.encryptedFileInfo?.toElementToDecrypt(),
|
action.messageFileContent.encryptedFileInfo?.toElementToDecrypt(),
|
||||||
object : MatrixCallback<File> {
|
object : MatrixCallback<File> {
|
||||||
override fun onSuccess(data: File) {
|
override fun onSuccess(data: File) {
|
||||||
_downloadedFileEvent.postValue(LiveEvent(DownloadFileState(
|
_downloadedFileEvent.postValue(LiveEvent(DownloadFileState(
|
||||||
// Mimetype default to plain text, should not be used
|
action.messageFileContent.getMimeType(),
|
||||||
action.messageFileContent.encryptedFileInfo?.mimetype
|
|
||||||
?: action.messageFileContent.info?.mimeType
|
|
||||||
?: ClipDescription.MIMETYPE_TEXT_PLAIN,
|
|
||||||
data,
|
data,
|
||||||
null
|
null
|
||||||
)))
|
)))
|
||||||
@ -469,10 +465,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
|||||||
|
|
||||||
override fun onFailure(failure: Throwable) {
|
override fun onFailure(failure: Throwable) {
|
||||||
_downloadedFileEvent.postValue(LiveEvent(DownloadFileState(
|
_downloadedFileEvent.postValue(LiveEvent(DownloadFileState(
|
||||||
// Mimetype default to plain text, should not be used
|
action.messageFileContent.getMimeType(),
|
||||||
action.messageFileContent.encryptedFileInfo?.mimetype
|
|
||||||
?: action.messageFileContent.info?.mimeType
|
|
||||||
?: ClipDescription.MIMETYPE_TEXT_PLAIN,
|
|
||||||
null,
|
null,
|
||||||
failure
|
failure
|
||||||
)))
|
)))
|
||||||
|
Loading…
Reference in New Issue
Block a user