Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if command -v prettier >/dev/null 2>&1; then
FMT="prettier"
elif command -v npx >/dev/null 2>&1; then
FMT="npx --yes prettier"
elif [ -x "$HOME/.local/node/npx.cmd" ]; then
elif [ -f "$HOME/.local/node/npx.cmd" ]; then # -f: sh doesn't see .cmd as executable
# portable node: npx needs its sibling node.exe on PATH
PATH="$HOME/.local/node:$PATH"
export PATH
Expand Down
38 changes: 33 additions & 5 deletions PRD.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ FIVE mode is deliberately **silent at 3:00 and 2:00** — no real signal exists
and phantom buzzes could be mistaken for signals. Cues are edge-triggered on the displayed
second so a sync can never double-fire or skip them. Two-stage final count (not a gradual
ramp) because discrete stage changes are countable on the wrist; amplitude ramps are not.
The gun haptic is **timeliness-guarded**: it fires only within ~2 s of the real deadline —
a frozen/cached process waking minutes late transitions to count-up silently.

## 6. Screen policy

Expand Down Expand Up @@ -111,7 +113,34 @@ Swipe-accessible from the watch face. Two states, driven by the same persisted r
- **Timer in flight**: status line (COUNTDOWN or RACING, green) + single "Open" chip.
The app requests a tile refresh on every phase transition.

## 9. Visual language
## 9. Complication

One-tap starts from the watch face itself. The complication supplies typed data; the face
renders it (Pixel faces: weather-style ring + dot, center text, small icon at the bottom).
Arms **the last mode used anywhere** (app toggle, tile, or complication start) — no
per-instance configuration; the armed label shows which sequence a tap starts.

| State | Ring (min 0, max duration) | Center text | Tap |
| --------- | ---------------------------------------------------------- | ------------------ | ------------------------- |
| Armed | full | "5m" / "3m" | open app **auto-started** |
| Countdown | dot sweeps (platform-evaluated, ~1 Hz) | ticking count-down | open app |
| Count-up | dot sweeps race progress vs a nominal 60 min, parks at max | ticking count-up | open app |

- Sailboat monochromatic icon in all states (the face may hide it in tight slots).
- **Zero-push design**: countdown text ticks via time-difference text; the dot sweeps via a
dynamic value; a data timeline flips countdown → count-up at the gun — all rendered by the
platform even if the app process is dead. Pushes happen only on phase transitions
(start / sync / gun / reset), same hook as the tile.
- Tap-to-start opens the app running (not a silent background start): the ticker, haptics,
wake lock, and screen policy live in the app process — a mute start would skip every cue.
Repeated deliveries can't restart a sequence (start() no-ops unless Idle).
- Types: RANGED_VALUE (preferred) + SHORT_TEXT fallback (same text/icon/tap, no ring).
- 12 h validity mirrors persistence (§7).
- Face-ambient caveat: in always-on mode the FACE updates complications at minute cadence
(platform AOD policy — same as weather), so tick/sweep coarsen until wake; values are
absolute, so everything is exact the instant the wrist wakes. Not a bug.

## 10. Visual language

- Black background always (OLED, sunlight).
- Digits: white (idle/countdown) → **amber** final 10 s → **green** count-up.
Expand All @@ -121,15 +150,15 @@ Swipe-accessible from the watch face. Two states, driven by the same persisted r
- Icon: gold burgee (flying right) + green Bootstrap stopwatch, colors from the
johnhringiv.com burgee favicon; all pennant vertices r=30 from icon center (circular-mask safe).

## 10. Explicitly out of scope (decided against)
## 11. Explicitly out of scope (decided against)

- Audio signals (inaudible on the water; haptics only)
- Crown/rotary input (accidental-activation risk — see §4)
- Telemetry/analytics of any kind (Play Console platform stats suffice)
- Live ticking time on the tile (refresh-budget rabbit hole)
- Continuous haptic amplitude ramps (indistinguishable on the wrist)

## 11. Versioning & release
## 12. Versioning & release

