From 2c568b4de92051a5647c1762229e1de8a2b9692a Mon Sep 17 00:00:00 2001 From: Valere Date: Wed, 29 Jan 2020 09:40:17 +0100 Subject: [PATCH] clean klint --- .../crypto/keysbackup/KeysBackupTest.kt | 24 +++++++++++++++---- .../crosssigning/CrossSigningService.kt | 1 - .../crypto/sas/SasVerificationTransaction.kt | 1 - .../session/crypto/sas/VerificationService.kt | 6 ++++- .../android/internal/crypto/CryptoModule.kt | 1 - .../internal/crypto/DefaultCryptoService.kt | 3 +-- .../DefaultCrossSigningService.kt | 15 +++++++----- .../model/rest/UploadSignatureQueryBuilder.kt | 6 ++++- .../crypto/store/db/RealmCryptoStore.kt | 15 ++++++++---- .../store/db/RealmCryptoStoreMigration.kt | 1 - .../crypto/tasks/UploadSignaturesTask.kt | 3 +-- .../DefaultVerificationService.kt | 13 ++++++---- .../SASDefaultVerificationTransaction.kt | 1 - .../DefaultQrCodeVerificationTransaction.kt | 2 -- .../core/ui/list/GenericItemWithValue.kt | 1 - .../VerificationBottomSheetViewModel.kt | 11 +++++++-- .../request/VerificationRequestFragment.kt | 2 -- .../home/room/detail/RoomDetailFragment.kt | 2 +- .../timeline/factory/TimelineItemFactory.kt | 2 +- .../riotx/features/popup/PopupAlertManager.kt | 1 - .../RoomMemberProfileController.kt | 4 ++-- .../RoomMemberProfileFragment.kt | 24 ------------------- .../RoomMemberProfileViewModel.kt | 3 --- .../RoomMemberProfileViewState.kt | 1 - .../devices/DeviceListEpoxyController.kt | 4 ---- .../devices/DeviceTrustInfoActionFragment.kt | 3 --- .../CrossSigningEpoxyController.kt | 1 - .../CrossSigningSettingsFragment.kt | 1 - .../CrossSigningSettingsViewModel.kt | 1 - .../features/settings/devices/DeviceItem.kt | 2 -- .../DeviceVerificationInfoBottomSheet.kt | 3 +-- ...iceVerificationInfoBottomSheetViewModel.kt | 3 ++- .../DeviceVerificationInfoEpoxyController.kt | 5 +--- .../settings/devices/DevicesController.kt | 2 -- .../settings/devices/DevicesViewModel.kt | 2 +- 35 files changed, 78 insertions(+), 92 deletions(-) diff --git a/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/keysbackup/KeysBackupTest.kt b/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/keysbackup/KeysBackupTest.kt index 81096424d5..03dba96d40 100644 --- a/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/keysbackup/KeysBackupTest.kt +++ b/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/keysbackup/KeysBackupTest.kt @@ -25,7 +25,14 @@ import im.vector.matrix.android.api.session.Session import im.vector.matrix.android.api.session.crypto.keysbackup.KeysBackupService import im.vector.matrix.android.api.session.crypto.keysbackup.KeysBackupState import im.vector.matrix.android.api.session.crypto.keysbackup.KeysBackupStateListener -import im.vector.matrix.android.common.* +import im.vector.matrix.android.common.CommonTestHelper +import im.vector.matrix.android.common.CryptoTestData +import im.vector.matrix.android.common.CryptoTestHelper +import im.vector.matrix.android.common.SessionTestParams +import im.vector.matrix.android.common.TestConstants +import im.vector.matrix.android.common.TestMatrixCallback +import im.vector.matrix.android.common.assertDictEquals +import im.vector.matrix.android.common.assertListEquals import im.vector.matrix.android.internal.crypto.MXCRYPTO_ALGORITHM_MEGOLM_BACKUP import im.vector.matrix.android.internal.crypto.MegolmSessionData import im.vector.matrix.android.internal.crypto.OutgoingRoomKeyRequest @@ -36,12 +43,18 @@ import im.vector.matrix.android.internal.crypto.keysbackup.model.rest.KeysVersio import im.vector.matrix.android.internal.crypto.keysbackup.model.rest.KeysVersionResult import im.vector.matrix.android.internal.crypto.model.ImportRoomKeysResult import im.vector.matrix.android.internal.crypto.model.OlmInboundGroupSessionWrapper -import org.junit.Assert.* +import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse +import org.junit.Assert.assertNotNull +import org.junit.Assert.assertNull +import org.junit.Assert.assertTrue +import org.junit.Assert.fail import org.junit.FixMethodOrder import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.MethodSorters -import java.util.* +import java.util.ArrayList +import java.util.Collections import java.util.concurrent.CountDownLatch @RunWith(AndroidJUnit4::class) @@ -298,7 +311,10 @@ class KeysBackupTest : InstrumentedTest { val decryption = keysBackup.pkDecryptionFromRecoveryKey(keyBackupCreationInfo.recoveryKey) assertNotNull(decryption) // - Check decryptKeyBackupData() returns stg - val sessionData = keysBackup.decryptKeyBackupData(keyBackupData, session.olmInboundGroupSession!!.sessionIdentifier(), cryptoTestData.roomId, decryption!!) + val sessionData = keysBackup + .decryptKeyBackupData(keyBackupData, + session.olmInboundGroupSession!!.sessionIdentifier(), + cryptoTestData.roomId, decryption!!) assertNotNull(sessionData) // - Compare the decrypted megolm key with the original one assertKeysEquals(session.exportKeys(), sessionData) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/crosssigning/CrossSigningService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/crosssigning/CrossSigningService.kt index 99423ed094..b01f42cd84 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/crosssigning/CrossSigningService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/crosssigning/CrossSigningService.kt @@ -21,7 +21,6 @@ import im.vector.matrix.android.api.MatrixCallback import im.vector.matrix.android.api.util.Optional import im.vector.matrix.android.internal.crypto.crosssigning.DeviceTrustResult import im.vector.matrix.android.internal.crypto.crosssigning.UserTrustResult -import im.vector.matrix.android.internal.crypto.model.rest.SignatureUploadResponse import im.vector.matrix.android.internal.crypto.model.rest.UserPasswordAuth interface CrossSigningService { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/sas/SasVerificationTransaction.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/sas/SasVerificationTransaction.kt index 0f2f4a581f..912e2b65e8 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/sas/SasVerificationTransaction.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/sas/SasVerificationTransaction.kt @@ -33,5 +33,4 @@ interface SasVerificationTransaction : VerificationTransaction { fun userHasVerifiedShortCode() fun shortCodeDoesNotMatch() - } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/sas/VerificationService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/sas/VerificationService.kt index aafc64d267..a491014682 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/sas/VerificationService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/crypto/sas/VerificationService.kt @@ -52,7 +52,11 @@ interface VerificationService { /** * Request a key verification from another user using toDevice events. */ - fun requestKeyVerificationInDMs(methods: List, otherUserId: String, roomId: String, localId: String? = LocalEcho.createLocalEchoId()): PendingVerificationRequest + fun requestKeyVerificationInDMs(methods: List, + otherUserId: String, + roomId: String, + localId: String? = LocalEcho.createLocalEchoId() + ): PendingVerificationRequest fun declineVerificationRequestInDMs(otherUserId: String, otherDeviceId: String, transactionId: String, roomId: String) 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 4e0cf5f6af..5ffa4b2166 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 @@ -16,7 +16,6 @@ package im.vector.matrix.android.internal.crypto -import com.zhuinden.monarchy.Monarchy import dagger.Binds import dagger.Module import dagger.Provides diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/DefaultCryptoService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/DefaultCryptoService.kt index 0f4358e725..1ceb45939c 100755 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/DefaultCryptoService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/DefaultCryptoService.kt @@ -155,7 +155,6 @@ internal class DefaultCryptoService @Inject constructor( private val cryptoCoroutineScope: CoroutineScope ) : CryptoService { - init { verificationService.cryptoService = this } @@ -188,7 +187,7 @@ internal class DefaultCryptoService @Inject constructor( .configureWith(SetDeviceNameTask.Params(deviceId, deviceName)) { this.callback = object : MatrixCallback { override fun onSuccess(data: Unit) { - //bg refresh of crypto device + // bg refresh of crypto device downloadKeys(listOf(credentials.userId), true, object : MatrixCallback> {}) callback.onSuccess(data) } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/crosssigning/DefaultCrossSigningService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/crosssigning/DefaultCrossSigningService.kt index 9df145b0ef..cbde0dc046 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/crosssigning/DefaultCrossSigningService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/crosssigning/DefaultCrossSigningService.kt @@ -27,7 +27,6 @@ import im.vector.matrix.android.internal.crypto.MXOlmDevice import im.vector.matrix.android.internal.crypto.MyDeviceInfoHolder import im.vector.matrix.android.internal.crypto.model.CryptoCrossSigningKey import im.vector.matrix.android.internal.crypto.model.KeyUsage -import im.vector.matrix.android.internal.crypto.model.rest.KeysQueryResponse import im.vector.matrix.android.internal.crypto.model.rest.UploadSignatureQueryBuilder import im.vector.matrix.android.internal.crypto.model.rest.UserPasswordAuth import im.vector.matrix.android.internal.crypto.store.IMXCryptoStore @@ -245,7 +244,7 @@ internal class DefaultCrossSigningService @Inject constructor( resetTrustOnKeyChange() uploadSignaturesTask.configureWith(UploadSignaturesTask.Params(uploadSignatureQueryBuilder.build())) { - //this.retryCount = 3 + // this.retryCount = 3 this.constraints = TaskConstraints(true) this.callback = object : MatrixCallback { override fun onSuccess(data: Unit) { @@ -254,7 +253,7 @@ internal class DefaultCrossSigningService @Inject constructor( } override fun onFailure(failure: Throwable) { - //Clear + // Clear Timber.e(failure, "## CrossSigning - Failed to upload signatures") clearSigningKeys() } @@ -584,8 +583,13 @@ internal class DefaultCrossSigningService @Inject constructor( */ val otherSSKSignature = otherDevice.signatures?.get(otherUserId)?.get("ed25519:${otherKeys.selfSigningKey()?.unpaddedBase64PublicKey}") - ?: return legacyFallbackTrust(locallyTrusted, DeviceTrustResult.MissingDeviceSignature(otherDeviceId, otherKeys.selfSigningKey()?.unpaddedBase64PublicKey - ?: "")) + ?: return legacyFallbackTrust( + locallyTrusted, + DeviceTrustResult.MissingDeviceSignature(otherDeviceId, otherKeys.selfSigningKey() + ?.unpaddedBase64PublicKey + ?: "" + ) + ) // Check bob's device is signed by bob's SSK try { @@ -606,7 +610,6 @@ internal class DefaultCrossSigningService @Inject constructor( } override fun onUsersDeviceUpdate(users: List) { - Timber.d("## CrossSigning - onUsersDeviceUpdate for ${users.size} users") users.forEach { otherUserId -> diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/UploadSignatureQueryBuilder.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/UploadSignatureQueryBuilder.kt index ba877afedd..f4e71c7dca 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/UploadSignatureQueryBuilder.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/model/rest/UploadSignatureQueryBuilder.kt @@ -38,7 +38,11 @@ data class UploadSignatureQueryBuilder( fun build(): Map> { val map = HashMap>() - val usersList = (deviceInfoList.map { it.userId } + signingKeyInfoList.mapNotNull { it.userId }).distinct() + val usersList = ( + deviceInfoList.map { it.userId } + + signingKeyInfoList + .map { it.userId } + ).distinct() usersList.forEach { userID -> val userMap = HashMap() diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/store/db/RealmCryptoStore.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/store/db/RealmCryptoStore.kt index c80035fe7e..7f4d4c0c0a 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/store/db/RealmCryptoStore.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/store/db/RealmCryptoStore.kt @@ -365,7 +365,11 @@ internal class RealmCryptoStore(private val realmConfiguration: RealmConfigurati override fun getLiveDeviceList(userId: String): LiveData> { val liveData = monarchy.findAllMappedWithChanges( - { realm: Realm -> realm.where().equalTo(UserEntityFields.USER_ID, userId) }, + { realm: Realm -> + realm + .where() + .equalTo(UserEntityFields.USER_ID, userId) + }, { entity -> entity.devices.map { CryptoMapper.mapToModel(it) } } @@ -929,7 +933,7 @@ internal class RealmCryptoStore(private val realmConfiguration: RealmConfigurati val xInfoEntities = realm.where(CrossSigningInfoEntity::class.java) .findAll() xInfoEntities?.forEach { info -> - //Need to ignore mine + // Need to ignore mine if (info.userId != credentials.userId) { info.crossSigningKeys.forEach { it.trustLevelEntity = null @@ -969,7 +973,10 @@ internal class RealmCryptoStore(private val realmConfiguration: RealmConfigurati override fun getLiveCrossSigningInfo(userId: String): LiveData> { val liveData = monarchy.findAllMappedWithChanges( - { realm: Realm -> realm.where().equalTo(UserEntityFields.USER_ID, userId) }, + { realm: Realm -> + realm.where() + .equalTo(UserEntityFields.USER_ID, userId) + }, { entity -> MXCrossSigningInfo( userId = userId, @@ -1011,7 +1018,7 @@ internal class RealmCryptoStore(private val realmConfiguration: RealmConfigurati } else { // Just override existing, caller should check and untrust id needed existing = CrossSigningInfoEntity.getOrCreate(realm, userId) - // existing.crossSigningKeys.forEach { it.deleteFromRealm() } + // existing.crossSigningKeys.forEach { it.deleteFromRealm() } val xkeys = RealmList() info.crossSigningKeys.forEach { cryptoCrossSigningKey -> xkeys.add( diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/store/db/RealmCryptoStoreMigration.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/store/db/RealmCryptoStoreMigration.kt index d7116ef440..6839f6995b 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/store/db/RealmCryptoStoreMigration.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/store/db/RealmCryptoStoreMigration.kt @@ -49,7 +49,6 @@ internal object RealmCryptoStoreMigration : RealmMigration { .addField(TrustLevelEntityFields.LOCALLY_VERIFIED, Boolean::class.java) .setNullable(TrustLevelEntityFields.LOCALLY_VERIFIED, true) - val keyInfoEntitySchema = realm.schema.create("KeyInfoEntity") .addField(KeyInfoEntityFields.PUBLIC_KEY_BASE64, String::class.java) .addField(KeyInfoEntityFields.SIGNATURES, String::class.java) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/tasks/UploadSignaturesTask.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/tasks/UploadSignaturesTask.kt index ce74806843..fdaf14bfdb 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/tasks/UploadSignaturesTask.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/tasks/UploadSignaturesTask.kt @@ -34,8 +34,7 @@ internal class DefaultUploadSignaturesTask @Inject constructor( private val eventBus: EventBus ) : UploadSignaturesTask { - override suspend fun execute(params: UploadSignaturesTask.Params): Unit { - + override suspend fun execute(params: UploadSignaturesTask.Params) { try { val response = executeRequest(eventBus) { apiCall = cryptoApi.uploadSignatures(params.signatures) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultVerificationService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultVerificationService.kt index 2fa32b1b98..9d7e531750 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultVerificationService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/DefaultVerificationService.kt @@ -383,7 +383,7 @@ internal class DefaultVerificationService @Inject constructor( val existing = getExistingTransaction(otherUserId, tid) when (startReq.method) { - VERIFICATION_METHOD_SAS -> { + VERIFICATION_METHOD_SAS -> { when (existing) { is SasVerificationTransaction -> { // should cancel both! @@ -400,8 +400,9 @@ internal class DefaultVerificationService @Inject constructor( ?.filterIsInstance(SasVerificationTransaction::class.java) ?.takeIf { it.isNotEmpty() } ?.also { - // Multiple keyshares between two devices: any two devices may only have at most one key verification in flight at a time. - Timber.v("## SAS onStartRequestReceived - There is already a transaction with this user ${startReq.transactionID}") + // Multiple keyshares between two devices: + // any two devices may only have at most one key verification in flight at a time. + Timber.v("## SAS onStartRequestReceived - Already a transaction with this user ${startReq.transactionID}") } ?.forEach { it.cancel(CancelCode.UnexpectedMessage) @@ -443,7 +444,7 @@ internal class DefaultVerificationService @Inject constructor( return CancelCode.UnexpectedMessage } } - else ->{ + else -> { Timber.e("## SAS onStartRequestReceived - unknown method ${startReq.method}") return CancelCode.UnknownMethod } @@ -882,7 +883,9 @@ internal class DefaultVerificationService @Inject constructor( val methodValues = if (crossSigningService.isCrossSigningEnabled()) { // Add reciprocate method if application declares it can scan or show QR codes // Not sure if it ok to do that (?) - val reciprocateMethod = methods.firstOrNull { it == VerificationMethod.QR_CODE_SCAN || it == VerificationMethod.QR_CODE_SHOW }?.let { listOf(VERIFICATION_METHOD_RECIPROCATE) }.orEmpty() + val reciprocateMethod = methods + .firstOrNull { it == VerificationMethod.QR_CODE_SCAN || it == VerificationMethod.QR_CODE_SHOW } + ?.let { listOf(VERIFICATION_METHOD_RECIPROCATE) }.orEmpty() methods.map { it.toValue() } + reciprocateMethod } else { // Filter out SCAN and SHOW qr code method diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/SASDefaultVerificationTransaction.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/SASDefaultVerificationTransaction.kt index a879cdb797..495326d59d 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/SASDefaultVerificationTransaction.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/SASDefaultVerificationTransaction.kt @@ -27,7 +27,6 @@ import im.vector.matrix.android.api.session.events.model.EventType import im.vector.matrix.android.internal.crypto.actions.SetDeviceVerificationAction import im.vector.matrix.android.internal.crypto.crosssigning.DeviceTrustLevel import im.vector.matrix.android.internal.crypto.model.MXKey -import im.vector.matrix.android.internal.crypto.model.rest.SignatureUploadResponse import im.vector.matrix.android.internal.crypto.store.IMXCryptoStore import im.vector.matrix.android.internal.extensions.toUnsignedInt import im.vector.matrix.android.internal.util.withoutPrefix diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/qrcode/DefaultQrCodeVerificationTransaction.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/qrcode/DefaultQrCodeVerificationTransaction.kt index 60216600f0..9dafd4ff51 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/qrcode/DefaultQrCodeVerificationTransaction.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/verification/qrcode/DefaultQrCodeVerificationTransaction.kt @@ -24,7 +24,6 @@ import im.vector.matrix.android.api.session.crypto.sas.VerificationTxState import im.vector.matrix.android.api.session.events.model.EventType import im.vector.matrix.android.internal.crypto.actions.SetDeviceVerificationAction import im.vector.matrix.android.internal.crypto.crosssigning.DeviceTrustLevel -import im.vector.matrix.android.internal.crypto.model.rest.SignatureUploadResponse import im.vector.matrix.android.internal.crypto.store.IMXCryptoStore import im.vector.matrix.android.internal.crypto.verification.DefaultVerificationTransaction import im.vector.matrix.android.internal.crypto.verification.VerificationInfo @@ -135,7 +134,6 @@ internal class DefaultQrCodeVerificationTransaction( } } } - } if (!canTrustOtherUserMasterKey && toVerifyDeviceIds.isEmpty()) { diff --git a/vector/src/main/java/im/vector/riotx/core/ui/list/GenericItemWithValue.kt b/vector/src/main/java/im/vector/riotx/core/ui/list/GenericItemWithValue.kt index 8e338c4bc4..37c65aa4cc 100644 --- a/vector/src/main/java/im/vector/riotx/core/ui/list/GenericItemWithValue.kt +++ b/vector/src/main/java/im/vector/riotx/core/ui/list/GenericItemWithValue.kt @@ -66,7 +66,6 @@ abstract class GenericItemWithValue : VectorEpoxyModel next.expirationTimestamp!!) { diff --git a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileController.kt b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileController.kt index 411295333c..5a18588daa 100644 --- a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileController.kt +++ b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileController.kt @@ -78,7 +78,7 @@ class RoomMemberProfileController @Inject constructor( if (state.userMXCrossSigningInfo != null) { // Cross signing is enabled for this user if (state.userMXCrossSigningInfo.isTrusted()) { - //User is trusted + // User is trusted val icon = if (state.allDevicesAreTrusted.invoke() == true) R.drawable.ic_shield_trusted else R.drawable.ic_shield_warning @@ -95,7 +95,7 @@ class RoomMemberProfileController @Inject constructor( action = { callback?.onShowDeviceList() } ) } else { - //Not trusted, propose to verify + // Not trusted, propose to verify if (!state.isMine) { buildProfileAction( id = "learn_more", diff --git a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileFragment.kt b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileFragment.kt index de3a3902a9..5a711f5cdb 100644 --- a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileFragment.kt @@ -101,7 +101,6 @@ class RoomMemberProfileFragment @Inject constructor( } } } - } } @@ -148,31 +147,8 @@ class RoomMemberProfileFragment @Inject constructor( override fun onTapVerify() { viewModel.handle(RoomMemberProfileAction.VerifyUser()) -// if (state.isRoomEncrypted) { -// if( !state.isMine && state.userMXCrossSigningInfo?.isTrusted == false) { -// // we want to verify -// // TODO do not use current room, find or create DM -// VerificationBottomSheet.withArgs( -// state.roomId, -// state.userId -// ).show(parentFragmentManager, "REQ") -// } -// } } -// override fun onTapVerify() = withState(viewModel) { state -> -// if (state.isRoomEncrypted) { -// if( !state.isMine && state.userMXCrossSigningInfo?.isTrusted == false) { -// // we want to verify -// // TODO do not use current room, find or create DM -// VerificationBottomSheet.withArgs( -// state.roomId, -// state.userId -// ).show(parentFragmentManager, "REQ") -// } -// } -// } - override fun onShowDeviceList() = withState(viewModel) { DeviceListBottomSheet.newInstance(it.userId).show(parentFragmentManager, "DEV_LIST") } diff --git a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileViewModel.kt b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileViewModel.kt index cf8e678f97..aba6274dff 100644 --- a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileViewModel.kt @@ -48,9 +48,7 @@ import im.vector.matrix.rx.unwrap import im.vector.riotx.R import im.vector.riotx.core.platform.VectorViewModel import im.vector.riotx.core.resources.StringProvider -import im.vector.riotx.core.utils.DataSource import im.vector.riotx.core.utils.LiveEvent -import im.vector.riotx.core.utils.PublishDataSource import io.reactivex.Observable import io.reactivex.functions.BiFunction import kotlinx.coroutines.Dispatchers @@ -149,7 +147,6 @@ class RoomMemberProfileViewModel @AssistedInject constructor(@Assisted private v ) } } - } private fun observeRoomMemberSummary(room: Room) { diff --git a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileViewState.kt b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileViewState.kt index 2cf96441dc..b9044b1d36 100644 --- a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileViewState.kt +++ b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileViewState.kt @@ -23,7 +23,6 @@ import com.airbnb.mvrx.Uninitialized import im.vector.matrix.android.api.session.crypto.crosssigning.MXCrossSigningInfo import im.vector.matrix.android.api.session.room.model.PowerLevelsContent import im.vector.matrix.android.api.util.MatrixItem -import im.vector.matrix.android.internal.crypto.model.CryptoDeviceInfo data class RoomMemberProfileViewState( val userId: String, diff --git a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/devices/DeviceListEpoxyController.kt b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/devices/DeviceListEpoxyController.kt index 525927c8f5..50a87b24a4 100644 --- a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/devices/DeviceListEpoxyController.kt +++ b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/devices/DeviceListEpoxyController.kt @@ -55,7 +55,6 @@ class DeviceListEpoxyController @Inject constructor(private val stringProvider: } when (data.cryptoDevices) { Uninitialized -> { - } is Loading -> { loadingItem { @@ -64,12 +63,10 @@ class DeviceListEpoxyController @Inject constructor(private val stringProvider: } } is Success -> { - val deviceList = data.cryptoDevices.invoke().sortedByDescending { it.isVerified } - // Build top header val allGreen = deviceList.fold(true, { prev, device -> prev && device.isVerified @@ -96,7 +93,6 @@ class DeviceListEpoxyController @Inject constructor(private val stringProvider: id("sessions") style(GenericItem.STYLE.BIG_TEXT) title(stringProvider.getString(R.string.room_member_profile_sessions_section_title)) - } if (deviceList.isEmpty()) { // Can this really happen? diff --git a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/devices/DeviceTrustInfoActionFragment.kt b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/devices/DeviceTrustInfoActionFragment.kt index 7ecff5409b..6c9de742bc 100644 --- a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/devices/DeviceTrustInfoActionFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/devices/DeviceTrustInfoActionFragment.kt @@ -34,7 +34,6 @@ class DeviceTrustInfoActionFragment @Inject constructor( val epoxyController: DeviceTrustInfoEpoxyController ) : VectorBaseFragment(), DeviceTrustInfoEpoxyController.InteractionListener { - override fun getLayoutResId() = R.layout.bottom_sheet_generic_list private val viewModel: DeviceListBottomSheetViewModel by parentFragmentViewModel(DeviceListBottomSheetViewModel::class) @@ -66,5 +65,3 @@ class DeviceTrustInfoActionFragment @Inject constructor( viewModel.manuallyVerify(device) } } - - diff --git a/vector/src/main/java/im/vector/riotx/features/settings/crosssigning/CrossSigningEpoxyController.kt b/vector/src/main/java/im/vector/riotx/features/settings/crosssigning/CrossSigningEpoxyController.kt index 87cb74ce80..ccaa3d749d 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/crosssigning/CrossSigningEpoxyController.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/crosssigning/CrossSigningEpoxyController.kt @@ -118,7 +118,6 @@ class CrossSigningEpoxyController @Inject constructor( id("loading") } } else { - val crossSigningKeys = data.crossSigningInfo crossSigningKeys?.masterKey()?.let { diff --git a/vector/src/main/java/im/vector/riotx/features/settings/crosssigning/CrossSigningSettingsFragment.kt b/vector/src/main/java/im/vector/riotx/features/settings/crosssigning/CrossSigningSettingsFragment.kt index 6c756ec445..168855b201 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/crosssigning/CrossSigningSettingsFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/crosssigning/CrossSigningSettingsFragment.kt @@ -122,4 +122,3 @@ class CrossSigningSettingsFragment @Inject constructor( viewModel.handle(CrossSigningAction.InitializeCrossSigning()) } } - diff --git a/vector/src/main/java/im/vector/riotx/features/settings/crosssigning/CrossSigningSettingsViewModel.kt b/vector/src/main/java/im/vector/riotx/features/settings/crosssigning/CrossSigningSettingsViewModel.kt index b7343eac7a..cba86da599 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/crosssigning/CrossSigningSettingsViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/crosssigning/CrossSigningSettingsViewModel.kt @@ -99,7 +99,6 @@ class CrossSigningSettingsViewModel @AssistedInject constructor(@Assisted privat copy(isUploadingKeys = true) } session.getCrossSigningService().initializeCrossSigning(auth, object : MatrixCallback { - override fun onSuccess(data: Unit) { setState { copy(isUploadingKeys = false) diff --git a/vector/src/main/java/im/vector/riotx/features/settings/devices/DeviceItem.kt b/vector/src/main/java/im/vector/riotx/features/settings/devices/DeviceItem.kt index 17728b5c1a..267c0eb676 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/devices/DeviceItem.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/devices/DeviceItem.kt @@ -17,7 +17,6 @@ package im.vector.riotx.features.settings.devices import android.graphics.Typeface -import android.view.View import android.view.ViewGroup import android.widget.ImageView import android.widget.TextView @@ -110,7 +109,6 @@ abstract class DeviceItem : VectorEpoxyModel() { it.isVisible = false } } - } class Holder : VectorEpoxyHolder() { diff --git a/vector/src/main/java/im/vector/riotx/features/settings/devices/DeviceVerificationInfoBottomSheet.kt b/vector/src/main/java/im/vector/riotx/features/settings/devices/DeviceVerificationInfoBottomSheet.kt index d819a7af24..9863134cb7 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/devices/DeviceVerificationInfoBottomSheet.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/devices/DeviceVerificationInfoBottomSheet.kt @@ -43,7 +43,7 @@ class DeviceVerificationInfoBottomSheet : VectorBaseBottomSheetDialogFragment(), private val viewModel: DeviceVerificationInfoBottomSheetViewModel by fragmentViewModel(DeviceVerificationInfoBottomSheetViewModel::class) - private val sharedViewModel: DevicesViewModel by parentFragmentViewModel (DevicesViewModel::class) + private val sharedViewModel: DevicesViewModel by parentFragmentViewModel(DevicesViewModel::class) @Inject lateinit var deviceVerificationInfoViewModelFactory: DeviceVerificationInfoBottomSheetViewModel.Factory @@ -91,5 +91,4 @@ class DeviceVerificationInfoBottomSheet : VectorBaseBottomSheetDialogFragment(), dismiss() sharedViewModel.handle(action) } - } diff --git a/vector/src/main/java/im/vector/riotx/features/settings/devices/DeviceVerificationInfoBottomSheetViewModel.kt b/vector/src/main/java/im/vector/riotx/features/settings/devices/DeviceVerificationInfoBottomSheetViewModel.kt index 5fb61a1d95..b4eee1fdf7 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/devices/DeviceVerificationInfoBottomSheetViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/devices/DeviceVerificationInfoBottomSheetViewModel.kt @@ -47,7 +47,8 @@ class DeviceVerificationInfoBottomSheetViewModel @AssistedInject constructor(@As companion object : MvRxViewModelFactory { @JvmStatic - override fun create(viewModelContext: ViewModelContext, state: DeviceVerificationInfoBottomSheetViewState): DeviceVerificationInfoBottomSheetViewModel? { + override fun create(viewModelContext: ViewModelContext, state: DeviceVerificationInfoBottomSheetViewState) + : DeviceVerificationInfoBottomSheetViewModel? { val fragment: DeviceVerificationInfoBottomSheet = (viewModelContext as FragmentViewModelContext).fragment() return fragment.deviceVerificationInfoViewModelFactory.create(state) } diff --git a/vector/src/main/java/im/vector/riotx/features/settings/devices/DeviceVerificationInfoEpoxyController.kt b/vector/src/main/java/im/vector/riotx/features/settings/devices/DeviceVerificationInfoEpoxyController.kt index 111dda6962..d2e7fff215 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/devices/DeviceVerificationInfoEpoxyController.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/devices/DeviceVerificationInfoEpoxyController.kt @@ -22,11 +22,9 @@ import im.vector.riotx.core.epoxy.dividerItem import im.vector.riotx.core.epoxy.loadingItem import im.vector.riotx.core.resources.ColorProvider import im.vector.riotx.core.resources.StringProvider -import im.vector.riotx.core.resources.UserPreferencesProvider import im.vector.riotx.core.ui.list.GenericItem import im.vector.riotx.core.ui.list.genericItem import im.vector.riotx.features.crypto.verification.epoxy.bottomSheetVerificationActionItem -import im.vector.riotx.features.home.AvatarRenderer import javax.inject.Inject class DeviceVerificationInfoEpoxyController @Inject constructor(private val stringProvider: StringProvider, @@ -43,7 +41,6 @@ class DeviceVerificationInfoEpoxyController @Inject constructor(private val stri id("loading") } } else { - if (device.isVerified) { genericItem { id("trust${device.deviceId}") @@ -85,7 +82,7 @@ class DeviceVerificationInfoEpoxyController @Inject constructor(private val stri } if (device.deviceId != session.sessionParams.credentials.deviceId) { - //Add the delete option + // Add the delete option dividerItem { id("d2") } diff --git a/vector/src/main/java/im/vector/riotx/features/settings/devices/DevicesController.kt b/vector/src/main/java/im/vector/riotx/features/settings/devices/DevicesController.kt index e3c8e78034..769a540a1a 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/devices/DevicesController.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/devices/DevicesController.kt @@ -29,7 +29,6 @@ import im.vector.riotx.core.epoxy.errorWithRetryItem import im.vector.riotx.core.epoxy.loadingItem import im.vector.riotx.core.error.ErrorFormatter import im.vector.riotx.core.resources.StringProvider -import im.vector.riotx.core.ui.list.genericFooterItem import im.vector.riotx.core.ui.list.genericItemHeader import im.vector.riotx.features.settings.VectorPreferences import javax.inject.Inject @@ -97,7 +96,6 @@ class DevicesController @Inject constructor(private val errorFormatter: ErrorFor // Other devices if (devices.size > 1) { - genericItemHeader { id("others") text(stringProvider.getString(R.string.devices_other_devices)) diff --git a/vector/src/main/java/im/vector/riotx/features/settings/devices/DevicesViewModel.kt b/vector/src/main/java/im/vector/riotx/features/settings/devices/DevicesViewModel.kt index f9e28e35e0..e24f561a70 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/devices/DevicesViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/devices/DevicesViewModel.kt @@ -96,7 +96,7 @@ class DevicesViewModel @AssistedInject constructor(@Assisted initialState: Devic override fun transactionCreated(tx: VerificationTransaction) {} override fun transactionUpdated(tx: VerificationTransaction) { - if(tx.state == VerificationTxState.Verified) { + if (tx.state == VerificationTxState.Verified) { refreshDevicesList() } }