mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 13:38:49 +03:00
Rename MessageContent.type to MessageContent.msgType for code clarity and update a few the Javadoc
This commit is contained in:
parent
f72e5c1d94
commit
3384d91adb
24 changed files with 112 additions and 59 deletions
|
@ -200,7 +200,7 @@ data class Event(
|
||||||
|
|
||||||
fun Event.isTextMessage(): Boolean {
|
fun Event.isTextMessage(): Boolean {
|
||||||
return getClearType() == EventType.MESSAGE
|
return getClearType() == EventType.MESSAGE
|
||||||
&& when (getClearContent()?.toModel<MessageContent>()?.type) {
|
&& when (getClearContent()?.toModel<MessageContent>()?.msgType) {
|
||||||
MessageType.MSGTYPE_TEXT,
|
MessageType.MSGTYPE_TEXT,
|
||||||
MessageType.MSGTYPE_EMOTE,
|
MessageType.MSGTYPE_EMOTE,
|
||||||
MessageType.MSGTYPE_NOTICE -> true
|
MessageType.MSGTYPE_NOTICE -> true
|
||||||
|
@ -210,7 +210,7 @@ fun Event.isTextMessage(): Boolean {
|
||||||
|
|
||||||
fun Event.isImageMessage(): Boolean {
|
fun Event.isImageMessage(): Boolean {
|
||||||
return getClearType() == EventType.MESSAGE
|
return getClearType() == EventType.MESSAGE
|
||||||
&& when (getClearContent()?.toModel<MessageContent>()?.type) {
|
&& when (getClearContent()?.toModel<MessageContent>()?.msgType) {
|
||||||
MessageType.MSGTYPE_IMAGE -> true
|
MessageType.MSGTYPE_IMAGE -> true
|
||||||
else -> false
|
else -> false
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,9 +25,9 @@ import im.vector.matrix.android.internal.crypto.model.rest.EncryptedFileInfo
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
data class MessageAudioContent(
|
data class MessageAudioContent(
|
||||||
/**
|
/**
|
||||||
* Not documented
|
* Required. Must be 'm.audio'.
|
||||||
*/
|
*/
|
||||||
@Json(name = "msgtype") override val type: String,
|
@Json(name = "msgtype") override val msgType: String,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Required. A description of the audio e.g. 'Bee Gees - Stayin' Alive', or some kind of content description for accessibility e.g. 'audio attachment'.
|
* Required. A description of the audio e.g. 'Bee Gees - Stayin' Alive', or some kind of content description for accessibility e.g. 'audio attachment'.
|
||||||
|
@ -40,7 +40,7 @@ data class MessageAudioContent(
|
||||||
@Json(name = "info") val audioInfo: AudioInfo? = null,
|
@Json(name = "info") val audioInfo: AudioInfo? = null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Required. Required if the file is not encrypted. The URL (typically MXC URI) to the audio clip.
|
* Required if the file is not encrypted. The URL (typically MXC URI) to the audio clip.
|
||||||
*/
|
*/
|
||||||
@Json(name = "url") override val url: String? = null,
|
@Json(name = "url") override val url: String? = null,
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,7 @@ import im.vector.matrix.android.api.session.events.model.Content
|
||||||
import im.vector.matrix.android.api.session.room.model.relation.RelationDefaultContent
|
import im.vector.matrix.android.api.session.room.model.relation.RelationDefaultContent
|
||||||
|
|
||||||
interface MessageContent {
|
interface MessageContent {
|
||||||
// TODO Rename to msgType
|
val msgType: String
|
||||||
val type: String
|
|
||||||
val body: String
|
val body: String
|
||||||
val relatesTo: RelationDefaultContent?
|
val relatesTo: RelationDefaultContent?
|
||||||
val newContent: Content?
|
val newContent: Content?
|
||||||
|
|
|
@ -23,7 +23,7 @@ import im.vector.matrix.android.api.session.room.model.relation.RelationDefaultC
|
||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
data class MessageDefaultContent(
|
data class MessageDefaultContent(
|
||||||
@Json(name = "msgtype") override val type: String,
|
@Json(name = "msgtype") override val msgType: String,
|
||||||
@Json(name = "body") override val body: String,
|
@Json(name = "body") override val body: String,
|
||||||
@Json(name = "m.relates_to") override val relatesTo: RelationDefaultContent? = null,
|
@Json(name = "m.relates_to") override val relatesTo: RelationDefaultContent? = null,
|
||||||
@Json(name = "m.new_content") override val newContent: Content? = null
|
@Json(name = "m.new_content") override val newContent: Content? = null
|
||||||
|
|
|
@ -23,10 +23,26 @@ import im.vector.matrix.android.api.session.room.model.relation.RelationDefaultC
|
||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
data class MessageEmoteContent(
|
data class MessageEmoteContent(
|
||||||
@Json(name = "msgtype") override val type: String,
|
/**
|
||||||
|
* Required. Must be 'm.emote'.
|
||||||
|
*/
|
||||||
|
@Json(name = "msgtype") override val msgType: String,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Required. The emote action to perform.
|
||||||
|
*/
|
||||||
@Json(name = "body") override val body: String,
|
@Json(name = "body") override val body: String,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The format used in the formatted_body. Currently only org.matrix.custom.html is supported.
|
||||||
|
*/
|
||||||
@Json(name = "format") val format: String? = null,
|
@Json(name = "format") val format: String? = null,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The formatted version of the body. This is required if format is specified.
|
||||||
|
*/
|
||||||
@Json(name = "formatted_body") val formattedBody: String? = null,
|
@Json(name = "formatted_body") val formattedBody: String? = null,
|
||||||
|
|
||||||
@Json(name = "m.relates_to") override val relatesTo: RelationDefaultContent? = null,
|
@Json(name = "m.relates_to") override val relatesTo: RelationDefaultContent? = null,
|
||||||
@Json(name = "m.new_content") override val newContent: Content? = null
|
@Json(name = "m.new_content") override val newContent: Content? = null
|
||||||
) : MessageContent
|
) : MessageContent
|
||||||
|
|
|
@ -23,10 +23,13 @@ import im.vector.matrix.android.internal.crypto.model.rest.EncryptedFileInfo
|
||||||
*/
|
*/
|
||||||
interface MessageEncryptedContent : MessageContent {
|
interface MessageEncryptedContent : MessageContent {
|
||||||
/**
|
/**
|
||||||
* Required. Required if the file is unencrypted. The URL (typically MXC URI) to the image.
|
* Required if the file is unencrypted. The URL (typically MXC URI) to the image.
|
||||||
*/
|
*/
|
||||||
val url: String?
|
val url: String?
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Required if the file is encrypted. Information on the encrypted file, as specified in End-to-end encryption.
|
||||||
|
*/
|
||||||
val encryptedFileInfo: EncryptedFileInfo?
|
val encryptedFileInfo: EncryptedFileInfo?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,9 @@ import im.vector.matrix.android.internal.crypto.model.rest.EncryptedFileInfo
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
data class MessageFileContent(
|
data class MessageFileContent(
|
||||||
/**
|
/**
|
||||||
* Not documented
|
* Required. Must be 'm.file'.
|
||||||
*/
|
*/
|
||||||
@Json(name = "msgtype") override val type: String,
|
@Json(name = "msgtype") override val msgType: String,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Required. A human-readable description of the file. This is recommended to be the filename of the original upload.
|
* Required. A human-readable description of the file. This is recommended to be the filename of the original upload.
|
||||||
|
@ -46,13 +46,16 @@ data class MessageFileContent(
|
||||||
@Json(name = "info") val info: FileInfo? = null,
|
@Json(name = "info") val info: FileInfo? = null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Required. Required if the file is unencrypted. The URL (typically MXC URI) to the file.
|
* Required if the file is unencrypted. The URL (typically MXC URI) to the file.
|
||||||
*/
|
*/
|
||||||
@Json(name = "url") override val url: String? = null,
|
@Json(name = "url") override val url: String? = null,
|
||||||
|
|
||||||
@Json(name = "m.relates_to") override val relatesTo: RelationDefaultContent? = null,
|
@Json(name = "m.relates_to") override val relatesTo: RelationDefaultContent? = null,
|
||||||
@Json(name = "m.new_content") override val newContent: Content? = null,
|
@Json(name = "m.new_content") override val newContent: Content? = null,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
) : MessageEncryptedContent {
|
) : MessageEncryptedContent {
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ data class MessageImageContent(
|
||||||
/**
|
/**
|
||||||
* Required. Must be 'm.image'.
|
* Required. Must be 'm.image'.
|
||||||
*/
|
*/
|
||||||
@Json(name = "msgtype") override val type: String,
|
@Json(name = "msgtype") override val msgType: String,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Required. A textual representation of the image. This could be the alt text of the image, the filename of the image,
|
* Required. A textual representation of the image. This could be the alt text of the image, the filename of the image,
|
||||||
|
@ -41,7 +41,7 @@ data class MessageImageContent(
|
||||||
@Json(name = "info") override val info: ImageInfo? = null,
|
@Json(name = "info") override val info: ImageInfo? = null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Required. Required if the file is unencrypted. The URL (typically MXC URI) to the image.
|
* Required if the file is unencrypted. The URL (typically MXC URI) to the image.
|
||||||
*/
|
*/
|
||||||
@Json(name = "url") override val url: String? = null,
|
@Json(name = "url") override val url: String? = null,
|
||||||
|
|
||||||
|
|
|
@ -24,9 +24,9 @@ import im.vector.matrix.android.api.session.room.model.relation.RelationDefaultC
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
data class MessageLocationContent(
|
data class MessageLocationContent(
|
||||||
/**
|
/**
|
||||||
* Not documented
|
* Required. Must be 'm.location'.
|
||||||
*/
|
*/
|
||||||
@Json(name = "msgtype") override val type: String,
|
@Json(name = "msgtype") override val msgType: String,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Required. A description of the location e.g. 'Big Ben, London, UK', or some kind of content description for accessibility e.g. 'location attachment'.
|
* Required. A description of the location e.g. 'Big Ben, London, UK', or some kind of content description for accessibility e.g. 'location attachment'.
|
||||||
|
|
|
@ -23,10 +23,26 @@ import im.vector.matrix.android.api.session.room.model.relation.RelationDefaultC
|
||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
data class MessageNoticeContent(
|
data class MessageNoticeContent(
|
||||||
@Json(name = "msgtype") override val type: String,
|
/**
|
||||||
|
* Required. Must be 'm.notice'.
|
||||||
|
*/
|
||||||
|
@Json(name = "msgtype") override val msgType: String,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Required. The notice text to send.
|
||||||
|
*/
|
||||||
@Json(name = "body") override val body: String,
|
@Json(name = "body") override val body: String,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The format used in the formatted_body. Currently only org.matrix.custom.html is supported.
|
||||||
|
*/
|
||||||
@Json(name = "format") val format: String? = null,
|
@Json(name = "format") val format: String? = null,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The formatted version of the body. This is required if format is specified.
|
||||||
|
*/
|
||||||
@Json(name = "formatted_body") val formattedBody: String? = null,
|
@Json(name = "formatted_body") val formattedBody: String? = null,
|
||||||
|
|
||||||
@Json(name = "m.relates_to") override val relatesTo: RelationDefaultContent? = null,
|
@Json(name = "m.relates_to") override val relatesTo: RelationDefaultContent? = null,
|
||||||
@Json(name = "m.new_content") override val newContent: Content? = null
|
@Json(name = "m.new_content") override val newContent: Content? = null
|
||||||
) : MessageContent
|
) : MessageContent
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package im.vector.matrix.android.api.session.room.model.message
|
package im.vector.matrix.android.api.session.room.model.message
|
||||||
|
@ -28,7 +27,7 @@ data class MessageStickerContent(
|
||||||
/**
|
/**
|
||||||
* Set in local, not from server
|
* Set in local, not from server
|
||||||
*/
|
*/
|
||||||
override val type: String = MessageType.MSGTYPE_STICKER_LOCAL,
|
override val msgType: String = MessageType.MSGTYPE_STICKER_LOCAL,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Required. A textual representation of the image. This could be the alt text of the image, the filename of the image,
|
* Required. A textual representation of the image. This could be the alt text of the image, the filename of the image,
|
||||||
|
@ -42,7 +41,7 @@ data class MessageStickerContent(
|
||||||
@Json(name = "info") override val info: ImageInfo? = null,
|
@Json(name = "info") override val info: ImageInfo? = null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Required. Required if the file is unencrypted. The URL (typically MXC URI) to the image.
|
* Required if the file is unencrypted. The URL (typically MXC URI) to the image.
|
||||||
*/
|
*/
|
||||||
@Json(name = "url") override val url: String? = null,
|
@Json(name = "url") override val url: String? = null,
|
||||||
|
|
||||||
|
|
|
@ -23,10 +23,26 @@ import im.vector.matrix.android.api.session.room.model.relation.RelationDefaultC
|
||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
data class MessageTextContent(
|
data class MessageTextContent(
|
||||||
@Json(name = "msgtype") override val type: String,
|
/**
|
||||||
|
* Required. Must be 'm.text'.
|
||||||
|
*/
|
||||||
|
@Json(name = "msgtype") override val msgType: String,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Required. The body of the message.
|
||||||
|
*/
|
||||||
@Json(name = "body") override val body: String,
|
@Json(name = "body") override val body: String,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The format used in the formatted_body. Currently only org.matrix.custom.html is supported.
|
||||||
|
*/
|
||||||
@Json(name = "format") val format: String? = null,
|
@Json(name = "format") val format: String? = null,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The formatted version of the body. This is required if format is specified.
|
||||||
|
*/
|
||||||
@Json(name = "formatted_body") val formattedBody: String? = null,
|
@Json(name = "formatted_body") val formattedBody: String? = null,
|
||||||
|
|
||||||
@Json(name = "m.relates_to") override val relatesTo: RelationDefaultContent? = null,
|
@Json(name = "m.relates_to") override val relatesTo: RelationDefaultContent? = null,
|
||||||
@Json(name = "m.new_content") override val newContent: Content? = null
|
@Json(name = "m.new_content") override val newContent: Content? = null
|
||||||
) : MessageContent
|
) : MessageContent
|
||||||
|
|
|
@ -24,7 +24,7 @@ import im.vector.matrix.android.internal.crypto.verification.VerificationInfoReq
|
||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
data class MessageVerificationRequestContent(
|
data class MessageVerificationRequestContent(
|
||||||
@Json(name = "msgtype") override val type: String = MessageType.MSGTYPE_VERIFICATION_REQUEST,
|
@Json(name = "msgtype") override val msgType: String = MessageType.MSGTYPE_VERIFICATION_REQUEST,
|
||||||
@Json(name = "body") override val body: String,
|
@Json(name = "body") override val body: String,
|
||||||
@Json(name = "from_device") override val fromDevice: String?,
|
@Json(name = "from_device") override val fromDevice: String?,
|
||||||
@Json(name = "methods") override val methods: List<String>,
|
@Json(name = "methods") override val methods: List<String>,
|
||||||
|
|
|
@ -27,7 +27,7 @@ data class MessageVideoContent(
|
||||||
/**
|
/**
|
||||||
* Required. Must be 'm.video'.
|
* Required. Must be 'm.video'.
|
||||||
*/
|
*/
|
||||||
@Json(name = "msgtype") override val type: String,
|
@Json(name = "msgtype") override val msgType: String,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Required. A description of the video e.g. 'Gangnam style', or some kind of content description for accessibility e.g. 'video attachment'.
|
* Required. A description of the video e.g. 'Gangnam style', or some kind of content description for accessibility e.g. 'video attachment'.
|
||||||
|
@ -40,7 +40,7 @@ data class MessageVideoContent(
|
||||||
@Json(name = "info") val videoInfo: VideoInfo? = null,
|
@Json(name = "info") val videoInfo: VideoInfo? = null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Required. Required if the file is unencrypted. The URL (typically MXC URI) to the video clip.
|
* Required if the file is unencrypted. The URL (typically MXC URI) to the video clip.
|
||||||
*/
|
*/
|
||||||
@Json(name = "url") override val url: String? = null,
|
@Json(name = "url") override val url: String? = null,
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ internal class DefaultRoomVerificationUpdateTask @Inject constructor(
|
||||||
// done from another device of mine
|
// done from another device of mine
|
||||||
|
|
||||||
if (EventType.MESSAGE == event.type) {
|
if (EventType.MESSAGE == event.type) {
|
||||||
val msgType = event.getClearContent().toModel<MessageContent>()?.type
|
val msgType = event.getClearContent().toModel<MessageContent>()?.msgType
|
||||||
if (MessageType.MSGTYPE_VERIFICATION_REQUEST == msgType) {
|
if (MessageType.MSGTYPE_VERIFICATION_REQUEST == msgType) {
|
||||||
event.getClearContent().toModel<MessageVerificationRequestContent>()?.let {
|
event.getClearContent().toModel<MessageVerificationRequestContent>()?.let {
|
||||||
if (it.fromDevice != deviceId) {
|
if (it.fromDevice != deviceId) {
|
||||||
|
@ -144,7 +144,7 @@ internal class DefaultRoomVerificationUpdateTask @Inject constructor(
|
||||||
params.verificationService.onRoomEvent(event)
|
params.verificationService.onRoomEvent(event)
|
||||||
}
|
}
|
||||||
EventType.MESSAGE -> {
|
EventType.MESSAGE -> {
|
||||||
if (MessageType.MSGTYPE_VERIFICATION_REQUEST == event.getClearContent().toModel<MessageContent>()?.type) {
|
if (MessageType.MSGTYPE_VERIFICATION_REQUEST == event.getClearContent().toModel<MessageContent>()?.msgType) {
|
||||||
params.verificationService.onRoomRequestReceived(event)
|
params.verificationService.onRoomRequestReceived(event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,7 +165,7 @@ internal class DefaultVerificationService @Inject constructor(
|
||||||
onRoomDoneReceived(event)
|
onRoomDoneReceived(event)
|
||||||
}
|
}
|
||||||
EventType.MESSAGE -> {
|
EventType.MESSAGE -> {
|
||||||
if (MessageType.MSGTYPE_VERIFICATION_REQUEST == event.getClearContent().toModel<MessageContent>()?.type) {
|
if (MessageType.MSGTYPE_VERIFICATION_REQUEST == event.getClearContent().toModel<MessageContent>()?.msgType) {
|
||||||
onRoomRequestReceived(event)
|
onRoomRequestReceived(event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ internal class LocalEchoEventFactory @Inject constructor(
|
||||||
if (msgType == MessageType.MSGTYPE_TEXT || msgType == MessageType.MSGTYPE_EMOTE) {
|
if (msgType == MessageType.MSGTYPE_TEXT || msgType == MessageType.MSGTYPE_EMOTE) {
|
||||||
return createFormattedTextEvent(roomId, createTextContent(text, autoMarkdown), msgType)
|
return createFormattedTextEvent(roomId, createTextContent(text, autoMarkdown), msgType)
|
||||||
}
|
}
|
||||||
val content = MessageTextContent(type = msgType, body = text.toString())
|
val content = MessageTextContent(msgType = msgType, body = text.toString())
|
||||||
return createEvent(roomId, content)
|
return createEvent(roomId, content)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ internal class LocalEchoEventFactory @Inject constructor(
|
||||||
compatibilityText: String): Event {
|
compatibilityText: String): Event {
|
||||||
return createEvent(roomId,
|
return createEvent(roomId,
|
||||||
MessageTextContent(
|
MessageTextContent(
|
||||||
type = msgType,
|
msgType = msgType,
|
||||||
body = compatibilityText,
|
body = compatibilityText,
|
||||||
relatesTo = RelationDefaultContent(RelationType.REPLACE, targetEventId),
|
relatesTo = RelationDefaultContent(RelationType.REPLACE, targetEventId),
|
||||||
newContent = createTextContent(newBodyText, newBodyAutoMarkdown)
|
newContent = createTextContent(newBodyText, newBodyAutoMarkdown)
|
||||||
|
@ -131,7 +131,8 @@ internal class LocalEchoEventFactory @Inject constructor(
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createReplaceTextOfReply(roomId: String, eventReplaced: TimelineEvent,
|
fun createReplaceTextOfReply(roomId: String,
|
||||||
|
eventReplaced: TimelineEvent,
|
||||||
originalEvent: TimelineEvent,
|
originalEvent: TimelineEvent,
|
||||||
newBodyText: String,
|
newBodyText: String,
|
||||||
newBodyAutoMarkdown: Boolean,
|
newBodyAutoMarkdown: Boolean,
|
||||||
|
@ -157,11 +158,11 @@ internal class LocalEchoEventFactory @Inject constructor(
|
||||||
|
|
||||||
return createEvent(roomId,
|
return createEvent(roomId,
|
||||||
MessageTextContent(
|
MessageTextContent(
|
||||||
type = msgType,
|
msgType = msgType,
|
||||||
body = compatibilityText,
|
body = compatibilityText,
|
||||||
relatesTo = RelationDefaultContent(RelationType.REPLACE, eventReplaced.root.eventId),
|
relatesTo = RelationDefaultContent(RelationType.REPLACE, eventReplaced.root.eventId),
|
||||||
newContent = MessageTextContent(
|
newContent = MessageTextContent(
|
||||||
type = msgType,
|
msgType = msgType,
|
||||||
format = MessageType.FORMAT_MATRIX_HTML,
|
format = MessageType.FORMAT_MATRIX_HTML,
|
||||||
body = replyFallback,
|
body = replyFallback,
|
||||||
formattedBody = replyFormatted
|
formattedBody = replyFormatted
|
||||||
|
@ -214,7 +215,7 @@ internal class LocalEchoEventFactory @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
val content = MessageImageContent(
|
val content = MessageImageContent(
|
||||||
type = MessageType.MSGTYPE_IMAGE,
|
msgType = MessageType.MSGTYPE_IMAGE,
|
||||||
body = attachment.name ?: "image",
|
body = attachment.name ?: "image",
|
||||||
info = ImageInfo(
|
info = ImageInfo(
|
||||||
mimeType = attachment.mimeType,
|
mimeType = attachment.mimeType,
|
||||||
|
@ -246,7 +247,7 @@ internal class LocalEchoEventFactory @Inject constructor(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
val content = MessageVideoContent(
|
val content = MessageVideoContent(
|
||||||
type = MessageType.MSGTYPE_VIDEO,
|
msgType = MessageType.MSGTYPE_VIDEO,
|
||||||
body = attachment.name ?: "video",
|
body = attachment.name ?: "video",
|
||||||
videoInfo = VideoInfo(
|
videoInfo = VideoInfo(
|
||||||
mimeType = attachment.mimeType,
|
mimeType = attachment.mimeType,
|
||||||
|
@ -265,7 +266,7 @@ internal class LocalEchoEventFactory @Inject constructor(
|
||||||
|
|
||||||
private fun createAudioEvent(roomId: String, attachment: ContentAttachmentData): Event {
|
private fun createAudioEvent(roomId: String, attachment: ContentAttachmentData): Event {
|
||||||
val content = MessageAudioContent(
|
val content = MessageAudioContent(
|
||||||
type = MessageType.MSGTYPE_AUDIO,
|
msgType = MessageType.MSGTYPE_AUDIO,
|
||||||
body = attachment.name ?: "audio",
|
body = attachment.name ?: "audio",
|
||||||
audioInfo = AudioInfo(
|
audioInfo = AudioInfo(
|
||||||
mimeType = attachment.mimeType?.takeIf { it.isNotBlank() } ?: "audio/mpeg",
|
mimeType = attachment.mimeType?.takeIf { it.isNotBlank() } ?: "audio/mpeg",
|
||||||
|
@ -278,7 +279,7 @@ internal class LocalEchoEventFactory @Inject constructor(
|
||||||
|
|
||||||
private fun createFileEvent(roomId: String, attachment: ContentAttachmentData): Event {
|
private fun createFileEvent(roomId: String, attachment: ContentAttachmentData): Event {
|
||||||
val content = MessageFileContent(
|
val content = MessageFileContent(
|
||||||
type = MessageType.MSGTYPE_FILE,
|
msgType = MessageType.MSGTYPE_FILE,
|
||||||
body = attachment.name ?: "file",
|
body = attachment.name ?: "file",
|
||||||
info = FileInfo(
|
info = FileInfo(
|
||||||
mimeType = attachment.mimeType?.takeIf { it.isNotBlank() }
|
mimeType = attachment.mimeType?.takeIf { it.isNotBlank() }
|
||||||
|
@ -349,7 +350,7 @@ internal class LocalEchoEventFactory @Inject constructor(
|
||||||
|
|
||||||
val eventId = eventReplied.root.eventId ?: return null
|
val eventId = eventReplied.root.eventId ?: return null
|
||||||
val content = MessageTextContent(
|
val content = MessageTextContent(
|
||||||
type = MessageType.MSGTYPE_TEXT,
|
msgType = MessageType.MSGTYPE_TEXT,
|
||||||
format = MessageType.FORMAT_MATRIX_HTML,
|
format = MessageType.FORMAT_MATRIX_HTML,
|
||||||
body = replyFallback,
|
body = replyFallback,
|
||||||
formattedBody = replyFormatted,
|
formattedBody = replyFormatted,
|
||||||
|
@ -383,7 +384,7 @@ internal class LocalEchoEventFactory @Inject constructor(
|
||||||
* himself a reply, but it will contain the fallbacks, so we have to trim them.
|
* himself a reply, but it will contain the fallbacks, so we have to trim them.
|
||||||
*/
|
*/
|
||||||
private fun bodyForReply(content: MessageContent?, originalContent: MessageContent?): TextContent {
|
private fun bodyForReply(content: MessageContent?, originalContent: MessageContent?): TextContent {
|
||||||
when (content?.type) {
|
when (content?.msgType) {
|
||||||
MessageType.MSGTYPE_EMOTE,
|
MessageType.MSGTYPE_EMOTE,
|
||||||
MessageType.MSGTYPE_TEXT,
|
MessageType.MSGTYPE_TEXT,
|
||||||
MessageType.MSGTYPE_NOTICE -> {
|
MessageType.MSGTYPE_NOTICE -> {
|
||||||
|
|
|
@ -116,7 +116,7 @@ internal class LocalEchoRepository @Inject constructor(private val monarchy: Mon
|
||||||
EventType.REACTION -> {
|
EventType.REACTION -> {
|
||||||
val content = event.getClearContent().toModel<MessageContent>()
|
val content = event.getClearContent().toModel<MessageContent>()
|
||||||
if (content != null) {
|
if (content != null) {
|
||||||
when (content.type) {
|
when (content.msgType) {
|
||||||
MessageType.MSGTYPE_EMOTE,
|
MessageType.MSGTYPE_EMOTE,
|
||||||
MessageType.MSGTYPE_NOTICE,
|
MessageType.MSGTYPE_NOTICE,
|
||||||
MessageType.MSGTYPE_LOCATION,
|
MessageType.MSGTYPE_LOCATION,
|
||||||
|
@ -127,11 +127,11 @@ internal class LocalEchoRepository @Inject constructor(private val monarchy: Mon
|
||||||
MessageType.MSGTYPE_VIDEO,
|
MessageType.MSGTYPE_VIDEO,
|
||||||
MessageType.MSGTYPE_IMAGE,
|
MessageType.MSGTYPE_IMAGE,
|
||||||
MessageType.MSGTYPE_AUDIO -> {
|
MessageType.MSGTYPE_AUDIO -> {
|
||||||
// need to resend the attachement
|
// need to resend the attachment
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
Timber.e("Cannot resend message ${event.type} / ${content.type}")
|
Timber.e("Cannot resend message ${event.type} / ${content.msgType}")
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ data class TextContent(
|
||||||
|
|
||||||
fun TextContent.toMessageTextContent(msgType: String = MessageType.MSGTYPE_TEXT): MessageTextContent {
|
fun TextContent.toMessageTextContent(msgType: String = MessageType.MSGTYPE_TEXT): MessageTextContent {
|
||||||
return MessageTextContent(
|
return MessageTextContent(
|
||||||
type = msgType,
|
msgType = msgType,
|
||||||
format = MessageType.FORMAT_MATRIX_HTML.takeIf { formattedText != null },
|
format = MessageType.FORMAT_MATRIX_HTML.takeIf { formattedText != null },
|
||||||
body = text,
|
body = text,
|
||||||
formattedBody = formattedText
|
formattedBody = formattedText
|
||||||
|
|
|
@ -41,7 +41,7 @@ internal class CryptoSyncHandler @Inject constructor(private val cryptoService:
|
||||||
// Decrypt event if necessary
|
// Decrypt event if necessary
|
||||||
decryptEvent(event, null)
|
decryptEvent(event, null)
|
||||||
if (event.getClearType() == EventType.MESSAGE
|
if (event.getClearType() == EventType.MESSAGE
|
||||||
&& event.getClearContent()?.toModel<MessageContent>()?.type == "m.bad.encrypted") {
|
&& event.getClearContent()?.toModel<MessageContent>()?.msgType == "m.bad.encrypted") {
|
||||||
Timber.e("## handleToDeviceEvent() : Warning: Unable to decrypt to-device event : ${event.content}")
|
Timber.e("## handleToDeviceEvent() : Warning: Unable to decrypt to-device event : ${event.content}")
|
||||||
} else {
|
} else {
|
||||||
verificationService.onToDeviceEvent(event)
|
verificationService.onToDeviceEvent(event)
|
||||||
|
|
|
@ -480,7 +480,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
||||||
val existingBody = messageContent?.body ?: ""
|
val existingBody = messageContent?.body ?: ""
|
||||||
if (existingBody != action.text) {
|
if (existingBody != action.text) {
|
||||||
room.editTextMessage(state.sendMode.timelineEvent.root.eventId ?: "",
|
room.editTextMessage(state.sendMode.timelineEvent.root.eventId ?: "",
|
||||||
messageContent?.type ?: MessageType.MSGTYPE_TEXT,
|
messageContent?.msgType ?: MessageType.MSGTYPE_TEXT,
|
||||||
action.text,
|
action.text,
|
||||||
action.autoMarkdown)
|
action.autoMarkdown)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -203,7 +203,7 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted
|
||||||
private fun actionsForEvent(timelineEvent: TimelineEvent): List<EventSharedAction> {
|
private fun actionsForEvent(timelineEvent: TimelineEvent): List<EventSharedAction> {
|
||||||
val messageContent: MessageContent? = timelineEvent.annotations?.editSummary?.aggregatedContent.toModel()
|
val messageContent: MessageContent? = timelineEvent.annotations?.editSummary?.aggregatedContent.toModel()
|
||||||
?: timelineEvent.root.getClearContent().toModel()
|
?: timelineEvent.root.getClearContent().toModel()
|
||||||
val type = messageContent?.type
|
val msgType = messageContent?.msgType
|
||||||
|
|
||||||
return arrayListOf<EventSharedAction>().apply {
|
return arrayListOf<EventSharedAction>().apply {
|
||||||
if (timelineEvent.root.sendState.hasFailed()) {
|
if (timelineEvent.root.sendState.hasFailed()) {
|
||||||
|
@ -230,7 +230,7 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted
|
||||||
add(EventSharedAction.Delete(eventId))
|
add(EventSharedAction.Delete(eventId))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canCopy(type)) {
|
if (canCopy(msgType)) {
|
||||||
// TODO copy images? html? see ClipBoard
|
// TODO copy images? html? see ClipBoard
|
||||||
add(EventSharedAction.Copy(messageContent!!.body))
|
add(EventSharedAction.Copy(messageContent!!.body))
|
||||||
}
|
}
|
||||||
|
@ -251,7 +251,7 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted
|
||||||
add(EventSharedAction.ViewEditHistory(informationData))
|
add(EventSharedAction.ViewEditHistory(informationData))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canShare(type)) {
|
if (canShare(msgType)) {
|
||||||
if (messageContent is MessageImageContent) {
|
if (messageContent is MessageImageContent) {
|
||||||
session.contentUrlResolver().resolveFullSize(messageContent.url)?.let { url ->
|
session.contentUrlResolver().resolveFullSize(messageContent.url)?.let { url ->
|
||||||
add(EventSharedAction.Share(url))
|
add(EventSharedAction.Share(url))
|
||||||
|
@ -296,7 +296,7 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted
|
||||||
private fun canReply(event: TimelineEvent, messageContent: MessageContent?): Boolean {
|
private fun canReply(event: TimelineEvent, messageContent: MessageContent?): Boolean {
|
||||||
// Only event of type Event.EVENT_TYPE_MESSAGE are supported for the moment
|
// Only event of type Event.EVENT_TYPE_MESSAGE are supported for the moment
|
||||||
if (event.root.getClearType() != EventType.MESSAGE) return false
|
if (event.root.getClearType() != EventType.MESSAGE) return false
|
||||||
return when (messageContent?.type) {
|
return when (messageContent?.msgType) {
|
||||||
MessageType.MSGTYPE_TEXT,
|
MessageType.MSGTYPE_TEXT,
|
||||||
MessageType.MSGTYPE_NOTICE,
|
MessageType.MSGTYPE_NOTICE,
|
||||||
MessageType.MSGTYPE_EMOTE,
|
MessageType.MSGTYPE_EMOTE,
|
||||||
|
@ -311,7 +311,7 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted
|
||||||
private fun canQuote(event: TimelineEvent, messageContent: MessageContent?): Boolean {
|
private fun canQuote(event: TimelineEvent, messageContent: MessageContent?): Boolean {
|
||||||
// Only event of type Event.EVENT_TYPE_MESSAGE are supported for the moment
|
// Only event of type Event.EVENT_TYPE_MESSAGE are supported for the moment
|
||||||
if (event.root.getClearType() != EventType.MESSAGE) return false
|
if (event.root.getClearType() != EventType.MESSAGE) return false
|
||||||
return when (messageContent?.type) {
|
return when (messageContent?.msgType) {
|
||||||
MessageType.MSGTYPE_TEXT,
|
MessageType.MSGTYPE_TEXT,
|
||||||
MessageType.MSGTYPE_NOTICE,
|
MessageType.MSGTYPE_NOTICE,
|
||||||
MessageType.MSGTYPE_EMOTE,
|
MessageType.MSGTYPE_EMOTE,
|
||||||
|
@ -347,13 +347,13 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted
|
||||||
// TODO if user is admin or moderator
|
// TODO if user is admin or moderator
|
||||||
val messageContent = event.root.getClearContent().toModel<MessageContent>()
|
val messageContent = event.root.getClearContent().toModel<MessageContent>()
|
||||||
return event.root.senderId == myUserId && (
|
return event.root.senderId == myUserId && (
|
||||||
messageContent?.type == MessageType.MSGTYPE_TEXT
|
messageContent?.msgType == MessageType.MSGTYPE_TEXT
|
||||||
|| messageContent?.type == MessageType.MSGTYPE_EMOTE
|
|| messageContent?.msgType == MessageType.MSGTYPE_EMOTE
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun canCopy(type: String?): Boolean {
|
private fun canCopy(msgType: String?): Boolean {
|
||||||
return when (type) {
|
return when (msgType) {
|
||||||
MessageType.MSGTYPE_TEXT,
|
MessageType.MSGTYPE_TEXT,
|
||||||
MessageType.MSGTYPE_NOTICE,
|
MessageType.MSGTYPE_NOTICE,
|
||||||
MessageType.MSGTYPE_EMOTE,
|
MessageType.MSGTYPE_EMOTE,
|
||||||
|
@ -363,8 +363,8 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun canShare(type: String?): Boolean {
|
private fun canShare(msgType: String?): Boolean {
|
||||||
return when (type) {
|
return when (msgType) {
|
||||||
MessageType.MSGTYPE_IMAGE,
|
MessageType.MSGTYPE_IMAGE,
|
||||||
MessageType.MSGTYPE_AUDIO,
|
MessageType.MSGTYPE_AUDIO,
|
||||||
MessageType.MSGTYPE_VIDEO -> true
|
MessageType.MSGTYPE_VIDEO -> true
|
||||||
|
|
|
@ -229,7 +229,7 @@ class MessageItemFactory @Inject constructor(
|
||||||
informationData: MessageInformationData,
|
informationData: MessageInformationData,
|
||||||
highlight: Boolean,
|
highlight: Boolean,
|
||||||
callback: TimelineEventController.Callback?): DefaultItem? {
|
callback: TimelineEventController.Callback?): DefaultItem? {
|
||||||
val text = stringProvider.getString(R.string.rendering_event_error_type_of_message_not_handled, messageContent.type)
|
val text = stringProvider.getString(R.string.rendering_event_error_type_of_message_not_handled, messageContent.msgType)
|
||||||
return defaultItemFactory.create(text, informationData, highlight, callback)
|
return defaultItemFactory.create(text, informationData, highlight, callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,7 +258,7 @@ class MessageItemFactory @Inject constructor(
|
||||||
.highlighted(highlight)
|
.highlighted(highlight)
|
||||||
.mediaData(data)
|
.mediaData(data)
|
||||||
.apply {
|
.apply {
|
||||||
if (messageContent.type == MessageType.MSGTYPE_STICKER_LOCAL) {
|
if (messageContent.msgType == MessageType.MSGTYPE_STICKER_LOCAL) {
|
||||||
mode(ImageContentRenderer.Mode.STICKER)
|
mode(ImageContentRenderer.Mode.STICKER)
|
||||||
} else {
|
} else {
|
||||||
clickListener(
|
clickListener(
|
||||||
|
|
|
@ -46,7 +46,7 @@ class DisplayableEventFormatter @Inject constructor(
|
||||||
when (timelineEvent.root.getClearType()) {
|
when (timelineEvent.root.getClearType()) {
|
||||||
EventType.MESSAGE -> {
|
EventType.MESSAGE -> {
|
||||||
timelineEvent.getLastMessageContent()?.let { messageContent ->
|
timelineEvent.getLastMessageContent()?.let { messageContent ->
|
||||||
when (messageContent.type) {
|
when (messageContent.msgType) {
|
||||||
MessageType.MSGTYPE_VERIFICATION_REQUEST -> {
|
MessageType.MSGTYPE_VERIFICATION_REQUEST -> {
|
||||||
return simpleFormat(senderName, stringProvider.getString(R.string.verification_request), appendAuthor)
|
return simpleFormat(senderName, stringProvider.getString(R.string.verification_request), appendAuthor)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue