Automatically try again on partial failed QR scan

This commit is contained in:
Hugh Nimmo-Smith 2022-10-18 00:35:13 +01:00
parent 8cfe6b1363
commit cf1c7515fb
1 changed files with 6 additions and 1 deletions

View File

@ -63,6 +63,7 @@ class QrCodeLoginInstructionsFragment : VectorBaseFragment<FragmentQrCodeLoginIn
val scannedQrCode = QrCodeScannerActivity.getResultText(activityResult.data)
val wasQrCode = QrCodeScannerActivity.getResultIsQrCode(activityResult.data)
Timber.d("Scanned QR code: $scannedQrCode, was QR code: $wasQrCode")
if (wasQrCode && !scannedQrCode.isNullOrBlank()) {
onQrCodeScanned(scannedQrCode)
} else {
@ -76,7 +77,11 @@ class QrCodeLoginInstructionsFragment : VectorBaseFragment<FragmentQrCodeLoginIn
}
private fun onQrCodeScannerFailed() {
Timber.d("QrCodeLoginInstructionsFragment.onQrCodeScannerFailed")
// The user scanned something unexpected, so we try scanning again.
// This seems to happen particularly with the large QRs needed for rendezvous
// especially when the QR is partially off the screen
Timber.d("QrCodeLoginInstructionsFragment.onQrCodeScannerFailed - showing scanner again")
QrCodeScannerActivity.startForResult(requireActivity(), scanActivityResultLauncher)
}
override fun invalidate() = withState(viewModel) { state ->