psanford / wormhole-william-mobile

End-to-end encrypted file transfer for Android and iOS. A Magic Wormhole Mobile client.
MIT License
165 stars 16 forks source link

Adds QR code generation for sends #31

Open xxxserxxx opened 1 year ago

xxxserxxx commented 1 year ago

This implements #28. I've done no testing on mobile, but:

  1. It uses a QR library from rsc, which has no C dependencies
  2. It works running the patched app on my laptop, generating QR codes, and receiving (by scannang the codes) from the wormhole-william-mobile app on my phone
  3. I have no reason to expect -- given the simplicity of my changes, and of rsc's QR library -- that it won't work once it's on a mobile device

The QR codes are small, but they scan, and it works as-is. I don't have the Android SDK currently installed on my laptop because it's enormous.

Anyhoo, you said you'd be happy to have a patch for #28, so here it is.

psanford commented 1 year ago

Thanks for this! Overall the code looks good.

It doesn't look like the QR code is being hidden after the transfer has begun. We should use the same logic used for showing and hiding the text transfer code.

The QR code ends up looking blurry on my phone (it still scans). I'm not sure what the cause of that is but it seems like that should be fixable. I think we should also make the image larger. Either some reasonable minimal width or size it based on the size of the viewport.

xxxserxxx commented 1 year ago

I am very unfamiliar with the gioui library, and it's not a trivial library to get into, so I was trying to make the patch as small as possible.

I see what you mean about hiding the QR. Noted.

There's a scaling variable in the QR library (used at ui/ui.go#251), but it doesn't actually scale the pixels; it just makes the image bounds larger. I'm either missing something in the lib API, or we have to manually scale the image.

I see a fuzzy QR as well on the desktop. The only thing I can think that would cause blurriness is if something in the image processing was resulting in a lossy image. It might be worth running a test on the qr library by itself and see how the images it produces look without being filtered through gioui.

I'm going to be unable to work on this for another week or so, but I'll poke around with it when I get back.