mirror of
https://github.com/element-hq/element-android
synced 2024-11-27 03:48:12 +03:00
Fix QR code signaling
This commit is contained in:
parent
07041d066e
commit
704e14c6a4
2 changed files with 39 additions and 12 deletions
|
@ -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 */
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue