Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.
JavaScript apple-watchbodyweightdockerfitnessfitness-trackergymhealthiosmcpnodejspasskeysprogressive-web-applicationspwareactself-hostedself-hostingvitewebauthnweightliftingworkout-tracker
Android app: the phone vibrates when a rest or a hold ends, and Settings has a Vibrate switch next to Sounds (Discord)
Duarte Santos98b8c4ea068d
diff --git a/frontend/android/app/src/main/AndroidManifest.xml b/frontend/android/app/src/main/AndroidManifest.xmlindex cd316aa9b..bf03f6942 100644--- a/frontend/android/app/src/main/AndroidManifest.xml+++ b/frontend/android/app/src/main/AndroidManifest.xml@@ -43,6 +43,10 @@on Android 12+. Where it isn't granted, scheduling silently falls back to inexactalarms — the reminder still arrives, just not to the minute. --><uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />+ <!-- The buzz at the end of a rest or a hold and on a set tick (navigator.vibrate). The+ WebView drops every vibrate call from an app without this permission, so the phone+ stayed still. A normal permission: granted at install, no prompt. -->+ <uses-permission android:name="android.permission.VIBRATE" /><!-- Gym check-in: scanning a membership QR/barcode with the camera. --><uses-permission android:name="android.permission.CAMERA" /></manifest>diff --git a/frontend/src/App.jsx b/frontend/src/App.jsxindex 9bc2ab4f4..3d981c30e 100644--- a/frontend/src/App.jsx+++ b/frontend/src/App.jsx@@ -5,7 +5,7 @@ import { useUI } from './store/useUI.js'import { bindUI } from './components/ui.jsx'import { ACCENTS, setWeightDecimals } from './lib/format.js'import { setLang, useLang } from './lib/i18n.js'-import { setPlayOnSilent } from './lib/sound.js'+import { setPlayOnSilent, setVibrate } from './lib/sound.js'import { setNav } from './lib/nav.js'import { initBackButton } from './lib/back.js'import { useWakeLock } from './lib/wakelock.js'@@ -65,6 +65,8 @@ function Shell() {// iOS: whether timer sounds get past the ring/silent switch (Settings → Sounds). Page-level,// so it is applied here on load and on change rather than at each beep.useEffect(() => { setPlayOnSilent(!!S.soundOnSilent) }, [S.soundOnSilent])+ // Settings → Vibrate, the same way: one page-level switch rather than a check at each buzz.+ useEffect(() => { setVibrate(S.vibrate !== false) }, [S.vibrate])const isGuest = useStore(s => s.isGuest())const needsMobileOnboarding = useStore(s => s.needsMobileOnboarding)const langV = useLang() // re-renders the whole shell when the language (pack) changesdiff --git a/frontend/src/lib/pt-br-locale.test.js b/frontend/src/lib/pt-br-locale.test.jsindex 680046ae9..2d5b88ab8 100644--- a/frontend/src/lib/pt-br-locale.test.js+++ b/frontend/src/lib/pt-br-locale.test.js@@ -28,10 +28,10 @@ describe('Brazilian Portuguese locale', () => {const fingerprint = createHash('sha256').update(JSON.stringify(inherited)).digest('hex')expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(679)- expect(inherited).toHaveLength(674)+ expect(inherited).toHaveLength(675)// If this fails, review the changed keys and wording before accepting a new hash. From// frontend/: node scripts/pt-br-inheritance-fingerprint.mjs --list- expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('f81cca4b7e73e229526217b8a3825069ee65fb6a5586c143b324038f99499f75')+ expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('ef2572fbca0fee789c583658d22f6fe518a2aacd0f7c639acf6a26083b039385')})test('does not leak European Portuguese UI terms', () => {diff --git a/frontend/src/lib/sound.js b/frontend/src/lib/sound.jsindex 9724ab934..22ac68c63 100644--- a/frontend/src/lib/sound.js+++ b/frontend/src/lib/sound.js@@ -126,5 +126,15 @@ export function setPlayOnSilent(on) {try { navigator.audioSession.type = on ? 'playback' : 'auto' } catch (e) { /* */ }}--export function vibrate(p) { try { navigator.vibrate && navigator.vibrate(p) } catch (e) { /* */ } }+// Settings → "Vibrate" (Discord, asierlama): the buzz at the end of a rest or a hold and on a set+// tick, switched on its own the way Sounds is. A page-level switch like setPlayOnSilent, applied+// by App.jsx, so the places that buzz do not each have to read the profile. On by default.+let buzz = true+export function setVibrate(on) { buzz = on !== false }+// Offered where the browser can buzz at all: iOS has no navigator.vibrate. The Android app needs+// android.permission.VIBRATE in its manifest, without which the WebView drops every call.+export const vibrateSupported = () => typeof navigator !== 'undefined' && typeof navigator.vibrate === 'function'+export function vibrate(p) {+ if (!buzz) return+ try { navigator.vibrate && navigator.vibrate(p) } catch (e) { /* */ }+}diff --git a/frontend/src/lib/sound.test.js b/frontend/src/lib/sound.test.jsindex 7c97446d9..047396bcd 100644--- a/frontend/src/lib/sound.test.js+++ b/frontend/src/lib/sound.test.js@@ -289,3 +289,41 @@ describe('the chime at the end of a rest or a hold', () => {})})+// Discord (asierlama): vibration on or off on its own, the way sound is.+describe('vibrate switch', () => {+ let calls+ beforeEach(() => {+ calls = []+ Object.defineProperty(navigator, 'vibrate', { value: p => { calls.push(p); return true }, configurable: true, writable: true })+ })+ afterEach(() => { delete navigator.vibrate })++ it('buzzes by default', () => {+ sound.vibrate([200, 100, 200])+ expect(calls).toEqual([[200, 100, 200]])+ })++ it('stays still once switched off, and buzzes again once switched back on', () => {+ sound.setVibrate(false)+ sound.vibrate(30)+ expect(calls).toEqual([])+ sound.setVibrate(true)+ sound.vibrate(30)+ expect(calls).toEqual([30])+ })++ it('reads a profile that never chose as on', () => {+ sound.setVibrate(false)+ sound.setVibrate(undefined)+ sound.vibrate(30)+ expect(calls).toEqual([30])+ })++ it('is offered only where the browser can vibrate', () => {+ expect(sound.vibrateSupported()).toBe(true)+ delete navigator.vibrate+ Object.defineProperty(navigator, 'vibrate', { value: undefined, configurable: true, writable: true })+ expect(sound.vibrateSupported()).toBe(false)+ expect(() => sound.vibrate(30)).not.toThrow()+ })+})diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.jsindex d736fc60a..02f2951f9 100644--- a/frontend/src/locales/de.js+++ b/frontend/src/locales/de.js@@ -339,6 +339,7 @@ export default {'Rest timer': 'Pausen-Timer','Sounds': 'Töne','Flash screen when timer ends': 'Bildschirm bei Timer-Ende blinken lassen',+ 'Vibrate': 'Vibration','Weigh in before workouts': 'Vor dem Training wiegen','Asks for your body weight when a workout starts. Off starts the session straight away.': 'Fragt beim Start eines Trainings nach deinem Körpergewicht. Aus startet die Einheit direkt.','No entries yet — log your weight to start the curve.': 'Noch keine Einträge — trag dein Gewicht ein, um die Kurve zu starten.',diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.jsindex 5764277a7..0f55749a4 100644--- a/frontend/src/locales/es.js+++ b/frontend/src/locales/es.js@@ -324,6 +324,7 @@ export default {'Rest timer': 'Temporizador de descanso','Sounds': 'Sonidos','Flash screen when timer ends': 'Hacer parpadear la pantalla al finalizar el temporizador',+ 'Vibrate': 'Vibración','Weigh in before workouts': 'Pesarse antes de entrenar','Asks for your body weight when a workout starts. Off starts the session straight away.': 'Pide tu peso corporal al empezar un entrenamiento. Desactivado, la sesión empieza directamente.','No entries yet — log your weight to start the curve.': 'Sin registros aún — apunta tu peso para empezar la curva.',diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.jsindex 277c4dbc0..38e699557 100644--- a/frontend/src/locales/fr.js+++ b/frontend/src/locales/fr.js@@ -324,6 +324,7 @@ export default {'Rest timer': 'Minuteur de repos','Sounds': 'Sons','Flash screen when timer ends': 'Faire clignoter l’écran à la fin du minuteur',+ 'Vibrate': 'Vibration','Weigh in before workouts': 'Se peser avant la séance','Asks for your body weight when a workout starts. Off starts the session straight away.': 'Demande ton poids au début d’une séance. Désactivé, la séance démarre directement.','No entries yet — log your weight to start the curve.': 'Aucune entrée — note ton poids pour démarrer la courbe.',diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.jsindex 303289210..e6f48515b 100644--- a/frontend/src/locales/hi.js+++ b/frontend/src/locales/hi.js@@ -324,6 +324,7 @@ export default {'Rest timer': 'आराम टाइमर','Sounds': 'ध्वनियाँ','Flash screen when timer ends': 'टाइमर खत्म होने पर स्क्रीन फ्लैश करें',+ 'Vibrate': 'कंपन','Weigh in before workouts': 'वर्कआउट से पहले वज़न दर्ज करना','Asks for your body weight when a workout starts. Off starts the session straight away.': 'वर्कआउट शुरू होते समय आपका वज़न पूछता है। बंद होने पर सेशन सीधे शुरू होता है।','No entries yet — log your weight to start the curve.': 'अभी कोई एंट्री नहीं — ग्राफ़ शुरू करने के लिए वज़न दर्ज करें।',diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.jsindex 28c1a24a8..fc0a98607 100644--- a/frontend/src/locales/hu.js+++ b/frontend/src/locales/hu.js@@ -751,6 +751,7 @@ export default {'Logged sets stay with the original exercise. The replacement will be inserted afterward.': 'A naplózott sorozatok az eredeti gyakorlatnál maradnak. A csere utána kerül beszúrásra.','Rest after each set of this exercise. Leave at 0 to use your default rest timer.': 'Pihenő a gyakorlat minden sorozata után. Hagyd 0-n az alapértelmezett pihenőidőzítőhöz.','Flash screen when timer ends': 'Képernyő villogása, ha lejár az időzítő',+ 'Vibrate': 'Rezgés','Weigh in before workouts': 'Súlymérés edzés előtt','Asks for your body weight when a workout starts. Off starts the session straight away.': 'Edzés indításakor rákérdez a testsúlyodra. Kikapcsolva az edzés azonnal indul.','No entries yet — log your weight to start the curve.': 'Még nincs bejegyzés — rögzítsd a súlyodat a görbe elindításához.',diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.jsindex 65fbe048b..77eda1f16 100644--- a/frontend/src/locales/it.js+++ b/frontend/src/locales/it.js@@ -324,6 +324,7 @@ export default {'Rest timer': 'Timer di riposo','Sounds': 'Suoni','Flash screen when timer ends': 'Fai lampeggiare lo schermo alla fine del timer',+ 'Vibrate': 'Vibrazione','Weigh in before workouts': 'Pesarsi prima dell’allenamento','Asks for your body weight when a workout starts. Off starts the session straight away.': 'Chiede il tuo peso all’avvio di un allenamento. Disattivato, la sessione parte subito.','No entries yet — log your weight to start the curve.': 'Nessun dato — registra il tuo peso per iniziare la curva.',diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.jsindex 9018a95d3..51e1035a0 100644--- a/frontend/src/locales/ko.js+++ b/frontend/src/locales/ko.js@@ -324,6 +324,7 @@ export default {'Rest timer': '휴식 타이머','Sounds': '소리','Flash screen when timer ends': '타이머 종료 시 화면 깜박임',+ 'Vibrate': '진동','Weigh in before workouts': '운동 전 체중 기록','Asks for your body weight when a workout starts. Off starts the session straight away.': '운동을 시작할 때 체중을 물어봅니다. 끄면 세션이 바로 시작됩니다.','No entries yet — log your weight to start the curve.': '아직 기록이 없어요 — 체중을 기록해 그래프를 시작하세요.',diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.jsindex 668ec24b2..25c7ff02b 100644--- a/frontend/src/locales/pl.js+++ b/frontend/src/locales/pl.js@@ -324,6 +324,7 @@ export default {'Rest timer': 'Minutnik przerwy','Sounds': 'Dźwięki','Flash screen when timer ends': 'Migaj ekranem po zakończeniu minutnika',+ 'Vibrate': 'Wibracje','Weigh in before workouts': 'Ważenie przed treningiem','Asks for your body weight when a workout starts. Off starts the session straight away.': 'Pyta o Twoją masę ciała przy rozpoczęciu treningu. Wyłączone — sesja zaczyna się od razu.','No entries yet — log your weight to start the curve.': 'Brak wpisów — zapisz wagę, aby zacząć krzywą.',diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.jsindex fb5d3ef38..720d79539 100644--- a/frontend/src/locales/pt.js+++ b/frontend/src/locales/pt.js@@ -324,6 +324,7 @@ export default {'Rest timer': 'Temporizador de descanso','Sounds': 'Sons','Flash screen when timer ends': 'Piscar o ecrã quando o temporizador terminar',+ 'Vibrate': 'Vibração','Weigh in before workouts': 'Pesar antes do treino','Asks for your body weight when a workout starts. Off starts the session straight away.': 'Pede o teu peso ao iniciar um treino. Desligado, a sessão começa de imediato.','No entries yet — log your weight to start the curve.': 'Ainda sem registos — regista o teu peso para começar a curva.',diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.jsindex 9bfac9658..948236749 100644--- a/frontend/src/locales/ru.js+++ b/frontend/src/locales/ru.js@@ -324,6 +324,7 @@ export default {'Rest timer': 'Таймер отдыха','Sounds': 'Звуки','Flash screen when timer ends': 'Мигать экраном по окончании таймера',+ 'Vibrate': 'Вибрация','Weigh in before workouts': 'Взвешивание перед тренировкой','Asks for your body weight when a workout starts. Off starts the session straight away.': 'Спрашивает ваш вес при начале тренировки. Выключено — сессия начинается сразу.','No entries yet — log your weight to start the curve.': 'Записей пока нет — внеси вес, чтобы начать кривую.',diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.jsindex 952e70287..35248e0eb 100644--- a/frontend/src/locales/th.js+++ b/frontend/src/locales/th.js@@ -759,6 +759,7 @@ export default {'Logged sets stay with the original exercise. The replacement will be inserted afterward.': 'เซ็ตที่บันทึกแล้วจะอยู่กับท่าเดิม ท่าใหม่จะถูกแทรกไว้ถัดไป','Rest after each set of this exercise. Leave at 0 to use your default rest timer.': 'พักหลังแต่ละเซ็ตของท่านี้ ปล่อยไว้ที่ 0 เพื่อใช้ตัวจับเวลาพักค่าเริ่มต้น','Flash screen when timer ends': 'กะพริบหน้าจอเมื่อหมดเวลา',+ 'Vibrate': 'การสั่น','Weigh in before workouts': 'ชั่งน้ำหนักก่อนออกกำลังกาย','Asks for your body weight when a workout starts. Off starts the session straight away.': 'ถามน้ำหนักตัวเมื่อเริ่มออกกำลังกาย ถ้าปิด เซสชันจะเริ่มทันที','No entries yet — log your weight to start the curve.': 'ยังไม่มีข้อมูล — บันทึกน้ำหนักเพื่อเริ่มกราฟ',diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.jsindex 6f0a9eca2..4e2360817 100644--- a/frontend/src/locales/tr.js+++ b/frontend/src/locales/tr.js@@ -324,6 +324,7 @@ export default {'Rest timer': 'Dinlenme sayacı','Sounds': 'Sesler','Flash screen when timer ends': 'Zamanlayıcı bitince ekranı yanıp söndür',+ 'Vibrate': 'Titreşim','Weigh in before workouts': 'Antrenman öncesi tartılma','Asks for your body weight when a workout starts. Off starts the session straight away.': 'Antrenman başlarken kilonu sorar. Kapalıyken seans hemen başlar.','No entries yet — log your weight to start the curve.': 'Henüz kayıt yok — eğriyi başlatmak için kilonu gir.',diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.jsindex 5ad7f7998..df98a9896 100644--- a/frontend/src/locales/zh.js+++ b/frontend/src/locales/zh.js@@ -324,6 +324,7 @@ export default {'Rest timer': '休息计时','Sounds': '声音','Flash screen when timer ends': '计时结束时闪烁屏幕',+ 'Vibrate': '振动','Weigh in before workouts': '训练前称重','Asks for your body weight when a workout starts. Off starts the session straight away.': '开始训练时询问体重。关闭后直接进入训练。','No entries yet — log your weight to start the curve.': '还没有记录——记录体重以开始曲线。',diff --git a/frontend/src/views/Settings.jsx b/frontend/src/views/Settings.jsxindex a82efcf33..773e4c9f6 100644--- a/frontend/src/views/Settings.jsx+++ b/frontend/src/views/Settings.jsx@@ -6,7 +6,7 @@ import { convertStateUnit } from '../lib/units.js'import { useUI } from '../store/useUI.js'import { ACCENTS, todayISO, localTZ, weekStartOf, MONDAY, SUNDAY } from '../lib/format.js'import { effortOf } from '../lib/history.js'-import { unlock, playOnSilentSupported } from '../lib/sound.js'+import { unlock, playOnSilentSupported, vibrateSupported } from '../lib/sound.js'import { api, webauthnOK, passkeyRegister, IS_ANDROID } from '../lib/api.js'import { pushSupported, enablePush, disablePush, sendTestPush, syncPushSubscription } from '../lib/push.js'import { wakeLockSupported } from '../lib/wakelock.js'@@ -355,6 +355,14 @@ export default function Settings() {<Switch checked={!!S.soundOnSilent} onChange={v => update(s => { s.soundOnSilent = v })} /></Row>)}+ {/* The buzz at the end of a rest or a hold and on a set tick, on its own switch like the+ sound (Discord, asierlama). Not offered where there is nothing to buzz: iOS has no+ navigator.vibrate. */}+ {vibrateSupported() && (+ <Row icon="bell" iconTint="var(--indigo)" title={t('Vibrate')}>+ <Switch checked={S.vibrate !== false} onChange={v => update(s => { s.vibrate = v })} />+ </Row>+ )}<Row icon="sun" iconTint="var(--yellow)" title={t('Flash screen when timer ends')}><Switch checked={!!S.timerFlash} onChange={v => update(s => { s.timerFlash = v })} /></Row>diff --git a/frontend/src/views/Settings.sound.test.jsx b/frontend/src/views/Settings.sound.test.jsxindex 10feccb1d..7b28c873d 100644--- a/frontend/src/views/Settings.sound.test.jsx+++ b/frontend/src/views/Settings.sound.test.jsx@@ -130,3 +130,44 @@ describe('Settings — Sounds switch unlocks audio from the tap', () => {expect(unlock).not.toHaveBeenCalled()})})++// Discord (asierlama): the buzz on or off on its own, the way the sound is.+describe('Settings — vibrate', () => {+ const setVibrateApi = value => Object.defineProperty(navigator, 'vibrate', { value, configurable: true, writable: true })+ afterEach(() => { delete navigator.vibrate })++ it('is offered where the browser can vibrate, on by default, below the sound rows', () => {+ setVibrateApi(() => true)+ mount()+ const row = rowTitled('Vibrate')+ expect(row).toBeTruthy()+ expect(switchIn(row).getAttribute('aria-checked')).toBe('true')+ const rows = [...host.querySelectorAll('.lrow')]+ expect(rows.indexOf(row)).toBeGreaterThan(rows.indexOf(rowTitled('Sounds')))+ expect(rows.indexOf(row)).toBeLessThan(rows.indexOf(rowTitled('Flash screen when timer ends')))+ })++ it('stays on offer with Sounds off: the buzz does not depend on the sound', () => {+ setVibrateApi(() => true)+ mocks.S.sound = false+ mount()+ expect(rowTitled('Vibrate')).toBeTruthy()+ })++ it('writes vibrate to the store, off and back on', () => {+ setVibrateApi(() => true)+ mount()+ act(() => { switchIn(rowTitled('Vibrate')).click() })+ expect(mocks.S.vibrate).toBe(false)+ mount()+ expect(switchIn(rowTitled('Vibrate')).getAttribute('aria-checked')).toBe('false')+ act(() => { switchIn(rowTitled('Vibrate')).click() })+ expect(mocks.S.vibrate).toBe(true)+ })++ it('is not offered where there is nothing to buzz (iOS has no navigator.vibrate)', () => {+ setVibrateApi(undefined)+ mount()+ expect(rowTitled('Vibrate')).toBeUndefined()+ })+})