From 0919b9460d6e205090716e198fbc2e215e6da18e Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 9 Jul 2019 15:26:32 +0200 Subject: [PATCH] Code quality: split long lines --- .../im/vector/matrix/android/api/Matrix.kt | 3 +- .../api/pushrules/rest/PushCondition.kt | 3 +- .../api/session/crypto/MXCryptoError.kt | 6 ++- .../crypto/keysbackup/KeysBackupService.kt | 44 ++++++++++++++----- .../room/model/roomdirectory/PublicRoom.kt | 3 +- .../android/internal/crypto/CryptoModule.kt | 6 ++- .../android/internal/crypto/MXOlmDevice.kt | 3 +- .../crypto/OutgoingRoomKeyRequestManager.kt | 32 ++++++++------ .../algorithms/megolm/MXMegolmDecryption.kt | 20 +++++++-- .../crypto/algorithms/olm/MXOlmDecryption.kt | 3 +- .../internal/crypto/keysbackup/KeysBackup.kt | 9 ++-- .../internal/database/model/PusherEntity.kt | 3 +- .../session/group/GroupSummaryUpdater.kt | 3 +- .../notification/ProcessEventForPushTask.kt | 3 +- .../internal/session/room/RoomFactory.kt | 3 +- .../room/relation/DefaultRelationService.kt | 8 ++-- .../room/send/LocalEchoEventFactory.kt | 19 ++++++-- .../android/internal/util/CompatUtil.kt | 3 +- .../troubleshoot/TestAutoStartBoot.kt | 3 +- .../TestBackgroundRestrictions.kt | 3 +- .../settings/troubleshoot/TestPlayServices.kt | 3 +- .../troubleshoot/TestTokenRegistration.kt | 3 +- .../timeline/action/MessageMenuViewModel.kt | 3 +- 23 files changed, 132 insertions(+), 57 deletions(-) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/Matrix.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/Matrix.kt index 1df81889..bdc988d2 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/Matrix.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/Matrix.kt @@ -87,7 +87,8 @@ class Matrix private constructor(context: Context, matrixConfiguration: MatrixCo val matrixConfiguration = (appContext as MatrixConfiguration.Provider).providesMatrixConfiguration() instance = Matrix(appContext, matrixConfiguration) } else { - throw IllegalStateException("Matrix is not initialized properly. You should call Matrix.initialize or let your application implements MatrixConfiguration.Provider.") + throw IllegalStateException("Matrix is not initialized properly." + + " You should call Matrix.initialize or let your application implements MatrixConfiguration.Provider.") } } return instance diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/pushrules/rest/PushCondition.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/pushrules/rest/PushCondition.kt index 8e63e864..8f694016 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/pushrules/rest/PushCondition.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/pushrules/rest/PushCondition.kt @@ -40,7 +40,8 @@ data class PushCondition( /** * Required for room_member_count conditions. * A decimal integer optionally prefixed by one of, ==, <, >, >= or <=. - * A prefix of < matches rooms where the member count is strictly less than the given number and so forth. If no prefix is present, this parameter defaults to ==. + * A prefix of < matches rooms where the member count is strictly less than the given number and so forth. + * If no prefix is present, this parameter defaults to ==. */ @Json(name = "is") val iz: String? = null ) { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/MXCryptoError.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/MXCryptoError.kt index 42102124..b61a1e41 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/MXCryptoError.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/MXCryptoError.kt @@ -85,7 +85,9 @@ sealed class MXCryptoError : Throwable() { const val BAD_ENCRYPTED_MESSAGE_REASON = "Bad Encrypted Message" const val DUPLICATE_MESSAGE_INDEX_REASON = "Duplicate message index, possible replay attack %1\$s" const val ERROR_MISSING_PROPERTY_REASON = "No '%1\$s' property. Cannot prevent unknown-key attack" - const val UNKNOWN_DEVICES_REASON = "This room contains unknown devices which have not been verified.\n" + "We strongly recommend you verify them before continuing." - const val NO_MORE_ALGORITHM_REASON = "Room was previously configured to use encryption, but is no longer." + " Perhaps the homeserver is hiding the configuration event." + const val UNKNOWN_DEVICES_REASON = "This room contains unknown devices which have not been verified.\n" + + "We strongly recommend you verify them before continuing." + const val NO_MORE_ALGORITHM_REASON = "Room was previously configured to use encryption, but is no longer." + + " Perhaps the homeserver is hiding the configuration event." } } \ No newline at end of file diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/keysbackup/KeysBackupService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/keysbackup/KeysBackupService.kt index 02111012..6728daa5 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/keysbackup/KeysBackupService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/keysbackup/KeysBackupService.kt @@ -40,7 +40,8 @@ interface KeysBackupService { * @param keysBackupCreationInfo the info object from [prepareKeysBackupVersion]. * @param callback Asynchronous callback */ - fun createKeysBackupVersion(keysBackupCreationInfo: MegolmBackupCreationInfo, callback: MatrixCallback) + fun createKeysBackupVersion(keysBackupCreationInfo: MegolmBackupCreationInfo, + callback: MatrixCallback) /** * Facility method to get the total number of locally stored keys @@ -58,7 +59,8 @@ interface KeysBackupService { * @param progressListener the callback to follow the progress * @param callback the main callback */ - fun backupAllGroupSessions(progressListener: ProgressListener?, callback: MatrixCallback?) + fun backupAllGroupSessions(progressListener: ProgressListener?, + callback: MatrixCallback?) /** * Check trust on a key backup version. @@ -66,7 +68,8 @@ interface KeysBackupService { * @param keysBackupVersion the backup version to check. * @param callback block called when the operations completes. */ - fun getKeysBackupTrust(keysBackupVersion: KeysVersionResult, callback: MatrixCallback) + fun getKeysBackupTrust(keysBackupVersion: KeysVersionResult, + callback: MatrixCallback) /** * Return the current progress of the backup @@ -80,7 +83,8 @@ interface KeysBackupService { * @param version the backup version * @param callback */ - fun getVersion(version: String, callback: MatrixCallback) + fun getVersion(version: String, + callback: MatrixCallback) /** * This method fetches the last backup version on the server, then compare to the currently backup version use. @@ -114,7 +118,9 @@ interface KeysBackupService { * @param progressListener a progress listener, as generating private key from password may take a while * @param callback Asynchronous callback */ - fun prepareKeysBackupVersion(password: String?, progressListener: ProgressListener?, callback: MatrixCallback) + fun prepareKeysBackupVersion(password: String?, + progressListener: ProgressListener?, + callback: MatrixCallback) /** * Delete a keys backup version. It will delete all backed up keys on the server, and the backup itself. @@ -123,7 +129,8 @@ interface KeysBackupService { * @param version the backup version to delete. * @param callback Asynchronous callback */ - fun deleteBackup(version: String, callback: MatrixCallback?) + fun deleteBackup(version: String, + callback: MatrixCallback?) /** * Ask if the backup on the server contains keys that we may do not have locally. @@ -139,7 +146,9 @@ interface KeysBackupService { * @param trust the trust to set to the keys backup. * @param callback block called when the operations completes. */ - fun trustKeysBackupVersion(keysBackupVersion: KeysVersionResult, trust: Boolean, callback: MatrixCallback) + fun trustKeysBackupVersion(keysBackupVersion: KeysVersionResult, + trust: Boolean, + callback: MatrixCallback) /** * Set trust on a keys backup version. @@ -148,7 +157,9 @@ interface KeysBackupService { * @param recoveryKey the recovery key to challenge with the key backup public key. * @param callback block called when the operations completes. */ - fun trustKeysBackupVersionWithRecoveryKey(keysBackupVersion: KeysVersionResult, recoveryKey: String, callback: MatrixCallback) + fun trustKeysBackupVersionWithRecoveryKey(keysBackupVersion: KeysVersionResult, + recoveryKey: String, + callback: MatrixCallback) /** * Set trust on a keys backup version. @@ -157,7 +168,9 @@ interface KeysBackupService { * @param password the pass phrase to challenge with the keyBackupVersion public key. * @param callback block called when the operations completes. */ - fun trustKeysBackupVersionWithPassphrase(keysBackupVersion: KeysVersionResult, password: String, callback: MatrixCallback) + fun trustKeysBackupVersionWithPassphrase(keysBackupVersion: KeysVersionResult, + password: String, + callback: MatrixCallback) /** * Restore a backup with a recovery key from a given backup version stored on the homeserver. @@ -169,7 +182,11 @@ interface KeysBackupService { * @param stepProgressListener the step progress listener * @param callback Callback. It provides the number of found keys and the number of successfully imported keys. */ - fun restoreKeysWithRecoveryKey(keysVersionResult: KeysVersionResult, recoveryKey: String, roomId: String?, sessionId: String?, stepProgressListener: StepProgressListener?, callback: MatrixCallback) + fun restoreKeysWithRecoveryKey(keysVersionResult: KeysVersionResult, + recoveryKey: String, roomId: String?, + sessionId: String?, + stepProgressListener: StepProgressListener?, + callback: MatrixCallback) /** * Restore a backup with a password from a given backup version stored on the homeserver. @@ -181,7 +198,12 @@ interface KeysBackupService { * @param stepProgressListener the step progress listener * @param callback Callback. It provides the number of found keys and the number of successfully imported keys. */ - fun restoreKeyBackupWithPassword(keysBackupVersion: KeysVersionResult, password: String, roomId: String?, sessionId: String?, stepProgressListener: StepProgressListener?, callback: MatrixCallback) + fun restoreKeyBackupWithPassword(keysBackupVersion: KeysVersionResult, + password: String, + roomId: String?, + sessionId: String?, + stepProgressListener: StepProgressListener?, + callback: MatrixCallback) val keysBackupVersion: KeysVersionResult? val currentBackupVersion: String? diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/roomdirectory/PublicRoom.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/roomdirectory/PublicRoom.kt index 3ed3ec0c..508cbb55 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/roomdirectory/PublicRoom.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/roomdirectory/PublicRoom.kt @@ -67,7 +67,8 @@ data class PublicRoom( var worldReadable: Boolean = false, /** - * Required. Whether guest users may join the room and participate in it. If they can, they will be subject to ordinary power level rules like any other user. + * Required. Whether guest users may join the room and participate in it. If they can, + * they will be subject to ordinary power level rules like any other user. */ @Json(name = "guest_can_join") var guestCanJoin: Boolean = false, diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/CryptoModule.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/CryptoModule.kt index 9025d7b0..5ed0c0e2 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/CryptoModule.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/CryptoModule.kt @@ -168,8 +168,10 @@ internal abstract class CryptoModule { abstract fun bindSendToDeviceTask(sendToDeviceTask: DefaultSendToDeviceTask): SendToDeviceTask @Binds - abstract fun bindClaimOneTimeKeysForUsersDeviceTask(claimOneTimeKeysForUsersDevice: DefaultClaimOneTimeKeysForUsersDevice): ClaimOneTimeKeysForUsersDeviceTask + abstract fun bindClaimOneTimeKeysForUsersDeviceTask(claimOneTimeKeysForUsersDevice: DefaultClaimOneTimeKeysForUsersDevice) + : ClaimOneTimeKeysForUsersDeviceTask @Binds - abstract fun bindDeleteDeviceWithUserPasswordTask(deleteDeviceWithUserPasswordTask: DefaultDeleteDeviceWithUserPasswordTask): DeleteDeviceWithUserPasswordTask + abstract fun bindDeleteDeviceWithUserPasswordTask(deleteDeviceWithUserPasswordTask: DefaultDeleteDeviceWithUserPasswordTask) + : DeleteDeviceWithUserPasswordTask } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/MXOlmDevice.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/MXOlmDevice.kt index a9ea4a73..519a850f 100755 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/MXOlmDevice.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/MXOlmDevice.kt @@ -684,7 +684,8 @@ internal class MXOlmDevice @Inject constructor( adapter.fromJson(payloadString) } catch (e: Exception) { Timber.e("## decryptGroupMessage() : fails to parse the payload") - return@flatMap Try.Failure(MXCryptoError.Base(MXCryptoError.ErrorType.BAD_DECRYPTED_FORMAT, MXCryptoError.BAD_DECRYPTED_FORMAT_TEXT_REASON)) + return@flatMap Try.Failure( + MXCryptoError.Base(MXCryptoError.ErrorType.BAD_DECRYPTED_FORMAT, MXCryptoError.BAD_DECRYPTED_FORMAT_TEXT_REASON)) } return@flatMap Try.just( diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/OutgoingRoomKeyRequestManager.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/OutgoingRoomKeyRequestManager.kt index 29439c44..9436a398 100755 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/OutgoingRoomKeyRequestManager.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/OutgoingRoomKeyRequestManager.kt @@ -132,20 +132,26 @@ internal class OutgoingRoomKeyRequestManager @Inject constructor( Timber.v("cancelRoomKeyRequest: requestId: " + req.requestId + " state: " + req.state + " andResend: " + andResend) - if (req.state === OutgoingRoomKeyRequest.RequestState.CANCELLATION_PENDING || req.state === OutgoingRoomKeyRequest.RequestState.CANCELLATION_PENDING_AND_WILL_RESEND) { - // nothing to do here - } else if (req.state === OutgoingRoomKeyRequest.RequestState.UNSENT || req.state === OutgoingRoomKeyRequest.RequestState.FAILED) { - Timber.v("## cancelRoomKeyRequest() : deleting unnecessary room key request for $requestBody") - cryptoStore.deleteOutgoingRoomKeyRequest(req.requestId) - } else if (req.state === OutgoingRoomKeyRequest.RequestState.SENT) { - if (andResend) { - req.state = OutgoingRoomKeyRequest.RequestState.CANCELLATION_PENDING_AND_WILL_RESEND - } else { - req.state = OutgoingRoomKeyRequest.RequestState.CANCELLATION_PENDING + when (req.state) { + OutgoingRoomKeyRequest.RequestState.CANCELLATION_PENDING, + OutgoingRoomKeyRequest.RequestState.CANCELLATION_PENDING_AND_WILL_RESEND -> { + // nothing to do here + } + OutgoingRoomKeyRequest.RequestState.UNSENT, + OutgoingRoomKeyRequest.RequestState.FAILED -> { + Timber.v("## cancelRoomKeyRequest() : deleting unnecessary room key request for $requestBody") + cryptoStore.deleteOutgoingRoomKeyRequest(req.requestId) + } + OutgoingRoomKeyRequest.RequestState.SENT -> { + if (andResend) { + req.state = OutgoingRoomKeyRequest.RequestState.CANCELLATION_PENDING_AND_WILL_RESEND + } else { + req.state = OutgoingRoomKeyRequest.RequestState.CANCELLATION_PENDING + } + req.cancellationTxnId = makeTxnId() + cryptoStore.updateOutgoingRoomKeyRequest(req) + sendOutgoingRoomKeyRequestCancellation(req) } - req.cancellationTxnId = makeTxnId() - cryptoStore.updateOutgoingRoomKeyRequest(req) - sendOutgoingRoomKeyRequestCancellation(req) } } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/algorithms/megolm/MXMegolmDecryption.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/algorithms/megolm/MXMegolmDecryption.kt index fb90db7d..180b7aa6 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/algorithms/megolm/MXMegolmDecryption.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/algorithms/megolm/MXMegolmDecryption.kt @@ -81,7 +81,11 @@ internal class MXMegolmDecryption(private val credentials: Credentials, return Try.Failure(MXCryptoError.Base(MXCryptoError.ErrorType.MISSING_FIELDS, MXCryptoError.MISSING_FIELDS_REASON)) } - return olmDevice.decryptGroupMessage(encryptedEventContent.ciphertext, event.roomId, timeline, encryptedEventContent.sessionId, encryptedEventContent.senderKey) + return olmDevice.decryptGroupMessage(encryptedEventContent.ciphertext, + event.roomId, + timeline, + encryptedEventContent.sessionId, + encryptedEventContent.senderKey) .fold( { throwable -> if (throwable is MXCryptoError.OlmError) { @@ -211,7 +215,8 @@ internal class MXMegolmDecryption(private val credentials: Credentials, return } if (event.getClearType() == EventType.FORWARDED_ROOM_KEY) { - Timber.v("## onRoomKeyEvent(), forward adding key : roomId ${roomKeyContent.roomId} sessionId ${roomKeyContent.sessionId} sessionKey ${roomKeyContent.sessionKey}") // from " + event); + Timber.v("## onRoomKeyEvent(), forward adding key : roomId ${roomKeyContent.roomId}" + + " sessionId ${roomKeyContent.sessionId} sessionKey ${roomKeyContent.sessionKey}") val forwardedRoomKeyContent = event.getClearContent().toModel() ?: return @@ -259,7 +264,13 @@ internal class MXMegolmDecryption(private val credentials: Credentials, return } - val added = olmDevice.addInboundGroupSession(roomKeyContent.sessionId, roomKeyContent.sessionKey, roomKeyContent.roomId, senderKey, forwardingCurve25519KeyChain, keysClaimed, exportFormat) + val added = olmDevice.addInboundGroupSession(roomKeyContent.sessionId, + roomKeyContent.sessionKey, + roomKeyContent.roomId, + senderKey, + forwardingCurve25519KeyChain, + keysClaimed, + exportFormat) if (added) { keysBackup.maybeBackupKeys() @@ -322,7 +333,8 @@ internal class MXMegolmDecryption(private val credentials: Credentials, // were no one-time keys. Try.just(Unit) } - Timber.v("""## shareKeysWithDevice() : sharing keys for session ${body?.senderKey}|${body?.sessionId} with device $userId:$deviceId""") + Timber.v("## shareKeysWithDevice() : sharing keys for session" + + " ${body?.senderKey}|${body?.sessionId} with device $userId:$deviceId") val payloadJson = HashMap() payloadJson["type"] = EventType.FORWARDED_ROOM_KEY diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/algorithms/olm/MXOlmDecryption.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/algorithms/olm/MXOlmDecryption.kt index e24132c3..7b5a8cd4 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/algorithms/olm/MXOlmDecryption.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/algorithms/olm/MXOlmDecryption.kt @@ -106,7 +106,8 @@ internal class MXOlmDecryption( } if (olmPayloadContent.recipient != credentials.userId) { - Timber.e("## decryptEvent() : Event ${event.eventId}: Intended recipient ${olmPayloadContent.recipient} does not match our id ${credentials.userId}") + Timber.e("## decryptEvent() : Event ${event.eventId}:" + + " Intended recipient ${olmPayloadContent.recipient} does not match our id ${credentials.userId}") return Try.Failure(MXCryptoError.Base(MXCryptoError.ErrorType.BAD_RECIPIENT, String.format(MXCryptoError.BAD_RECIPIENT_REASON, olmPayloadContent.recipient))) } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/KeysBackup.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/KeysBackup.kt index 4dc3c634..5d4a9504 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/KeysBackup.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/keysbackup/KeysBackup.kt @@ -665,7 +665,8 @@ internal class KeysBackup @Inject constructor( // Do not trigger a backup for them if they come from the backup version we are using val backUp = keysVersionResult.version != keysBackupVersion?.version if (backUp) { - Timber.v("restoreKeysWithRecoveryKey: Those keys will be backed up to backup version: " + keysBackupVersion?.version) + Timber.v("restoreKeysWithRecoveryKey: Those keys will be backed up to backup version: " + + keysBackupVersion?.version) } // Import them into the crypto store @@ -1224,7 +1225,8 @@ internal class KeysBackup @Inject constructor( } try { - keysBackupData.roomIdToRoomKeysBackupData[olmInboundGroupSessionWrapper.roomId]!!.sessionIdToKeyBackupData[olmInboundGroupSessionWrapper.olmInboundGroupSession!!.sessionIdentifier()] = keyBackupData + keysBackupData.roomIdToRoomKeysBackupData[olmInboundGroupSessionWrapper.roomId]!! + .sessionIdToKeyBackupData[olmInboundGroupSessionWrapper.olmInboundGroupSession!!.sessionIdentifier()] = keyBackupData } catch (e: OlmException) { Timber.e(e, "OlmException") } @@ -1276,7 +1278,8 @@ internal class KeysBackup @Inject constructor( // Do not stay in KeysBackupState.WrongBackUpVersion but check what is available on the homeserver checkAndStartKeysBackup() } - else -> // Come back to the ready state so that we will retry on the next received key + else -> + // Come back to the ready state so that we will retry on the next received key keysBackupStateManager.state = KeysBackupState.ReadyToBackUp } } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/model/PusherEntity.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/model/PusherEntity.kt index 6e567c0a..a9d33c86 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/model/PusherEntity.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/model/PusherEntity.kt @@ -23,7 +23,8 @@ import io.realm.annotations.Index // at java.lang.Thread.run(Thread.java:764) // Caused by: java.lang.IllegalArgumentException: 'value' is not a valid managed object. // at io.realm.ProxyState.checkValidObject(ProxyState.java:213) -// at io.realm.im_vector_matrix_android_internal_database_model_PusherEntityRealmProxy.realmSet$data(im_vector_matrix_android_internal_database_model_PusherEntityRealmProxy.java:413) +// at io.realm.im_vector_matrix_android_internal_database_model_PusherEntityRealmProxy +// .realmSet$data(im_vector_matrix_android_internal_database_model_PusherEntityRealmProxy.java:413) // at im.vector.matrix.android.internal.database.model.PusherEntity.setData(PusherEntity.kt:16) // at im.vector.matrix.android.internal.session.pushers.AddHttpPusherWorker$doWork$$inlined$fold$lambda$2.execute(AddHttpPusherWorker.kt:70) // at io.realm.Realm.executeTransaction(Realm.java:1493) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/group/GroupSummaryUpdater.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/group/GroupSummaryUpdater.kt index a2ca8503..46578272 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/group/GroupSummaryUpdater.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/group/GroupSummaryUpdater.kt @@ -36,7 +36,8 @@ private const val GET_GROUP_DATA_WORKER = "GET_GROUP_DATA_WORKER" internal class GroupSummaryUpdater @Inject constructor(private val context: Context, private val credentials: Credentials, - @SessionDatabase realmConfiguration: RealmConfiguration) : RealmLiveEntityObserver(realmConfiguration) { + @SessionDatabase realmConfiguration: RealmConfiguration) + : RealmLiveEntityObserver(realmConfiguration) { override val query = Monarchy.Query { GroupEntity.where(it) } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/notification/ProcessEventForPushTask.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/notification/ProcessEventForPushTask.kt index 6989cb4c..fc6c8838 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/notification/ProcessEventForPushTask.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/notification/ProcessEventForPushTask.kt @@ -69,7 +69,8 @@ internal class DefaultProcessEventForPushTask @Inject constructor( }.filter { it.senderId != sessionParams.credentials.userId } - Timber.v("[PushRules] Found ${allEvents.size} out of ${(newJoinEvents + inviteEvents).size} to check for push rules with ${params.rules.size} rules") + Timber.v("[PushRules] Found ${allEvents.size} out of ${(newJoinEvents + inviteEvents).size}" + + " to check for push rules with ${params.rules.size} rules") allEvents.forEach { event -> fulfilledBingRule(event, params.rules)?.let { Timber.v("[PushRules] Rule $it match for event ${event.eventId}") diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/RoomFactory.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/RoomFactory.kt index dddcd37f..143ef60b 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/RoomFactory.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/RoomFactory.kt @@ -66,7 +66,8 @@ internal class RoomFactory @Inject constructor(private val context: Context, val stateService = DefaultStateService(roomId, taskExecutor, sendStateTask) val roomMembersService = DefaultMembershipService(roomId, monarchy, taskExecutor, loadRoomMembersTask, inviteTask, joinRoomTask, leaveRoomTask) val readService = DefaultReadService(roomId, monarchy, taskExecutor, setReadMarkersTask, credentials) - val relationService = DefaultRelationService(context, credentials, roomId, eventFactory, cryptoService, findReactionEventForUndoTask, monarchy, taskExecutor) + val relationService = DefaultRelationService(context, + credentials, roomId, eventFactory, cryptoService, findReactionEventForUndoTask, monarchy, taskExecutor) return DefaultRoom( roomId, diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/relation/DefaultRelationService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/relation/DefaultRelationService.kt index 31c381f4..27270c3e 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/relation/DefaultRelationService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/relation/DefaultRelationService.kt @@ -116,9 +116,11 @@ internal class DefaultRelationService @Inject constructor(private val context: C } override fun editTextMessage(targetEventId: String, newBodyText: String, newBodyAutoMarkdown: Boolean, compatibilityBodyText: String): Cancelable { - val event = eventFactory.createReplaceTextEvent(roomId, targetEventId, newBodyText, newBodyAutoMarkdown, MessageType.MSGTYPE_TEXT, compatibilityBodyText).also { - saveLocalEcho(it) - } + val event = eventFactory + .createReplaceTextEvent(roomId, targetEventId, newBodyText, newBodyAutoMarkdown, MessageType.MSGTYPE_TEXT, compatibilityBodyText) + .also { + saveLocalEcho(it) + } val workRequest = createSendEventWork(event) TimelineSendEventWorkCommon.postWork(context, roomId, workRequest) return CancelableWork(context, workRequest.id) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/LocalEchoEventFactory.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/LocalEchoEventFactory.kt index 4e7e8eed..c5f7a6e3 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/LocalEchoEventFactory.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/send/LocalEchoEventFactory.kt @@ -81,7 +81,12 @@ internal class LocalEchoEventFactory @Inject constructor(private val credentials } - fun createReplaceTextEvent(roomId: String, targetEventId: String, newBodyText: String, newBodyAutoMarkdown: Boolean, msgType: String, compatibilityText: String): Event { + fun createReplaceTextEvent(roomId: String, + targetEventId: String, + newBodyText: String, + newBodyAutoMarkdown: Boolean, + msgType: String, + compatibilityText: String): Event { var newContent = MessageTextContent( type = MessageType.MSGTYPE_TEXT, @@ -255,9 +260,15 @@ internal class LocalEchoEventFactory @Inject constructor(private val credentials // // This is where the reply goes. val body = bodyForReply(eventReplied.getClearContent().toModel()) - val replyFallbackTemplateFormatted = """ -
${stringProvider.getString(R.string.message_reply_to_prefix)}%s
%s
%s - """.trimIndent().format(permalink, userLink, userId, body.second ?: body.first, replyText) + val replyFallbackTemplateFormatted = """ +
+ ${stringProvider.getString(R.string.message_reply_to_prefix)} + %s +
+ %s +
+
+ %s""".trimIndent().format(permalink, userLink, userId, body.second ?: body.first, replyText) // // > <@alice:example.org> This is the original body // diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/util/CompatUtil.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/util/CompatUtil.kt index 76797ac7..e713c435 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/util/CompatUtil.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/util/CompatUtil.kt @@ -120,7 +120,8 @@ object CompatUtil { val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context) // Get the version of Android when the key has been generated, default to the current version of the system. In this case, the // key will be generated - val androidVersionWhenTheKeyHasBeenGenerated = sharedPreferences.getInt(SHARED_KEY_ANDROID_VERSION_WHEN_KEY_HAS_BEEN_GENERATED, Build.VERSION.SDK_INT) + val androidVersionWhenTheKeyHasBeenGenerated = sharedPreferences + .getInt(SHARED_KEY_ANDROID_VERSION_WHEN_KEY_HAS_BEEN_GENERATED, Build.VERSION.SDK_INT) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (keyStore.containsAlias(AES_LOCAL_PROTECTION_KEY_ALIAS)) { diff --git a/vector/src/fdroid/java/im/vector/riotx/fdroid/features/settings/troubleshoot/TestAutoStartBoot.kt b/vector/src/fdroid/java/im/vector/riotx/fdroid/features/settings/troubleshoot/TestAutoStartBoot.kt index 47e87aa4..77482823 100644 --- a/vector/src/fdroid/java/im/vector/riotx/fdroid/features/settings/troubleshoot/TestAutoStartBoot.kt +++ b/vector/src/fdroid/java/im/vector/riotx/fdroid/features/settings/troubleshoot/TestAutoStartBoot.kt @@ -26,7 +26,8 @@ import javax.inject.Inject * Test that the application is started on boot */ class TestAutoStartBoot @Inject constructor(private val context: AppCompatActivity, - private val stringProvider: StringProvider) : TroubleshootTest(R.string.settings_troubleshoot_test_service_boot_title) { + private val stringProvider: StringProvider) + : TroubleshootTest(R.string.settings_troubleshoot_test_service_boot_title) { override fun perform() { if (PreferencesManager.autoStartOnBoot(context)) { diff --git a/vector/src/fdroid/java/im/vector/riotx/fdroid/features/settings/troubleshoot/TestBackgroundRestrictions.kt b/vector/src/fdroid/java/im/vector/riotx/fdroid/features/settings/troubleshoot/TestBackgroundRestrictions.kt index ce9066c2..b0c40a54 100644 --- a/vector/src/fdroid/java/im/vector/riotx/fdroid/features/settings/troubleshoot/TestBackgroundRestrictions.kt +++ b/vector/src/fdroid/java/im/vector/riotx/fdroid/features/settings/troubleshoot/TestBackgroundRestrictions.kt @@ -25,7 +25,8 @@ import im.vector.riotx.features.settings.troubleshoot.TroubleshootTest import javax.inject.Inject class TestBackgroundRestrictions @Inject constructor(private val context: AppCompatActivity, - private val stringProvider: StringProvider) : TroubleshootTest(R.string.settings_troubleshoot_test_bg_restricted_title) { + private val stringProvider: StringProvider) + : TroubleshootTest(R.string.settings_troubleshoot_test_bg_restricted_title) { override fun perform() { (context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager).apply { diff --git a/vector/src/gplay/java/im/vector/riotx/gplay/features/settings/troubleshoot/TestPlayServices.kt b/vector/src/gplay/java/im/vector/riotx/gplay/features/settings/troubleshoot/TestPlayServices.kt index e97f3cea..2aaa0d2e 100644 --- a/vector/src/gplay/java/im/vector/riotx/gplay/features/settings/troubleshoot/TestPlayServices.kt +++ b/vector/src/gplay/java/im/vector/riotx/gplay/features/settings/troubleshoot/TestPlayServices.kt @@ -28,7 +28,8 @@ import javax.inject.Inject * Check that the play services APK is available an up-to-date. If needed provide quick fix to install it. */ class TestPlayServices @Inject constructor(private val context: AppCompatActivity, - private val stringProvider: StringProvider) : TroubleshootTest(R.string.settings_troubleshoot_test_play_services_title) { + private val stringProvider: StringProvider) + : TroubleshootTest(R.string.settings_troubleshoot_test_play_services_title) { override fun perform() { val apiAvailability = GoogleApiAvailability.getInstance() diff --git a/vector/src/gplay/java/im/vector/riotx/gplay/features/settings/troubleshoot/TestTokenRegistration.kt b/vector/src/gplay/java/im/vector/riotx/gplay/features/settings/troubleshoot/TestTokenRegistration.kt index b7b49940..f53813af 100644 --- a/vector/src/gplay/java/im/vector/riotx/gplay/features/settings/troubleshoot/TestTokenRegistration.kt +++ b/vector/src/gplay/java/im/vector/riotx/gplay/features/settings/troubleshoot/TestTokenRegistration.kt @@ -34,7 +34,8 @@ import javax.inject.Inject class TestTokenRegistration @Inject constructor(private val context: AppCompatActivity, private val stringProvider: StringProvider, private val pushersManager: PushersManager, - private val activeSessionHolder: ActiveSessionHolder) : TroubleshootTest(R.string.settings_troubleshoot_test_token_registration_title) { + private val activeSessionHolder: ActiveSessionHolder) + : TroubleshootTest(R.string.settings_troubleshoot_test_token_registration_title) { override fun perform() { //Check if we have a registered pusher for this token diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/MessageMenuViewModel.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/MessageMenuViewModel.kt index 032d690c..5b77cef7 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/MessageMenuViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/MessageMenuViewModel.kt @@ -178,7 +178,8 @@ class MessageMenuViewModel @AssistedInject constructor(@Assisted initialState: M this.add(SimpleAction(VIEW_SOURCE, R.string.view_source, R.drawable.ic_view_source,event.root.toContentStringWithIndent())) if (event.isEncrypted()) { - val decryptedContent = event.root.toClearContentStringWithIndent() ?: stringProvider.getString(R.string.encryption_information_decryption_error) + val decryptedContent = event.root.toClearContentStringWithIndent() + ?: stringProvider.getString(R.string.encryption_information_decryption_error) this.add(SimpleAction(VIEW_DECRYPTED_SOURCE, R.string.view_decrypted_source, R.drawable.ic_view_source, decryptedContent)) } this.add(SimpleAction(ACTION_COPY_PERMALINK, R.string.permalink, R.drawable.ic_permalink, event.root.eventId))