Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / maps / AGENTS.md
| 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 | - Globe body switch (zoomed-out globe only, session-only): Earth vector basemap plus bundled raster globes for Mercury, Venus, Mars, Jupiter, Saturn, Uranus, Neptune and the Moon — colour mosaics for all, packed DEMs for Mercury/Mars/Moon, ring strips for Saturn/Uranus/Neptune; all baked offline (sources/licences in `planet-data/DATASETS.md`, converter `planet-data/convert_planets.py`), never fetched at runtime |
| 20 | - 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 |
| 21 | - Handles external `geo:` / `google.navigation:` / Google-Maps links from other apps |
| 22 | **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. |
| 23 | **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`. |
| 24 | |
| 25 | ## One APK, two form factors (phone + watch) |
| 26 | This module is the single Maps APK for phones and watches: same |
| 27 | `applicationId = "com.vayunmathur.maps"` and signing on both, as the |
| 28 | WearLink handshake requires. The manifest deliberately declares no |
| 29 | `android.hardware.type.watch` feature (required=true would block |
| 30 | phones; required=false is disallowed for this feature), plus |
| 31 | touchscreen not-required and |
| 32 | `com.google.android.wearable.standalone=false`; distribution is |
| 33 | sideload/F-Droid, not Play's watch channel, so the APK installs on |
| 34 | phones and watches alike. `platform/FormFactor.kt` reads |
| 35 | `PackageManager.FEATURE_WATCH` at runtime: `MainActivity` (the sole |
| 36 | launcher entry) forwards watches to `ui/WearMainActivity` before any |
| 37 | phone state loads; phones get the map UI. The phone sync |
| 38 | (`platform/WearMapsSync`) gates on the same signal and never starts |
| 39 | on a watch; the one manifest receiver, the conduit sync-trigger |
| 40 | receiver (`sync/ConduitSyncTriggerReceiver`), invokes only that |
| 41 | phone-gated sync, so it is inert on a watch. |
| 42 | |
| 43 | ## Wear sync (Watch conduit client) |
| 44 | **Protocol:** shared wire types live in `:library:wearlink` at |
| 45 | `com.vayunmathur.library.wearlink.maps.WearMapsProtocol`; the |
| 46 | golden-JSON tests in this module pin the shared code's wire format. |
| 47 | - 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 |
| 48 | - Route overlay: conduit data item (`/maps/route`, phone -> watch); `active=false` is the explicit clear when navigation ends |
| 49 | - Position: conduit data item (`/maps/position`, phone -> watch) |
| 50 | - Watch state: conduit data item (`/maps/watch-state`, watch -> phone) |
| 51 | - Fresh region: conduit message (`/maps/request-region`), watch -> phone |
| 52 | - **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 as-is (no live-data label is shown on the map-only screen). |
| 53 | - **Push triggers:** the publish also runs on the phone Watch app's scheduled sync-trigger intent (`sync/ConduitSyncTriggerReceiver`, exported only under the `CONDUIT` signature permission, invoking `WearMapsSync.triggerPush()` — no UI, no prompt). Data arriving while the receiving process is dead lands in the conduit host's persistent store and replays on registration. |
| 54 | |
| 55 | ## Watch experience (in this module) |
| 56 | - `ui/WearMainActivity` (a `WearShellActivity`, `exported=false`, no launcher filter) routes `ui/WearRoute` to the rendered map only — no route-detail/saved screens, no phone-directed text, buttons or Open-on-phone action on the watch. |
| 57 | - 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, no native renderer (the arm64-only `libmap_renderer` cannot load on 32-bit watch userspace), north-up. The canvas always draws (land, user puck, scale, north) even before the first snapshot arrives, and all stroke/dot sizes are dp-based. Saved places and the live route draw as map dots/line only. On conduit (re)connect the bridge asks the phone for a fresh region (`WearLinkBridge`) — a data-path trigger, not a user action. |
| 58 | - Watch state persists in `data/WearMapsStore` (`wear-maps-*.json`); the watch experience has no UI strings of its own. |
| 59 | - 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. |
| 60 | **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`. |
| 61 | **Gotchas:** |
| 62 | - 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 |
| 63 | - `singleTop` warm-start geo/navigation links arrive via `onNewIntent`, not a fresh `onCreate` |
| 64 | - The map itself never splits panes (list/detail metadata only for settings/saved); its expanded side panel is separate inside `MapPage` |
| 65 | - `util/` now holds only `OfflineRouter.kt` (JNI package exception); car, cross-app clients and ViewModels all live in closed roots (`platform/`, `intents/`) |
| 66 | |
| 67 | ## Key files |
| 68 | ### Root — entry + navigation |
| 69 | - com/vayunmathur/maps/MainActivity.kt — geo-link handling, archive gate |
| 70 | - com/vayunmathur/maps/Route.kt — `Route` destinations incl. `…Dialog` routes |
| 71 | - com/vayunmathur/maps/Navigation.kt — `MainNavigation` entries (`DialogPage()` dialog hosts) |
| 72 | ### Watch experience (ui/ + platform/ + data/ + domain/ + sync/) |
| 73 | - com/vayunmathur/maps/ui/WearMainActivity.kt — watch entry (WearShellActivity) |
| 74 | - com/vayunmathur/maps/ui/WearRoute.kt, WearMapScreen.kt, WearMapCanvas.kt |
| 75 | - com/vayunmathur/maps/platform/FormFactor.kt — watch detection (`FEATURE_WATCH`) |
| 76 | - com/vayunmathur/maps/platform/WearMapsSync.kt — phone conduit client node; region/route/position publish, request-region handling (gated to phones) |
| 77 | - com/vayunmathur/maps/sync/WearLinkBridge.kt — watch conduit client node; region/route/position receive into the store, watch-state publish |
| 78 | - com/vayunmathur/maps/data/WearMapsStore.kt — persisted watch region/route/position |
| 79 | - com/vayunmathur/maps/domain/WearMapProjection.kt — north-up Canvas projection + route/saved helpers |
| 80 | ### platform/ — Android Auto surface |
| 81 | - com/vayunmathur/maps/platform/MapsCarAppService.kt |
| 82 | - com/vayunmathur/maps/platform/MapsSession.kt |
| 83 | - com/vayunmathur/maps/platform/NavMapScreen.kt |
| 84 | - com/vayunmathur/maps/platform/CarMapRenderer.kt |
| 85 | - com/vayunmathur/maps/platform/CarManeuvers.kt |
| 86 | - com/vayunmathur/maps/platform/CarSearchScreen.kt |
| 87 | ### data/ — prefs, places, POI + transit sources |
| 88 | - com/vayunmathur/maps/data/MapPreferences.kt |
| 89 | - com/vayunmathur/maps/data/MapLinkParser.kt — external geo/maps URL parsing |
| 90 | - com/vayunmathur/maps/data/GeoJson.kt |
| 91 | - com/vayunmathur/maps/data/SpecificFeature.kt |
| 92 | - com/vayunmathur/maps/data/OpeningHours.kt |
| 93 | - com/vayunmathur/maps/data/OsmMaxspeed.kt |
| 94 | - com/vayunmathur/maps/data/SavedPlace.kt |
| 95 | - com/vayunmathur/maps/data/SavedPlaceStore.kt |
| 96 | - com/vayunmathur/maps/data/RecentSearchStore.kt |
| 97 | - com/vayunmathur/maps/data/ParkingStore.kt |
| 98 | - com/vayunmathur/maps/data/google/GooglePoiDataSource.kt — Google place details (photos/hours/phone; no ratings/reviews) |
| 99 | - com/vayunmathur/maps/data/google/GooglePoiModels.kt |
| 100 | - com/vayunmathur/maps/data/PoiPin.kt — offline map POI pin |
| 101 | - com/vayunmathur/maps/data/google/GoogleResponse.kt |
| 102 | - com/vayunmathur/maps/data/google/StreetViewDataSource.kt |
| 103 | - com/vayunmathur/maps/data/google/StreetViewModels.kt |
| 104 | - com/vayunmathur/maps/data/transit/TransitousDataSource.kt |
| 105 | - com/vayunmathur/maps/data/transit/TransitousModels.kt |
| 106 | ### intents/ — assistant IPC |
| 107 | - com/vayunmathur/maps/intents/DirectionsIntent.kt |
| 108 | - 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 |
| 109 | - com/vayunmathur/maps/intents/SavedPlacesIntent.kt — OpenAssistant `maps_get_saved_places`: saved (starred + listed) places, summaries only (name + coordinates), ≤10 rows |
| 110 | ### intents/ — cross-app estimate/lookup clients |
| 111 | - com/vayunmathur/maps/intents/RideEstimateClient.kt — launches taxi intents |
| 112 | - com/vayunmathur/maps/intents/OrderLookupClient.kt — launches fooddelivery intents |
| 113 | - com/vayunmathur/maps/intents/FamilyLocationClient.kt |
| 114 | - com/vayunmathur/maps/intents/FamilyLocationProtocol.kt |
| 115 | - com/vayunmathur/maps/intents/IntentLaunch.kt |
| 116 | ### ui/ — pages, sheets, layers |
| 117 | - com/vayunmathur/maps/ui/MapPage.kt |
| 118 | - com/vayunmathur/maps/ui/MapPageScope.kt |
| 119 | - com/vayunmathur/maps/ui/MapContentBox.kt |
| 120 | - com/vayunmathur/maps/ui/MapSearchActions.kt |
| 121 | - com/vayunmathur/maps/ui/MapSheets.kt |
| 122 | - com/vayunmathur/maps/ui/MapSheetEffects.kt |
| 123 | - com/vayunmathur/maps/ui/MapSidePanel.kt |
| 124 | - com/vayunmathur/maps/ui/MapWideHost.kt |
| 125 | - com/vayunmathur/maps/ui/MapWideLayout.kt |
| 126 | - com/vayunmathur/maps/ui/BottomSheetContent.kt |
| 127 | - com/vayunmathur/maps/ui/BottomSheetHeader.kt |
| 128 | - com/vayunmathur/maps/ui/SearchSheet.kt |
| 129 | - com/vayunmathur/maps/ui/PlaceSheet.kt |
| 130 | - com/vayunmathur/maps/ui/PlaceSheetHeader.kt |
| 131 | - com/vayunmathur/maps/ui/PlaceSheetHours.kt |
| 132 | - com/vayunmathur/maps/ui/PlaceActionRow.kt |
| 133 | - com/vayunmathur/maps/ui/ContactAddressButton.kt |
| 134 | - com/vayunmathur/maps/ui/MapContactAddressEffects.kt — consent route push + contact chooser result delivery |
| 135 | - 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) |
| 136 | - com/vayunmathur/maps/ui/SearchResultLayer.kt |
| 137 | - com/vayunmathur/maps/ui/RouteSheet.kt |
| 138 | - com/vayunmathur/maps/ui/RouteSheetTabs.kt |
| 139 | - com/vayunmathur/maps/ui/TripSheet.kt |
| 140 | - com/vayunmathur/maps/ui/NavigationOverlay.kt |
| 141 | - com/vayunmathur/maps/ui/DeparturesSheet.kt |
| 142 | - com/vayunmathur/maps/ui/DepartureTime.kt |
| 143 | - com/vayunmathur/maps/ui/CategoryChips.kt |
| 144 | - com/vayunmathur/maps/ui/LayersButton.kt |
| 145 | - com/vayunmathur/maps/ui/LayersSheet.kt |
| 146 | - com/vayunmathur/maps/ui/CompassButton.kt |
| 147 | - com/vayunmathur/maps/ui/MapScaleBar.kt |
| 148 | - com/vayunmathur/maps/ui/VoiceSearchButton.kt |
| 149 | - com/vayunmathur/maps/ui/SavedPlacesPage.kt |
| 150 | - com/vayunmathur/maps/ui/SavedPlacesLayer.kt |
| 151 | - com/vayunmathur/maps/ui/FamilyLocationLayer.kt |
| 152 | - com/vayunmathur/maps/ui/ParkingLayer.kt |
| 153 | - com/vayunmathur/maps/ui/ParkingSheet.kt |
| 154 | - com/vayunmathur/maps/ui/RoadsLayer.kt |
| 155 | - com/vayunmathur/maps/ui/SafetyLayer.kt |
| 156 | - com/vayunmathur/maps/ui/SatelliteLayer.kt |
| 157 | - com/vayunmathur/maps/ui/TransitStopsLayer.kt |
| 158 | - com/vayunmathur/maps/ui/PoiEnrichment.kt |
| 159 | - com/vayunmathur/maps/ui/RestaurantItem.kt |
| 160 | - com/vayunmathur/maps/ui/LineBadge.kt |
| 161 | - com/vayunmathur/maps/ui/ManeuverIcon.kt |
| 162 | ### ui/map/ — surface, camera, overlays |
| 163 | - com/vayunmathur/maps/ui/map/MapSurface.kt |
| 164 | - com/vayunmathur/maps/ui/map/MapSurfaceHelpers.kt |
| 165 | - com/vayunmathur/maps/ui/map/MapCamera.kt |
| 166 | - com/vayunmathur/maps/ui/map/MapChrome.kt |
| 167 | - com/vayunmathur/maps/ui/map/MapChromeState.kt |
| 168 | - com/vayunmathur/maps/ui/map/MapFabStack.kt |
| 169 | - com/vayunmathur/maps/ui/map/MapLayers.kt |
| 170 | - com/vayunmathur/maps/ui/map/MapOverlays.kt |
| 171 | - com/vayunmathur/maps/ui/map/MapFeaturePicker.kt |
| 172 | - com/vayunmathur/maps/ui/map/MapPinFeatures.kt |
| 173 | - com/vayunmathur/maps/ui/map/RouteOverlayBuilder.kt |
| 174 | - com/vayunmathur/maps/ui/map/RailLines.kt |
| 175 | - com/vayunmathur/maps/ui/map/TransitVehicles.kt |
| 176 | - com/vayunmathur/maps/ui/map/TrafficPrefetchEffect.kt |
| 177 | - com/vayunmathur/maps/ui/map/WaypointList.kt |
| 178 | ### ui/nav/ — guidance widgets |
| 179 | - com/vayunmathur/maps/ui/nav/ManeuverBanner.kt |
| 180 | - com/vayunmathur/maps/ui/nav/LaneGuidance.kt |
| 181 | - com/vayunmathur/maps/ui/nav/SpeedWidget.kt |
| 182 | - com/vayunmathur/maps/ui/nav/RouteShield.kt |
| 183 | - com/vayunmathur/maps/ui/nav/ArrivalSummary.kt |
| 184 | - com/vayunmathur/maps/ui/nav/StepsSheet.kt |
| 185 | - com/vayunmathur/maps/ui/nav/ElevationChart.kt |
| 186 | ### ui/streetview/ + ui/settings/ + ui/theme/ |
| 187 | - com/vayunmathur/maps/ui/streetview/StreetViewScreen.kt |
| 188 | - com/vayunmathur/maps/ui/streetview/StreetViewPegman.kt |
| 189 | - com/vayunmathur/maps/ui/streetview/StreetViewArrows.kt |
| 190 | - com/vayunmathur/maps/ui/settings/MapSettingsPage.kt |
| 191 | - com/vayunmathur/maps/ui/theme/MapTokens.kt |
| 192 | - com/vayunmathur/maps/ui/theme/BasemapPalette.kt |
| 193 | - com/vayunmathur/maps/ui/theme/MapChromeMetrics.kt |
| 194 | ### platform/ + data/ + domain/ + service/ — ViewModels, offline router, navigation service |
| 195 | - com/vayunmathur/maps/platform/BodyAssetLoader.kt — per-body bundled raster specs + loader (assets/<body>/) |
| 196 | - com/vayunmathur/maps/platform/SelectedFeatureViewModel.kt |
| 197 | - com/vayunmathur/maps/platform/MapsSearchViewModel.kt |
| 198 | - com/vayunmathur/maps/platform/MapsUiContract.kt |
| 199 | - com/vayunmathur/maps/platform/SavedPlacesViewModel.kt |
| 200 | - com/vayunmathur/maps/platform/MapSettingsViewModel.kt |
| 201 | - com/vayunmathur/maps/platform/PlacePanelState.kt |
| 202 | - com/vayunmathur/maps/platform/PoiMapViewModel.kt — map POI pins from the offline index |
| 203 | - com/vayunmathur/maps/platform/TransitStopsViewModel.kt |
| 204 | - com/vayunmathur/maps/domain/TransitClock.kt |
| 205 | - com/vayunmathur/maps/platform/ParkingViewModel.kt |
| 206 | - com/vayunmathur/maps/data/MapTileCache.kt — `.mamaps` archive access |
| 207 | - com/vayunmathur/maps/util/OfflineRouter.kt |
| 208 | - com/vayunmathur/maps/data/OfflineRouterRoadRoutes.kt |
| 209 | - com/vayunmathur/maps/data/OfflineRouterRouteBuilder.kt |
| 210 | - com/vayunmathur/maps/data/OfflineRouterTraffic.kt |
| 211 | - com/vayunmathur/maps/data/OfflineRouterTransit.kt |
| 212 | - com/vayunmathur/maps/domain/RouteService.kt |
| 213 | - com/vayunmathur/maps/service/NavigationService.kt — foreground guidance service |
| 214 | - com/vayunmathur/maps/platform/NavigationSessionManager.kt |
| 215 | - com/vayunmathur/maps/platform/NavigationTts.kt |
| 216 | - com/vayunmathur/maps/domain/PolylineProgress.kt |
| 217 | - com/vayunmathur/maps/data/GTFSProvider.kt |
| 218 | - com/vayunmathur/maps/data/PoiIndex.kt |
| 219 | - com/vayunmathur/maps/data/PoiIndexAttrs.kt |
| 220 | - com/vayunmathur/maps/data/PoiIndexSpatial.kt |
| 221 | - com/vayunmathur/maps/data/PoiIndexWords.kt |
| 222 | - com/vayunmathur/maps/data/PoiIndexRegion.kt — `poi_region` (kind 15) boundary links |
| 223 | - com/vayunmathur/maps/data/PoiIndexAdmin.kt — `poi_admin` (kind 16) hierarchy; search-row locality ("City, State, Country") |
| 224 | - com/vayunmathur/maps/data/PoiSearchEngine.kt — indexed name search (ordinal scans + grid join, blended text/distance rank) |
| 225 | - com/vayunmathur/maps/data/PoiSearchHits.kt — ordinal hit table for the search engine |
| 226 | - com/vayunmathur/maps/data/PoiArchive.kt — POI sections out of the archive (per-section mmaps; planet is ~80 GB) |
| 227 | - com/vayunmathur/maps/data/PoiCategories.kt |
| 228 | - com/vayunmathur/maps/domain/SpatialKey.kt |
| 229 | - com/vayunmathur/maps/platform/RegionalUnits.kt |
| 230 | - com/vayunmathur/maps/domain/ItineraryWording.kt |
| 231 | - com/vayunmathur/maps/domain/CameraBounds.kt |
| 232 | - com/vayunmathur/maps/platform/ContactLookup.kt |
| 233 | - com/vayunmathur/maps/platform/FrameworkLocationManager.kt |
| 234 | |
| 235 | ## Verify (this module only) |
| 236 | ``` |
| 237 | ./gradlew :maps:compileDevKotlin |
| 238 | ./gradlew :maps:lint |
| 239 | ./gradlew :maps:checkMetadata |
| 240 | ``` |