Skip to content
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

api: create QR codes from any data #6090

Merged
merged 3 commits into from
Oct 22, 2024
Merged

api: create QR codes from any data #6090

merged 3 commits into from
Oct 22, 2024

Conversation

r10s
Copy link
Member

@r10s r10s commented Oct 21, 2024

this PR adds a function that can be used to create any QR code, in a raw form.

this can be used to create add-contact as well as add-second-device QR codes (eg. dc_create_qr_svg(dc_get_securejoin_qr())) - as well as for other QR codes as proxies.

the disadvantage of the rich-formatted QR codes as created by dc_get_securejoin_qr_svg() and dc_backup_provider_get_qr_svg() were:

  • they do not look good and cannot interact with UI layout wise (but also tapping eg. an address is not easily possible)
  • esp. text really looks bad. even with some hacks it stays buggy; the bugs mainly come from different SVG implementation, all need their own quirks
  • accessibility is probably bad as well

we thought that time, SVG is a great thing for QR codes, but apart from basic geometrics, it is not.

so, we avoid text, this also means to avoid putting an avatar in the middle of the QR code (we can put some generic symbol there, eg. different ones for add-contact and add-second-device).

while this looks like a degradation, also other messengers use more raw QR codes. also, we removed many data from the QR code anyway, eg. the email address is no longer there. that time, sharing QR images was more a thing, meanwhile we have invite links, that are much better for that purpose.

in theory, we could also leave the SVG path completely and go for PNG - which we did not that time as PNG and text looks bad, as the system font is not easily usable :) but going for PNG would add further challenges as passing binary data around, and also UI-implemtation-wise, that would be a larger step. so, let's stay with SVG in a form we know is compatible.

the old QR code functions are deprecated.

@r10s r10s force-pushed the r10s/raw-qr-codes branch from cd6cc5e to 2ea6f60 Compare October 21, 2024 22:42
@link2xt link2xt changed the title create QR codes from any data api: create QR codes from any data Oct 21, 2024
src/qr_code_generator.rs Outdated Show resolved Hide resolved
src/qr_code_generator.rs Outdated Show resolved Hide resolved
@r10s r10s force-pushed the r10s/raw-qr-codes branch 3 times, most recently from aad3c99 to 564b475 Compare October 22, 2024 13:09
@r10s r10s marked this pull request as ready for review October 22, 2024 13:20
@r10s r10s requested review from link2xt and adbenitez October 22, 2024 13:28
@r10s r10s force-pushed the r10s/raw-qr-codes branch from 795e495 to 1b2e537 Compare October 22, 2024 13:31
Copy link
Collaborator

@link2xt link2xt left a comment

Choose a reason for hiding this comment

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

JSON-RPC API is missing, but fine to merge without it. Can be added in a separate PR then.

@r10s
Copy link
Member Author

r10s commented Oct 22, 2024

+1 (i left out jsonrpc on purpose, let's see if the api is sufficient :)

@r10s r10s merged commit 839b0e9 into main Oct 22, 2024
37 checks passed
@r10s r10s deleted the r10s/raw-qr-codes branch October 22, 2024 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants