From 8af49891ffeebf76b9968241ebf0c260304633f3 Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Tue, 31 May 2022 14:23:02 +0200 Subject: [PATCH] Post merge conflict reformatting --- .../verification/qrcode/VerificationTest.kt | 10 +- .../keysbackup/DefaultKeysBackupService.kt | 108 +++++++++++------- .../session/room/DefaultRoomService.kt | 36 +++--- .../room/summary/RoomSummaryDataSource.kt | 54 +++++---- .../home/room/list/RoomSummaryItemFactory.kt | 42 ++++--- .../features/media/ImageContentRenderer.kt | 54 +++++---- 6 files changed, 187 insertions(+), 117 deletions(-) diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/verification/qrcode/VerificationTest.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/verification/qrcode/VerificationTest.kt index 462f47cafc..265b7c8c4c 100644 --- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/verification/qrcode/VerificationTest.kt +++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/verification/qrcode/VerificationTest.kt @@ -151,10 +151,12 @@ class VerificationTest : InstrumentedTest { // TODO Add tests without SAS - private fun doTest(aliceSupportedMethods: List, - bobSupportedMethods: List, - expectedResultForAlice: ExpectedResult, - expectedResultForBob: ExpectedResult) = runCryptoTest(context()) { cryptoTestHelper, testHelper -> + private fun doTest( + aliceSupportedMethods: List, + bobSupportedMethods: List, + expectedResultForAlice: ExpectedResult, + expectedResultForBob: ExpectedResult + ) = runCryptoTest(context()) { cryptoTestHelper, testHelper -> val cryptoTestData = cryptoTestHelper.doE2ETestWithAliceAndBobInARoom() val aliceSession = cryptoTestData.firstSession diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/DefaultKeysBackupService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/DefaultKeysBackupService.kt index efd3bca824..8ecb1d72c6 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/DefaultKeysBackupService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/DefaultKeysBackupService.kt @@ -151,9 +151,11 @@ internal class DefaultKeysBackupService @Inject constructor( keysBackupStateManager.removeListener(listener) } - override fun prepareKeysBackupVersion(password: String?, - progressListener: ProgressListener?, - callback: MatrixCallback) { + override fun prepareKeysBackupVersion( + password: String?, + progressListener: ProgressListener?, + callback: MatrixCallback + ) { cryptoCoroutineScope.launch(coroutineDispatchers.io) { try { val olmPkDecryption = OlmPkDecryption() @@ -227,8 +229,10 @@ internal class DefaultKeysBackupService @Inject constructor( } } - override fun createKeysBackupVersion(keysBackupCreationInfo: MegolmBackupCreationInfo, - callback: MatrixCallback) { + override fun createKeysBackupVersion( + keysBackupCreationInfo: MegolmBackupCreationInfo, + callback: MatrixCallback + ) { @Suppress("UNCHECKED_CAST") val createKeysBackupVersionBody = CreateKeysBackupVersionBody( algorithm = keysBackupCreationInfo.algorithm, @@ -339,8 +343,10 @@ internal class DefaultKeysBackupService @Inject constructor( return cryptoStore.inboundGroupSessionsCount(true) } - override fun backupAllGroupSessions(progressListener: ProgressListener?, - callback: MatrixCallback?) { + override fun backupAllGroupSessions( + progressListener: ProgressListener?, + callback: MatrixCallback? + ) { if (!isEnabled() || backupOlmPkEncryption == null || keysBackupVersion == null) { callback?.onFailure(Throwable("Backup not enabled")) return @@ -391,8 +397,10 @@ internal class DefaultKeysBackupService @Inject constructor( }) } - override fun getKeysBackupTrust(keysBackupVersion: KeysVersionResult, - callback: MatrixCallback) { + override fun getKeysBackupTrust( + keysBackupVersion: KeysVersionResult, + callback: MatrixCallback + ) { // TODO Validate with François that this is correct object : Task { override suspend fun execute(params: KeysVersionResult): KeysBackupVersionTrust { @@ -499,9 +507,11 @@ internal class DefaultKeysBackupService @Inject constructor( ) } - override fun trustKeysBackupVersion(keysBackupVersion: KeysVersionResult, - trust: Boolean, - callback: MatrixCallback) { + override fun trustKeysBackupVersion( + keysBackupVersion: KeysVersionResult, + trust: Boolean, + callback: MatrixCallback + ) { Timber.v("trustKeyBackupVersion: $trust, version ${keysBackupVersion.version}") // Get auth data to update it @@ -583,9 +593,11 @@ internal class DefaultKeysBackupService @Inject constructor( } } - override fun trustKeysBackupVersionWithRecoveryKey(keysBackupVersion: KeysVersionResult, - recoveryKey: String, - callback: MatrixCallback) { + override fun trustKeysBackupVersionWithRecoveryKey( + keysBackupVersion: KeysVersionResult, + recoveryKey: String, + callback: MatrixCallback + ) { Timber.v("trustKeysBackupVersionWithRecoveryKey: version ${keysBackupVersion.version}") cryptoCoroutineScope.launch(coroutineDispatchers.io) { @@ -602,9 +614,11 @@ internal class DefaultKeysBackupService @Inject constructor( } } - override fun trustKeysBackupVersionWithPassphrase(keysBackupVersion: KeysVersionResult, - password: String, - callback: MatrixCallback) { + override fun trustKeysBackupVersionWithPassphrase( + keysBackupVersion: KeysVersionResult, + password: String, + callback: MatrixCallback + ) { Timber.v("trustKeysBackupVersionWithPassphrase: version ${keysBackupVersion.version}") cryptoCoroutineScope.launch(coroutineDispatchers.io) { @@ -701,12 +715,14 @@ internal class DefaultKeysBackupService @Inject constructor( progressListener.onProgress(backedUpKeys, total) } - override fun restoreKeysWithRecoveryKey(keysVersionResult: KeysVersionResult, - recoveryKey: String, - roomId: String?, - sessionId: String?, - stepProgressListener: StepProgressListener?, - callback: MatrixCallback) { + override fun restoreKeysWithRecoveryKey( + keysVersionResult: KeysVersionResult, + recoveryKey: String, + roomId: String?, + sessionId: String?, + stepProgressListener: StepProgressListener?, + callback: MatrixCallback + ) { Timber.v("restoreKeysWithRecoveryKey: From backup version: ${keysVersionResult.version}") cryptoCoroutineScope.launch(coroutineDispatchers.io) { @@ -800,12 +816,14 @@ internal class DefaultKeysBackupService @Inject constructor( } } - override fun restoreKeyBackupWithPassword(keysBackupVersion: KeysVersionResult, - password: String, - roomId: String?, - sessionId: String?, - stepProgressListener: StepProgressListener?, - callback: MatrixCallback) { + override fun restoreKeyBackupWithPassword( + keysBackupVersion: KeysVersionResult, + password: String, + roomId: String?, + sessionId: String?, + stepProgressListener: StepProgressListener?, + callback: MatrixCallback + ) { Timber.v("[MXKeyBackup] restoreKeyBackup with password: From backup version: ${keysBackupVersion.version}") cryptoCoroutineScope.launch(coroutineDispatchers.io) { @@ -853,9 +871,11 @@ internal class DefaultKeysBackupService @Inject constructor( * Same method as [RoomKeysRestClient.getRoomKey] except that it accepts nullable * parameters and always returns a KeysBackupData object through the Callback. */ - private suspend fun getKeys(sessionId: String?, - roomId: String?, - version: String): KeysBackupData { + private suspend fun getKeys( + sessionId: String?, + roomId: String?, + version: String + ): KeysBackupData { return if (roomId != null && sessionId != null) { // Get key for the room and for the session val data = getRoomSessionDataTask.execute(GetRoomSessionDataTask.Params(roomId, sessionId, version)) @@ -933,8 +953,10 @@ internal class DefaultKeysBackupService @Inject constructor( } } - override fun getVersion(version: String, - callback: MatrixCallback) { + override fun getVersion( + version: String, + callback: MatrixCallback + ) { getKeysBackupVersionTask .configureWith(version) { this.callback = object : MatrixCallback { @@ -1173,10 +1195,12 @@ internal class DefaultKeysBackupService @Inject constructor( } } - override fun computePrivateKey(passphrase: String, - privateKeySalt: String, - privateKeyIterations: Int, - progressListener: ProgressListener): ByteArray { + override fun computePrivateKey( + passphrase: String, + privateKeySalt: String, + privateKeyIterations: Int, + progressListener: ProgressListener + ): ByteArray { return deriveKey(passphrase, privateKeySalt, privateKeyIterations, progressListener) } @@ -1476,8 +1500,10 @@ internal class DefaultKeysBackupService @Inject constructor( get() = cryptoStore @VisibleForTesting - fun createFakeKeysBackupVersion(keysBackupCreationInfo: MegolmBackupCreationInfo, - callback: MatrixCallback) { + fun createFakeKeysBackupVersion( + keysBackupCreationInfo: MegolmBackupCreationInfo, + callback: MatrixCallback + ) { @Suppress("UNCHECKED_CAST") val createKeysBackupVersionBody = CreateKeysBackupVersionBody( algorithm = keysBackupCreationInfo.algorithm, diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/DefaultRoomService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/DefaultRoomService.kt index a7a5dbf4f3..7a7804c354 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/DefaultRoomService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/DefaultRoomService.kt @@ -94,8 +94,10 @@ internal class DefaultRoomService @Inject constructor( return roomSummaryDataSource.getRoomSummaryLive(roomId) } - override fun getRoomSummaries(queryParams: RoomSummaryQueryParams, - sortOrder: RoomSortOrder): List { + override fun getRoomSummaries( + queryParams: RoomSummaryQueryParams, + sortOrder: RoomSortOrder + ): List { return roomSummaryDataSource.getRoomSummaries(queryParams, sortOrder) } @@ -119,20 +121,26 @@ internal class DefaultRoomService @Inject constructor( } } - override fun getRoomSummariesLive(queryParams: RoomSummaryQueryParams, - sortOrder: RoomSortOrder): LiveData> { + override fun getRoomSummariesLive( + queryParams: RoomSummaryQueryParams, + sortOrder: RoomSortOrder + ): LiveData> { return roomSummaryDataSource.getRoomSummariesLive(queryParams, sortOrder) } - override fun getPagedRoomSummariesLive(queryParams: RoomSummaryQueryParams, - pagedListConfig: PagedList.Config, - sortOrder: RoomSortOrder): LiveData> { + override fun getPagedRoomSummariesLive( + queryParams: RoomSummaryQueryParams, + pagedListConfig: PagedList.Config, + sortOrder: RoomSortOrder + ): LiveData> { return roomSummaryDataSource.getSortedPagedRoomSummariesLive(queryParams, pagedListConfig, sortOrder) } - override fun getFilteredPagedRoomSummariesLive(queryParams: RoomSummaryQueryParams, - pagedListConfig: PagedList.Config, - sortOrder: RoomSortOrder): UpdatableLivePageResult { + override fun getFilteredPagedRoomSummariesLive( + queryParams: RoomSummaryQueryParams, + pagedListConfig: PagedList.Config, + sortOrder: RoomSortOrder + ): UpdatableLivePageResult { return roomSummaryDataSource.getUpdatablePagedRoomSummariesLive(queryParams, pagedListConfig, sortOrder, getFlattenedParents = true) } @@ -160,9 +168,11 @@ internal class DefaultRoomService @Inject constructor( joinRoomTask.execute(JoinRoomTask.Params(roomIdOrAlias, reason, viaServers)) } - override suspend fun joinRoom(roomId: String, - reason: String?, - thirdPartySigned: SignInvitationResult) { + override suspend fun joinRoom( + roomId: String, + reason: String?, + thirdPartySigned: SignInvitationResult + ) { joinRoomTask.execute(JoinRoomTask.Params(roomId, reason, thirdPartySigned = thirdPartySigned)) } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/RoomSummaryDataSource.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/RoomSummaryDataSource.kt index 4b453908e7..b3467c694d 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/RoomSummaryDataSource.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/RoomSummaryDataSource.kt @@ -85,16 +85,20 @@ internal class RoomSummaryDataSource @Inject constructor( } } - fun getRoomSummaries(queryParams: RoomSummaryQueryParams, - sortOrder: RoomSortOrder = RoomSortOrder.NONE): List { + fun getRoomSummaries( + queryParams: RoomSummaryQueryParams, + sortOrder: RoomSortOrder = RoomSortOrder.NONE + ): List { return monarchy.fetchAllMappedSync( { roomSummariesQuery(it, queryParams).process(sortOrder) }, { roomSummaryMapper.map(it) } ) } - fun getRoomSummariesLive(queryParams: RoomSummaryQueryParams, - sortOrder: RoomSortOrder = RoomSortOrder.NONE): LiveData> { + fun getRoomSummariesLive( + queryParams: RoomSummaryQueryParams, + sortOrder: RoomSortOrder = RoomSortOrder.NONE + ): LiveData> { return monarchy.findAllMappedWithChanges( { roomSummariesQuery(it, queryParams).process(sortOrder) @@ -103,8 +107,10 @@ internal class RoomSummaryDataSource @Inject constructor( ) } - fun getSpaceSummariesLive(queryParams: SpaceSummaryQueryParams, - sortOrder: RoomSortOrder = RoomSortOrder.NONE): LiveData> { + fun getSpaceSummariesLive( + queryParams: SpaceSummaryQueryParams, + sortOrder: RoomSortOrder = RoomSortOrder.NONE + ): LiveData> { return getRoomSummariesLive(queryParams, sortOrder) } @@ -129,8 +135,10 @@ internal class RoomSummaryDataSource @Inject constructor( } } - fun getSpaceSummaries(spaceSummaryQueryParams: SpaceSummaryQueryParams, - sortOrder: RoomSortOrder = RoomSortOrder.NONE): List { + fun getSpaceSummaries( + spaceSummaryQueryParams: SpaceSummaryQueryParams, + sortOrder: RoomSortOrder = RoomSortOrder.NONE + ): List { return getRoomSummaries(spaceSummaryQueryParams, sortOrder) } @@ -171,9 +179,11 @@ internal class RoomSummaryDataSource @Inject constructor( .sort(RoomSummaryEntityFields.BREADCRUMBS_INDEX) } - fun getSortedPagedRoomSummariesLive(queryParams: RoomSummaryQueryParams, - pagedListConfig: PagedList.Config, - sortOrder: RoomSortOrder): LiveData> { + fun getSortedPagedRoomSummariesLive( + queryParams: RoomSummaryQueryParams, + pagedListConfig: PagedList.Config, + sortOrder: RoomSortOrder + ): LiveData> { val realmDataSourceFactory = monarchy.createDataSourceFactory { realm -> roomSummariesQuery(realm, queryParams).process(sortOrder) } @@ -186,10 +196,12 @@ internal class RoomSummaryDataSource @Inject constructor( ) } - fun getUpdatablePagedRoomSummariesLive(queryParams: RoomSummaryQueryParams, - pagedListConfig: PagedList.Config, - sortOrder: RoomSortOrder, - getFlattenedParents: Boolean = false): UpdatableLivePageResult { + fun getUpdatablePagedRoomSummariesLive( + queryParams: RoomSummaryQueryParams, + pagedListConfig: PagedList.Config, + sortOrder: RoomSortOrder, + getFlattenedParents: Boolean = false + ): UpdatableLivePageResult { val realmDataSourceFactory = monarchy.createDataSourceFactory { realm -> roomSummariesQuery(realm, queryParams).process(sortOrder) } @@ -424,11 +436,13 @@ internal class RoomSummaryDataSource @Inject constructor( } } - fun flattenSubSpace(current: RoomSummary, - parenting: List, - output: MutableList, - memberShips: List, - includeCurrent: Boolean = true) { + fun flattenSubSpace( + current: RoomSummary, + parenting: List, + output: MutableList, + memberShips: List, + includeCurrent: Boolean = true + ) { if (includeCurrent) { output.add(current) } diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt index 3f29c1d14c..9601ccf914 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt @@ -37,18 +37,22 @@ import org.matrix.android.sdk.api.session.room.model.SpaceChildInfo import org.matrix.android.sdk.api.util.toMatrixItem import javax.inject.Inject -class RoomSummaryItemFactory @Inject constructor(private val displayableEventFormatter: DisplayableEventFormatter, - private val dateFormatter: VectorDateFormatter, - private val stringProvider: StringProvider, - private val typingHelper: TypingHelper, - private val avatarRenderer: AvatarRenderer, - private val errorFormatter: ErrorFormatter) { +class RoomSummaryItemFactory @Inject constructor( + private val displayableEventFormatter: DisplayableEventFormatter, + private val dateFormatter: VectorDateFormatter, + private val stringProvider: StringProvider, + private val typingHelper: TypingHelper, + private val avatarRenderer: AvatarRenderer, + private val errorFormatter: ErrorFormatter +) { - fun create(roomSummary: RoomSummary, - roomChangeMembershipStates: Map, - selectedRoomIds: Set, - displayMode: RoomListDisplayMode, - listener: RoomListListener?): VectorEpoxyModel<*> { + fun create( + roomSummary: RoomSummary, + roomChangeMembershipStates: Map, + selectedRoomIds: Set, + displayMode: RoomListDisplayMode, + listener: RoomListListener? + ): VectorEpoxyModel<*> { return when (roomSummary.membership) { Membership.INVITE -> { val changeMembershipState = roomChangeMembershipStates[roomSummary.roomId] ?: ChangeMembershipState.Unknown @@ -60,9 +64,11 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor } } - fun createSuggestion(spaceChildInfo: SpaceChildInfo, - suggestedRoomJoiningStates: Map>, - listener: RoomListListener?): VectorEpoxyModel<*> { + fun createSuggestion( + spaceChildInfo: SpaceChildInfo, + suggestedRoomJoiningStates: Map>, + listener: RoomListListener? + ): VectorEpoxyModel<*> { val error = (suggestedRoomJoiningStates[spaceChildInfo.childRoomId] as? Fail)?.error return SpaceChildInfoItem_() .id("sug_${spaceChildInfo.childRoomId}") @@ -84,9 +90,11 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor .itemClickListener { listener?.onSuggestedRoomClicked(spaceChildInfo) } } - private fun createInvitationItem(roomSummary: RoomSummary, - changeMembershipState: ChangeMembershipState, - listener: RoomListListener?): VectorEpoxyModel<*> { + private fun createInvitationItem( + roomSummary: RoomSummary, + changeMembershipState: ChangeMembershipState, + listener: RoomListListener? + ): VectorEpoxyModel<*> { val secondLine = if (roomSummary.isDirect) { roomSummary.inviterId } else { diff --git a/vector/src/main/java/im/vector/app/features/media/ImageContentRenderer.kt b/vector/src/main/java/im/vector/app/features/media/ImageContentRenderer.kt index 0cd469fa66..3406e8f7c4 100644 --- a/vector/src/main/java/im/vector/app/features/media/ImageContentRenderer.kt +++ b/vector/src/main/java/im/vector/app/features/media/ImageContentRenderer.kt @@ -66,10 +66,12 @@ interface AttachmentData : Parcelable { private const val URL_PREVIEW_IMAGE_MIN_FULL_WIDTH_PX = 600 private const val URL_PREVIEW_IMAGE_MIN_FULL_HEIGHT_PX = 315 -class ImageContentRenderer @Inject constructor(private val localFilesHelper: LocalFilesHelper, - private val activeSessionHolder: ActiveSessionHolder, - private val dimensionConverter: DimensionConverter, - private val vectorPreferences: VectorPreferences) { +class ImageContentRenderer @Inject constructor( + private val localFilesHelper: LocalFilesHelper, + private val activeSessionHolder: ActiveSessionHolder, + private val dimensionConverter: DimensionConverter, + private val vectorPreferences: VectorPreferences +) { @Parcelize data class Data( @@ -184,19 +186,23 @@ class ImageContentRenderer @Inject constructor(private val localFilesHelper: Loc createGlideRequest(data, mode, imageView, size) .listener(object : RequestListener { - override fun onLoadFailed(e: GlideException?, - model: Any?, - target: Target?, - isFirstResource: Boolean): Boolean { + override fun onLoadFailed( + e: GlideException?, + model: Any?, + target: Target?, + isFirstResource: Boolean + ): Boolean { callback?.invoke(false) return false } - override fun onResourceReady(resource: Drawable?, - model: Any?, - target: Target?, - dataSource: DataSource?, - isFirstResource: Boolean): Boolean { + override fun onResourceReady( + resource: Drawable?, + model: Any?, + target: Target?, + dataSource: DataSource?, + isFirstResource: Boolean + ): Boolean { callback?.invoke(true) return false } @@ -227,19 +233,23 @@ class ImageContentRenderer @Inject constructor(private val localFilesHelper: Loc } req.listener(object : RequestListener { - override fun onLoadFailed(e: GlideException?, - model: Any?, - target: Target?, - isFirstResource: Boolean): Boolean { + override fun onLoadFailed( + e: GlideException?, + model: Any?, + target: Target?, + isFirstResource: Boolean + ): Boolean { callback?.invoke(false) return false } - override fun onResourceReady(resource: Drawable?, - model: Any?, - target: Target?, - dataSource: DataSource?, - isFirstResource: Boolean): Boolean { + override fun onResourceReady( + resource: Drawable?, + model: Any?, + target: Target?, + dataSource: DataSource?, + isFirstResource: Boolean + ): Boolean { callback?.invoke(true) return false }