Fix QR code signaling

This commit is contained in:
valere 2023-02-03 00:10:05 +01:00
parent 07041d066e
commit 704e14c6a4
2 changed files with 39 additions and 12 deletions

View File

@ -33,6 +33,7 @@ import org.matrix.android.sdk.internal.crypto.network.RequestSender
import org.matrix.android.sdk.internal.crypto.verification.VerificationListenersHolder
import org.matrix.rustcomponents.sdk.crypto.CryptoStoreException
import org.matrix.rustcomponents.sdk.crypto.QrCode
import org.matrix.rustcomponents.sdk.crypto.QrCodeState
import timber.log.Timber
/** Class representing a QR code based verification flow */
@ -97,18 +98,21 @@ internal class QrCodeVerification @AssistedInject constructor(
}
override fun state(): QRCodeVerificationState {
Timber.w("VALR state: weStarted ${inner.weStarted()}")
Timber.w("VALR state: reciprocated ${inner.reciprocated()}")
Timber.w("VALR state: isDone ${inner.isDone()}")
Timber.w("VALR state: hasBeenScanned ${inner.hasBeenScanned()}")
if (inner.hasBeenScanned()) {
return QRCodeVerificationState.WaitingForScanConfirmation
Timber.v("SAS QR state${inner.state()}")
return when (inner.state()) {
// / The QR verification has been started.
QrCodeState.Started -> QRCodeVerificationState.Reciprocated
// / The QR verification has been scanned by the other side.
QrCodeState.Scanned -> QRCodeVerificationState.WaitingForScanConfirmation
// / The scanning of the QR code has been confirmed by us.
QrCodeState.Confirmed -> QRCodeVerificationState.WaitingForOtherDone
// / We have successfully scanned the QR code and are able to send a
// / reciprocation event.
QrCodeState.Reciprocated -> QRCodeVerificationState.WaitingForOtherDone
// / The verification process has been successfully concluded.
QrCodeState.Done -> QRCodeVerificationState.Done
is QrCodeState.Cancelled -> QRCodeVerificationState.Cancelled
}
if (inner.isCancelled()) return QRCodeVerificationState.Cancelled
if (inner.isDone()) return QRCodeVerificationState.Done
return QRCodeVerificationState.Reciprocated
}
/** Get the unique id of this verification */

View File

@ -361,7 +361,30 @@ fun BaseEpoxyVerificationController.renderQrTransaction(transaction: Verificatio
listener { host.listener?.onUserConfirmsQrCodeScanned() }
}
}
QRCodeVerificationState.WaitingForOtherDone,
QRCodeVerificationState.WaitingForOtherDone -> {
bottomSheetVerificationNoticeItem {
id("notice")
apply {
notice(host.stringProvider.getString(R.string.qr_code_scanned_verif_waiting_notice).toEpoxyCharSequence())
}
}
bottomSheetVerificationBigImageItem {
id("image")
roomEncryptionTrustLevel(RoomEncryptionTrustLevel.Trusted)
}
bottomSheetVerificationWaitingItem {
id("waiting")
apply {
if (otherUserItem != null) {
title(host.stringProvider.getString(R.string.qr_code_scanned_verif_waiting, otherUserItem.getBestName()))
} else {
title(host.stringProvider.getString(R.string.qr_code_scanned_verif_waiting, transaction.otherDeviceId.orEmpty()))
}
}
}
}
QRCodeVerificationState.Done -> {
// Done
}