From e82e79d7e2874cb378daea2e7144c164331e3a86 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Fri, 29 Apr 2022 14:21:44 +0200 Subject: [PATCH] Fixing code quality issues --- .../model/message/MessageBeaconInfoContent.kt | 4 -- .../EventRelationsAggregationProcessor.kt | 2 +- .../room/send/LocalEchoEventFactory.kt | 48 ++++++++++++------- .../timeline/factory/MessageItemFactory.kt | 2 +- 4 files changed, 34 insertions(+), 22 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageBeaconInfoContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageBeaconInfoContent.kt index 8327a4e10e..82101e76f2 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageBeaconInfoContent.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/message/MessageBeaconInfoContent.kt @@ -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) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/EventRelationsAggregationProcessor.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/EventRelationsAggregationProcessor.kt index 8f3020aeb4..62f7282e44 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/EventRelationsAggregationProcessor.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/EventRelationsAggregationProcessor.kt @@ -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 diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/LocalEchoEventFactory.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/LocalEchoEventFactory.kt index c9b2230d84..deddbe9b36 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/LocalEchoEventFactory.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/LocalEchoEventFactory.kt @@ -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 + ) } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt index 02cbdf7151..e4522b260e 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt @@ -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