Skip to content

Conversation

@bmarty
Copy link
Member

@bmarty bmarty commented Dec 16, 2025

Content

Add, behind a feature flag, a new "Link new device" entry in the main preference screen.
When this user click on this new entry, they have the option to either show a QR code so that another device can login to the same account using "Sign in with Qr Code" button (this flow is working), or scan a QrCode displayed on a client able to render a QrCode to get logged in (this flow is not working yet).

Need matrix-org/matrix-rust-sdk#5957 to be finalized, but will be done in a follow up PR.
Lint errors are due to translation still in the default location. A full Localazy sync will be performed just before merging the PR (so once approved).

Motivation and context

Simplify login and verifyng another device on another client.

Epic: https://github.com/element-hq/element-internal/issues/697

Screenshots / GIFs

On the video below, another Android device is scanning the QR code and get logged in and verified at the end of the flow. Not that the feature to login using a QrCode already exist and this PR does not touch it.

Screen_recording_20251218_122012.mp4

Tests

  • Enable feature flag "QR Code Login"
  • Log in to a session on a homeserver which support log in new device using QrCode (element.io for instance, matrix.org does not have this support yet)
  • On the main menu click on "Link new device"
  • Select "Mobile device"
  • A Qr code is displayed
  • It should be possible to finish the flow by scanning the QrCode using another device.

If log in to a home server which does not support QrCode, an error should be displayed when the user select "Link new device"

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

  • Changes have been tested on an Android device or Android emulator with API 24
  • UI change has been tested on both light and dark themes
  • Accessibility has been taken into account. See https://github.com/element-hq/element-x-android/blob/develop/CONTRIBUTING.md#accessibility
  • Pull request is based on the develop branch
  • Pull request title will be used in the release note, it clearly define what will change for the user
  • Pull request includes screenshots or videos if containing UI changes
  • You've made a self review of your PR

@bmarty bmarty added the PR-Feature For a new feature label Dec 16, 2025
@ElementBot
Copy link
Collaborator

ElementBot commented Dec 16, 2025

Warnings
⚠️

gradle/libs.versions.toml#L8 - A newer version of org.jetbrains.kotlin.plugin.serialization than 2.2.20 is available: 2.3.0

⚠️

gradle/libs.versions.toml#L10 - A newer version of com.google.devtools.ksp:symbol-processing-api than 2.2.20-2.0.2 is available: 2.2.20-2.0.4

⚠️

gradle/libs.versions.toml#L18 - A newer version of androidx.lifecycle:lifecycle-runtime-ktx than 2.9.2 is available: 2.10.0

⚠️

gradle/libs.versions.toml#L19 - A newer version of androidx.activity:activity-compose than 1.11.0 is available: 1.12.2

⚠️

gradle/libs.versions.toml#L20 - A newer version of androidx.media3:media3-ui than 1.8.0 is available: 1.9.0

⚠️

gradle/libs.versions.toml#L25 - A newer version of androidx.compose:compose-bom than 2025.07.00 is available: 2025.12.01

⚠️

gradle/libs.versions.toml#L47 - A newer version of io.element.android:wysiwyg-compose than 2.40.0 is available: 2.41.0

⚠️

gradle/libs.versions.toml#L49 - A newer version of dev.chrisbanes.haze:haze-materials than 1.6.10 is available: 1.7.1

⚠️

gradle/libs.versions.toml#L55 - A newer version of dev.zacsweers.metro:runtime than 0.8.2 is available: 0.9.1

⚠️

gradle/libs.versions.toml#L65 - A newer version of org.jetbrains.kotlinx:kover-gradle-plugin than 0.9.1 is available: 0.9.4

⚠️

gradle/libs.versions.toml#L81 - A newer version of com.google.firebase:firebase-bom than 34.6.0 is available: 34.7.0

⚠️

gradle/libs.versions.toml#L85 - A newer version of com.google.crypto.tink:tink-android than 1.19.0 is available: 1.20.0

⚠️

gradle/libs.versions.toml#L118 - A newer version of androidx.webkit:webkit than 1.14.0 is available: 1.15.0

⚠️

gradle/libs.versions.toml#L168 - A newer version of org.robolectric:robolectric than 4.15.1 is available: 4.16

⚠️

gradle/libs.versions.toml#L170 - A newer version of io.github.sergio-sastre.ComposablePreviewScanner:android than 0.7.2 is available: 0.8.0

⚠️

gradle/libs.versions.toml#L180 - A newer version of org.matrix.rustcomponents:sdk-android than 25.12.10 is available: 25.12.17

⚠️

gradle/libs.versions.toml#L209 - A newer version of org.maplibre.gl:android-sdk than 12.2.2 is available: 12.3.0

⚠️

gradle/libs.versions.toml#L215 - A newer version of com.google.zxing:core than 3.3.3 is available: 3.5.4

⚠️

gradle/libs.versions.toml#L222 - A newer version of com.posthog:posthog-android than 3.26.0 is available: 3.27.2

⚠️

gradle/libs.versions.toml#L223 - A newer version of io.sentry:sentry-android than 8.28.0 is available: 8.29.0

⚠️

gradle/libs.versions.toml#L270 - A newer version of org.sonarqube than 7.2.0.6526 is available: 7.2.2.6593

⚠️

libraries/qrcode/src/main/kotlin/io/element/android/libraries/qrcode/QrCodeImage.kt#L61 - Modifier parameter should be the first optional parameter

