From 015438289e25cf540342bebf6d2d63d47f9339ba Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 13 Apr 2022 19:25:08 +0200 Subject: [PATCH] Immutable data class. var -> val --- .../auth/data/LocalizedFlowDataLoginTerms.kt | 8 +++--- .../session/crypto/model/CryptoDeviceInfo.kt | 4 +-- .../crypto/model/OutgoingRoomKeyRequest.kt | 16 +++++------ .../room/model/EventAnnotationsSummary.kt | 10 +++---- .../model/PollResponseAggregatedSummary.kt | 8 +++--- .../session/room/timeline/TimelineEvent.kt | 2 +- .../securestorage/SsssKeyCreationInfo.kt | 2 +- .../sdk/api/session/threads/ThreadDetails.kt | 2 +- .../crypto/OutgoingGossipingRequest.kt | 6 ++--- .../session/profile/BindThreePidBody.kt | 6 ++--- .../app/features/login/terms/converter.kt | 27 ++++++++++++------- 11 files changed, 46 insertions(+), 45 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/auth/data/LocalizedFlowDataLoginTerms.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/auth/data/LocalizedFlowDataLoginTerms.kt index 863abf7f51..1e844a1d94 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/auth/data/LocalizedFlowDataLoginTerms.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/auth/data/LocalizedFlowDataLoginTerms.kt @@ -24,8 +24,8 @@ import kotlinx.parcelize.Parcelize */ @Parcelize data class LocalizedFlowDataLoginTerms( - var policyName: String? = null, - var version: String? = null, - var localizedUrl: String? = null, - var localizedName: String? = null + val policyName: String?, + val version: String?, + val localizedUrl: String?, + val localizedName: String? ) : Parcelable diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/crypto/model/CryptoDeviceInfo.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/crypto/model/CryptoDeviceInfo.kt index 3fa8c31cf5..418b1e6ce3 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/crypto/model/CryptoDeviceInfo.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/crypto/model/CryptoDeviceInfo.kt @@ -22,12 +22,12 @@ import org.matrix.android.sdk.internal.crypto.model.CryptoInfo data class CryptoDeviceInfo( val deviceId: String, override val userId: String, - var algorithms: List? = null, + val algorithms: List? = null, override val keys: Map? = null, override val signatures: Map>? = null, val unsigned: UnsignedDeviceInfo? = null, var trustLevel: DeviceTrustLevel? = null, - var isBlocked: Boolean = false, + val isBlocked: Boolean = false, val firstTimeSeenLocalTs: Long? = null ) : CryptoInfo { diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/crypto/model/OutgoingRoomKeyRequest.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/crypto/model/OutgoingRoomKeyRequest.kt index f0a4b24c5f..5f35cc908f 100755 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/crypto/model/OutgoingRoomKeyRequest.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/crypto/model/OutgoingRoomKeyRequest.kt @@ -25,14 +25,14 @@ import org.matrix.android.sdk.internal.crypto.OutgoingGossipingRequest @JsonClass(generateAdapter = true) data class OutgoingRoomKeyRequest( // RequestBody - var requestBody: RoomKeyRequestBody?, + val requestBody: RoomKeyRequestBody?, // list of recipients for the request - override var recipients: Map>, + override val recipients: Map>, // Unique id for this request. Used for both // an id within the request for later pairing with a cancellation, and for // the transaction id when sending the to_device messages to our local - override var requestId: String, // current state of this request - override var state: OutgoingGossipingRequestState + override val requestId: String, // current state of this request + override val state: OutgoingGossipingRequestState // transaction id for the cancellation, if any // override var cancellationTxnId: String? = null ) : OutgoingGossipingRequest { @@ -43,9 +43,7 @@ data class OutgoingRoomKeyRequest( * @return the room id. */ val roomId: String? - get() = if (null != requestBody) { - requestBody!!.roomId - } else null + get() = requestBody?.roomId /** * Used only for log. @@ -53,7 +51,5 @@ data class OutgoingRoomKeyRequest( * @return the session id */ val sessionId: String? - get() = if (null != requestBody) { - requestBody!!.sessionId - } else null + get() = requestBody?.sessionId } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/EventAnnotationsSummary.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/EventAnnotationsSummary.kt index 3a4912e457..0238eb6c8d 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/EventAnnotationsSummary.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/EventAnnotationsSummary.kt @@ -16,9 +16,9 @@ package org.matrix.android.sdk.api.session.room.model data class EventAnnotationsSummary( - var eventId: String, - var reactionsSummary: List = emptyList(), - var editSummary: EditAggregatedSummary? = null, - var pollResponseSummary: PollResponseAggregatedSummary? = null, - var referencesAggregatedSummary: ReferencesAggregatedSummary? = null + val eventId: String, + val reactionsSummary: List = emptyList(), + val editSummary: EditAggregatedSummary? = null, + val pollResponseSummary: PollResponseAggregatedSummary? = null, + val referencesAggregatedSummary: ReferencesAggregatedSummary? = null ) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/PollResponseAggregatedSummary.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/PollResponseAggregatedSummary.kt index a15d8be084..b16852e47d 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/PollResponseAggregatedSummary.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/PollResponseAggregatedSummary.kt @@ -16,13 +16,11 @@ package org.matrix.android.sdk.api.session.room.model data class PollResponseAggregatedSummary( - - var aggregatedContent: PollSummaryContent? = null, - + val aggregatedContent: PollSummaryContent? = null, // If set the poll is closed (Clients SHOULD NOT consider responses after the close event) - var closedTime: Long? = null, + val closedTime: Long? = null, // Clients SHOULD validate that the option in the relationship is a valid option, and ignore the response if invalid - var nbOptions: Int = 0, + val nbOptions: Int = 0, // The list of the eventIDs used to build the summary (might be out of sync if chunked received from message chunk) val sourceEvents: List, val localEchos: List diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/timeline/TimelineEvent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/timeline/TimelineEvent.kt index d70049a144..a2ae8bfeb5 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/timeline/TimelineEvent.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/timeline/TimelineEvent.kt @@ -56,7 +56,7 @@ data class TimelineEvent( * It's not unique on the timeline as it's reset on each chunk. */ val displayIndex: Int, - var ownedByThreadChunk: Boolean = false, + val ownedByThreadChunk: Boolean = false, val senderInfo: SenderInfo, val annotations: EventAnnotationsSummary? = null, val readReceipts: List = emptyList() diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/securestorage/SsssKeyCreationInfo.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/securestorage/SsssKeyCreationInfo.kt index eeb1b31f9c..7a91a16c8c 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/securestorage/SsssKeyCreationInfo.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/securestorage/SsssKeyCreationInfo.kt @@ -18,7 +18,7 @@ package org.matrix.android.sdk.api.session.securestorage data class SsssKeyCreationInfo( val keyId: String = "", - var content: SecretStorageKeyContent?, + val content: SecretStorageKeyContent?, val recoveryKey: String = "", val keySpec: SsssKeySpec ) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/threads/ThreadDetails.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/threads/ThreadDetails.kt index d6937d5b26..c8fe1c85ea 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/threads/ThreadDetails.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/threads/ThreadDetails.kt @@ -29,7 +29,7 @@ data class ThreadDetails( val threadSummarySenderInfo: SenderInfo? = null, val threadSummaryLatestEvent: Event? = null, val lastMessageTimestamp: Long? = null, - var threadNotificationState: ThreadNotificationState = ThreadNotificationState.NO_NEW_MESSAGE, + val threadNotificationState: ThreadNotificationState = ThreadNotificationState.NO_NEW_MESSAGE, val isThread: Boolean = false, val lastRootThreadEdition: String? = null ) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/OutgoingGossipingRequest.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/OutgoingGossipingRequest.kt index b16b46cf98..2438e01102 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/OutgoingGossipingRequest.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/OutgoingGossipingRequest.kt @@ -19,9 +19,9 @@ package org.matrix.android.sdk.internal.crypto import org.matrix.android.sdk.api.session.crypto.model.OutgoingGossipingRequestState internal interface OutgoingGossipingRequest { - var recipients: Map> - var requestId: String - var state: OutgoingGossipingRequestState + val recipients: Map> + val requestId: String + val state: OutgoingGossipingRequestState // transaction id for the cancellation, if any // var cancellationTxnId: String? } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/BindThreePidBody.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/BindThreePidBody.kt index fa45ae9940..4d2a999137 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/BindThreePidBody.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/BindThreePidBody.kt @@ -30,17 +30,17 @@ internal data class BindThreePidBody( * Required. The identity server to use. (without "https://") */ @Json(name = "id_server") - var identityServerUrlWithoutProtocol: String, + val identityServerUrlWithoutProtocol: String, /** * Required. An access token previously registered with the identity server. */ @Json(name = "id_access_token") - var identityServerAccessToken: String, + val identityServerAccessToken: String, /** * Required. The session identifier given by the identity server. */ @Json(name = "sid") - var sid: String + val sid: String ) diff --git a/vector/src/main/java/im/vector/app/features/login/terms/converter.kt b/vector/src/main/java/im/vector/app/features/login/terms/converter.kt index 56dc1edf9d..64e4fb65d9 100644 --- a/vector/src/main/java/im/vector/app/features/login/terms/converter.kt +++ b/vector/src/main/java/im/vector/app/features/login/terms/converter.kt @@ -48,15 +48,17 @@ fun TermPolicies.toLocalizedLoginTerms(userLanguage: String, val policies = get("policies") if (policies is Map<*, *>) { policies.keys.forEach { policyName -> - val localizedFlowDataLoginTerms = LocalizedFlowDataLoginTerms() - localizedFlowDataLoginTerms.policyName = policyName as String + val localizedFlowDataLoginTermsPolicyName = policyName as String + var localizedFlowDataLoginTermsVersion: String? = null + var localizedFlowDataLoginTermsLocalizedUrl: String? = null + var localizedFlowDataLoginTermsLocalizedName: String? = null val policy = policies[policyName] // Enter this policy if (policy is Map<*, *>) { // Version - localizedFlowDataLoginTerms.version = policy["version"] as String? + localizedFlowDataLoginTermsVersion = policy["version"] as String? var userLanguageUrlAndName: UrlAndName? = null var defaultLanguageUrlAndName: UrlAndName? = null @@ -86,21 +88,26 @@ fun TermPolicies.toLocalizedLoginTerms(userLanguage: String, // Copy found language data by priority when { userLanguageUrlAndName != null -> { - localizedFlowDataLoginTerms.localizedUrl = userLanguageUrlAndName!!.url - localizedFlowDataLoginTerms.localizedName = userLanguageUrlAndName!!.name + localizedFlowDataLoginTermsLocalizedUrl = userLanguageUrlAndName!!.url + localizedFlowDataLoginTermsLocalizedName = userLanguageUrlAndName!!.name } defaultLanguageUrlAndName != null -> { - localizedFlowDataLoginTerms.localizedUrl = defaultLanguageUrlAndName!!.url - localizedFlowDataLoginTerms.localizedName = defaultLanguageUrlAndName!!.name + localizedFlowDataLoginTermsLocalizedUrl = defaultLanguageUrlAndName!!.url + localizedFlowDataLoginTermsLocalizedName = defaultLanguageUrlAndName!!.name } firstUrlAndName != null -> { - localizedFlowDataLoginTerms.localizedUrl = firstUrlAndName!!.url - localizedFlowDataLoginTerms.localizedName = firstUrlAndName!!.name + localizedFlowDataLoginTermsLocalizedUrl = firstUrlAndName!!.url + localizedFlowDataLoginTermsLocalizedName = firstUrlAndName!!.name } } } - result.add(localizedFlowDataLoginTerms) + result.add(LocalizedFlowDataLoginTerms( + policyName = localizedFlowDataLoginTermsPolicyName, + version = localizedFlowDataLoginTermsVersion, + localizedUrl = localizedFlowDataLoginTermsLocalizedUrl, + localizedName = localizedFlowDataLoginTermsLocalizedName + )) } }