diff --git a/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/verification/SASTest.kt b/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/verification/SASTest.kt index 6b254efd5d..79670bb21e 100644 --- a/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/verification/SASTest.kt +++ b/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/verification/SASTest.kt @@ -66,7 +66,7 @@ class SASTest : InstrumentedTest { val bobVerificationService = bobSession!!.getVerificationService() val bobTxCreatedLatch = CountDownLatch(1) - val bobListener = object : VerificationService.VerificationListener { + val bobListener = object : VerificationService.Listener { override fun transactionUpdated(tx: VerificationTransaction) { bobTxCreatedLatch.countDown() } @@ -102,7 +102,7 @@ class SASTest : InstrumentedTest { // Let's cancel from alice side val cancelLatch = CountDownLatch(1) - val bobListener2 = object : VerificationService.VerificationListener { + val bobListener2 = object : VerificationService.Listener { override fun transactionUpdated(tx: VerificationTransaction) { if (tx.transactionId == txID) { val immutableState = (tx as SASDefaultVerificationTransaction).state @@ -149,7 +149,7 @@ class SASTest : InstrumentedTest { var cancelReason: CancelCode? = null val cancelLatch = CountDownLatch(1) - val bobListener = object : VerificationService.VerificationListener { + val bobListener = object : VerificationService.Listener { override fun transactionUpdated(tx: VerificationTransaction) { if (tx.transactionId == tid && tx.state is VerificationTxState.Cancelled) { cancelReason = (tx.state as VerificationTxState.Cancelled).cancelCode @@ -174,7 +174,7 @@ class SASTest : InstrumentedTest { val aliceUserID = aliceSession.myUserId val aliceDevice = aliceSession.getMyDevice().deviceId - val aliceListener = object : VerificationService.VerificationListener { + val aliceListener = object : VerificationService.Listener { override fun transactionUpdated(tx: VerificationTransaction) { if ((tx as IncomingSasVerificationTransaction).uxState === IncomingSasVerificationTransaction.UxState.SHOW_ACCEPT) { (tx as IncomingSasVerificationTransaction).performAccept() @@ -312,7 +312,7 @@ class SASTest : InstrumentedTest { val aliceCreatedLatch = CountDownLatch(2) val aliceCancelledLatch = CountDownLatch(2) val createdTx = mutableListOf() - val aliceListener = object : VerificationService.VerificationListener { + val aliceListener = object : VerificationService.Listener { override fun transactionCreated(tx: VerificationTransaction) { createdTx.add(tx as SASDefaultVerificationTransaction) aliceCreatedLatch.countDown() @@ -354,7 +354,7 @@ class SASTest : InstrumentedTest { var startReq: KeyVerificationStart? = null val aliceAcceptedLatch = CountDownLatch(1) - val aliceListener = object : VerificationService.VerificationListener { + val aliceListener = object : VerificationService.Listener { override fun transactionUpdated(tx: VerificationTransaction) { if ((tx as SASDefaultVerificationTransaction).state === VerificationTxState.OnAccepted) { val at = tx as SASDefaultVerificationTransaction @@ -366,7 +366,7 @@ class SASTest : InstrumentedTest { } aliceVerificationService.addListener(aliceListener) - val bobListener = object : VerificationService.VerificationListener { + val bobListener = object : VerificationService.Listener { override fun transactionUpdated(tx: VerificationTransaction) { if ((tx as IncomingSasVerificationTransaction).uxState === IncomingSasVerificationTransaction.UxState.SHOW_ACCEPT) { val at = tx as IncomingSasVerificationTransaction @@ -407,7 +407,7 @@ class SASTest : InstrumentedTest { val bobVerificationService = bobSession!!.getVerificationService() val aliceSASLatch = CountDownLatch(1) - val aliceListener = object : VerificationService.VerificationListener { + val aliceListener = object : VerificationService.Listener { override fun transactionUpdated(tx: VerificationTransaction) { val uxState = (tx as OutgoingSasVerificationTransaction).uxState when (uxState) { @@ -421,7 +421,7 @@ class SASTest : InstrumentedTest { aliceVerificationService.addListener(aliceListener) val bobSASLatch = CountDownLatch(1) - val bobListener = object : VerificationService.VerificationListener { + val bobListener = object : VerificationService.Listener { override fun transactionUpdated(tx: VerificationTransaction) { val uxState = (tx as IncomingSasVerificationTransaction).uxState when (uxState) { @@ -463,7 +463,7 @@ class SASTest : InstrumentedTest { val bobVerificationService = bobSession!!.getVerificationService() val aliceSASLatch = CountDownLatch(1) - val aliceListener = object : VerificationService.VerificationListener { + val aliceListener = object : VerificationService.Listener { override fun transactionUpdated(tx: VerificationTransaction) { val uxState = (tx as OutgoingSasVerificationTransaction).uxState when (uxState) { @@ -480,7 +480,7 @@ class SASTest : InstrumentedTest { aliceVerificationService.addListener(aliceListener) val bobSASLatch = CountDownLatch(1) - val bobListener = object : VerificationService.VerificationListener { + val bobListener = object : VerificationService.Listener { override fun transactionUpdated(tx: VerificationTransaction) { val uxState = (tx as IncomingSasVerificationTransaction).uxState when (uxState) { diff --git a/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/verification/qrcode/VerificationTest.kt b/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/verification/qrcode/VerificationTest.kt index adde452619..61ea0f35b4 100644 --- a/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/verification/qrcode/VerificationTest.kt +++ b/matrix-sdk-android/src/androidTest/java/im/vector/matrix/android/internal/crypto/verification/qrcode/VerificationTest.kt @@ -178,7 +178,7 @@ class VerificationTest : InstrumentedTest { var bobReadyPendingVerificationRequest: PendingVerificationRequest? = null val latch = CountDownLatch(2) - val aliceListener = object : VerificationService.VerificationListener { + val aliceListener = object : VerificationService.Listener { override fun verificationRequestUpdated(pr: PendingVerificationRequest) { // Step 4: Alice receive the ready request if (pr.isReady) { @@ -189,7 +189,7 @@ class VerificationTest : InstrumentedTest { } aliceVerificationService.addListener(aliceListener) - val bobListener = object : VerificationService.VerificationListener { + val bobListener = object : VerificationService.Listener { override fun verificationRequestCreated(pr: PendingVerificationRequest) { // Step 2: Bob accepts the verification request bobVerificationService.readyPendingVerificationInDMs( 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 9df2dc9a89..d3b33cb6f5 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 @@ -30,9 +30,9 @@ import im.vector.matrix.android.internal.crypto.verification.PendingVerification */ interface VerificationService { - fun addListener(listener: VerificationListener) + fun addListener(listener: Listener) - fun removeListener(listener: VerificationListener) + fun removeListener(listener: Listener) /** * Mark this device as verified manually @@ -95,7 +95,8 @@ interface VerificationService { otherUserId: String, transactionId: String): Boolean - interface VerificationListener { + interface Listener { + // TODO javadoc fun verificationRequestCreated(pr: PendingVerificationRequest) {} fun verificationRequestUpdated(pr: PendingVerificationRequest) {} 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 d7589ede5c..00ac4a6986 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 @@ -176,9 +176,9 @@ internal class DefaultVerificationService @Inject constructor( } } - private var listeners = ArrayList() + private var listeners = ArrayList() - override fun addListener(listener: VerificationService.VerificationListener) { + override fun addListener(listener: VerificationService.Listener) { uiHandler.post { if (!listeners.contains(listener)) { listeners.add(listener) @@ -186,7 +186,7 @@ internal class DefaultVerificationService @Inject constructor( } } - override fun removeListener(listener: VerificationService.VerificationListener) { + override fun removeListener(listener: VerificationService.Listener) { uiHandler.post { listeners.remove(listener) } 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 bc97ac5ee5..f890aef91b 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 @@ -56,7 +56,7 @@ import kotlin.collections.HashMap @Singleton class KeyRequestHandler @Inject constructor(private val context: Context) : RoomKeysRequestListener, - VerificationService.VerificationListener { + VerificationService.Listener { private val alertsToRequests = HashMap>() 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 99c28b52dc..8765dbc0d9 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 @@ -34,7 +34,7 @@ import javax.inject.Singleton * Listens to the VerificationManager and add a new notification when an incoming request is detected. */ @Singleton -class IncomingVerificationRequestHandler @Inject constructor(private val context: Context) : VerificationService.VerificationListener { +class IncomingVerificationRequestHandler @Inject constructor(private val context: Context) : VerificationService.Listener { private var session: Session? = null diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/verification/VerificationBottomSheetViewModel.kt b/vector/src/main/java/im/vector/riotx/features/crypto/verification/VerificationBottomSheetViewModel.kt index a9f9987c7f..85b878fe16 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/verification/VerificationBottomSheetViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/verification/VerificationBottomSheetViewModel.kt @@ -60,7 +60,7 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(@Assisted ini @Assisted args: VerificationBottomSheet.VerificationArgs, private val session: Session) : VectorViewModel(initialState), - VerificationService.VerificationListener { + VerificationService.Listener { init { session.getVerificationService().addListener(this) diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/verification/choose/VerificationChooseMethodViewModel.kt b/vector/src/main/java/im/vector/riotx/features/crypto/verification/choose/VerificationChooseMethodViewModel.kt index 17d8c1578d..bdb07ed0dc 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/verification/choose/VerificationChooseMethodViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/verification/choose/VerificationChooseMethodViewModel.kt @@ -45,7 +45,7 @@ data class VerificationChooseMethodViewState( class VerificationChooseMethodViewModel @AssistedInject constructor( @Assisted initialState: VerificationChooseMethodViewState, private val session: Session -) : VectorViewModel(initialState), VerificationService.VerificationListener { +) : VectorViewModel(initialState), VerificationService.Listener { override fun transactionCreated(tx: VerificationTransaction) { transactionUpdated(tx) diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/verification/emoji/VerificationEmojiCodeViewModel.kt b/vector/src/main/java/im/vector/riotx/features/crypto/verification/emoji/VerificationEmojiCodeViewModel.kt index 69d106a4b4..637b7d7cc9 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/verification/emoji/VerificationEmojiCodeViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/verification/emoji/VerificationEmojiCodeViewModel.kt @@ -52,7 +52,7 @@ data class VerificationEmojiCodeViewState( class VerificationEmojiCodeViewModel @AssistedInject constructor( @Assisted initialState: VerificationEmojiCodeViewState, private val session: Session -) : VectorViewModel(initialState), VerificationService.VerificationListener { +) : VectorViewModel(initialState), VerificationService.Listener { init { withState { state -> 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 1862412cb5..b931f5d66f 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 @@ -52,7 +52,7 @@ data class DevicesViewState( class DevicesViewModel @AssistedInject constructor(@Assisted initialState: DevicesViewState, private val session: Session) - : VectorViewModel(initialState), VerificationService.VerificationListener { + : VectorViewModel(initialState), VerificationService.Listener { @AssistedInject.Factory interface Factory {