Skip to content

Add QR-code pairing - #22

Merged
mikahatdichlieb merged 4 commits into
mainfrom
feat/qr-pairing
Oct 26, 2026
Merged

mikahatdichlieb merged 4 commits into
mainfrom
feat/qr-pairing

Conversation

@mikahatdichlieb

Copy link
Copy Markdown
Contributor

Summary

  • In-app QR scanner (CameraX + ZXing, fully offline, no Play Services) next to the existing manual server+code entry, which stays unchanged.
  • Registers this app as the handler for daycompass://pair links (matching the server's new QR-pairing format, backend Daycompass/Daycompass#65, not yet merged to backend main), so the system camera or another app can hand off here too.
  • Mandatory confirmation screen showing the server's host (and port) before pairing — scanning or opening a link never pairs automatically.
  • Keeps this client's HTTPS-only fixed design decision: a pairing link with an http server is refused with the existing "Daycompass only connects over HTTPS" message, rather than the warn-and-allow behavior the backend spec permits for other platforms' LAN installs. Confirmed with the maintainer before implementing.
  • Reuses the existing manual-pairing error handling/API client unchanged — both flows end up calling the same DeviceApiClient.pair.

Permissions/manifest surface added (flagging per repo convention): new android.permission.CAMERA (+ optional android.hardware.camera.any feature, so camera-less devices still install and can pair manually) and a new daycompass://pair intent-filter on MainActivity, which now runs singleTask.

New dependencies: androidx.camera:* 1.6.2 and com.google.zxing:core 3.5.4 (zero runtime deps), both Apache-2.0 with no Play Services anywhere in their dependency trees; also androidx.lifecycle:lifecycle-runtime-compose for the non-deprecated LocalLifecycleOwner. gradle/verification-metadata.xml regenerated and reviewed.

Closes #21

Test plan

  • ./gradlew ktlintCheck detekt lint testDebugUnitTest assembleDebug all pass (101 unit tests, 0 failures; 16 new in PairingLinkTest covering link parsing, percent-decoding incl. IPv6+port, and the "confirmation is mandatory" invariant)
  • gitleaks detect — no leaks
  • On a real device/emulator: scan an actual QR code end-to-end, and exercise the camera-permission-denied fallback (not verifiable from the dev environment this was built in)
  • adb shell am start -a android.intent.action.VIEW -d "daycompass://pair?v=1&server=https%3A%2F%2Fexample.org&code=<code>" org.daycompass.android lands on the confirm screen showing example.org, pairs only after confirming

Pure, Android-framework-free parser for the dashboard's QR/link pairing
format, plus the client policy on top of it: a valid https link needs
confirmation before anything happens, an http link is rejected to keep
this app's HTTPS-only design, and a bad version or otherwise malformed
link gets a clear error. Never pairs by itself.
Both are FOSS (Apache-2.0) with no Play Services in their dependency
trees: androidx.camera:* 1.6.2 for the camera preview/frame analysis,
com.google.zxing:core 3.5.4 (zero runtime deps) for decoding. Also adds
androidx.lifecycle:lifecycle-runtime-compose, needed for the
non-deprecated LocalLifecycleOwner this build's warnings-as-errors
settings require.
Adds an in-app scanner (CameraX + ZXing, fully offline) next to the
existing manual server+code entry, and registers this app as the
handler for daycompass://pair links so the system camera or other
apps can hand off to it too. Both paths land on a mandatory
confirmation screen showing the server's host before pairing - never
automatically. Camera permission is asked for only when the person
taps "Scan QR code", and a denial falls back to manual entry.

Adds the CAMERA permission and a new daycompass://pair intent-filter
to the manifest; MainActivity now runs singleTask and scrubs the link
out of the activity's Intent right after reading it, since the link is
a secret until redeemed.
@mikahatdichlieb
mikahatdichlieb merged commit 24282ea into main Oct 26, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add QR-code pairing

1 participant