Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
translate ▾

Modern-Apps.git / maps / AGENTS.md

AGENTS.md16.5 KiBRenderedCodeRaw
1# AGENTS.md — maps/ (':maps')
2
3> Scoped supplement. Global rules in root `AGENTS.md` apply. Stay inside `maps/` + allowed shared modules. Do not root-scan.
4
5_Install: ./install maps (dev by default)._
6- Gradle: :maps / dir: maps/
7- Package roots present: ui, data, domain, platform, service, intents, sync, util (single JNI-exception file)
8- Entry files: MainActivity.kt (sole launcher; routes watches to WearMainActivity), Route.kt, Navigation.kt (`Route` + `Navigation` in their own files beside it), ui/WearMainActivity.kt
9- Deps: :library:map, :library:image, :library:network, :library:downloadservice, :library:wearlink, :library:log, Wear Compose (material + foundation)
10- Metadata: metadata_data/maps.md (present)
11- Rust: yes / screenshotTest: yes
12
13## Overview
14**Purpose:** A fast open-source map + navigation app on OpenStreetMap, with all routing on device. Internet only for new tiles, search, traffic, and transit delays.
15**Key features:**
16- On-device routing (drive/walk/bike/transit) over a single packed `.mamaps` archive, downloaded once on first launch; viewed areas keep working offline
17- Turn-by-turn navigation with voice (TTS), lane guidance, speed-limit widget, and elevation; Android Auto via `platform/`
18- Place details, saved places, transit departure boards, Street View, parking, and POI search (offline index from the archive; ratings/review counts/summaries are archive-only, `poi_attrs` keys 10-12)
19- Google is used for exactly two opt-in features (Settings → Google services): Street View and non-review place details (photos, hours, phone/website, popular times) via `GooglePoiDataSource`. No Google search, traffic, POI discovery or reviews
20- Handles external `geo:` / `google.navigation:` / Google-Maps links from other apps
21**Architecture / data-flow:** `ui/` map surface + sheets over per-concern `platform/` ViewModels (`SelectedFeatureViewModel`, `MapsSearchViewModel`, `SavedPlacesViewModel`, …) → `data/` stores/parsers + `data/OfflineRouter*` routing against the memory-mapped archive; guidance runs in the `service/NavigationService` foreground service via `NavigationSessionManager`. `onCreateBeforeContent`: `NetworkClient.init(FIRST_PARTY)` → delete the legacy `world_z0-6.pmtiles` → route the cold-start deep link; `Content()` gates on the `.mamaps` download before the map renders.
22**Entry points + reading order:** `Route` (`MapPage` / `SavedPlacesPage` / `SettingsPage` / `StreetView` / `Navigating` + dialog destinations) → `MainActivity.kt` (`handleIntent`, `navigateTo`) → `ui/MapPage.kt` → `platform/SelectedFeatureViewModel.kt` → `data/OfflineRouterRoadRoutes.kt`.
23
24## One APK, two form factors (phone + watch)
25This module is the single Maps APK for phones and watches: same
26`applicationId = "com.vayunmathur.maps"` and signing on both, as the
27WearLink handshake requires. The manifest deliberately declares no
28`android.hardware.type.watch` feature (required=true would block
29phones; required=false is disallowed for this feature), plus
30touchscreen not-required and
31`com.google.android.wearable.standalone=false`; distribution is
32sideload/F-Droid, not Play's watch channel, so the APK installs on
33phones and watches alike. `platform/FormFactor.kt` reads
34`PackageManager.FEATURE_WATCH` at runtime: `MainActivity` (the sole
35launcher entry) forwards watches to `ui/WearMainActivity` before any
36phone state loads; phones get the map UI. The phone sync
37(`platform/WearMapsSync`) gates on the same signal and never starts
38on a watch; the watch experience carries no manifest receivers, so no
39receiver gating is needed.
40
41## Wear sync (Watch conduit client)
42**Protocol:** shared wire types live in `:library:wearlink` at
43`com.vayunmathur.library.wearlink.maps.WearMapsProtocol`; the
44golden-JSON tests in this module pin the shared code's wire format.
45- Region snapshot: conduit data item (`/maps/region`, phone -> watch) — bounded, simplified, quantized vector geometry for the watch Canvas renderer; the watch carries no tile stack and no planet data
46- Route overlay: conduit data item (`/maps/route`, phone -> watch); `active=false` is the explicit clear when navigation ends
47- Position: conduit data item (`/maps/position`, phone -> watch)
48- Watch state: conduit data item (`/maps/watch-state`, watch -> phone)
49- Fresh region: conduit message (`/maps/request-region`), watch -> phone
50- **Transport: Watch conduit client** — phone side `platform/WearMapsSync.kt` and watch side `sync/WearLinkBridge.kt` both use `WearLinkClientNode` (Messenger to the Watch app's `watch_conduit` service, appId `maps`); this app owns no RFCOMM link and holds no Bluetooth permission for this channel, so neither entry activity prompts for Bluetooth. With the Watch app absent the node reports `NotInstalled`/`Unavailable` and the sync stays idle; region and route republish on conduit `Connected`. The phone supplies the region and is the position source (its location manager / navigation session); the watch runs no GPS of its own. The phone republishes the region when the user nears the snapshot edge (hysteresis, 65% of radius); with the link down the watch renders the last region with a stale/offline label — never as live data.
51
52## Watch experience (in this module)
53- `ui/WearMainActivity` (a `WearShellActivity`, `exported=false`, no launcher filter) routes `ui/WearRoute` over the rendered map home / route detail / saved-places glance.
54- The watch renders one phone-supplied vector snapshot with a plain Canvas projection (`ui/WearMapCanvas.kt`, `domain/WearMapProjection.kt`): no tile stack, no planet data, north-up; the phone has no Home/Work saved-place concept, so the saved glance shows saved places with distance — no ETA is invented.
55- Watch state persists in `data/WearMapsStore` (`wear-maps-*.json`); watch strings are in `res/values/wear_strings.xml`.
56- Watch listing screenshots are the `group = "wear"` previews in `src/screenshotTest/.../ui/WearMetadataPreviews.kt`, collected by `:maps:metadata` into `metadata_data/photos/maps/wear/`; phone shots use the `phone` bucket.
57**Dialogs + screenshots:** every dialog is a `Route.…Dialog` destination (`DialogPage()` entries in `Navigation.kt`, args in the route, stateless content under `ui/dialogs/`; hosts act on the ViewModels, the contact chooser returns its pick via the `RESULT_CONTACT_ADDRESS_*` result keys) — never `show…`/pending-target state in a screen. Each route has a deterministic capture in `src/screenshotTest` (`<n>-<route-key>`, group `phone`); `StreetView` is exempted in `Route.kt` (live Google panorama + GL sphere). Search is a sheet over the live map, so `SearchSheet` carries a `SCAFFOLD SEARCH EXCEPTION`.
58**Gotchas:**
59- The `.mamaps` gate hosts app start — the archive URL must be live before a version ships; `adb push` the file to sideload a locally built archive
60- `singleTop` warm-start geo/navigation links arrive via `onNewIntent`, not a fresh `onCreate`
61- The map itself never splits panes (list/detail metadata only for settings/saved); its expanded side panel is separate inside `MapPage`
62- `util/` now holds only `OfflineRouter.kt` (JNI package exception); car, cross-app clients and ViewModels all live in closed roots (`platform/`, `intents/`)
63
64## Key files
65### Root — entry + navigation
66- com/vayunmathur/maps/MainActivity.kt — geo-link handling, archive gate
67- com/vayunmathur/maps/Route.kt — `Route` destinations incl. `…Dialog` routes
68- com/vayunmathur/maps/Navigation.kt — `MainNavigation` entries (`DialogPage()` dialog hosts)
69### Watch experience (ui/ + platform/ + data/ + domain/ + sync/)
70- com/vayunmathur/maps/ui/WearMainActivity.kt — watch entry (WearShellActivity)
71- com/vayunmathur/maps/ui/WearRoute.kt, WearMapScreen.kt, WearMapCanvas.kt, WearRouteDetailScreen.kt, WearSavedScreen.kt
72- com/vayunmathur/maps/platform/FormFactor.kt — watch detection (`FEATURE_WATCH`)
73- com/vayunmathur/maps/platform/WearMapsSync.kt — phone conduit client node; region/route/position publish, request-region handling (gated to phones)
74- com/vayunmathur/maps/sync/WearLinkBridge.kt — watch conduit client node; region/route/position receive into the store, watch-state publish
75- com/vayunmathur/maps/data/WearMapsStore.kt — persisted watch region/route/position
76- com/vayunmathur/maps/domain/WearMapProjection.kt — north-up Canvas projection + route/saved helpers
77### platform/ — Android Auto surface
78- com/vayunmathur/maps/platform/MapsCarAppService.kt
79- com/vayunmathur/maps/platform/MapsSession.kt
80- com/vayunmathur/maps/platform/NavMapScreen.kt
81- com/vayunmathur/maps/platform/CarMapRenderer.kt
82- com/vayunmathur/maps/platform/CarManeuvers.kt
83- com/vayunmathur/maps/platform/CarSearchScreen.kt
84### data/ — prefs, places, POI + transit sources
85- com/vayunmathur/maps/data/MapPreferences.kt
86- com/vayunmathur/maps/data/MapLinkParser.kt — external geo/maps URL parsing
87- com/vayunmathur/maps/data/GeoJson.kt
88- com/vayunmathur/maps/data/SpecificFeature.kt
89- com/vayunmathur/maps/data/OpeningHours.kt
90- com/vayunmathur/maps/data/OsmMaxspeed.kt
91- com/vayunmathur/maps/data/SavedPlace.kt
92- com/vayunmathur/maps/data/SavedPlaceStore.kt
93- com/vayunmathur/maps/data/RecentSearchStore.kt
94- com/vayunmathur/maps/data/ParkingStore.kt
95- com/vayunmathur/maps/data/google/GooglePoiDataSource.kt — Google place details (photos/hours/phone; no ratings/reviews)
96- com/vayunmathur/maps/data/google/GooglePoiModels.kt
97- com/vayunmathur/maps/data/PoiPin.kt — offline map POI pin
98- com/vayunmathur/maps/data/google/GoogleResponse.kt
99- com/vayunmathur/maps/data/google/StreetViewDataSource.kt
100- com/vayunmathur/maps/data/google/StreetViewModels.kt
101- com/vayunmathur/maps/data/transit/TransitousDataSource.kt
102- com/vayunmathur/maps/data/transit/TransitousModels.kt
103### intents/ — assistant IPC
104- com/vayunmathur/maps/intents/DirectionsIntent.kt
105- com/vayunmathur/maps/intents/SearchPlacesIntent.kt — OpenAssistant `maps_search_places`: offline POI text search (optional near/category), provider-clamped to ≤10 rows, name/address ≤120 chars; coordinates chain into directions/taxi tools
106- com/vayunmathur/maps/intents/SavedPlacesIntent.kt — OpenAssistant `maps_get_saved_places`: saved (starred + listed) places, summaries only (name + coordinates), ≤10 rows
107### intents/ — cross-app estimate/lookup clients
108- com/vayunmathur/maps/intents/RideEstimateClient.kt — launches taxi intents
109- com/vayunmathur/maps/intents/OrderLookupClient.kt — launches fooddelivery intents
110- com/vayunmathur/maps/intents/FamilyLocationClient.kt
111- com/vayunmathur/maps/intents/FamilyLocationProtocol.kt
112- com/vayunmathur/maps/intents/IntentLaunch.kt
113### ui/ — pages, sheets, layers
114- com/vayunmathur/maps/ui/MapPage.kt
115- com/vayunmathur/maps/ui/MapPageScope.kt
116- com/vayunmathur/maps/ui/MapContentBox.kt
117- com/vayunmathur/maps/ui/MapSearchActions.kt
118- com/vayunmathur/maps/ui/MapSheets.kt
119- com/vayunmathur/maps/ui/MapSheetEffects.kt
120- com/vayunmathur/maps/ui/MapSidePanel.kt
121- com/vayunmathur/maps/ui/MapWideHost.kt
122- com/vayunmathur/maps/ui/MapWideLayout.kt
123- com/vayunmathur/maps/ui/BottomSheetContent.kt
124- com/vayunmathur/maps/ui/BottomSheetHeader.kt
125- com/vayunmathur/maps/ui/SearchSheet.kt
126- com/vayunmathur/maps/ui/PlaceSheet.kt
127- com/vayunmathur/maps/ui/PlaceSheetHeader.kt
128- com/vayunmathur/maps/ui/PlaceSheetHours.kt
129- com/vayunmathur/maps/ui/PlaceActionRow.kt
130- com/vayunmathur/maps/ui/ContactAddressButton.kt
131- com/vayunmathur/maps/ui/MapContactAddressEffects.kt — consent route push + contact chooser result delivery
132- com/vayunmathur/maps/ui/dialogs/ — stateless dialog contents + route hosts (Google consent, contact chooser, end-trip, saved-places rename/create/add-to-list, shared text entry)
133- com/vayunmathur/maps/ui/SearchResultLayer.kt
134- com/vayunmathur/maps/ui/RouteSheet.kt
135- com/vayunmathur/maps/ui/RouteSheetTabs.kt
136- com/vayunmathur/maps/ui/TripSheet.kt
137- com/vayunmathur/maps/ui/NavigationOverlay.kt
138- com/vayunmathur/maps/ui/DeparturesSheet.kt
139- com/vayunmathur/maps/ui/DepartureTime.kt
140- com/vayunmathur/maps/ui/CategoryChips.kt
141- com/vayunmathur/maps/ui/LayersButton.kt
142- com/vayunmathur/maps/ui/LayersSheet.kt
143- com/vayunmathur/maps/ui/CompassButton.kt
144- com/vayunmathur/maps/ui/MapScaleBar.kt
145- com/vayunmathur/maps/ui/VoiceSearchButton.kt
146- com/vayunmathur/maps/ui/SavedPlacesPage.kt
147- com/vayunmathur/maps/ui/SavedPlacesLayer.kt
148- com/vayunmathur/maps/ui/FamilyLocationLayer.kt
149- com/vayunmathur/maps/ui/ParkingLayer.kt
150- com/vayunmathur/maps/ui/ParkingSheet.kt
151- com/vayunmathur/maps/ui/RoadsLayer.kt
152- com/vayunmathur/maps/ui/SafetyLayer.kt
153- com/vayunmathur/maps/ui/SatelliteLayer.kt
154- com/vayunmathur/maps/ui/TransitStopsLayer.kt
155- com/vayunmathur/maps/ui/PoiEnrichment.kt
156- com/vayunmathur/maps/ui/RestaurantItem.kt
157- com/vayunmathur/maps/ui/LineBadge.kt
158- com/vayunmathur/maps/ui/ManeuverIcon.kt
159### ui/map/ — surface, camera, overlays
160- com/vayunmathur/maps/ui/map/MapSurface.kt
161- com/vayunmathur/maps/ui/map/MapSurfaceHelpers.kt
162- com/vayunmathur/maps/ui/map/MapCamera.kt
163- com/vayunmathur/maps/ui/map/MapChrome.kt
164- com/vayunmathur/maps/ui/map/MapChromeState.kt
165- com/vayunmathur/maps/ui/map/MapFabStack.kt
166- com/vayunmathur/maps/ui/map/MapLayers.kt
167- com/vayunmathur/maps/ui/map/MapOverlays.kt
168- com/vayunmathur/maps/ui/map/MapFeaturePicker.kt
169- com/vayunmathur/maps/ui/map/MapPinFeatures.kt
170- com/vayunmathur/maps/ui/map/RouteOverlayBuilder.kt
171- com/vayunmathur/maps/ui/map/RailLines.kt
172- com/vayunmathur/maps/ui/map/TransitVehicles.kt
173- com/vayunmathur/maps/ui/map/TrafficPrefetchEffect.kt
174- com/vayunmathur/maps/ui/map/WaypointList.kt
175### ui/nav/ — guidance widgets
176- com/vayunmathur/maps/ui/nav/ManeuverBanner.kt
177- com/vayunmathur/maps/ui/nav/LaneGuidance.kt
178- com/vayunmathur/maps/ui/nav/SpeedWidget.kt
179- com/vayunmathur/maps/ui/nav/RouteShield.kt
180- com/vayunmathur/maps/ui/nav/ArrivalSummary.kt
181- com/vayunmathur/maps/ui/nav/StepsSheet.kt
182- com/vayunmathur/maps/ui/nav/ElevationChart.kt
183### ui/streetview/ + ui/settings/ + ui/theme/
184- com/vayunmathur/maps/ui/streetview/StreetViewScreen.kt
185- com/vayunmathur/maps/ui/streetview/StreetViewPegman.kt
186- com/vayunmathur/maps/ui/streetview/StreetViewArrows.kt
187- com/vayunmathur/maps/ui/settings/MapSettingsPage.kt
188- com/vayunmathur/maps/ui/theme/MapTokens.kt
189- com/vayunmathur/maps/ui/theme/BasemapPalette.kt
190- com/vayunmathur/maps/ui/theme/MapChromeMetrics.kt
191### platform/ + data/ + domain/ + service/ — ViewModels, offline router, navigation service
192- com/vayunmathur/maps/platform/SelectedFeatureViewModel.kt
193- com/vayunmathur/maps/platform/MapsSearchViewModel.kt
194- com/vayunmathur/maps/platform/MapsUiContract.kt
195- com/vayunmathur/maps/platform/SavedPlacesViewModel.kt
196- com/vayunmathur/maps/platform/MapSettingsViewModel.kt
197- com/vayunmathur/maps/platform/PlacePanelState.kt
198- com/vayunmathur/maps/platform/PoiMapViewModel.kt — map POI pins from the offline index
199- com/vayunmathur/maps/platform/TransitStopsViewModel.kt
200- com/vayunmathur/maps/domain/TransitClock.kt
201- com/vayunmathur/maps/platform/ParkingViewModel.kt
202- com/vayunmathur/maps/data/MapTileCache.kt — `.mamaps` archive access
203- com/vayunmathur/maps/util/OfflineRouter.kt
204- com/vayunmathur/maps/data/OfflineRouterRoadRoutes.kt
205- com/vayunmathur/maps/data/OfflineRouterRouteBuilder.kt
206- com/vayunmathur/maps/data/OfflineRouterTraffic.kt
207- com/vayunmathur/maps/data/OfflineRouterTransit.kt
208- com/vayunmathur/maps/domain/RouteService.kt
209- com/vayunmathur/maps/service/NavigationService.kt — foreground guidance service
210- com/vayunmathur/maps/platform/NavigationSessionManager.kt
211- com/vayunmathur/maps/platform/NavigationTts.kt
212- com/vayunmathur/maps/domain/PolylineProgress.kt
213- com/vayunmathur/maps/data/GTFSProvider.kt
214- com/vayunmathur/maps/data/PoiIndex.kt
215- com/vayunmathur/maps/data/PoiIndexAttrs.kt
216- com/vayunmathur/maps/data/PoiIndexSpatial.kt
217- com/vayunmathur/maps/data/PoiIndexWords.kt
218- com/vayunmathur/maps/data/PoiIndexRegion.kt — `poi_region` (kind 15) boundary links
219- com/vayunmathur/maps/data/PoiIndexAdmin.kt — `poi_admin` (kind 16) hierarchy; search-row locality ("City, State, Country")
220- com/vayunmathur/maps/data/PoiSearchEngine.kt — indexed name search (ordinal scans + grid join, blended text/distance rank)
221- com/vayunmathur/maps/data/PoiSearchHits.kt — ordinal hit table for the search engine
222- com/vayunmathur/maps/data/PoiArchive.kt — POI sections out of the archive (per-section mmaps; planet is ~80 GB)
223- com/vayunmathur/maps/data/PoiCategories.kt
224- com/vayunmathur/maps/domain/SpatialKey.kt
225- com/vayunmathur/maps/platform/RegionalUnits.kt
226- com/vayunmathur/maps/domain/ItineraryWording.kt
227- com/vayunmathur/maps/domain/CameraBounds.kt
228- com/vayunmathur/maps/platform/ContactLookup.kt
229- com/vayunmathur/maps/platform/FrameworkLocationManager.kt
230
231## Verify (this module only)
232```
233./gradlew :maps:compileDevKotlin
234./gradlew :maps:lint
235./gradlew :maps:checkMetadata
236```