Phase 7d — Following a ride: the screen kept on and a voice at the junctions
Sequence lives in PLAN.md; the live worklist lives in DOD.md. This phase
relies on ADR-0010 (the router and its network, unchanged: a junction is read from what a planned Route
already keeps) and ADR-0011
(Cycling follows marked Bike routes), and amends
ADR-0008 once: the voice is another app’s, and
Kozica asks it only for a voice that runs on the phone (§ 4). It reopens three decisions of
phase-6b.md, below. CONTEXT.md gains Junction. Planned with the
owner on 2026-11-29.
What closing this phase means. Today Following in Cycling is 6b’s on-screen Following over a ride’s line: the screen dims on the phone’s own timeout, nothing is spoken, and with the screen off Following knows nothing until the user looks. After this phase, in Cycling, the screen stays on while Following or Recording; a card shows the next Junction as an arrow, a distance and the colour of the Bike route the Route turns onto; and a voice, the phone’s own and offline, says the same at about 150 m and again at about 30 m, says when the user has left the Route and when they are back on it, guides them along a leg back, names each via point as they pass it and says when they have arrived. While Recording it goes on speaking with the screen off. Sharp-bend warnings come in, experimental and off by default. Hiking stays silent and keeps the phone’s timeout, but Following there shows the same card for the next Junction over the Trails, with the Trail’s colour. The difference a device can be asked about: on the test phone in airplane mode, a ride replayed along a Route with a left turn onto a red Bike route speaks “In 150 metres, turn left onto the red Bike route” and then “Turn left now”, with the screen locked and a recording running.
PLAN.md’s paragraph holds, and gains what this planning added: the voice also covers leaving the
Route, the leg back, via points and arrival, and keeps speaking with the screen off while Recording.
What this overturns
- Phase 6b’s “Not in: Turn-by-turn announcements”, for Cycling. 6b’s reason, a user who checks the map at junctions anyway, is a walker’s; a rider with both hands on the bar does not. Hiking keeps 6b’s refusal of anything spoken, but gains the junction card on screen (§ 2): a walker who looks at junctions anyway gets the answer at a glance, from the same Junctions over the Trails.
- Phase 6b’s “Nothing of ours runs with the screen off except a recording … Following does not start one”. Following still starts nothing, but while a recording runs in Cycling, Following rides on it (§ 5) and speaks with the screen off. 6b’s “A warning with the screen off” comes in on that condition.
- Phase 6b § 3’s “Following keeps the screen’s own timeout”, for Cycling while Following or Recording (§ 1). The battery cost 6b’s paragraph worried about is the rider’s to choose: the switch turns it off.
0. What this phase inherits
- A planned Route (
data/routes/RoutePlanner.kt) keepslegs, each aLegofStep(edge, from, to)in order (Router.kt), and alineof samples with position, metres, height,Approachand, in Cycling, aRideWay(surface, MTB). A sample names no edge, node or Bike route, and the line drops vertices under 0.5 m apart, so where two edges meet is not marked on it. - The network (
TrailNetwork.kt, ADR-0010) knows each node’s position and height, each edge’s geometry, its nodes and its sets (Trail, Touring, MTB bits), and every node’s edges (adjacencyStart/adjacentEdges). It cuts an edge where the Trails or the surface class change, so a node is not always a junction. A Bike route’s edges are intrails.edges(TrailWalks); no edge names its Bike routes, but the inverse is a pass over that map. - Following (
data/routes/Following.kt,ui/map/MapViewModel.kt) matches Progress forward along the line, in Cycling over a window of the fastest riding speed; leaves at 40 m (or the fix’s accuracy) for 30 s; plans a leg back on request; and ends at the end. It is fed only by the map’s fixes, from aLaunchedEffectinMapScreen, so it stops when the screen does. Its Route and Progress survive a closed app throughAppPreferences.followedRoute. - The recorder is phase 6’s
locationforeground service (record/RecordingService.kt), the only thing of ours that runs with the screen off. It takes a fix every 5 s in both Modes: 7c’s gate kept the walker’s interval for Rides (verdict 1). - Nothing keeps the screen on and nothing speaks: no
FLAG_KEEP_SCREEN_ON, wake lock,TextToSpeechor audio focus anywhere inapp/src/main. - The leaving rule was set on foot. Phase 7b left it to 7d to read on a ride and change only by that
reading (
phase-7b.md, Known gaps): 30 s at 20 km/h is about 170 m.
What is in, and what is deliberately not
In, in Hiking: the junction card while Following, on screen only (§ 2). In, in Cycling: the screen kept on while Following or Recording, with a Settings switch, on by default (§ 1); the junction card while Following (§ 2); Junctions read from the planned Route (§ 3); the voice, offline, at Junctions, on leaving and rejoining the Route, along a leg back, at via points and at the end, with a Settings switch, on by default, and a mute segment on the card until Stop or the end of Following (§ 4); Following with the screen off while Recording (§ 5); sharp-bend warnings from the Route’s own shape, experimental, off by default (§ 6).
Not in, and each with a reason rather than a phase:
- The voice and the screen kept on in Hiking. The phone is in a pocket and the signposts stand at every junction; 6b’s refusals hold there for anything spoken or kept awake. The card comes in (§ 2).
- A voice with the screen off and no recording. It needs a location service of Following’s own: a second foreground service, a second Console declaration and the battery, for the ride the user chose not to record. Recording is one tap, and the rider who wants the voice in the pocket takes it.
- A voice from the network. ADR-0008. A phone with no offline voice in the app’s language gets the card and a way to install one (§ 4), not an online voice, and not another language’s.
- Junctions with ways on no Bike route. The network holds only ways on a Trail or a Bike route (ADR-0010), so a road crossing between two Bike routes is not known to meet them. Adding every way would grow each Region’s network several times over for a call the signs and the card already cover.
- Directions along a dashed join (
Approach.OFF_TRAIL, a via point off the network). A join is a straight line to where the user chose to go; the via point’s own announcement covers it. - Speed, a trip computer or a ride screen of its own. Kozica is a map; the card is the voice’s on-screen twin, not a bike computer.
- A rerouting of the Route itself. The leg back already joins the user to the Route they planned; replanning it from wherever they are would discard their choice.
The tempting one: speaking in Hiking too, off by default. It looks free once the voice exists, but it would need thresholds for a walker’s pace and a reading on a hike, for a user the signposts already guide and whose phone is in a pocket. The card answers “which way” when they look. Not in this phase.
Checkpoints
| Checkpoint | Merges | Depends on | |
|---|---|---|---|
| A | The screen and the card: the screen kept on and its switch (§ 1), Junctions (§ 3), the card (§ 2) | feat: |
— |
| B | The voice on screen (§ 4): the offline check and its switch, Junctions at 150 m and 30 m with the route’s colour, leaving and back, the leg back, via points, arrival, the mute button, ducking | feat: |
A |
| C | The voice with the screen off (§ 5): Following moves into the recording service while Recording in Cycling | feat: |
B |
| D | Sharp-bend warnings (§ 6), experimental, off by default | feat: |
B |
A comes first because it makes the voice’s Junctions visible before anything speaks: a wrong Junction is a picture on a screencap, not a sentence missed on a ride. C waits for B because it moves Following into the service, the riskiest change here (HyperOS kills background work), and a voice that already works on screen tells a service fault from a voice fault. D is last because it is the most uncertain, and nothing else depends on it.
No seam. Each checkpoint reaches every build when it merges: each is whole on its own, and D is off by default. Unlike 7c, no half of the phase is unusable without the rest.
1. The screen kept on
While the Mode is Cycling and a Route is being Followed or a recording runs (paused included), the
activity window carries FLAG_KEEP_SCREEN_ON, set and cleared from Compose with the state
(LocalView.current.keepScreenOn, so it goes with the window, not with a wake lock that could outlive
it). Stop, the end of Following, the Mode switched to Hiking or the switch turned off clears it at once.
The power button still turns the screen off: this only stops the timeout.
Settings gains “Keep the screen on while riding”, on by default, with “While following a Route or
recording a ride in Cycling. Uses more battery.” beneath it. It goes in a new section headed Cycling
(the Mode switch’s own mode_cycling, Polish Rowerem), which holds this phase’s three switches (this
one, “Voice directions” in § 4 and “Sharp-bend warnings” in § 6) and shows on every phone, unlike
Outing recording, which SettingsScreen draws only where the significant-motion sensor exists.
2. The junction card
The cue card, picked by the owner by eye on 2026-11-29 from three mock-ups (a full-width sign at the
top, the Route sheet’s head, a card): a card floating at the top start of the map, in the Mode switch’s
place, which Following already hides. It holds the next Junction’s turn arrow (64 dp), the distance to it
along the line, and, when the Route turns onto a different Bike route or Trail there, its marking: the
Bike route sheet’s plate (BikeRoutePlate, a coloured stripe on the theme’s surfaceBright, light in the
light theme and dark in the dark) in Cycling or the Trail sheet’s painted stripe (TrailMark, on the same
ground) in Hiking, the shared components so the card matches the sheets, with the colour word beside it, so a black or yellow one reads in both themes and a colour-blind
user still has the word. In Cycling a mute segment across the card’s width (≥ 48 dp tall) silences the
voice until Stop or the end of Following, and shows which it is by its icon, a speaker or a speaker
crossed out, with its label, never by colour alone; Hiking has no voice and no segment. The Safety button keeps its place.
- It shows while Following, in both Modes, in the normal view and in full screen. Past the last Junction it is gone and the Following line says the rest, as today. While a leg back is followed it shows the leg back’s next Junction. A leg back with no Junctions shows no card, and the sheet’s “Back to the Route: …” line says the way (the owner’s call, 2026-12-02), rather than a card for the rejoin or the Route’s own next Junction.
- When space is short (360 dp at font scale 1.3 with a recording running, where the full card is
taller than the map left), it takes a compact form: one row, a 48 dp arrow, the distance
(
headlineMedium) over the plate or stripe and the colour word, and in Cycling the mute as a 56 dp end cap as tall as the card; about 98 dp at font scale 1.3 against 249 dp. The rule: compact when the tall card, measured with its plate or stripe and, in Cycling, its mute segment, would take more than 60 % of the map’s height between the top row and the Route sheet. The map’s height changes only when the chrome does, so the form never flips as the distance counts down; a banner appearing can flip it. - At font scale 2.0 the card is always the compact form, whatever the rule says. The arrow and the distance keep one row and the distance is never ellipsised; the plate or stripe and the colour word may wrap to a second line below them. Nothing of the card is clipped at any font scale the system offers.
- TalkBack reads the card’s sentence as one node, the sentence the voice would say (“In 150 m, turn left onto the red Bike route”). In Cycling the mute segment is a sibling node, not merged into the sentence, so it is reached and operated on its own: a switch, after the sentence in traversal order, “Mute voice directions”, on while muted. Its name never changes with its state, so TalkBack never reads an action against a state (“Unmute …, checked”).
- A live region only when nothing speaks. In Hiking, which has no voice, and in Cycling whenever the voice is muted, switched off in Settings or unavailable (§ 4), the sentence is a polite live region that announces only when the next Junction changes, never as the distance counts down. In Cycling with the voice speaking it is not one, since the voice already says it.
- Mock-ups:
captures/phase-7d/option-*.html(gitignored): the three options, andoption-3b.htmlwith the compact form and Hiking’s card (the Trail’s own symbol, white, colour, white; a Trail of none of the five colours shows the map’s grey).
3. Junctions
A Junction is a node of the network on the Route’s line where three or more edges the Mode may ride
meet (Travel.allows in data/routes/Travel.kt), at which the Route either turns or leaves the Bike route it is on. Read once,
when the Route is planned or a leg back is, from legs: for each pair of consecutive steps, the node
between them, which is the node the first step ends at (edgeTo if Step.forward, else edgeFrom,
since a step walked against its edge’s stored direction ends at its start); its degree over the edges
the Mode allows; and the bearings 20 m before and 20 m after it, measured along the Route’s steps: where
an edge is shorter than 20 m the measure walks on into the neighbouring steps’ geometry rather than
stopping at the edge’s end.
- The turn is the signed difference of those bearings: straight under 20°, slight 20°–45°, a plain turn 45°–120°, sharp over 120°, each left or right. A straight Junction is a Junction only when the Route leaves its Bike route there.
- Leaving the Bike route at a node: no Bike route of the edge before is a Bike route of the edge
after, from the edge-to-Bike-routes index built once per network from
trails.edges. - The colour spoken and shown is the marking colour of the edge after’s Bike route that the Route rides furthest from the node; one with no marking colour has none, and the call says “another Bike route”.
- In Hiking the same, over the edges Hiking allows and the Trails: a Junction is where the Route turns or leaves the Trail it is on, and the card shows the Trail’s colour. The thresholds are the same until a hike (R8) says otherwise.
- Where on the line: the node’s position is matched to the nearest line sample at or after the previous Junction’s, so each Junction has a metre on the line that Progress can be compared with. The planner keeps the node’s line index instead if matching proves fragile (a test decides).
junctionsOf(planned, network, filter, routesOfEdge, colourOf)indata/routes/Junctions.kt, a pure function. Its inputs are what § 3 needs and the planned Route does not keep:planned: PlannedRoute(itslegs,lineandmode);network: TrailNetwork;filter: BikeRouteFilter, the one the Route was planned with (FollowedRoute.bikeRouteFilterwhile Following, the planner’s for a leg back), sinceTravel(network, mode, filter).allowsneeds it andPlannedRoute.kindunder All is only the edges’ majority;routesOfEdge: (Int) -> LongArray, the edge-to-routes index built once per network fromTrailWalks(trails.edges, throughTrailNetworks.walks), whichTrailNetworkdoes not hold; andcolourOf: (Long) -> TrailColour?, the marking colour fromplaces.sqlitethroughPlaceIndex(bikeRoute(id)?.colourfrombike_routesin Cycling,trail(id)?.colourin Hiking). Unit tests run it over a small hand-built network with hand-built lookups: a T, a fork, a crossroads, a straight node where the Bike route changes, a degree-2 node where the surface changes (not a Junction), an out-and-back over the same node, a step ridden against its edge’s direction (the node is itsedgeFrom), and an edge shorter than 20 m between two Junction candidates (the bearings reach past it).
The thresholds (20 m, 20°, 45°, 120°) are provisional; the replayed rides (R2) and a real one (R6) set them.
Decided while building checkpoint A (2026-11-29), where the above is silent:
- The screen is kept on by the map’s Mode, and only while the map is on screen. Settings, Routes and Outings keep the phone’s timeout, as Following itself stops feeding there (§ 0). The switch sits in the Cycling section, after Appearance and before Outing recording.
- A Junction is a node between two steps of one leg. A via point is none: its own call (§ 4) covers it. The bearings reach as far as the leg does, so at a leg’s first or last 20 m they are shorter.
- Every node between two steps is matched to the line in turn, a Junction or not, so on an
out-and-back a first pass that is no Junction still moves the match past itself.
JunctionsTestholds it; the planner keeps no line indices. - The other Mode’s routes on a shared edge are left out of leaving:
colourOfis null for an id that is not the Route’s Mode’s. An edge before that carries none of the Mode’s routes is never left. junctionsOfalso takesisMtb: (Long) -> Boolean, so the sentence says “MTB route” for one.- The class boundaries are inclusive at the top: 45° is slight, 120° a turn.
- Straight on and leaving says “go straight on, leaving the Bike route” (or Trail), as § 4’s table does, while the card shows the plate or stripe it goes onto. The straight arrow has no side branch: which side the old route turns off to is not kept.
- The card’s distance is rounded to 10 m, the voice’s rounding (one
roundedMetresfor both), and from 1 km on is kilometres to one decimal, as elsewhere. It never reads “0 m”: under 5 m it reads 10 m until the Junction is passed. Before the first fix that counts it counts from the Route’s start, as the Following line does. - The card skips what the voice skips at the start (an emulator reading of checkpoint B showed “In 0 m, bear right” at a Junction 4 m from the start): a Junction within 30 m of the Progress at which Following, or a leg back, first saw its Junctions is never shown, in either Mode. The voice’s calls are settled at that same Progress, so the card and the voice skip the same ones.
- A leg back’s Progress is matched along it by Following’s own rule, for its card only.
- The live region is polite only for 3 s after the next Junction changes, saying the sentence as it was then. A Compose live region announces every change to its node, so one kept live would announce the countdown; TalkBack’s own read of the card always has the current distance.
- The map’s height for the compact rule is the map less the search row in the normal view, and the whole map in full screen, where the card shares the Safety button’s row.
- One with no marking colour reads “Another Bike route”, “Another MTB route” or “Another Trail” beside its plate or stripe.
- Going on into the next Section is not leaving (the owner, 2026-11-30, on the author’s
recommendation after the review):
junctionsOfalso takeswholeOf: (Long) -> Long, which folds a Section to its Long-distance Trail or Bike route with Sections (long_distanceinplaces.sqlite, already the outermost), itself for a route with none. The leaving test and the route ridden furthest compare wholes, so a straight node where one Section hands over to the next is no Junction; the colour is the edge after’s Section’s own. - The card never reaches the Record button’s row (R9 found it overlapping at font scale 2.0): it is compact also where the tall card is taller than the room between its top and that row, less 8 dp; the room also leaves out the banners and results stacked under the card. It is never measured taller than that room nor shorter than the whole compact card, so nothing of it hides behind a scroll, and its arrow sits at the top of its row.
- Where even the compact card does not fit (360 dp at font scale 2.0, checkpoint D’s reading), the Route sheet folds to the one line it shows in full screen (phase 6d § 5): a tap opens it, the handle or Back folds it again (the owner, 2026-12-01, on the design pass’s recommendation over docking the card as the sheet’s head or entering full screen by itself). It folds where, beside the Following sheet at rest, the map would be shorter than the search row, the whole compact card, the controls below it and 8 dp. The sheet is measured only while unfolded, so folding never unfolds it; measured against the sheet’s cap instead, it folded at 1.3 too (R9). The sheet’s button rows wrap whole buttons, so “Stop” never breaks.
4. The voice
The engine. android.speech.tts.TextToSpeech with the default engine, which runs in its own app.
Kozica asks it for a Voice in the app’s language (the per-app locale, else the system’s) whose
isNetworkConnectionRequired() is false and whose features do not include
KEY_FEATURE_NETWORK_SYNTHESIS, and passes KEY_FEATURE_NETWORK_SYNTHESIS = false with every
utterance. No such voice, or no engine: the voice is unavailable (below). The manifest’s <queries>
gains android.intent.action.TTS_SERVICE, which Android 11+ needs for the engine to be visible.
When it is unavailable, the Settings switch reads “No offline voice in Polish on this phone” (in
the app’s language) with an “Install a voice” button that opens the system’s text-to-speech
settings (TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA, else com.android.settings.TTS_SETTINGS). The card
still works. It is checked again each time Following starts.
The audio. AudioAttributes with USAGE_ASSISTANCE_NAVIGATION_GUIDANCE and
CONTENT_TYPE_SPEECH; audio focus AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK for each utterance, released
when it is done, so music and podcasts get quieter and come back. A call in progress gets no
announcement (focus refused).
What it says (English copy; Polish and the rest translated from it per
translator-brief.md, gender-neutral, Polish plurals per CLDR):
| When | Says |
|---|---|
| About 150 m before a Junction | “In 150 metres, turn left onto the red Bike route” (“…MTB route” for one) · “…, bear right” (slight) · “…, turn sharp left” · “…, go straight on, leaving the Bike route” · “…, turn left onto another Bike route” (no colour) |
| About 30 m before it | “Turn left now onto the red Bike route” · “Bear right now” · … |
| The next Junction under 60 m after this one, at the 30 m call | “Turn left now, then right” |
| The leaving rule fires | “You’ve left the Route” (once until back) |
| Progress moves again after leaving | “Back on the Route” |
| A leg back is planned and followed | its Junctions as above, then “Back on the Route” |
| Progress passes a via point with a name | “Reached Przełęcz Salmopolska” |
| The end | “You’ve arrived”, and Following ends as it does today |
- The distances are along the line from Progress to the Junction. Each call is spoken once per Junction. Following that starts within 150 m of one skips its first call; one within 30 m is not announced at all. The spoken distance is rounded to 10 m.
- One Junction at a time. A Junction’s calls are due only once Progress has passed the Junction before it, so the voice never speaks the next one’s 150 m call ahead of this one’s 30 m call. A next Junction already inside 150 m when the previous one is passed loses its 150 m call, as at a start inside 150 m; inside 30 m it is said only through the previous call’s “then”.
- A via point with no name is skipped: coordinates read aloud help nobody.
- The leaving rule stays 40 m for 30 s until a real ride (R6) says otherwise; it changes only by that reading, as 7b wrote.
- The mute segment on the card silences everything until Stop or the end of Following; the next Follow speaks again.
Settings’ Cycling section (§ 1) gains “Voice directions”, on by default, with “Spoken at junctions while following a Route in Cycling. Uses the phone’s own voice, with no connection.” beneath it.
ADR-0008’s amendment, in this phase’s planning pull request: the voice is the system’s TTS engine, a separate app; Kozica sends it only the sentence to speak and asks only for an offline voice, so nothing of the user’s leaves the phone through it, and a phone with only online voices gets none.
Decided while building checkpoint B (2026-12-01), where the above is silent:
- The voice’s language is the language of the app’s strings: the first of the app’s locales (the per-app one, else the system’s) that the app ships, else English, as Android picks the strings. A phone set to German speaks the English sentences, so it needs an English voice. “No offline voice in …” names each strings file’s own language rather than taking a language name as an argument.
- A voice whose data is not on the phone yet (
KEY_FEATURE_NOT_INSTALLED) is refused with the online ones. Of the rest, the engine’s default voice first, then one of the language’s own country, then quality. A language and a country match by their three-letter codes too, as some engines report them (“pol”, “POL”).OfflineVoiceTestholds it against a fake engine. - A Junction’s calls are settled on the first Progress after it becomes the next one: inside 150 m it loses the 150 m call, inside 30 m both. A Progress that jumps from beyond 150 m to inside 30 m says only the 30 m call; one that jumps past a Junction says nothing of it afterwards.
- “Then” names only the next Junction’s turn (“then right”, “then bear left”, “then straight on”), not its Bike route. A next Junction 30–60 m on still gets its own 30 m call once the first is passed.
- “Back on the Route” is said when Progress moves forward after “You’ve left the Route”, or at the first Progress where the leaving rule fired before any; leaving again before then says nothing.
- A via point’s name is its label on the Route sheet (the place name the planner put there). Only the farthest one passed in a single Progress step is named, so a jump by “Find me on the Route” names one, not each; one already behind the first Progress (a Route resumed part-way) is not named.
- “You’ve arrived” is said alone: a call due on the same fix is dropped, and nothing follows it.
- A leg back’s Junctions are called from its own Progress; a leg back planned again starts its calls over.
- The mute segment shows in Cycling while Settings’ switch is on and the voice is not known to be missing; with the switch off or no offline voice there is nothing to mute. It reads “Mute” beside the speaker, or the crossed-out speaker while muted; TalkBack hears a switch, “Mute voice directions”, on while muted (aria’s review: a name that flipped with the state read “Unmute voice directions, checked”). Muting also stops a sentence already being spoken.
- The engine is bound only while it is needed: while a Route is Followed in Cycling with the switch on
(checked again at each start), and for a check whenever Settings is shown, which covers the return
from installing a voice. It is let go once what is queued has been said, so “You’ve arrived” is not
cut off. Audio focus is asked per sentence and given back when nothing is queued. A sentence ends at its
first
onDone,onErrororonStop, or 30 s after it was queued, since an engine that dies mid-sentence calls nothing back; an engine that fails to start again lets go of every sentence. Either way the focus is given back and the engine let go. - The engine lives beside the preferences in
MainApplication, not in the container, since Settings checks it and Settings is reachable while the schema gate is shut. - The card says “In 150 m”; the voice says “In 150 metres”, a plural, since a unit symbol is not spoken.
KozicaVoiceis debug-only (src/debug/…/voice/VoiceLog.kt): one line per sentence with its metre and whether it was said, or why not (silent,unavailable,refused,failed), so an emulator with no voice still reads every sentence.- Polish copy, gender-neutral: “Jesteś poza trasą”, “Z powrotem na trasie”, “Osiągnięto: name” (a name cannot be inflected) and “Jesteś na miejscu”.
5. With the screen off (checkpoint C)
While a recording runs in Cycling and a Route is Followed, Following lives in RecordingService: it is
handed the FollowedLine and feeds it each of its own fixes, and the voice speaks from there. The
service is never bound (RecordingService.onBind returns null), so the screen reaches it the way it
already reaches the recording: the service reports Following’s Progress, leaving and leg back into
Recorder’s StateFlow (its Recording state gains them), and the map’s ViewModel reads them from
there instead of feeding fixes itself, so there is one Following, not two. Stop, or the end of the
recording, hands it back to the screen.
- The service’s fixes are requested every 5 s and 5 m today (
RecordingService.requestFixes’sINTERVAL_MSandMIN_METRES, 7c’s verdict 1), andstore()writes every fix it is given; at 20 km/h that is 28 m between fixes, so the 30 m call may come one fix late. The service asks for fixes every 2 s while a Route is Followed in Cycling, and goes back to 5 s otherwise. So that Rides stay as 7c’s verdict 1 set them, a new store-side filter keeps a fix in the Track only when it is at least 5 s and 5 m from the last fix kept; Following still gets every fix. A unit test holds the filter. R5 reads the battery cost. - A leg back asked for on the screen reaches the service as a new start-command action beside
ACTION_PAUSEandACTION_STOP(ACTION_LEG_BACK) and is planned there; with the screen off none is planned, and the voice says “You’ve left the Route” and nothing more until the user looks. - The followed Route still survives a closed app through
AppPreferences.followedRoute, as in 6b. - On HyperOS the service needs autostart and the battery exemption as phase 6’s recording does; nothing new is asked.
Decided while building checkpoint C (2026-12-01), where the above is silent:
- One Following, handed over, never copied.
FollowingSession(data/routes/) holds what the map’sViewModelheld: the line, leaving, the leg back and the voice’s calls. The map makes it at Follow and hands it toRecorder.handOver; the service feeds that same object whileRecording.holdsFollowing, and the map feeds it only otherwise. The map shows each state the service reports inRecording.following, ordered by a revision so a late report never undoes a newer change of the map’s own. Handing back is the map feeding it again. - A paused Ride hands Following back to the screen. Pausing stops the service’s fixes, as in phase 6, so the map’s fixes feed it until Resume.
- The mute and “Find me on the Route” act on the shared Following from the screen; only the leg back goes through the service, as above. The service plans it from the last fix it gave Following, so the command carries nothing.
- The voice has a keeper each:
Speaker.openandclosename who keeps the engine, the map or the service, so Back on the map does not let go of the engine the service speaks through. - A map opened again while a recording follows a Route takes that Following back as it is, its Progress, Junctions and calls, rather than planning the stored Route again. A Following the recording already ended, at the Route’s end, is let go without resuming the stored Route. With no recording running, a Following left behind is let go and the stored Route resumes as in 6b.
- The Track’s filter runs only at 2 s fixes: at 5 s a fix arriving a moment early would be dropped, so a recording without Following stores what it did before. At 2 s it keeps about one fix in 6 s.
- 2 s while any Route is followed during a Ride; the voice speaks only for one planned in Cycling.
6. Sharp-bend warnings (checkpoint D)
From the Route’s own line, since OpenStreetMap marks almost no bends off roads
(cycling-research.md § 3): a sharp bend is a stretch of the line where the
bearing turns 60° or more within 25 m, on a descent of 6 % or more over the 100 m before it, and not at
a Junction (a Junction’s call covers it). bendsOf(planned) in data/routes/Bends.kt, pure, with tests.
Spoken once, about 50 m before: “Sharp bend left in 50 metres”. Shown on the card as the bend’s arrow with “Bend” when it is nearer than the next Junction.
Settings’ Cycling section (§ 1) gains “Sharp-bend warnings”, off by default, marked experimental: “Experimental. From the map’s shape, which is drawn roughly off roads: expect warnings where there is no bend, and silence at some that are.” Its thresholds are provisional; real rides (R7) set them, and a reading that warns more often wrongly than rightly keeps it off by default.
Decided while building checkpoint D (2026-12-01), where the above is silent:
bendsOfalso takes the Route’s Junctions, read with them, since the line marks none. A bend within 20 m of one, the reach its turn is measured over (§ 3), is that Junction’s.- The turn is the sum of the line’s corners, and a bend is the shortest stretch whose corners reach 60° within 25 m. It is placed where that stretch starts to turn, and goes on while the turning goes on the same way, so a hairpin is one bend, two corners the same way within 25 m are one, and two a straight apart are two. A corner where a dashed join meets the network is none. Its arrow is a plain turn up to 120° and a sharp one beyond, as a Junction’s; the voice says “sharp bend” either way.
- The descent is the line’s own heights, from 100 m before the bend’s start to the start. A bend under 100 m from the Route’s start has no descent to measure and is none.
- Each bend is warned once, on the first Progress within 50 m, at that distance rounded to 10 m. One within 50 m of the Progress where Following first saw its bends is never warned or shown, as a Junction inside 150 m loses its first call. A bend past the next Junction waits until that Junction is passed, so the voice speaks in the line’s order: a bend due on the same fix as a Junction’s call comes first.
- The card shows a bend whenever it is nearer than the next Junction, and past the last Junction too, with “Sharp bend left in 50 m” for TalkBack. A leg back’s bends are not read.
- The switch is read at each sentence and each frame, by the map and by the service alike: off, the bends are still passed in order but nothing is said or shown, so turning it on mid-ride warns of the ones still ahead. The voice’s own switch and the mute silence a warning as any other sentence.
Tests
JunctionsTest(§ 3),BendsTest(§ 6): pure, over hand-built networks and lines.AnnouncementsTest: from a Route’s Junctions, via points and a sequence of Progress values, which sentences are due and when; each once; the 150 m call skipped inside 150 m; “then” under 60 m; two Junctions 100 m apart, the second’s calls only after the first is passed; leaving once until back; arrival last.TrackFilterTest(§ 5): at 2 s fixes, the Track keeps only fixes 5 s and 5 m after the last one kept.OfflineVoiceTest: the voice chooser refuses a voice that needs the network and one in another language, against a fake engine, and matches three-letter codes.UtterancesTest: a sentence ends once, whichever of its callbacks or its timeout comes first, and the focus is given back when the last one ends.JunctionCardTest: the card skips a Junction within 30 m of where its Junctions were first seen, and never reads 0 m.TranslationTestholds the plurals of the spoken distances in every shipped language.
Readings
PLAN.md rule 3. The emulator reads the card and the sentences (logged under KozicaVoice with their
metre on the line); a real ride decides the thresholds.
| # | Reading | Command | Result |
|---|---|---|---|
| R1 | The screen stays on while Following and Recording in Cycling, not in Hiking, not after Stop, not with the switch off | adb shell dumpsys window (FLAG_KEEP_SCREEN_ON), emulator |
Pass, 2026-11-30, pixel-api37 (API 37, -gpu host, windowed), debug build at dc38b05. On while Following in Cycling, Recording a Ride, paused, and Recording with no Route; off after Stop, after Stop Following, Following and Recording in Hiking, the Mode switched to Hiking mid-ride, the switch off, on Settings, and at the Route’s end. The Cycling section sits after Appearance, its switch on by default. |
| R2 | Junctions on five replayed Routes over Beskidy Zachodnie’s Bike routes: every turn found, no straight node called, colours right | RouteReceiver + logcat -s KozicaVoice, emulator; screencaps of the card |
Pass on what could be judged, 2026-11-30, same emulator and build. Cycling, Istebna–Jaworzynka, 6.9 km: “bear right” at 1,810 m (+33°), “turn sharp left onto the green Bike route” at 3,540 m (−122°) with the plate and “Green”, “bear left” at 6,520 m (−42°). Two Bielsko Routes: every turn class matched the line (+81°, +40°, +164°, −51°, +73°), no plates. Hiking, Szczyrk–Skrzyczne: “turn left onto the blue Trail” at 720 m with the stripe, “turn right” at 1,510 m, “bear left” at 7,450 m. Distance in 10 m steps, kilometres to one decimal; the next Junction after passing one; gone after the last; full screen works. A few bends over 45° had no card (Route C at 5,320 and 5,365 m, 49.5359 18.8570; a Bielsko Route at 10,100 m, 49.8009 18.9984): degree-2 bends or missed Junctions, not told apart at the zoom Following keeps. R6 decides; the thresholds stay until then. The bends with no card, checked 2026-12-05 against the network (pin-4965-net2): at Route C’s 5,320 m a point within one way (55°), at 5,365 m a degree-2 node between two ways of the same green Bike route (73°), and at the Bielsko Route’s 10,100 m a node whose third edge is a Trail only, so degree 2 in Cycling (55°). No card is right at all three. |
| R3 | The voice in airplane mode with an offline Polish voice: each sentence of § 4 spoken, music ducked | test phone, a replayed ride | Pass on the emulator, in English, 2026-12-01, pixel-api37 (API 37, -gpu host, windowed), debug build at eb5fcbc: Google TTS, whose only offline voice on the AVD is en-US (en-us-x-iog-seanet-embedded; Polish has none), airplane mode. Cycling, Istebna–Jaworzynka, 6,893 m: at 1,646 m “In 140 metres, bear right”, 1,771 “Bear right now, then bear right”, 3,416 “In 120 metres, turn sharp left onto the green Bike route”, 3,518 “Turn sharp left now onto the green Bike route”, 3,700 “You’ve left the Route” once (60 m off for about 40 s), 3,736 “Back on the Route”, 6,856 “You’ve arrived” alone, and Following ended. A long-press Route with Polenica as its via point: 1,075 “Reached Polenica”; an unnamed via point silent. Audio focus GAIN_TRANSIENT_MAY_DUCK with USAGE_ASSISTANCE_NAVIGATION_GUIDANCE / CONTENT_TYPE_SPEECH, held only while a sentence plays. The mute silenced every call (outcome=silent) until Stop. At 20–25 m between fixes the 150 m call came one fix late (120–140 m). Still owed: the test phone with an offline Polish voice, and the ducking heard over music. |
| R4 | No offline voice: the switch says so, “Install a voice” opens the system’s settings, the card still works | emulator with the voice data removed | Pass, the live region not confirmed, 2026-12-01, same emulator and build, in Polish, which has no offline voice there: Settings says “Brak głosu offline po polsku na tym telefonie” with “Zainstaluj głos”, which opens Google TTS’s VoiceDataInstallActivity, and Back returns. Following shows the card (“Za 80 m odbij w prawo”) with no mute segment, each sentence logged outcome=unavailable. Not read: the card’s live region with TalkBack running. |
| R5 | The screen off while Recording: a replayed ride speaks with the screen locked; battery per hour at 2 s fixes | test phone, then the owner’s phone (HyperOS, autostart read first) | The emulator half passes, 2026-12-01, pixel-api37 (API 37, headless, -read-only), fixes by adb emu geo fix. QA at d0a51d7: Cycling, a Ride recorded with the screen locked, the service spoke the whole 5.5 km (“In 130 metres, bear left” … “You’ve arrived”); Pause gave Following to the map and Resume back; Stop mid-Follow handed the live Following back to the map; “You’ve left the Route” once, no leg back with the screen off, one planned on screen (“Back to the Route: 110 m”). Main at d0a51d7: the GPS request at 2 s while Following in Cycling (Request[@+2s0ms … minUpdateDistance=5.0]), 5 s after Stop Following, at the Route’s end and in Hiking. App swiped from recents at 1,300 m: the service said “You’ve arrived” at 6,834 m with no activity open; Stop from the notification and a cold relaunch followed nothing and kept no followed Route. Stop mid-Follow then Keep recording: the reopened map took the live Following back. Hiking: the map drives Following (5 s fixes), the voice silent. The Track over 3 min 20 s at 2 s fixes: 30 steps, the smallest 5.02 s and 5.6 m, mean 6.62 s. Taken for a defect, superseded by the reading below: after that Stop, while “You’ve left the Route” showed, the Junction card was gone until the next fix. Read again, 2026-12-02, pixel-api37 headless, debug build at 3e530e3, Cycling, Wisła → Szczyrk, fixes by adb emu geo fix 430 m off the Route: with “You’ve left the Route” showing while Recording and no leg back asked, Stop kept the card (“In 3.4 km, turn right”) through the hand-back and later fixes; “Back to the Route” then planned a 1.1 km leg back with no Junctions, and the card went, as § 2 says of a Route past its last Junction, the sheet saying “Back to the Route: 1.1 km”. QA’s run had asked for a leg back first, so that, not Stop, emptied the card. The owner kept it so (2026-12-02), rather than a card for the rejoin or the Route’s own next Junction. Still owed: the test phone, the owner’s phone with autostart, and battery per hour. |
| R6 | A real ride: calls land before the turn at riding speed, no false Junctions, the leaving rule at speed | the owner’s phone, a Followed Route on a bike | |
| R7 | Sharp-bend warnings on real descents: right, wrong, missed | the owner’s phone, the switch on | The emulator half passes, 2026-12-01, pixel-api37 (API 37), debug build at e6c87d5, fixes by adb emu geo fix. QA, a 10.4 km Cycling Route in Beskidy Zachodnie: off by default with its “Experimental.” text; with the switch off no bend said or shown; on, “Sharp bend left in 30” or “50 metres” once per bend at 1,840, 2,080 and 4,720 m, the card showing the arrow and “Bend”; a bend beyond the next Junction waited for it, the Junction’s call first; the bends warned matched a separate computation from the line, and the 4.9 % descent, the climbing candidate and the 61° bend on a climb stayed silent. Skrzyczne to Szczyrk, a 7.4 km Route in Cycling, Recording with the screen locked, replayed to 2.5 km only: the service said “Sharp bend right in 40 metres” at 768 m and “… in 50 metres” at 2,184 m, once each, for its first two bends; the six further down, from 3.0 to 4.7 km, were not reached. In Polish: “Ostrzeżenia o ostrych zakrętach”, “Ostry zakręt w lewo za 50 metrów” logged, the card “Zakręt”. Hiking, the same ends, replayed past its 11 candidate bends: none said or shown. Still owed: real descents, which set the thresholds and whether it stays off. |
| R8 | The card in Hiking on a real hike: Junctions where the signposts are, no straight node shown, colours right | the owner’s phone, a Followed Route on foot | |
| R9 | The card’s accessibility: TalkBack’s order and labels in Cycling and Hiking (the sentence, then the mute toggle with its state), the live region with the voice muted and off, font scale 2.0 in the compact form with nothing clipped, and the plate, stripe and mute icon in light and dark | emulator, TalkBack on | Pass but one defect, 2026-11-30, same emulator and build. At 360 dp and font scale 2.0 compact, the distance not ellipsised; at 1.3 tall without a recording, compact with one; one TalkBack node (“In 1.6 km, turn sharp left onto the green Bike route”, “In 720 m, turn left onto the blue Trail”); plate, stripe and word readable in light and dark. Defect, fixed in this checkpoint: at 2.0 the card ([24,426][662,745] px) overlapped the Record button ([24,690][516,850]) by about 55 px; § 3’s decisions say how it now stays above. Not read: the live region and the traversal with TalkBack running, the mute segment (checkpoint B), a black marking in the dark theme. Checkpoint B, in part, 2026-12-01, pixel-api37, debug build at eb5fcbc: at 360 dp and font scale 2.0 in Cycling the compact card with its 56 dp mute cap clears Record and the full-screen button, “1.4 km” not ellipsised, the mute its own checkable, labelled node; the compact card scrolls to show the arrow, the plate and the word. The mute became a switch with one name afterwards (aria’s review), so its TalkBack reading is owed again, with the live region. Checkpoint D, 2026-12-01, pixel-api37, e6c87d5: the bend card is one TalkBack node (“Sharp bend left in 130 m”, “Ostry zakręt w lewo za 40 m”), and tall at 360 dp and font scale 1.0 it clears Record and the full-screen button in light and dark. Defect, pre-dating D: at 360 dp and font scale 2.0 the compact card holds one 64 dp row, so “Bend” (as the Junction’s colour word before it) shows only after a scroll and the arrow sits in the bottom corner; without a recording it overlaps Record by 4 px, where checkpoint B had cleared it with Record’s row lower (its top at 786 px, here at 614 px); while Recording the “© OpenStreetMap contributors” credit lies under the card, the full-screen button shrinks to 5 px under the search bar, and the sheet’s “Stop” wraps. ANR, seen on the emulator only: changing wm density while Recording and Following froze the app, its main thread waiting in MapLibreSurfaceView$RenderThread.onWindowResize from surfaceChanged while the GL thread sat in eglSwapBuffers → BLASTBufferQueue::onFrameAvailable; once the app was closed, the relaunch offered “Resume recording” and Following resumed. Whether a real phone does the same on a density or size change is owed in the DOD. The compact card’s fix, 2026-12-02, pixel-api37 with -gpu host and a window, the debug build at 49eef29, wm density 480 for 360 dp: at font scale 2.0 the Route sheet folds to “To the end: …” while Following, in Hiking (Szczyrk → Skrzyczne, “In 790 m, turn left onto the blue Trail”) with and without a recording: the compact card whole, “Blue” and its stripe under the distance with no scroll, the arrow at the top of its row, and Record, the full-screen button and the credit clear of it. A tap on the line opens the sheet with “Find me on the Route” and “Stop” each whole on its own line; the handle folds it again. At 1.3 the sheet stays open and the compact card clears Record. Cycling (Wisła → Szczyrk, 63.7 km, “In 4.9 km, turn right” with the mute cap) was read at 2.0 with and without a recording on an earlier form of this fix, which measured against the sheet’s cap and also folded at 1.3; the rule then moved to the resting Following sheet. Not read: a Bend card and the leg back at 2.0, nor Cycling after the rule moved. Seen beside the fix: the “Download failed / Retry” card of a debug build with no Region pack sits under the card; once, the first launch after the emulator’s host renderer crashed and it was booted again drew black with the app’s main thread asleep, and a relaunch drew normally. TalkBack running, 2026-12-05, pixel-api36 (API 36), debug build at 90ac549, TalkBack 16.0 with its speech logged: the live region announced only the Junction’s change, never the countdown, with the voice muted (“In 5.4 km, turn sharp left onto the red Bike route”; in Polish “Za 6,4 km skręć w lewo”), off in Settings (“In 6.8 km, turn sharp left”, the mute segment gone) and unavailable (Google’s speech engine disabled), and stayed off with the voice speaking. The mute switch is its own node, read “Off, Mute voice directions, Switch”, its name unchanged by its state; its icon, struck through when muted, and a green plate readable in light and dark. TalkBack there ignored injected touches and swipes, so the card’s sentence (“In 4.9 km, turn right”) and the order, sentence then switch, were read only from the tree; no Route gave a black-marked Junction. Seen beside it: each Settings switch was a second focus stop reading only “On, Switch”; its row is now one labelled switch. A density and size change on a real phone, 2026-12-05, the owner’s phone (Redmi Note 14 Pro 5G, HyperOS, API 36), debug build at 0890576 (0.28.1) over wireless adb: while Recording and Following in Hiking (“In 790 m, turn left onto the blue Trail”, off the Route), wm density 400, 560 and reset, then wm size 1080x2400 and reset, 8 s apart: each change redrawn, the card tall or wide as the width allowed, the recording’s clock running on, no ANR and no crash. The emulator’s freeze did not reproduce on this phone. |
Known gaps, deliberately
- A road on no Bike route is no Junction (Not in). The card and the voice say nothing where it crosses.
- The colour is the Bike route’s, not the paint on the post. Where OSM’s
colourdiffers from the marking on the ground, the voice is wrong in the way the map is. - With the screen off, no leg back is planned (§ 5).
- With the app closed, the stored Route’s Progress stands still while the recording follows it: the map writes it, as in 6b. A process lost then resumes from where the app was closed, and the window reaches on with the time since.
- In the dark theme a black Bike route’s or Trail’s marking sits on a dark ground: the card keeps the
sheets’
BikeRoutePlateandTrailMark, whose ground issurfaceBrightthere, so the colour word carries it. - A Junction matched to the wrong line index on an out-and-back over the same node would be called
twice or at the wrong pass;
JunctionsTestcovers the out-and-back, and the planner keeps indices if it fails.