- `versionCode`: bumped on every feature-branch change (CI-enforced > main).
- `versionName`: bumped once per PR to main (CI-enforced ≠ main). Squash-merge only;
Expand All @@ -138,9 +167,8 @@ Swipe-accessible from the watch face. Two states, driven by the same persisted r
- Distribution: GitHub releases (sideload) now; Google Play closed test → production later
(see `playstore/listing.md`).

## 12. Roadmap (open issues)
## 13. Roadmap (open issues)

- [#2](https://github.com/johnhringiv/regatta-timer/issues/2) Watch-face complication
- [#4](https://github.com/johnhringiv/regatta-timer/issues/4) Custom sequence lengths
- [#5](https://github.com/johnhringiv/regatta-timer/issues/5) Race log (start timestamps)
- [#6](https://github.com/johnhringiv/regatta-timer/issues/6) Ongoing Activity chip during count-up
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
A sailing race start timer for Wear OS (built for and tested on the Pixel Watch 3). Fully standalone — no phone, no companion app, no account, no network. Built because nothing on the market handled a real start line: the screen must never leave the timer mid-sequence, and a missed start press must be correctable at the next gun.

<p align="center">
<img src="docs/demo.gif" width="240" alt="The final seconds: amber countdown, the gun, automatic green count-up" />
<img src="docs/demo.gif" width="220" alt="The final seconds: amber countdown, the gun, automatic green count-up" />
<img src="docs/demo-complication.gif" width="220" alt="The complication: dot sweeping the ring as the countdown ticks" />
</p>

## Features
Expand All @@ -23,8 +24,10 @@ A sailing race start timer for Wear OS (built for and tested on the Pixel Watch
- **Screen never leaves the app** while armed or counting down; count-up dims to an always-on ambient display
- **Wet-proof**: countdown, display, and haptics keep running even when water forces the watch into ambient mode; huge half-screen touch targets; long-press-guarded reset so splashes can't kill your sequence
- **Quick-launch tile**: swipe from the watch face, tap 5 min or 3 min, and the timer opens pre-armed
- **Watch-face complication**: weather-style ring where the dot is time remaining, ticking countdown in the center — one tap starts the last-used sequence right from the face
- **Survives interruptions**: an in-flight countdown or race is restored at the correct time even if the app is closed — or the watch reboots
- **Battery guard**: an armed timer releases the screen after 10 idle minutes (any tap re-arms it); the countdown itself always holds the screen
- **Free, no ads, no tracking**: GPL open source; no account, no network, [no data collection](https://regatta-timer.johnhringiv.com/privacy.html) — about 2 MB

### The app

Expand All @@ -40,6 +43,16 @@ Swipe from the watch face. When a timer is in flight the tile says so instead of
| ---------------------------------------------- | -------------------------------------------------- |
| ![Tile armed](docs/screenshots/tile_armed.png) | ![Tile running](docs/screenshots/tile_running.png) |

### The complication

Put the timer in a watch-face complication slot: a ring where the dot is time remaining, a ticking countdown in the center, and a sailboat at the bottom (on faces that render ranged values, like the Pixel defaults). Armed, it shows the last-used sequence (`5m`/`3m`); one tap starts it with the app opening mid-count.

| Armed on the face | Counting down |
| -------------------------------------------------------------- | ---------------------------------------------------------------------- |
| ![Complication armed](docs/screenshots/complication_armed.png) | ![Complication countdown](docs/screenshots/complication_countdown.png) |

**Worth knowing**: in always-on (ambient) display, watch faces refresh complications about once a minute, so the countdown on the _face_ can read up to a minute stale until you turn your wrist — identical to the built-in stopwatch/timer complications. Inside the app, the countdown stays live to the second even in ambient.

## Install (sideload)

Grab the APK from [Releases](https://github.com/johnhringiv/regatta-timer/releases), then:
Expand Down
6 changes: 4 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ android {
targetSdk = 36
// versionCode bumps on every feature-branch change (CI-enforced > main).
// versionName bumps once per PR to main (CI-enforced).
versionCode = 14
versionName = "0.6"
versionCode = 19
versionName = "0.7"
}

signingConfigs {
Expand Down Expand Up @@ -70,6 +70,8 @@ dependencies {
implementation(libs.lifecycle.viewmodel.compose)
implementation(libs.wear.tiles)
implementation(libs.wear.protolayout.material)
implementation(libs.wear.protolayout.expression)
implementation(libs.wear.watchface.complications)
implementation(libs.guava)

testImplementation(libs.junit)
Expand Down
18 changes: 18 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,24 @@
</intent-filter>
</activity>

<service
android:name=".RegattaComplicationService"
android:exported="true"
android:label="@string/app_name"
android:icon="@drawable/ic_complication_sailboat"
android:permission="com.google.android.wearable.permission.BIND_COMPLICATION_PROVIDER">
<intent-filter>
<action android:name="android.support.wearable.complications.ACTION_COMPLICATION_UPDATE_REQUEST" />
</intent-filter>
<meta-data
android:name="android.support.wearable.complications.SUPPORTED_TYPES"
android:value="RANGED_VALUE,SHORT_TEXT" />
<!-- push-only: transitions call requestUpdateAll; countdown/dot tick face-side -->
<meta-data
android:name="android.support.wearable.complications.UPDATE_PERIOD_SECONDS"
android:value="0" />
</service>

<service
android:name=".RegattaTileService"
android:exported="true"
Expand Down
11 changes: 10 additions & 1 deletion app/src/main/java/com/johnhringiv/regattatimer/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ import androidx.compose.runtime.setValue
import androidx.wear.ambient.AmbientLifecycleObserver
import com.johnhringiv.regattatimer.ui.TimerScreen

/** Intent extra (set by the tile) naming the [Mode] to arm on launch. */
/** Intent extra (set by the tile/complication) naming the [Mode] to arm on launch. */
const val EXTRA_MODE = "mode"

/** Intent extra (set by the complication) to start the sequence immediately on launch. */
const val EXTRA_AUTO_START = "auto_start"

class MainActivity : ComponentActivity() {

private val viewModel: TimerViewModel by viewModels()
Expand Down Expand Up @@ -89,5 +92,11 @@ class MainActivity : ComponentActivity() {
private fun armModeFromIntent(intent: Intent?) {
val name = intent?.getStringExtra(EXTRA_MODE) ?: return
runCatching { Mode.valueOf(name) }.getOrNull()?.let(viewModel::armMode)
if (intent.getBooleanExtra(EXTRA_AUTO_START, false)) {
viewModel.start() // no-ops unless Idle, so a running race is never disturbed
// strip the extra so recents/recreation redelivery can't restart a reset timer
intent.removeExtra(EXTRA_AUTO_START)
setIntent(intent)
}
}
}
12 changes: 11 additions & 1 deletion app/src/main/java/com/johnhringiv/regattatimer/RaceStore.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ class RaceStore(context: Context) {
/** [gunWallMs]: wall-clock time the race started. */
fun saveCountUp(mode: Mode, gunWallMs: Long) = save("COUNTUP", mode, gunWallMs)

fun clear() = prefs.edit().clear().apply()
/** Clears the persisted race but not the last-used mode. */
fun clear() = prefs.edit()
.remove("phase").remove("mode").remove("wall").remove("savedAt")
.apply()

fun load(): Persisted? {
val phase = prefs.getString("phase", null) ?: return null
Expand All @@ -42,6 +45,13 @@ class RaceStore(context: Context) {
const val MAX_AGE_MS = 12 * 60 * 60_000L
}

/** The last mode used anywhere (app toggle, tile, complication start). */
fun lastMode(): Mode =
runCatching { Mode.valueOf(prefs.getString("lastMode", "") ?: "") }
.getOrDefault(Mode.FIVE)

fun setLastMode(mode: Mode) = prefs.edit().putString("lastMode", mode.name).apply()

private fun save(phase: String, mode: Mode, wallMs: Long) {
prefs.edit()
.putString("phase", phase)
Expand Down
Loading