Fixing code quality issues

This commit is contained in:
Maxime NATUREL 2022-04-29 14:21:44 +02:00
parent e8556ec830
commit e82e79d7e2
4 changed files with 34 additions and 22 deletions

View File

@ -19,10 +19,6 @@ package org.matrix.android.sdk.api.session.room.model.message
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import org.matrix.android.sdk.api.session.events.model.Content
import org.matrix.android.sdk.api.session.room.model.message.LocationAsset
import org.matrix.android.sdk.api.session.room.model.message.LocationAssetType
import org.matrix.android.sdk.api.session.room.model.message.MessageContent
import org.matrix.android.sdk.api.session.room.model.message.MessageType
import org.matrix.android.sdk.api.session.room.model.relation.RelationDefaultContent
@JsonClass(generateAdapter = true)

View File

@ -34,9 +34,9 @@ import org.matrix.android.sdk.api.session.room.model.ReferencesAggregatedContent
import org.matrix.android.sdk.api.session.room.model.VoteInfo
import org.matrix.android.sdk.api.session.room.model.VoteSummary
import org.matrix.android.sdk.api.session.room.model.message.MessageBeaconInfoContent
import org.matrix.android.sdk.api.session.room.model.message.MessageBeaconLocationDataContent
import org.matrix.android.sdk.api.session.room.model.message.MessageContent
import org.matrix.android.sdk.api.session.room.model.message.MessageEndPollContent
import org.matrix.android.sdk.api.session.room.model.message.MessageBeaconLocationDataContent
import org.matrix.android.sdk.api.session.room.model.message.MessagePollContent
import org.matrix.android.sdk.api.session.room.model.message.MessagePollResponseContent
import org.matrix.android.sdk.api.session.room.model.message.MessageRelationContent

View File