Generated by 🚫 dangerJS against 798132f

@github-actions
Copy link
Contributor

github-actions bot commented Dec 16, 2025

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/LaBxx8

@codecov
Copy link

codecov bot commented Dec 16, 2025

Codecov Report

❌ Patch coverage is 89.52703% with 93 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.53%. Comparing base (5ebb615) to head (798132f).
⚠️ Report is 93 commits behind head on develop.

Files with missing lines Patch % Lines
.../android/libraries/matrix/impl/RustMatrixClient.kt 0.00% 16 Missing ⚠️
...atures/linknewdevice/impl/LinkNewDesktopHandler.kt 58.33% 6 Missing and 4 partials ⚠️
...inknewdevice/impl/screens/error/ErrorScreenType.kt 0.00% 8 Missing ⚠️
...e/impl/screens/number/component/NumberTextField.kt 89.39% 3 Missing and 4 partials ⚠️
...nknewdevice/HumanQrGrantLoginExceptionExtension.kt 12.50% 2 Missing and 5 partials ⚠️
.../linknewdevice/impl/screens/scan/ScanQrCodeView.kt 92.59% 1 Missing and 5 partials ⚠️
...eatures/linknewdevice/impl/LinkNewMobileHandler.kt 76.19% 1 Missing and 4 partials ⚠️
...wdevice/impl/screens/root/LinkNewDeviceRootView.kt 93.33% 0 Missing and 5 partials ⚠️
...id/libraries/matrix/api/linknewdevice/ErrorType.kt 37.50% 5 Missing ⚠️
...nknewdevice/impl/screens/number/EnterNumberView.kt 92.45% 2 Missing and 2 partials ⚠️
... and 13 more
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #5909      +/-   ##
===========================================
+ Coverage    81.40%   81.53%   +0.12%     
===========================================
  Files         2485     2532      +47     
  Lines        66239    67120     +881     
  Branches      8414     8517     +103     
===========================================
+ Hits         53924    54728     +804     
- Misses        9224     9263      +39     
- Partials      3091     3129      +38     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

bmarty and others added 5 commits December 16, 2025 16:14
@bmarty bmarty force-pushed the feature/bma/qrCodeLogin branch from 73b9916 to ec10a0b Compare December 16, 2025 17:38
@bmarty bmarty marked this pull request as ready for review December 18, 2025 11:15
@bmarty bmarty requested a review from a team as a code owner December 18, 2025 11:15
@bmarty bmarty requested review from jmartinesp and removed request for a team December 18, 2025 11:15
@bmarty bmarty changed the title Link new device using QrCode. DRAFT Link new device using QrCode - First version Dec 18, 2025
@jmartinesp
Copy link
Member

jmartinesp commented Dec 18, 2025

I'm just looking at the functionality for now, I think I found a small issue:

screen-20251218-130155.mp4

If you exit that screen and start the process again everything seems to work. If not, after some time I see a 'something went wrong' screen, and when tapping on 'start over' I'm taken back to the 'what type of device do you want to link?' screen, with an additional error dialog on the screen.


The error I mentioned (after an almost 60s timeout):

error.mp4

Copy link
Member

@jmartinesp jmartinesp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The flow works quite well overall, the UX is nice, good job! I did find some issues with cancelling the flow, which I displayed above. There are also some minor improvements to the code we could make.

import io.element.android.libraries.core.log.logger.LoggerTag

object LoggerTags {
val linkNewDevice = LoggerTag("LinkNewDevice")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this so the tag is used for all the logs in the link new device login instead of having a per-screen one?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tag can be used as a parent tag and so we can get log like this for instance:

elementx: [LinkNewDevice/LinkNewDeviceFlowNode] step: Uninitialized | LinkNewDeviceFlowNode.kt:129

import io.element.android.libraries.androidutils.system.setFullBrightness

@Composable
fun ForceMaxBrightness() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

Comment on lines +214 to +215
# Stick to 3.3.3 because of https://github.com/zxing/zxing/issues/1170
google_zxing = "com.google.zxing:core:3.3.3"
Copy link
Member

@jmartinesp jmartinesp Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should think about replacing zxing_cpp with some google alternative too (there seem to be some 'android integration' ones). Not for this PR, of course.

Comment on lines 81 to 82
var job1: Job? = null
var job2: Job? = null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe make these a bit more descriptive 😅 ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we increase the screenshot size so it contains all list items?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could change the value defined in the declaration of @PreviewWithLargeHeight but maybe do this in a dedicated PR?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be done on a separate PR, yes. Also, since this may continue growing, maybe it would be better to use separa @Preview(height = ...) annotations for day and night so we can customise the value only for this screen.

bmarty and others added 4 commits December 18, 2025 14:48
Translations are not located in the current module. They will be imported in the correct module once the current PR with the Localazy config has been merged.
@bmarty
Copy link
Member Author

bmarty commented Dec 18, 2025

Thanks for the review @jmartinesp. I have fixed the navigation issue you found and another one that I have seen too.
I have also deleted the pending translations, lint should be happy now.

@sonarqubecloud
Copy link

Copy link
Member

@jmartinesp jmartinesp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@bmarty bmarty enabled auto-merge December 18, 2025 14:50
@bmarty bmarty merged commit 3ea10c2 into develop Dec 18, 2025
29 of 30 checks passed
@bmarty bmarty deleted the feature/bma/qrCodeLogin branch December 18, 2025 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR-Feature For a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants