-
Notifications
You must be signed in to change notification settings - Fork 731
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
Implement logic for sign in with QR #7369
Conversation
# Conflicts: # library/ui-strings/src/main/res/values/strings.xml # library/ui-styles/src/main/res/values/stylable_sessions_list_header_view.xml # vector-app/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesStateFactory.kt # vector-app/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt # vector/src/main/java/im/vector/app/core/di/MavericksViewModelModule.kt # vector/src/main/java/im/vector/app/features/VectorFeatures.kt # vector/src/main/java/im/vector/app/features/settings/devices/v2/VectorSettingsDevicesFragment.kt # vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionsListHeaderView.kt # vector/src/main/res/layout/fragment_other_sessions.xml # vector/src/main/res/layout/fragment_settings_devices.xml
# Conflicts: # library/ui-strings/src/main/res/values/strings.xml # library/ui-styles/src/main/res/values/stylable_sessions_list_header_view.xml # vector-app/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesStateFactory.kt # vector-app/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt # vector/src/main/java/im/vector/app/core/di/MavericksViewModelModule.kt # vector/src/main/java/im/vector/app/features/VectorFeatures.kt # vector/src/main/java/im/vector/app/features/settings/devices/v2/VectorSettingsDevicesFragment.kt # vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionsListHeaderView.kt # vector/src/main/res/layout/fragment_other_sessions.xml # vector/src/main/res/layout/fragment_settings_devices.xml
|
||
_viewEvents.post(QrCodeLoginViewEvents.NavigateToStatusScreen) | ||
|
||
viewModelScope.launch(Dispatchers.IO) { |
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.
I think it's just calling session.coroutineDispatchers.io
.../main/java/org/matrix/android/sdk/api/rendezvous/transports/SimpleHttpRendezvousTransport.kt
Show resolved
Hide resolved
.../main/java/org/matrix/android/sdk/api/rendezvous/transports/SimpleHttpRendezvousTransport.kt
Show resolved
Hide resolved
.../main/java/org/matrix/android/sdk/api/rendezvous/transports/SimpleHttpRendezvousTransport.kt
Show resolved
Hide resolved
.../main/java/org/matrix/android/sdk/api/rendezvous/transports/SimpleHttpRendezvousTransport.kt
Outdated
Show resolved
Hide resolved
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.
Nice work.
There is a bit of architecture rework to do on the SDK, but I would not block the PR for that.
The only blocking remark is about the logs: #7369 (comment)
matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/rendezvous/RendezvousChannel.kt
Outdated
Show resolved
Hide resolved
matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/rendezvous/RendezvousChannel.kt
Outdated
Show resolved
Hide resolved
...ndroid/src/main/java/org/matrix/android/sdk/api/rendezvous/channels/ECDHRendezvousChannel.kt
Outdated
Show resolved
Hide resolved
} | ||
import org.matrix.android.sdk.api.rendezvous.RendezvousFailureReason | ||
|
||
class RendezvousError(val description: String, val reason: RendezvousFailureReason) : Exception(description) |
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.
You could extend Failure.FeatureFailure()
instead.
class RendezvousError(val description: String, val reason: RendezvousFailureReason) : Exception(description) | |
class RendezvousError(val description: String, val reason: RendezvousFailureReason) : Failure.FeatureFailure() |
|
||
val transport = SimpleHttpRendezvousTransport(parsed.rendezvous.transport.uri) | ||
|
||
return Rendezvous( |
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.
You can return an instance of RendezvousImpl
here.
/** | ||
* Implementation of the Simple HTTP transport MSC3886: https://github.com/matrix-org/matrix-spec-proposals/pull/3886 | ||
*/ | ||
class SimpleHttpRendezvousTransport(rendezvousUri: String?) : RendezvousTransport { |
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.
internal.
QrCodeLoginErrorType.DEVICE_IS_NOT_SUPPORTED -> getString(R.string.qr_code_login_header_failed_device_is_not_supported_description) | ||
QrCodeLoginErrorType.TIMEOUT -> getString(R.string.qr_code_login_header_failed_timeout_description) | ||
QrCodeLoginErrorType.REQUEST_WAS_DENIED -> getString(R.string.qr_code_login_header_failed_denied_description) | ||
private fun getErrorDescription(reason: RendezvousFailureReason): String { |
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.
I would move this method to DefaultErrorFormatter
, and errorType
could be a Throwable.
vector/src/main/java/im/vector/app/features/login/qr/QrCodeLoginViewModel.kt
Outdated
Show resolved
Hide resolved
Co-authored-by: Benoit Marty <benoitm@matrix.org>
…ndezvous/RendezvousChannel.kt Co-authored-by: Benoit Marty <benoitm@matrix.org>
…ndezvous/channels/ECDHRendezvousChannel.kt Co-authored-by: Benoit Marty <benoitm@matrix.org>
…ndezvous/RendezvousChannel.kt Co-authored-by: Benoit Marty <benoitm@matrix.org>
…tor-im/element-android into feature/hughns/qr_code_login
Thank you. Blocker should now be resolved. Re: architecture - I agree this needs work and my plan is to do this when we add in the next round of capabilities about signing in another device from the settings screen in Android. |
.../main/java/org/matrix/android/sdk/api/rendezvous/transports/SimpleHttpRendezvousTransport.kt
Outdated
Show resolved
Hide resolved
...ndroid/src/main/java/org/matrix/android/sdk/api/rendezvous/channels/ECDHRendezvousChannel.kt
Outdated
Show resolved
Hide resolved
…tor-im/element-android into feature/hughns/qr_code_login
SonarCloud Quality Gate failed. |
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.
LGTM, with the reserve of the architecture update in the future. Thanks!
This PR is dependent on #7338. Compare
Type of change
Content
This PR has the logic to implement the UI from #7338
Motivation and context
The motivation is as per #7338
Screenshots / GIFs
See #7338
Tests
Testing requires generating a QR code in Element Web and scanning it in Element Android.
To generate a code in Element Web:
To scan in Android:
- Go back to main screen - Select "I already have an account" - Press EDIT to enter a different homeserver - Enter https://synapse-msc3882.rendezvous.lab.element.dev - Press next - You should then see a new button:
- Press Scan QR code and follow instructions
Tested devices
Checklist
Signed-off-by: Hugh Nimmo-Smith hughns@element.io