-
Notifications
You must be signed in to change notification settings - Fork 187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sign in with QR code #2793
Merged
Merged
Sign in with QR code #2793
Changes from 64 commits
Commits
Show all changes
67 commits
Select commit
Hold shift + click to select a range
855647f
QrCode login: enable and navigate to new Node
bmarty cb0287a
QrCode login: Intro screen with Camera permission
bmarty 188e5e1
QrCode Scanner - WIP
bmarty 8af1d52
to merge if it works.
bmarty ad608bb
WIP changes:
jmartinesp 6f36885
Add new code confirmation and connection not secure screens
jmartinesp 2a30842
WIP: start integrating Rust SDK APIs.
jmartinesp 253ce12
Set up QR code login flow up to failure at the end
jmartinesp c9a2e29
Add localized strings
jmartinesp c83e6c5
Fix multiple `ClientBuilder` instances being created
jmartinesp 92ea84c
Use `checkCodeString` for the check code value instead
jmartinesp 0542be7
Finish the login flow on a successful QR code login
jmartinesp a3ba41c
WIP changes to try to fix verification state
jmartinesp 4803864
Reuse existing code and simplify the flow
jmartinesp 8f35a7b
Remove unnecessary 'link new device' option
jmartinesp a580355
Actually cancel the QR code login and do a cleanup of any lingering c…
jmartinesp 2fc6499
Add some tests to onboarding screen
jmartinesp f4b51f9
Add some tests to QR code intro screen
jmartinesp d6ef9be
Fix generic error screen not being displayed
jmartinesp 5791d32
More tests
jmartinesp 7b2c4ad
Add minimal tests to `QrCodeLoginFlowNode`.
jmartinesp dc435f8
Workaround QrCodeErrorView crash
jmartinesp 18a8fd8
Fix QR code login and verification
jmartinesp def8af2
Fix navigation issues in login flow by actually resetting the state o…
jmartinesp f3b2aa8
Actually `QrCodeLoginManagerImpl` doesn't need to be a singleton
jmartinesp 14775d5
Add and fix tests
jmartinesp bf87cfe
Display the 'establishing secure connection' after the QR code is suc…
jmartinesp 1ec15c0
Update strings
jmartinesp 57e7379
Move `OnboardingConfig` to `appconfig` module
jmartinesp e12c19e
More tests, rename `QrCodeLoginManagerImpl` to `DefaultQrCodeLoginMan…
jmartinesp 6bd9135
Merge remote-tracking branch 'origin/develop' into feature/bma/signIn…
jmartinesp f01de85
Fix merge issues
jmartinesp f4a24cc
Fix lint issues, update strings
jmartinesp 261aef6
Use custom Rust SDK version
jmartinesp e8acd32
Merge remote-tracking branch 'origin/develop' into feature/bma/signIn…
jmartinesp 4141f7a
Adapt to changes in SDK
jmartinesp b38ec55
Fix reading several incorrect QR codes breaking previews
jmartinesp 3b56690
Use SNAPSHOT version for the Rust SDK
jmartinesp 338f819
Only display the preview view when it's receiving video input
jmartinesp fe2e2f3
Add error mapping
jmartinesp a503634
Merge remote-tracking branch 'origin/develop' into feature/bma/signIn…
jmartinesp c70a890
WIP: mapping errors to error screens
jmartinesp fdbcd04
Add error handling (to be tested)
jmartinesp ac1e464
Use Zxing-CPP instead of outdated Zxing `v3.3.3`
jmartinesp 5d474e2
Add new error codes and screens
jmartinesp 1356778
Create `QrCodeLoginScope` to isolate the feature and make sure `QrCod…
jmartinesp 91cdb8c
Merge remote-tracking branch 'origin/develop' into feature/bma/signIn…
jmartinesp 14b21dd
Fix and improve tests and related code
jmartinesp 43276e3
Fix lint issues
jmartinesp c50ec27
Update screenshots
f4e8f3b
Bump Matrix Rust SDK to `v0.2.21` and fix conflicts
jmartinesp 3336a3b
Merge branch 'misc/jme/rust-sdk-0.2.21' into feature/bma/signInWithQr…
jmartinesp 32e1609
Add QR code login FF enabled only for debug and nightly builds
jmartinesp 53f5f09
Add new `QrLoginException.OtherDeviceNotSignedIn` and remove `QrLogin…
jmartinesp bfd27ed
Bump SDK, fix tests and lint issues
jmartinesp 13c5007
Merge remote-tracking branch 'origin/develop' into feature/bma/signIn…
jmartinesp b81556f
Fix more lint issues
jmartinesp fdc1f8f
Update screenshots
9f615c4
Use enum for login flow type
jmartinesp 0688064
Make nodes in qrcode feature use `QrCodeLoginScope` instead of `AppSc…
jmartinesp 6ff42bc
Add bottom padding to the camera preview in `QrCodeScanView`
jmartinesp 13c97ca
Update screenshots
a2ac07a
Update strings
jmartinesp 6b5e558
Merge remote-tracking branch 'origin/develop' into feature/bma/signIn…
jmartinesp 6375be4
Update screenshots
eab9676
Fix lint issues
jmartinesp 7fad1a6
Fix maestro tests
jmartinesp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
*/ | ||
plugins { | ||
id("io.element.android-library") | ||
id("kotlin-parcelize") | ||
} | ||
|
||
android { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...gin/impl/src/main/kotlin/io/element/android/features/login/impl/di/QrCodeLoginBindings.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright (c) 2024 New Vector Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.element.android.features.login.impl.di | ||
|
||
import com.squareup.anvil.annotations.ContributesTo | ||
import io.element.android.features.login.impl.qrcode.QrCodeLoginManager | ||
|
||
@ContributesTo(QrCodeLoginScope::class) | ||
interface QrCodeLoginBindings { | ||
fun qrCodeLoginManager(): QrCodeLoginManager | ||
} |
38 changes: 38 additions & 0 deletions
38
...in/impl/src/main/kotlin/io/element/android/features/login/impl/di/QrCodeLoginComponent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (c) 2024 New Vector Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.element.android.features.login.impl.di | ||
|
||
import com.squareup.anvil.annotations.ContributesTo | ||
import com.squareup.anvil.annotations.MergeSubcomponent | ||
import dagger.Subcomponent | ||
import io.element.android.libraries.architecture.NodeFactoriesBindings | ||
import io.element.android.libraries.di.AppScope | ||
import io.element.android.libraries.di.SingleIn | ||
|
||
@SingleIn(QrCodeLoginScope::class) | ||
@MergeSubcomponent(QrCodeLoginScope::class) | ||
interface QrCodeLoginComponent : NodeFactoriesBindings { | ||
@Subcomponent.Builder | ||
interface Builder { | ||
fun build(): QrCodeLoginComponent | ||
} | ||
|
||
@ContributesTo(AppScope::class) | ||
interface ParentBindings { | ||
fun qrCodeLoginComponentBuilder(): Builder | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
.../login/impl/src/main/kotlin/io/element/android/features/login/impl/di/QrCodeLoginScope.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright (c) 2024 New Vector Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.element.android.features.login.impl.di | ||
|
||
abstract class QrCodeLoginScope private constructor() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...rc/main/kotlin/io/element/android/features/login/impl/qrcode/DefaultQrCodeLoginManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright (c) 2024 New Vector Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.element.android.features.login.impl.qrcode | ||
|
||
import com.squareup.anvil.annotations.ContributesBinding | ||
import io.element.android.features.login.impl.di.QrCodeLoginScope | ||
import io.element.android.libraries.di.SingleIn | ||
import io.element.android.libraries.matrix.api.auth.MatrixAuthenticationService | ||
import io.element.android.libraries.matrix.api.auth.qrlogin.MatrixQrCodeLoginData | ||
import io.element.android.libraries.matrix.api.auth.qrlogin.QrCodeLoginStep | ||
import io.element.android.libraries.matrix.api.auth.qrlogin.QrLoginException | ||
import io.element.android.libraries.matrix.api.core.SessionId | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import kotlinx.coroutines.flow.StateFlow | ||
import javax.inject.Inject | ||
|
||
@SingleIn(QrCodeLoginScope::class) | ||
@ContributesBinding(QrCodeLoginScope::class) | ||
class DefaultQrCodeLoginManager @Inject constructor( | ||
private val authenticationService: MatrixAuthenticationService, | ||
) : QrCodeLoginManager { | ||
private val _currentLoginStep = MutableStateFlow<QrCodeLoginStep>(QrCodeLoginStep.Uninitialized) | ||
override val currentLoginStep: StateFlow<QrCodeLoginStep> = _currentLoginStep | ||
|
||
override suspend fun authenticate(qrCodeLoginData: MatrixQrCodeLoginData): Result<SessionId> { | ||
reset() | ||
|
||
return authenticationService.loginWithQrCode(qrCodeLoginData) { step -> | ||
_currentLoginStep.value = step | ||
}.onFailure { throwable -> | ||
if (throwable is QrLoginException) { | ||
_currentLoginStep.value = QrCodeLoginStep.Failed(throwable) | ||
} | ||
} | ||
} | ||
|
||
override fun reset() { | ||
_currentLoginStep.value = QrCodeLoginStep.Uninitialized | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need a separate component and scope for this? This is just to keep the
StateFlow<QrCodeLoginStep>
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem here is
QrCodeLoginManager
had to be shared by several components (QrCodeLofingFlowNode
,QrCodeScanPresenter
) and for that I needed a singleton if I'm not mistaken. But having a singleton can be troublesome if you aren't super careful with cleaning up its state once you're done working with it, so I created a new component to hold it that will be created when the QR code flow starts and discarded once it's finished.This should ensure the object is shared but can't be leaked in any way, although it's more complex than I intended it to be.