From 2144bb9d496636b864737fe2ff0a774d79467014 Mon Sep 17 00:00:00 2001 From: ganfra Date: Thu, 9 Sep 2021 18:25:20 +0200 Subject: [PATCH 1/2] Timeline: remove reaction animation views for now --- .../reactions/widget/ReactionButton.kt | 215 +----------------- .../src/main/res/layout/reaction_button.xml | 31 +-- 2 files changed, 11 insertions(+), 235 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/reactions/widget/ReactionButton.kt b/vector/src/main/java/im/vector/app/features/reactions/widget/ReactionButton.kt index d81767cc7f..0f6f1620a8 100644 --- a/vector/src/main/java/im/vector/app/features/reactions/widget/ReactionButton.kt +++ b/vector/src/main/java/im/vector/app/features/reactions/widget/ReactionButton.kt @@ -15,27 +15,18 @@ */ package im.vector.app.features.reactions.widget -import android.animation.Animator -import android.animation.AnimatorListenerAdapter -import android.animation.AnimatorSet -import android.animation.ObjectAnimator import android.content.Context -import android.content.res.TypedArray import android.graphics.drawable.Drawable import android.util.AttributeSet +import android.view.Gravity import android.view.View -import android.view.animation.AccelerateDecelerateInterpolator -import android.view.animation.DecelerateInterpolator -import android.view.animation.OvershootInterpolator -import android.widget.ImageView -import androidx.annotation.ColorInt -import androidx.annotation.ColorRes -import androidx.constraintlayout.widget.ConstraintLayout +import android.widget.LinearLayout import androidx.core.content.ContextCompat import androidx.core.content.withStyledAttributes import im.vector.app.EmojiCompatWrapper import im.vector.app.R import im.vector.app.core.di.HasScreenInjector +import im.vector.app.core.utils.DimensionConverter import im.vector.app.core.utils.TextUtils import im.vector.app.databinding.ReactionButtonBinding import javax.inject.Inject @@ -47,7 +38,7 @@ import javax.inject.Inject class ReactionButton @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) - : ConstraintLayout(context, attrs, defStyleAttr), View.OnClickListener, View.OnLongClickListener { + : LinearLayout(context, attrs, defStyleAttr), View.OnClickListener, View.OnLongClickListener { init { if (context is HasScreenInjector) { @@ -55,21 +46,11 @@ class ReactionButton @JvmOverloads constructor(context: Context, } } - companion object { - private val DECCELERATE_INTERPOLATOR = DecelerateInterpolator() - private val ACCELERATE_DECELERATE_INTERPOLATOR = AccelerateDecelerateInterpolator() - private val OVERSHOOT_INTERPOLATOR = OvershootInterpolator(4f) - } - @Inject lateinit var emojiCompatWrapper: EmojiCompatWrapper private val views: ReactionButtonBinding var reactedListener: ReactedListener? = null - private var dotPrimaryColor: Int = 0 - private var dotSecondaryColor: Int = 0 - private var circleStartColor: Int = 0 - private var circleEndColor: Int = 0 var reactionCount = 11 set(value) { @@ -85,50 +66,24 @@ class ReactionButton @JvmOverloads constructor(context: Context, views.reactionText.text = emojiSpanned } - private var animationScaleFactor: Float = 0.toFloat() - private var isChecked: Boolean = false - - private var animatorSet: AnimatorSet? = null - private var onDrawable: Drawable? = null private var offDrawable: Drawable? = null init { inflate(context, R.layout.reaction_button, this) + orientation = HORIZONTAL + minimumHeight = DimensionConverter(context.resources).dpToPx(30) + gravity = Gravity.CENTER views = ReactionButtonBinding.bind(this) views.reactionCount.text = TextUtils.formatCountToShortDecimal(reactionCount) - -// emojiView?.typeface = this.emojiTypeFace ?: Typeface.DEFAULT context.withStyledAttributes(attrs, R.styleable.ReactionButton, defStyleAttr) { onDrawable = ContextCompat.getDrawable(context, R.drawable.reaction_rounded_rect_shape) offDrawable = ContextCompat.getDrawable(context, R.drawable.reaction_rounded_rect_shape_off) - - circleStartColor = getColor(R.styleable.ReactionButton_circle_start_color, 0) - - if (circleStartColor != 0) { - views.circle.startColor = circleStartColor - } - - circleEndColor = getColor(R.styleable.ReactionButton_circle_end_color, 0) - - if (circleEndColor != 0) { - views.circle.endColor = circleEndColor - } - - dotPrimaryColor = getColor(R.styleable.ReactionButton_dots_primary_color, 0) - dotSecondaryColor = getColor(R.styleable.ReactionButton_dots_secondary_color, 0) - - if (dotPrimaryColor != 0 && dotSecondaryColor != 0) { - views.dots.setColors(dotPrimaryColor, dotSecondaryColor) - } - getString(R.styleable.ReactionButton_emoji)?.let { reactionString = it } - reactionCount = getInt(R.styleable.ReactionButton_reaction_count, 0) - val status = getBoolean(R.styleable.ReactionButton_toggled, false) setChecked(status) } @@ -137,12 +92,6 @@ class ReactionButton @JvmOverloads constructor(context: Context, setOnLongClickListener(this) } - private fun getDrawableFromResource(array: TypedArray, styleableIndexId: Int): Drawable? { - val id = array.getResourceId(styleableIndexId, -1) - - return if (-1 != id) ContextCompat.getDrawable(context, id) else null - } - /** * This triggers the entire functionality of the button such as icon changes, * animations, listeners etc. @@ -153,164 +102,25 @@ class ReactionButton @JvmOverloads constructor(context: Context, if (!isEnabled) { return } - isChecked = !isChecked - // icon!!.setImageDrawable(if (isChecked) likeDrawable else unLikeDrawable) background = if (isChecked) onDrawable else offDrawable if (isChecked) { reactedListener?.onReacted(this) - } else { - reactedListener?.onUnReacted(this) - } - - if (animatorSet != null) { - animatorSet!!.cancel() - } - - if (isChecked) { views.reactionText.animate().cancel() views.reactionText.scaleX = 0f views.reactionText.scaleY = 0f - - views.circle.innerCircleRadiusProgress = 0f - views.circle.outerCircleRadiusProgress = 0f - views.dots.currentProgress = 0f - - animatorSet = AnimatorSet() - - val outerCircleAnimator = ObjectAnimator.ofFloat(views.circle, CircleView.OUTER_CIRCLE_RADIUS_PROGRESS, 0.1f, 1f) - outerCircleAnimator.duration = 250 - outerCircleAnimator.interpolator = DECCELERATE_INTERPOLATOR - - val innerCircleAnimator = ObjectAnimator.ofFloat(views.circle, CircleView.INNER_CIRCLE_RADIUS_PROGRESS, 0.1f, 1f) - innerCircleAnimator.duration = 200 - innerCircleAnimator.startDelay = 200 - innerCircleAnimator.interpolator = DECCELERATE_INTERPOLATOR - - val starScaleYAnimator = ObjectAnimator.ofFloat(views.reactionText, ImageView.SCALE_Y, 0.2f, 1f) - starScaleYAnimator.duration = 350 - starScaleYAnimator.startDelay = 250 - starScaleYAnimator.interpolator = OVERSHOOT_INTERPOLATOR - - val starScaleXAnimator = ObjectAnimator.ofFloat(views.reactionText, ImageView.SCALE_X, 0.2f, 1f) - starScaleXAnimator.duration = 350 - starScaleXAnimator.startDelay = 250 - starScaleXAnimator.interpolator = OVERSHOOT_INTERPOLATOR - - val dotsAnimator = ObjectAnimator.ofFloat(views.dots, DotsView.DOTS_PROGRESS, 0f, 1f) - // .ofFloat(views.dots, DotsView.DOTS_PROGRESS, 0, 1f) - dotsAnimator.duration = 900 - dotsAnimator.startDelay = 50 - dotsAnimator.interpolator = ACCELERATE_DECELERATE_INTERPOLATOR - - animatorSet!!.playTogether( - outerCircleAnimator, - innerCircleAnimator, - starScaleYAnimator, - starScaleXAnimator, - dotsAnimator - ) - - animatorSet!!.addListener(object : AnimatorListenerAdapter() { - override fun onAnimationCancel(animation: Animator) { - views.circle.innerCircleRadiusProgress = 0f - views.circle.outerCircleRadiusProgress = 0f - views.dots.currentProgress = 0f - views.reactionText.scaleX = 1f - views.reactionText.scaleY = 1f - } - - override fun onAnimationEnd(animation: Animator) { -// if (animationEndListener != null) { -// // animationEndListener!!.onAnimationEnd(this@ReactionButton) -// } - } - }) - - animatorSet!!.start() + } else { + reactedListener?.onUnReacted(this) } } - /** - * Used to trigger the scale animation that takes places on the - * icon when the button is touched. - * - * @param event - * @return - */ -// override fun onTouchEvent(event: MotionEvent): Boolean { -// if (!isEnabled) -// return true -// -// when (event.action) { -// MotionEvent.ACTION_DOWN -> -// /* -// Commented out this line and moved the animation effect to the action up event due to -// conflicts that were occurring when library is used in sliding type views. -// -// icon.animate().scaleX(0.7f).scaleY(0.7f).setDuration(150).setInterpolator(DECCELERATE_INTERPOLATOR); -// */ -// isPressed = true -// -// MotionEvent.ACTION_MOVE -> { -// val x = event.x -// val y = event.y -// val isInside = x > 0 && x < width && y > 0 && y < height -// if (isPressed != isInside) { -// isPressed = isInside -// } -// } -// -// MotionEvent.ACTION_UP -> { -// views.reactionText!!.animate().scaleX(0.7f).scaleY(0.7f).setDuration(150).interpolator = DECCELERATE_INTERPOLATOR -// views.reactionText!!.animate().scaleX(1f).scaleY(1f).interpolator = DECCELERATE_INTERPOLATOR -// if (isPressed) { -// performClick() -// isPressed = false -// } -// } -// MotionEvent.ACTION_CANCEL -> isPressed = false -// } -// return true -// } - override fun onLongClick(v: View?): Boolean { reactedListener?.onLongClick(this) return reactedListener != null } - /** - * This set sets the colours that are used for the little dots - * that will be exploding once the like button is clicked. - * - * @param primaryColor - * @param secondaryColor - */ - fun setExplodingDotColorsRes(@ColorRes primaryColor: Int, @ColorRes secondaryColor: Int) { - views.dots.setColors(ContextCompat.getColor(context, primaryColor), ContextCompat.getColor(context, secondaryColor)) - } - - fun setExplodingDotColorsInt(@ColorInt primaryColor: Int, @ColorInt secondaryColor: Int) { - views.dots.setColors(primaryColor, secondaryColor) - } - - fun setCircleStartColorRes(@ColorRes circleStartColor: Int) { - this.circleStartColor = ContextCompat.getColor(context, circleStartColor) - views.circle.startColor = this.circleStartColor - } - - fun setCircleStartColorInt(@ColorInt circleStartColor: Int) { - this.circleStartColor = circleStartColor - views.circle.startColor = circleStartColor - } - - fun setCircleEndColorRes(@ColorRes circleEndColor: Int) { - this.circleEndColor = ContextCompat.getColor(context, circleEndColor) - views.circle.endColor = this.circleEndColor - } - /** * Sets the initial state of the button to liked * or unliked. @@ -327,13 +137,6 @@ class ReactionButton @JvmOverloads constructor(context: Context, } } - /** - * Sets the factor by which the dots should be sized. - */ - fun setAnimationScaleFactor(animationScaleFactor: Float) { - this.animationScaleFactor = animationScaleFactor - } - interface ReactedListener { fun onReacted(reactionButton: ReactionButton) fun onUnReacted(reactionButton: ReactionButton) diff --git a/vector/src/main/res/layout/reaction_button.xml b/vector/src/main/res/layout/reaction_button.xml index f31e86ed96..e30c6df60a 100644 --- a/vector/src/main/res/layout/reaction_button.xml +++ b/vector/src/main/res/layout/reaction_button.xml @@ -7,7 +7,8 @@ android:background="@drawable/reaction_rounded_rect_shape" android:clipChildren="false" android:minWidth="44dp" - tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout"> + android:gravity="center" + tools:parentTag="android.widget.LinearLayout"> @@ -15,25 +16,6 @@ - - - - From f96485c4934074531ffd2120c63517ea32740aa2 Mon Sep 17 00:00:00 2001 From: ganfra Date: Thu, 9 Sep 2021 19:06:09 +0200 Subject: [PATCH 2/2] Timeline: use json directly to be a bit more speedy (those methods are called a lot) --- .../android/sdk/api/session/events/model/Event.kt | 12 ++++++------ .../room/model/message/MessageAudioContent.kt | 2 +- .../api/session/room/model/message/MessageContent.kt | 5 +++++ .../room/model/message/MessageDefaultContent.kt | 2 +- .../room/model/message/MessageEmoteContent.kt | 2 +- .../session/room/model/message/MessageFileContent.kt | 2 +- .../room/model/message/MessageImageContent.kt | 2 +- .../room/model/message/MessageLocationContent.kt | 2 +- .../room/model/message/MessageNoticeContent.kt | 2 +- .../room/model/message/MessageOptionsContent.kt | 2 +- .../room/model/message/MessagePollResponseContent.kt | 2 +- .../session/room/model/message/MessageTextContent.kt | 2 +- .../message/MessageVerificationRequestContent.kt | 2 +- .../room/model/message/MessageVideoContent.kt | 2 +- 14 files changed, 23 insertions(+), 18 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/events/model/Event.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/events/model/Event.kt index 3d82846e7e..1f8471c111 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/events/model/Event.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/events/model/Event.kt @@ -239,7 +239,7 @@ data class Event( fun Event.isTextMessage(): Boolean { return getClearType() == EventType.MESSAGE - && when (getClearContent()?.toModel()?.msgType) { + && when (getClearContent()?.get(MessageContent.MSG_TYPE_JSON_KEY)) { MessageType.MSGTYPE_TEXT, MessageType.MSGTYPE_EMOTE, MessageType.MSGTYPE_NOTICE -> true @@ -249,7 +249,7 @@ fun Event.isTextMessage(): Boolean { fun Event.isImageMessage(): Boolean { return getClearType() == EventType.MESSAGE - && when (getClearContent()?.toModel()?.msgType) { + && when (getClearContent()?.get(MessageContent.MSG_TYPE_JSON_KEY)) { MessageType.MSGTYPE_IMAGE -> true else -> false } @@ -257,7 +257,7 @@ fun Event.isImageMessage(): Boolean { fun Event.isVideoMessage(): Boolean { return getClearType() == EventType.MESSAGE - && when (getClearContent()?.toModel()?.msgType) { + && when (getClearContent()?.get(MessageContent.MSG_TYPE_JSON_KEY)) { MessageType.MSGTYPE_VIDEO -> true else -> false } @@ -265,7 +265,7 @@ fun Event.isVideoMessage(): Boolean { fun Event.isAudioMessage(): Boolean { return getClearType() == EventType.MESSAGE - && when (getClearContent()?.toModel()?.msgType) { + && when (getClearContent()?.get(MessageContent.MSG_TYPE_JSON_KEY)) { MessageType.MSGTYPE_AUDIO -> true else -> false } @@ -273,7 +273,7 @@ fun Event.isAudioMessage(): Boolean { fun Event.isFileMessage(): Boolean { return getClearType() == EventType.MESSAGE - && when (getClearContent()?.toModel()?.msgType) { + && when (getClearContent()?.get(MessageContent.MSG_TYPE_JSON_KEY)) { MessageType.MSGTYPE_FILE -> true else -> false } @@ -281,7 +281,7 @@ fun Event.isFileMessage(): Boolean { fun Event.isAttachmentMessage(): Boolean { return getClearType() == EventType.MESSAGE - && when (getClearContent()?.toModel()?.msgType) { + && when (getClearContent()?.get(MessageContent.MSG_TYPE_JSON_KEY)) { MessageType.MSGTYPE_IMAGE, MessageType.MSGTYPE_AUDIO, MessageType.MSGTYPE_VIDEO, diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageAudioContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageAudioContent.kt index 1bcb10d88c..ebf3d127ce 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageAudioContent.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageAudioContent.kt @@ -28,7 +28,7 @@ data class MessageAudioContent( /** * Required. Must be 'm.audio'. */ - @Json(name = "msgtype") override val msgType: String, + @Json(name = MessageContent.MSG_TYPE_JSON_KEY) 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'. diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageContent.kt index df5641a622..5a1b66c91c 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageContent.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageContent.kt @@ -20,6 +20,11 @@ import org.matrix.android.sdk.api.session.events.model.Content import org.matrix.android.sdk.api.session.room.model.relation.RelationDefaultContent interface MessageContent { + + companion object { + const val MSG_TYPE_JSON_KEY = "msgtype" + } + val msgType: String val body: String val relatesTo: RelationDefaultContent? diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageDefaultContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageDefaultContent.kt index 65e89cdfee..1dadc92271 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageDefaultContent.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageDefaultContent.kt @@ -23,7 +23,7 @@ import org.matrix.android.sdk.api.session.room.model.relation.RelationDefaultCon @JsonClass(generateAdapter = true) data class MessageDefaultContent( - @Json(name = "msgtype") override val msgType: String, + @Json(name = MessageContent.MSG_TYPE_JSON_KEY) override val msgType: String, @Json(name = "body") override val body: String, @Json(name = "m.relates_to") override val relatesTo: RelationDefaultContent? = null, @Json(name = "m.new_content") override val newContent: Content? = null diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageEmoteContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageEmoteContent.kt index 77983a031e..a2ada416ba 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageEmoteContent.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageEmoteContent.kt @@ -26,7 +26,7 @@ data class MessageEmoteContent( /** * Required. Must be 'm.emote'. */ - @Json(name = "msgtype") override val msgType: String, + @Json(name = MessageContent.MSG_TYPE_JSON_KEY) override val msgType: String, /** * Required. The emote action to perform. diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageFileContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageFileContent.kt index 96877b4d9f..78f9a5d2f2 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageFileContent.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageFileContent.kt @@ -28,7 +28,7 @@ data class MessageFileContent( /** * Required. Must be 'm.file'. */ - @Json(name = "msgtype") override val msgType: String, + @Json(name = MessageContent.MSG_TYPE_JSON_KEY) override val msgType: String, /** * Required. A human-readable description of the file. This is recommended to be the filename of the original upload. diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageImageContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageImageContent.kt index 73fd1eab56..ea7ab50688 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageImageContent.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageImageContent.kt @@ -27,7 +27,7 @@ data class MessageImageContent( /** * Required. Must be 'm.image'. */ - @Json(name = "msgtype") override val msgType: String, + @Json(name = MessageContent.MSG_TYPE_JSON_KEY) 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, diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageLocationContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageLocationContent.kt index bdb54910dd..6881c09924 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageLocationContent.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageLocationContent.kt @@ -26,7 +26,7 @@ data class MessageLocationContent( /** * Required. Must be 'm.location'. */ - @Json(name = "msgtype") override val msgType: String, + @Json(name = MessageContent.MSG_TYPE_JSON_KEY) override val msgType: String, /** * Required. A description of the location e.g. 'Big Ben, London, UK', or some kind diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageNoticeContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageNoticeContent.kt index b2fd8cb0c0..dd960355ca 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageNoticeContent.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageNoticeContent.kt @@ -26,7 +26,7 @@ data class MessageNoticeContent( /** * Required. Must be 'm.notice'. */ - @Json(name = "msgtype") override val msgType: String, + @Json(name = MessageContent.MSG_TYPE_JSON_KEY) override val msgType: String, /** * Required. The notice text to send. diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageOptionsContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageOptionsContent.kt index 7924469884..7a1a99bd5f 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageOptionsContent.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageOptionsContent.kt @@ -30,7 +30,7 @@ const val OPTION_TYPE_BUTTONS = "org.matrix.buttons" */ @JsonClass(generateAdapter = true) data class MessageOptionsContent( - @Json(name = "msgtype") override val msgType: String = MessageType.MSGTYPE_OPTIONS, + @Json(name = MessageContent.MSG_TYPE_JSON_KEY) override val msgType: String = MessageType.MSGTYPE_OPTIONS, @Json(name = "type") val optionType: String? = null, @Json(name = "body") override val body: String, @Json(name = "label") val label: String?, diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessagePollResponseContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessagePollResponseContent.kt index d827475277..9edfe118b0 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessagePollResponseContent.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessagePollResponseContent.kt @@ -26,7 +26,7 @@ import org.matrix.android.sdk.api.session.room.model.relation.RelationDefaultCon */ @JsonClass(generateAdapter = true) data class MessagePollResponseContent( - @Json(name = "msgtype") override val msgType: String = MessageType.MSGTYPE_RESPONSE, + @Json(name = MessageContent.MSG_TYPE_JSON_KEY) override val msgType: String = MessageType.MSGTYPE_RESPONSE, @Json(name = "body") override val body: String, @Json(name = "m.relates_to") override val relatesTo: RelationDefaultContent? = null, @Json(name = "m.new_content") override val newContent: Content? = null diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageTextContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageTextContent.kt index e45245a9bf..5968fecd43 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageTextContent.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageTextContent.kt @@ -26,7 +26,7 @@ data class MessageTextContent( /** * Required. Must be 'm.text'. */ - @Json(name = "msgtype") override val msgType: String, + @Json(name = MessageContent.MSG_TYPE_JSON_KEY) override val msgType: String, /** * Required. The body of the message. diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageVerificationRequestContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageVerificationRequestContent.kt index 25b5f44815..b2b3cdac90 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageVerificationRequestContent.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageVerificationRequestContent.kt @@ -24,7 +24,7 @@ import org.matrix.android.sdk.internal.crypto.verification.VerificationInfoReque @JsonClass(generateAdapter = true) data class MessageVerificationRequestContent( - @Json(name = "msgtype") override val msgType: String = MessageType.MSGTYPE_VERIFICATION_REQUEST, + @Json(name = MessageContent.MSG_TYPE_JSON_KEY)override val msgType: String = MessageType.MSGTYPE_VERIFICATION_REQUEST, @Json(name = "body") override val body: String, @Json(name = "from_device") override val fromDevice: String?, @Json(name = "methods") override val methods: List, diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageVideoContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageVideoContent.kt index 3f5d2dab2e..e1b0cd8607 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageVideoContent.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageVideoContent.kt @@ -27,7 +27,7 @@ data class MessageVideoContent( /** * Required. Must be 'm.video'. */ - @Json(name = "msgtype") override val msgType: String, + @Json(name = MessageContent.MSG_TYPE_JSON_KEY)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'.