mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 12:07:28 +00:00
Merge develop into the PreviewParam rename
The 174 commits develop gained since this branch was cut touch preview data in three ways, and each is resolved so the flipped konsist rule still holds across the merged tree. Two screens the branch had renamed were deleted upstream by "Remove the account provider search screen and homeserver resolver": the changeaccountprovider and searchaccountprovider packages. Their deletion wins, so ChangeAccountProviderStatePreviewParam, SearchAccountProviderStatePreviewParam and the two views that used them go with them rather than coming back under the new name. Two preview classes develop added still carried the old suffix and are renamed here, along with the `@PreviewParameter` reference in each view: GlobalSearchStateProvider -> GlobalSearchStatePreviewParam and SendFailureDialogStateProvider -> SendFailureDialogStatePreviewParam. Everything else merged textually. No production class extending PreviewParameterProvider is left with a `Provider` name, and no reference to any of the 194 renamed names survives outside the CHANGES.md entry that records a past pull request title.
This commit is contained in:
+29
-3
@@ -39,6 +39,10 @@ class LinkNewDesktopHandler(
|
||||
LinkDesktopStep.Uninitialized
|
||||
)
|
||||
|
||||
/**
|
||||
* A [StateFlow] that emits the current step of the link desktop process.
|
||||
* It starts with [LinkDesktopStep.Uninitialized] and will emit other steps as they occur.
|
||||
*/
|
||||
val stepFlow: StateFlow<LinkDesktopStep>
|
||||
get() = linkDesktopStepFlow.asStateFlow()
|
||||
|
||||
@@ -53,15 +57,31 @@ class LinkNewDesktopHandler(
|
||||
timerJob = null
|
||||
}
|
||||
|
||||
fun createNewHandler() {
|
||||
resetJobs()
|
||||
handler = matrixClient.createLinkDesktopHandler().getOrNull()
|
||||
/**
|
||||
* Starts (or restarts) a timer that will emit an error in [stepFlow] after 2 minutes.
|
||||
*/
|
||||
fun startTimer() {
|
||||
timerJob?.cancel()
|
||||
timerJob = sessionScope.launch {
|
||||
delay(2.minutes)
|
||||
linkDesktopStepFlow.emit(LinkDesktopStep.Error(ErrorType.Expired("Scanning QrCode took too long.")))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new [LinkDesktopHandler] and cancels any existing job.
|
||||
* This should be called when the user wants to retry scanning a QR code.
|
||||
*/
|
||||
fun createNewHandler() {
|
||||
currentJob?.cancel()
|
||||
currentJob = null
|
||||
handler = matrixClient.createLinkDesktopHandler().getOrNull()
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the state of the handler and cancels any existing job.
|
||||
* This should be called when the user wants to start over.
|
||||
*/
|
||||
fun reset() {
|
||||
resetJobs()
|
||||
sessionScope.launch {
|
||||
@@ -69,6 +89,12 @@ class LinkNewDesktopHandler(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the scanned QR code data.
|
||||
* This should be called when the user scans a QR code.
|
||||
*
|
||||
* @param data The scanned QR code data as a byte array.
|
||||
*/
|
||||
fun onScannedCode(data: ByteArray) {
|
||||
resetJobs()
|
||||
val currentHandler = handler
|
||||
|
||||
+8
@@ -263,6 +263,8 @@ class LinkNewDeviceFlowNode(
|
||||
}
|
||||
LinkDeviceType.Desktop -> {
|
||||
linkNewDesktopHandler.reset()
|
||||
// Ensure unlock state does not last longer than the timeout for scanning the QR code, so start the timer after unlock
|
||||
linkNewDesktopHandler.startTimer()
|
||||
backstack.push(NavTarget.DesktopNotice)
|
||||
}
|
||||
}
|
||||
@@ -278,10 +280,14 @@ class LinkNewDeviceFlowNode(
|
||||
NavTarget.DesktopNotice -> {
|
||||
val callback = object : DesktopNoticeNode.Callback {
|
||||
override fun navigateBack() {
|
||||
// Stop the timer when the user leaves the screen (user will have to authenticate again)
|
||||
linkNewDesktopHandler.reset()
|
||||
backstack.pop()
|
||||
}
|
||||
|
||||
override fun navigateToQrCodeScanner() {
|
||||
// Start again the timer when the user enters the next screen (they clicked on "Ready to scan")
|
||||
linkNewDesktopHandler.startTimer()
|
||||
backstack.push(NavTarget.DesktopScanQrCode)
|
||||
}
|
||||
}
|
||||
@@ -290,6 +296,8 @@ class LinkNewDeviceFlowNode(
|
||||
NavTarget.DesktopScanQrCode -> {
|
||||
val callback = object : ScanQrCodeNode.Callback {
|
||||
override fun cancel() {
|
||||
// start again the timer when the user goes back to the DesktopNoticeNode
|
||||
linkNewDesktopHandler.startTimer()
|
||||
backstack.pop()
|
||||
}
|
||||
}
|
||||
|
||||
+22
@@ -40,9 +40,19 @@ class LinkNewMobileHandler(
|
||||
LinkMobileStep.Uninitialized
|
||||
)
|
||||
|
||||
/**
|
||||
* A [StateFlow] that emits the current step of the link mobile process.
|
||||
* It starts with [LinkMobileStep.Uninitialized] and will emit other steps as they occur.
|
||||
*/
|
||||
val stepFlow: StateFlow<LinkMobileStep>
|
||||
get() = linkMobileStepFlow.asStateFlow()
|
||||
|
||||
/**
|
||||
* Creates a new [LinkMobileHandler] and starts the linking process.
|
||||
* If [forRotating] is true, it indicates that this is a rotation of the QR code.
|
||||
*
|
||||
* @param forRotating Whether this is a rotation of the QR code. Defaults to false.
|
||||
*/
|
||||
fun createAndStartNewHandler(forRotating: Boolean = false) {
|
||||
Timber.tag(loggerTag.value).d("createAndStartNewHandler()")
|
||||
currentJob?.cancel()
|
||||
@@ -62,6 +72,10 @@ class LinkNewMobileHandler(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the handler and cancels any ongoing job.
|
||||
* This will also emit [LinkMobileStep.Uninitialized] to the [stepFlow].
|
||||
*/
|
||||
fun reset() {
|
||||
currentJob?.cancel()
|
||||
currentJob = null
|
||||
@@ -70,10 +84,18 @@ class LinkNewMobileHandler(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotates the QR code by creating a new handler and starting the linking process.
|
||||
* This is typically called when a timeout occurs for the current QR code.
|
||||
*/
|
||||
fun rotateQrCode() {
|
||||
createAndStartNewHandler(forRotating = true)
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the case where there are too many QR code rotations.
|
||||
* This will reset the handler and emit an error to the [stepFlow].
|
||||
*/
|
||||
fun onTooManyRotation() {
|
||||
reset()
|
||||
sessionScope.launch {
|
||||
|
||||
Reference in New Issue
Block a user