From cfcec0402962e04f7014498d7e596ee5cf65ff0f Mon Sep 17 00:00:00 2001 From: Valere Date: Tue, 24 Mar 2020 14:57:51 +0100 Subject: [PATCH] code cleaning --- .../android/internal/crypto/gossiping/KeyShareTests.kt | 5 +---- .../internal/crypto/IncomingGossipingRequestManager.kt | 1 - .../matrix/android/internal/crypto/SendGossipWorker.kt | 2 -- .../crypto/verification/DefaultVerificationService.kt | 4 ++-- .../session/room/timeline/TimelineEventDecryptor.kt | 2 +- .../features/crypto/keysrequest/KeyRequestHandler.kt | 1 - .../verification/IncomingVerificationRequestHandler.kt | 2 -- .../crypto/verification/VerificationBottomSheet.kt | 1 - .../verification/cancel/VerificationNotMeController.kt | 1 - .../verification/request/VerificationRequestController.kt | 2 -- .../java/im/vector/riotx/features/home/HomeActivity.kt | 1 - .../im/vector/riotx/features/home/HomeDetailFragment.kt | 2 +- .../riotx/features/home/HomeSharedActionViewModel.kt | 8 -------- .../features/home/UnknwonDeviceDetectorSharedViewModel.kt | 4 ++-- .../lifecycle/VectorActivityLifecycleCallbacks.kt | 1 - 15 files changed, 7 insertions(+), 30 deletions(-) diff --git a/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/gossiping/KeyShareTests.kt b/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/gossiping/KeyShareTests.kt index cc8abdb5f8..aec5e6c423 100644 --- a/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/gossiping/KeyShareTests.kt +++ b/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/gossiping/KeyShareTests.kt @@ -187,7 +187,6 @@ class KeyShareTests : InstrumentedTest { @Test fun test_ShareSSSSSecret() { - val aliceSession1 = mTestHelper.createAccount(TestConstants.USER_ALICE, SessionTestParams(true)) mTestHelper.doSync { @@ -203,7 +202,7 @@ class KeyShareTests : InstrumentedTest { val aliceVerificationService1 = aliceSession1.cryptoService().verificationService() val aliceVerificationService2 = aliceSession2.cryptoService().verificationService() - //force keys download + // force keys download mTestHelper.doSync> { aliceSession1.cryptoService().downloadKeys(listOf(aliceSession1.myUserId), true, it) } @@ -245,7 +244,6 @@ class KeyShareTests : InstrumentedTest { aliceVerificationService2.beginKeyVerification(VerificationMethod.SAS, aliceSession1.myUserId, aliceSession1.sessionParams.credentials.deviceId ?: "", txId) - mTestHelper.waitWithLatch { latch -> mTestHelper.retryPeriodicallyWithLatch(latch) { aliceSession1.cryptoService().getDeviceInfo(aliceSession1.myUserId, aliceSession2.sessionParams.credentials.deviceId ?: "")?.isVerified == true @@ -267,5 +265,4 @@ class KeyShareTests : InstrumentedTest { } } } - } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/IncomingGossipingRequestManager.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/IncomingGossipingRequestManager.kt index 608ac35a04..ffdd99f89f 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/IncomingGossipingRequestManager.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/IncomingGossipingRequestManager.kt @@ -287,7 +287,6 @@ internal class IncomingGossipingRequestManager @Inject constructor( }?.let { secretValue -> Timber.i("## GOSSIP processIncomingSecretShareRequest() : Sharing secret $secretName with $device locally trusted") if (isDeviceLocallyVerified == true && hasBeenVerifiedLessThanFiveMinutesFromNow(deviceId)) { - val params = SendGossipWorker.Params( sessionId = sessionId, secretValue = secretValue, diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/SendGossipWorker.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/SendGossipWorker.kt index 75a9eedea5..8a273da338 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/SendGossipWorker.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/SendGossipWorker.kt @@ -99,7 +99,6 @@ internal class SendGossipWorker(context: Context, } } - val payloadJson = mapOf( "type" to EventType.SEND_SECRET, "content" to toDeviceContent.toContent() @@ -112,7 +111,6 @@ internal class SendGossipWorker(context: Context, Timber.e("## Fail to encrypt gossip + ${failure.localizedMessage}") } - cryptoStore.saveGossipingEvent(Event( type = eventType, content = toDeviceContent.toContent(), 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 1a7549d696..dc68fa6b76 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 @@ -456,7 +456,7 @@ internal class DefaultVerificationService @Inject constructor( private suspend fun handleStart(otherUserId: String?, startReq: ValidVerificationInfoStart, txConfigure: (DefaultVerificationTransaction) -> Unit): CancelCode? { - Timber.d("## SAS onStartRequestReceived ${startReq}") + Timber.d("## SAS onStartRequestReceived $startReq") if (otherUserId?.let { checkKeysAreDownloaded(it, startReq.fromDevice) } != null) { val tid = startReq.transactionId var existing = getExistingTransaction(otherUserId, tid) @@ -549,7 +549,7 @@ internal class DefaultVerificationService @Inject constructor( existing.onStartReceived(startReq) return null } else { - Timber.w("## SAS onStartRequestReceived - unexpected message ${startReq.transactionId} / ${existing}") + Timber.w("## SAS onStartRequestReceived - unexpected message ${startReq.transactionId} / $existing") return CancelCode.UnexpectedMessage } } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/TimelineEventDecryptor.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/TimelineEventDecryptor.kt index ebffef33f3..e129513d4b 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/TimelineEventDecryptor.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/TimelineEventDecryptor.kt @@ -128,7 +128,7 @@ internal class TimelineEventDecryptor @Inject constructor( } } } catch (t: Throwable) { - Timber.e( "Failed to decrypt event $eventId, ${t.localizedMessage}") + Timber.e("Failed to decrypt event $eventId, ${t.localizedMessage}") } finally { synchronized(existingRequests) { existingRequests.remove(request) diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/keysrequest/KeyRequestHandler.kt b/vector/src/main/java/im/vector/riotx/features/crypto/keysrequest/KeyRequestHandler.kt index 8fe128ef73..ddb50628d6 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/keysrequest/KeyRequestHandler.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/keysrequest/KeyRequestHandler.kt @@ -38,7 +38,6 @@ import im.vector.matrix.android.internal.crypto.model.rest.DevicesListResponse import im.vector.riotx.R import im.vector.riotx.features.popup.DefaultVectorAlert import im.vector.riotx.features.popup.PopupAlertManager -import im.vector.riotx.features.popup.VectorAlert import timber.log.Timber import java.text.DateFormat import java.text.SimpleDateFormat diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/verification/IncomingVerificationRequestHandler.kt b/vector/src/main/java/im/vector/riotx/features/crypto/verification/IncomingVerificationRequestHandler.kt index 9f12e9eb55..7bb8154484 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/verification/IncomingVerificationRequestHandler.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/verification/IncomingVerificationRequestHandler.kt @@ -78,7 +78,6 @@ class IncomingVerificationRequestHandler @Inject constructor( } else true }) .apply { - matrixItem = session?.getUser(tx.otherUserId ?: "")?.toMatrixItem() contentAction = Runnable { @@ -135,7 +134,6 @@ class IncomingVerificationRequestHandler @Inject constructor( } else true }) .apply { - matrixItem = session?.getUser(pr.otherUserId)?.toMatrixItem() contentAction = Runnable { diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/verification/VerificationBottomSheet.kt b/vector/src/main/java/im/vector/riotx/features/crypto/verification/VerificationBottomSheet.kt index 9edf57e39d..ddd647fd8d 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/verification/VerificationBottomSheet.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/verification/VerificationBottomSheet.kt @@ -155,7 +155,6 @@ class VerificationBottomSheet : VectorBaseBottomSheetDialogFragment() { state.otherUserMxItem?.let { matrixItem -> if (state.isMe) { - avatarRenderer.render(matrixItem, otherUserAvatarImageView) if (state.sasTransactionState == VerificationTxState.Verified || state.qrTransactionState == VerificationTxState.Verified diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/verification/cancel/VerificationNotMeController.kt b/vector/src/main/java/im/vector/riotx/features/crypto/verification/cancel/VerificationNotMeController.kt index 3929c1a166..3978ab8ba5 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/verification/cancel/VerificationNotMeController.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/verification/cancel/VerificationNotMeController.kt @@ -43,7 +43,6 @@ class VerificationNotMeController @Inject constructor( } override fun buildModels() { - bottomSheetVerificationNoticeItem { id("notice") notice(eventHtmlRenderer.render(stringProvider.getString(R.string.verify_not_me_self_verification))) diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/verification/request/VerificationRequestController.kt b/vector/src/main/java/im/vector/riotx/features/crypto/verification/request/VerificationRequestController.kt index 9eb464ab06..60d0d86aeb 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/verification/request/VerificationRequestController.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/verification/request/VerificationRequestController.kt @@ -95,7 +95,6 @@ class VerificationRequestController @Inject constructor( } } - bottomSheetVerificationNoticeItem { id("notice") notice(styledText) @@ -142,7 +141,6 @@ class VerificationRequestController @Inject constructor( } if (state.isMe && state.currentDeviceCanCrossSign) { - dividerItem { id("sep_notMe") } diff --git a/vector/src/main/java/im/vector/riotx/features/home/HomeActivity.kt b/vector/src/main/java/im/vector/riotx/features/home/HomeActivity.kt index 9a9c1241a1..8efcdba15f 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/HomeActivity.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/HomeActivity.kt @@ -42,7 +42,6 @@ import im.vector.riotx.core.pushers.PushersManager import im.vector.riotx.features.disclaimer.showDisclaimerDialog import im.vector.riotx.features.notifications.NotificationDrawerManager import im.vector.riotx.features.popup.PopupAlertManager -import im.vector.riotx.features.popup.VectorAlert import im.vector.riotx.features.popup.VerificationVectorAlert import im.vector.riotx.features.rageshake.VectorUncaughtExceptionHandler import im.vector.riotx.features.settings.VectorPreferences diff --git a/vector/src/main/java/im/vector/riotx/features/home/HomeDetailFragment.kt b/vector/src/main/java/im/vector/riotx/features/home/HomeDetailFragment.kt index 6fbe6f58d3..2fb557eb12 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/HomeDetailFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/HomeDetailFragment.kt @@ -91,7 +91,7 @@ class HomeDetailFragment @Inject constructor( it.unknownSessions.invoke()?.let { unknownDevices -> Timber.v("## Detector - ${unknownDevices.size} Unknown sessions") unknownDevices.forEachIndexed { index, deviceInfo -> - Timber.v("## Detector - #${index} deviceId:${deviceInfo.second.deviceId} lastSeenTs:${deviceInfo.second.lastSeenTs}") + Timber.v("## Detector - #$index deviceId:${deviceInfo.second.deviceId} lastSeenTs:${deviceInfo.second.lastSeenTs}") } if (it.canCrossSign && unknownDevices.isNotEmpty()) { val newest = unknownDevices.first().second diff --git a/vector/src/main/java/im/vector/riotx/features/home/HomeSharedActionViewModel.kt b/vector/src/main/java/im/vector/riotx/features/home/HomeSharedActionViewModel.kt index 7aa9cfa0a1..ecbe460b90 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/HomeSharedActionViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/HomeSharedActionViewModel.kt @@ -16,15 +16,7 @@ package im.vector.riotx.features.home -import androidx.lifecycle.MutableLiveData -import im.vector.matrix.android.api.session.Session -import im.vector.matrix.android.api.util.NoOpCancellable -import im.vector.matrix.android.internal.crypto.model.rest.DeviceInfo -import im.vector.matrix.android.internal.crypto.model.rest.DevicesListResponse -import im.vector.matrix.rx.rx -import im.vector.matrix.rx.singleBuilder import im.vector.riotx.core.platform.VectorSharedActionViewModel -import io.reactivex.android.schedulers.AndroidSchedulers import javax.inject.Inject class HomeSharedActionViewModel @Inject constructor() : VectorSharedActionViewModel() { diff --git a/vector/src/main/java/im/vector/riotx/features/home/UnknwonDeviceDetectorSharedViewModel.kt b/vector/src/main/java/im/vector/riotx/features/home/UnknwonDeviceDetectorSharedViewModel.kt index 6ba194bb54..1693c7fe81 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/UnknwonDeviceDetectorSharedViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/UnknwonDeviceDetectorSharedViewModel.kt @@ -36,8 +36,8 @@ import im.vector.riotx.core.platform.VectorViewModel import io.reactivex.android.schedulers.AndroidSchedulers data class UnknownDevicesState( - val unknownSessions: Async>?> = Uninitialized, - val verifiedSessions: Async>?> = Uninitialized, + val unknownSessions: Async>?> = Uninitialized, + val verifiedSessions: Async>?> = Uninitialized, val canCrossSign: Boolean = false ) : MvRxState diff --git a/vector/src/main/java/im/vector/riotx/features/lifecycle/VectorActivityLifecycleCallbacks.kt b/vector/src/main/java/im/vector/riotx/features/lifecycle/VectorActivityLifecycleCallbacks.kt index 6074309f13..668adc7edd 100644 --- a/vector/src/main/java/im/vector/riotx/features/lifecycle/VectorActivityLifecycleCallbacks.kt +++ b/vector/src/main/java/im/vector/riotx/features/lifecycle/VectorActivityLifecycleCallbacks.kt @@ -20,7 +20,6 @@ import android.app.Activity import android.app.Application import android.os.Bundle import im.vector.riotx.features.popup.PopupAlertManager -import javax.inject.Inject class VectorActivityLifecycleCallbacks constructor(private val popupAlertManager: PopupAlertManager) : Application.ActivityLifecycleCallbacks { override fun onActivityPaused(activity: Activity) {