@ -37,13 +37,13 @@ import org.matrix.android.sdk.api.session.room.model.message.LocationAsset
import org.matrix.android.sdk.api.session.room.model.message.LocationAssetType
import org.matrix.android.sdk.api.session.room.model.message.LocationInfo
import org.matrix.android.sdk.api.session.room.model.message.MessageAudioContent
import org.matrix.android.sdk.api.session.room.model.message.MessageBeaconLocationDataContent
import org.matrix.android.sdk.api.session.room.model.message.MessageContent
import org.matrix.android.sdk.api.session.room.model.message.MessageContentWithFormattedBody
import org.matrix.android.sdk.api.session.room.model.message.MessageEndPollContent
import org.matrix.android.sdk.api.session.room.model.message.MessageFileContent
import org.matrix.android.sdk.api.session.room.model.message.MessageFormat
import org.matrix.android.sdk.api.session.room.model.message.MessageImageContent
import org.matrix.android.sdk.api.session.room.model.message.MessageBeaconLocationDataContent
import org.matrix.android.sdk.api.session.room.model.message.MessageLocationContent
import org.matrix.android.sdk.api.session.room.model.message.MessagePollContent
import org.matrix.android.sdk.api.session.room.model.message.MessagePollResponseContent
@ -123,7 +123,8 @@ internal class LocalEchoEventFactory @Inject constructor(
newBodyAutoMarkdown: Boolean,
msgType: String,
compatibilityText: String): Event {
return createMessageEvent(roomId,
return createMessageEvent(
roomId,
MessageTextContent(
msgType = msgType,
body = compatibilityText,
@ -131,7 +132,8 @@ internal class LocalEchoEventFactory @Inject constructor(
newContent = createTextContent(newBodyText, newBodyAutoMarkdown)
.toMessageTextContent(msgType)
.toContent()
))
)
)
}
private fun createPollContent(question: String,
@ -187,7 +189,8 @@ internal class LocalEchoEventFactory @Inject constructor(
eventId = localId,
type = EventType.POLL_RESPONSE.first(),
content = content.toContent(),
unsignedData = UnsignedData(age = null, transactionId = localId))
unsignedData = UnsignedData(age = null, transactionId = localId)
)
}
fun createPollEvent(roomId: String,
@ -203,7 +206,8 @@ internal class LocalEchoEventFactory @Inject constructor(
eventId = localId,
type = EventType.POLL_START.first(),
content = content.toContent(),
unsignedData = UnsignedData(age = null, transactionId = localId))
unsignedData = UnsignedData(age = null, transactionId = localId)
)
}
fun createEndPollEvent(roomId: String,
@ -222,7 +226,8 @@ internal class LocalEchoEventFactory @Inject constructor(
eventId = localId,
type = EventType.POLL_END.first(),
content = content.toContent(),
unsignedData = UnsignedData(age = null, transactionId = localId))
unsignedData = UnsignedData(age = null, transactionId = localId)
)
}
fun createLocationEvent(roomId: String,
@ -266,7 +271,8 @@ internal class LocalEchoEventFactory @Inject constructor(
eventId = localId,
type = EventType.BEACON_LOCATION_DATA.first(),
content = content.toContent(),
unsignedData = UnsignedData(age = null, transactionId = localId))
unsignedData = UnsignedData(age = null, transactionId = localId)
)
}
fun createReplaceTextOfReply(roomId: String,
@ -296,7 +302,8 @@ internal class LocalEchoEventFactory @Inject constructor(
//
val replyFallback = buildReplyFallback(body, originalEvent.root.senderId ?: "", newBodyText)
return createMessageEvent(roomId,
return createMessageEvent(
roomId,
MessageTextContent(
msgType = msgType,
body = compatibilityText,
@ -308,7 +315,8 @@ internal class LocalEchoEventFactory @Inject constructor(
formattedBody = replyFormatted
)
.toContent()
))
)
)
}
fun createMediaEvent(roomId: String,
@ -340,7 +348,8 @@ internal class LocalEchoEventFactory @Inject constructor(
eventId = localId,
type = EventType.REACTION,
content = content.toContent(),
unsignedData = UnsignedData(age = null, transactionId = localId))
unsignedData = UnsignedData(age = null, transactionId = localId)
)
}
private fun createImageEvent(roomId: String, attachment: ContentAttachmentData, rootThreadEventId: String?): Event {
@ -531,8 +540,10 @@ internal class LocalEchoEventFactory @Inject constructor(
content.toThreadTextContent(
rootThreadEventId = rootThreadEventId,
latestThreadEventId = localEchoRepository.getLatestThreadEvent(rootThreadEventId),
msgType = msgType)
.toContent())
msgType = msgType
)
.toContent()
)
}
private fun dummyOriginServerTs(): Long {
@ -581,7 +592,9 @@ internal class LocalEchoEventFactory @Inject constructor(
relatesTo = generateReplyRelationContent(
eventId = eventId,
rootThreadEventId = rootThreadEventId,
showInThread = showInThread))
showInThread = showInThread
)
)
return createMessageEvent(roomId, content)
}
@ -604,7 +617,8 @@ internal class LocalEchoEventFactory @Inject constructor(
eventId = it,
isFallingBack = showInThread,
// False when is a rich reply from within a thread, and true when is a reply that should be visible from threads
inReplyTo = ReplyToContent(eventId = eventId))
inReplyTo = ReplyToContent(eventId = eventId)
)
} ?: RelationDefaultContent(null, null, ReplyToContent(eventId = eventId))
private fun buildFormattedReply(permalink: String, userLink: String, userId: String, bodyFormatted: String, newBodyFormatted: String): String {
@ -739,13 +753,15 @@ internal class LocalEchoEventFactory @Inject constructor(
.toThreadTextContent(
rootThreadEventId = rootThreadEventId,
latestThreadEventId = localEchoRepository.getLatestThreadEvent(rootThreadEventId),
msgType = MessageType.MSGTYPE_TEXT)
msgType = MessageType.MSGTYPE_TEXT
)
)
} else {
createFormattedTextEvent(
roomId,
markdownParser.parse(quoteText, force = true, advanced = autoMarkdown),
MessageType.MSGTYPE_TEXT)
MessageType.MSGTYPE_TEXT
)
}
}

View File

@ -98,8 +98,8 @@ import org.matrix.android.sdk.api.session.events.model.RelationType
import org.matrix.android.sdk.api.session.events.model.content.EncryptedEventContent
import org.matrix.android.sdk.api.session.events.model.isThread
import org.matrix.android.sdk.api.session.events.model.toModel
import org.matrix.android.sdk.api.session.room.model.message.MessageBeaconInfoContent
import org.matrix.android.sdk.api.session.room.model.message.MessageAudioContent
import org.matrix.android.sdk.api.session.room.model.message.MessageBeaconInfoContent
import org.matrix.android.sdk.api.session.room.model.message.MessageContent
import org.matrix.android.sdk.api.session.room.model.message.MessageContentWithFormattedBody
import org.matrix.android.sdk.api.session.room.model.message.MessageEmoteContent