diff --git a/NOTICE.md b/NOTICE.md index a6a1cf2..e5090bc 100644 --- a/NOTICE.md +++ b/NOTICE.md @@ -123,3 +123,59 @@ English source produced with OpenAI Codex and Anthropic Claude Code language-model assistance. They are not copied from a separate Portuguese dataset. Their review status and translation policy are documented alongside the source files. + +## Gym check-in QR codes + +The gym check-in feature (a saved membership code shown as a QR code on the phone, added by +typing, importing a photo, or scanning with the camera) uses three third-party packages. All are +permissively licensed and compatible with openGym's AGPL, and all load on demand: the QR renderer +and the browser decoder only when a card is shown or scanned, the ML Kit plugin only in the +Android/iOS app. + +### QR/barcode rendering — `lean-qr` + +openGym renders each saved code on the phone with [**lean-qr**](https://github.com/davidje13/lean-qr) +by David Evans, used under the **MIT License** and reproduced below. Only the code's stored value +is kept; the picture is generated fresh from that value each time it is shown, never stored. +It runs the same way in the app and in the browser/PWA. + +``` +MIT License + +Copyright (c) 2021-2025 David Evans + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +``` + +### Camera scan & photo decode in the browser — `jsQR` + +In a browser (including the installed PWA), reading a code from the camera or from an imported +photo uses [**jsQR**](https://github.com/cozmo/jsQR) by Cosmo Wolfe, under the **Apache License +2.0** (text at and in the package's own `LICENSE`). +Where the browser has a native `BarcodeDetector`, that is tried first and jsQR is the fallback. +Video frames are decoded in memory and never uploaded or stored. + +### Camera scan & photo decode in the app — `@capacitor-mlkit/barcode-scanning` + +In the Android/iOS app, reading a code — from the camera or from an imported photo — uses the +[**@capacitor-mlkit/barcode-scanning**](https://github.com/capawesome-team/capacitor-mlkit) plugin +by the Capawesome Team (Robin Genz), a Capacitor wrapper around Google's ML Kit, used under the +**Apache License 2.0**. openGym pins the `7.x` line to stay on Capacitor 7. The full license text is +available at and in the package's own `LICENSE` file. +The decoded string is what openGym keeps; the photo itself is never stored. diff --git a/frontend/android/app/build.gradle b/frontend/android/app/build.gradle index 98868cd..f477595 100644 --- a/frontend/android/app/build.gradle +++ b/frontend/android/app/build.gradle @@ -21,6 +21,12 @@ android { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } + debug { + // Test build installs side-by-side with the real app: its own applicationId, so both + // can live on one device. The name/icon label is overridden by the debug resource + // overlay in src/debug/res. The release build (the "real" app) is untouched. + applicationIdSuffix ".test" + } } } diff --git a/frontend/android/app/capacitor.build.gradle b/frontend/android/app/capacitor.build.gradle index af1bea9..d612497 100644 --- a/frontend/android/app/capacitor.build.gradle +++ b/frontend/android/app/capacitor.build.gradle @@ -9,6 +9,8 @@ android { apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle" dependencies { + implementation project(':aparajita-capacitor-secure-storage') + implementation project(':capacitor-mlkit-barcode-scanning') implementation project(':capacitor-app') implementation project(':capacitor-filesystem') implementation project(':capacitor-local-notifications') diff --git a/frontend/android/app/src/debug/res/values/strings.xml b/frontend/android/app/src/debug/res/values/strings.xml new file mode 100644 index 0000000..eff2a58 --- /dev/null +++ b/frontend/android/app/src/debug/res/values/strings.xml @@ -0,0 +1,7 @@ + + + + OpenGymTest + OpenGymTest + diff --git a/frontend/android/app/src/main/AndroidManifest.xml b/frontend/android/app/src/main/AndroidManifest.xml index d137fe6..d84111a 100644 --- a/frontend/android/app/src/main/AndroidManifest.xml +++ b/frontend/android/app/src/main/AndroidManifest.xml @@ -27,6 +27,10 @@ android:grantUriPermissions="true"> + + + @@ -36,4 +40,6 @@ on Android 12+. Where it isn't granted, scheduling silently falls back to inexact alarms — the reminder still arrives, just not to the minute. --> + + diff --git a/frontend/android/capacitor.settings.gradle b/frontend/android/capacitor.settings.gradle index d757f12..7d3aea6 100644 --- a/frontend/android/capacitor.settings.gradle +++ b/frontend/android/capacitor.settings.gradle @@ -2,6 +2,12 @@ include ':capacitor-android' project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/android/capacitor') +include ':aparajita-capacitor-secure-storage' +project(':aparajita-capacitor-secure-storage').projectDir = new File('../node_modules/@aparajita/capacitor-secure-storage/android') + +include ':capacitor-mlkit-barcode-scanning' +project(':capacitor-mlkit-barcode-scanning').projectDir = new File('../node_modules/@capacitor-mlkit/barcode-scanning/android') + include ':capacitor-app' project(':capacitor-app').projectDir = new File('../node_modules/@capacitor/app/android') diff --git a/frontend/ios/App/App/Info.plist b/frontend/ios/App/App/Info.plist index 8e81fcd..1987307 100644 --- a/frontend/ios/App/App/Info.plist +++ b/frontend/ios/App/App/Info.plist @@ -45,5 +45,7 @@ UIViewControllerBasedStatusBarAppearance + NSCameraUsageDescription + Used to scan your gym membership QR code so you can check in from the app. diff --git a/frontend/ios/App/Podfile b/frontend/ios/App/Podfile index 4faddd0..46ec9a1 100644 --- a/frontend/ios/App/Podfile +++ b/frontend/ios/App/Podfile @@ -11,6 +11,8 @@ install! 'cocoapods', :disable_input_output_paths => true def capacitor_pods pod 'Capacitor', :path => '../../node_modules/@capacitor/ios' pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios' + pod 'AparajitaCapacitorSecureStorage', :path => '../../node_modules/@aparajita/capacitor-secure-storage' + pod 'CapacitorMlkitBarcodeScanning', :path => '../../node_modules/@capacitor-mlkit/barcode-scanning' pod 'CapacitorApp', :path => '../../node_modules/@capacitor/app' pod 'CapacitorFilesystem', :path => '../../node_modules/@capacitor/filesystem' pod 'CapacitorLocalNotifications', :path => '../../node_modules/@capacitor/local-notifications' diff --git a/frontend/package-lock.json b/frontend/package-lock.json index b7956fa..3718b2f 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -10,11 +10,14 @@ "license": "AGPL-3.0-or-later", "dependencies": { "@aparajita/capacitor-secure-storage": "^7.1.6", + "@capacitor-mlkit/barcode-scanning": "^7.5.0", "@capacitor/app": "^7.1.2", "@capacitor/core": "^7.6.8", "@capacitor/filesystem": "^7.1.8", "@capacitor/local-notifications": "^7.0.7", "@capacitor/share": "^7.0.4", + "jsqr": "^1.4.0", + "lean-qr": "^2.7.3", "react": "^19.2.7", "react-dom": "^19.2.7", "react-router-dom": "^7.18.2", @@ -120,6 +123,24 @@ "node": ">=18" } }, + "node_modules/@capacitor-mlkit/barcode-scanning": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@capacitor-mlkit/barcode-scanning/-/barcode-scanning-7.5.0.tgz", + "integrity": "sha512-DBWRykYYLW0YMj/UzlQ0sVGn83mwGAJsbZVxFsd44pppEEy88OO04lxy9Esv5QpnNBIKPjSIqLWmSLuhoFGPaQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/capawesome-team/" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/capawesome" + } + ], + "peerDependencies": { + "@capacitor/core": ">=7.0.0" + } + }, "node_modules/@capacitor/android": { "version": "7.6.8", "resolved": "https://registry.npmjs.org/@capacitor/android/-/android-7.6.8.tgz", @@ -3933,6 +3954,11 @@ "node": "*" } }, + "node_modules/jsqr": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/jsqr/-/jsqr-1.4.0.tgz", + "integrity": "sha512-dxLob7q65Xg2DvstYkRpkYtmKm2sPJ9oFhrhmudT1dZvNFFTlroai3AWSpLey/w5vMcLBXRgOJsbXpdN9HzU/A==" + }, "node_modules/kind-of": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", @@ -3951,6 +3977,14 @@ "node": ">=6" } }, + "node_modules/lean-qr": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/lean-qr/-/lean-qr-2.7.3.tgz", + "integrity": "sha512-/eQryMvYyTL3dSMK/IlvSjUYG0ShQv62owXiFbGkSH+lFZzf4VOsPP+UInAgeUH/rPIyz59uQE9XHRbn9o8SyQ==", + "bin": { + "lean-qr": "cli.mjs" + } + }, "node_modules/lightningcss": { "version": "1.32.0", "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.32.0.tgz", diff --git a/frontend/package.json b/frontend/package.json index a937684..9a6654f 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -15,11 +15,14 @@ "license": "AGPL-3.0-or-later", "dependencies": { "@aparajita/capacitor-secure-storage": "^7.1.6", + "@capacitor-mlkit/barcode-scanning": "^7.5.0", "@capacitor/app": "^7.1.2", "@capacitor/core": "^7.6.8", "@capacitor/filesystem": "^7.1.8", "@capacitor/local-notifications": "^7.0.7", "@capacitor/share": "^7.0.4", + "jsqr": "^1.4.0", + "lean-qr": "^2.7.3", "react": "^19.2.7", "react-dom": "^19.2.7", "react-router-dom": "^7.18.2", diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index dd5f41c..c9d70aa 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -19,6 +19,7 @@ import TimerFlash from './components/TimerFlash.jsx' import Login from './views/Login.jsx' import MobileOnboarding from './views/MobileOnboarding.jsx' import Home from './views/Home.jsx' +import CheckIn from './views/CheckIn.jsx' import Plan from './views/Plan.jsx' import RoutineEdit from './views/RoutineEdit.jsx' import Workout from './views/Workout.jsx' @@ -113,6 +114,9 @@ function Shell() { {!authed ? : needsMobileOnboarding ? : ( } /> + {/* Gym check-in — switched off in Settings, the route falls through to the + catch-all redirect below. */} + {S.checkIn !== false && } />} } /> } /> } /> diff --git a/frontend/src/components/CameraScan.jsx b/frontend/src/components/CameraScan.jsx new file mode 100644 index 0000000..dc04aba --- /dev/null +++ b/frontend/src/components/CameraScan.jsx @@ -0,0 +1,69 @@ +import { useEffect, useRef, useState } from 'react' +import { t } from '../lib/i18n.js' +import { decodeSource } from '../lib/scan-web.js' +import { Button } from '../components/ui.jsx' + +// Live camera scanner for the browser/PWA (the app build uses ML Kit's own UI instead — see +// lib/scan.js). Opens the rear camera into a