maps: merge maps-wear into the single maps APK
- Commit
5b49368022340887e4c2ac5745878407a01ff246- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-04 18:11 UTC (1 day ago)
- Parents
7d9df61
Owner directive: singular apps that detect when they are on a watch and adapt, instead of a separate *-wear APK per companion. Maps follows the merged clock pilot (adec0c398 + 31a81d3c5). The merged :maps APK keeps applicationId com.vayunmathur.maps and the convention signing on both form factors, as the WearLink handshake requires; neither side's identity changed. Runtime detection is PackageManager.FEATURE_WATCH (platform/FormFactor): MainActivity, the sole launcher entry, forwards watches to ui/WearMainActivity before any phone state (network init, phone WearMapsSync, archive gate, permission gate) is touched, and phones keep the existing map UI. The phone sync WearMapsSync.start gates on the same signal; the wear experience registers no manifest receivers, so no receiver gating is needed. Tile rendering and routing are untouched; this is the wear slice only. Manifest shape, verified against AGP lint: no android.hardware.type.watch uses-feature is declared. required=true would block phone installs and required=false is disallowed for this feature (InvalidWearFeatureAttribute; Google's packaging model does not support a single Wear/non-Wear APK through Play). Distribution here is sideload/F-Droid, not Play's watch channel, so installation on a watch needs no feature declaration; the standalone=false meta-data, WAKE_LOCK, touchscreen-not-required, and the wear activity (exported=false, no launcher filter) are carried into the phone application element. All maps-wear sources move into maps' closed package roots (wear/data -> data, wear/domain -> domain, wear/sync -> sync, wear/ui -> ui), R references retarget to com.vayunmathur.maps.R, and wear strings merge as res/values/wear_strings.xml (duplicate app_name dropped). The watch unit tests merge into the existing WearMapsProtocolTest (its golden JSON was already pinned there); a new FormFactorTest covers the routing signal. Watch screenshot previews become ui/WearMetadataPreviews with group="wear", so :maps:metadata renders them into metadata_data/photos/maps/wear/ (the old maps-wear bucket captures move there unchanged). The maps-wear module, its settings include, and its AGENTS.md are deleted; root and maps AGENTS.md describe the merged state. Verified fresh on devvm21958 in this worktree: ./gradlew :maps:lint :maps:lintVitalRelease :maps:testDevUnitTest green (972 unit tests, 0 failures, including the moved watch projection/protocol tests and FormFactorTest), plus :maps:compileDevKotlin and :maps:compileDevScreenshotTestKotlin green. Only a real watch can confirm install, FEATURE_WATCH routing, and the Wear OS launcher surface.
Diff
AGENTS.md
diff --git a/AGENTS.md b/AGENTS.mdindex 630ea4b7f3..6ed68055c0 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -49,7 +49,7 @@ Monorepo: ~100 Gradle modules + Rust workspace. Do scoped work only. ### Apps (Gradle key → dir) Reference: `backup/` satisfies every rule; `notes/` second + `intents/` demo. `camera` + `games/voxels` hand-commit screenshots. Full canonical index (Gradle key → dir + group + notes): `.llms/repo-map.md`.-`clock`, `notes`, `calendar`, `launcher` and `todo` are single merged APKs for phone and watch (watch experience inside the phone app's module; the remaining `*-wear` modules are separate companion APKs with the phone app's applicationId/signing).+`clock`, `notes`, `calendar`, `launcher`, `todo` and `maps` are single merged APKs for phone and watch (watch experience inside the phone app's module; the remaining `*-wear` modules are separate companion APKs with the phone app's applicationId/signing). `appstore→appstore/` `astronomy→astronomy/` `auto→auto/,auto/protocol/` `backup→backup/` `calculator→calculator/` `calendar→calendar/` `camera→camera/` `cast→cast/,cast/protocol/,cast/tv/` `clock→clock/` `code→code/` `communicate→communicate/` `contacts→contacts/` `education→education/` `email→email/` `emergency→emergency/` `euicc→euicc/` `everysync→everysync/` `files→files/` `findfamily→findfamily/` `findfamily-ios→apple/FindFamily/` (SwiftPM/xtool, not Gradle) `flashcards→flashcards/` `fooddelivery→fooddelivery/` `health→health/` `keyboard→keyboard/` `launcher→launcher/` `logviewer→logviewer/` `maps→maps/` `measure→measure/` `music→music/` `networklocation→networklocation/` `news→news/` `notes→notes/` `office→office/` `openassistant→openassistant/` `passwords→passwords/` `pdf→pdf/` `photos→photos/` `parentalcontrols→parentalcontrols/` `screentime→screentime/` `setupwizard→setupwizard/` `share→share/` `speech→speech/` `taxi→taxi/` `things→things/` `todo→todo/` `translate→translate/` `travel→travel/` `tuner→tuner/` `updater→updater/` `vpn→vpn/` `weather→weather/` `watch→watch/,watch-wear/` `web→web/` `youpipe→youpipe/,youpipe/extractor/` `games-hub→games/hub/` `games-arrows→games/arrows/` `games-chess→games/chess/` `games-logicgate→games/logicgate/` `games-minesweeper→games/minesweeper/` `games-nonogram→games/nonogram/` `games-pipes→games/pipes/` `games-solitaire→games/solitaire/` `games-sudoku→games/sudoku/` `games-unblockjam→games/unblockjam/` `games-voxels→games/voxels/` `games-wordmaker→games/wordmaker/` Slash == colon for Gradle (`games/voxels` == `games:voxels`).
maps-wear/AGENTS.md
diff --git a/maps-wear/AGENTS.md b/maps-wear/AGENTS.mddeleted file mode 100644index b9e3ee693c..0000000000--- a/maps-wear/AGENTS.md+++ /dev/null@@ -1,51 +0,0 @@-# AGENTS.md — maps-wear/ (':maps:wear')--> Scoped supplement. Global rules in root `AGENTS.md` apply. Stay inside-> `maps-wear/` + `maps/` (the phone side of the same feature).--- Gradle: :maps:wear / dir: maps-wear/ (convention: `common-conventions-wear`)-- Package roots present: ui, data, domain, sync-- Entry file: ui/WearMainActivity.kt--## Why this module exists (read before changing identity)-Wear OS companion of the phone Maps (`:maps`). This module deliberately-uses `applicationId = "com.vayunmathur.maps"` (the phone app's) with the-shared dev/release signing from the convention plugins: WearLink's-handshake token requires the same signing certificate on both sides, so-changing either breaks phone<->watch sync. Bootstrap is a one-time ADB-sideload of this APK onto the watch.--## Protocol-The wire protocol lives in `:library:wearlink` at-`com.vayunmathur.library.wearlink.maps.WearMapsProtocol` (shared by-`:maps` and `:maps:wear`; neither app module depends on the other).-Each side's `WearMapsProtocolTest` pins the same golden JSON against-that shared code.--- Region snapshot: WearLink data item (`/maps/region`, phone -> watch) —- bounded, simplified, quantized vector geometry for a Canvas renderer;- the watch carries no tile stack and no planet data-- Route overlay: WearLink data item (`/maps/route`, phone -> watch);- `active=false` is the explicit clear when navigation ends-- Position: WearLink data item (`/maps/position`, phone -> watch)-- Watch state: WearLink data item (`/maps/watch-state`, watch -> phone)-- Fresh region: WearLink message (`/maps/request-region`), watch -> phone-- Transport: :library:wearlink (RFCOMM, no Play services); app-lifecycle-bound--## Execution model (stated, not implied)-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); between republishes the watch moves the-user dot and follows it within the last region. With the link down the-last region renders with a stale/offline label — never as live data.-North-up in v1; the renderer is a plain Canvas projection, so bearing-rotation is a cheap future step, not claimed here. The phone has no-Home/Work saved-place concept, so the saved glance shows saved places-with distance — no ETA is invented.--## Verify (this module only)-```-./gradlew :maps:wear:assembleDev-./gradlew :maps:wear:testDebugUnitTest-```
maps-wear/build.gradle.kts
diff --git a/maps-wear/build.gradle.kts b/maps-wear/build.gradle.ktsdeleted file mode 100644index 18ce28ed40..0000000000--- a/maps-wear/build.gradle.kts+++ /dev/null@@ -1,31 +0,0 @@-plugins {- id("common-conventions-wear")- id("common-conventions-preview-metadata")-}--launcherIcon {- symbol = "location_on"-}--// Version shared with the phone app (root version.txt).-val wearVersionLines = file("../version.txt").readLines()-val wearVersionCode = wearVersionLines[0].trim().toInt()-val wearVersionName = wearVersionLines[1].trim()--android {- // WearLink handshake requires same package + signing as the phone app.- namespace = "com.vayunmathur.maps.wear"- defaultConfig {- applicationId = "com.vayunmathur.maps"- minSdk = 31- versionCode = wearVersionCode- versionName = wearVersionName- }-}--dependencies {- implementation(libs.kotlinx.coroutines.android)- implementation(project(":library:wearlink"))- testImplementation(libs.kotlin.test)- testImplementation(libs.kotlin.test.junit)-}
maps-wear/src/main/AndroidManifest.xml
diff --git a/maps-wear/src/main/AndroidManifest.xml b/maps-wear/src/main/AndroidManifest.xmldeleted file mode 100644index a7b9f447b3..0000000000--- a/maps-wear/src/main/AndroidManifest.xml+++ /dev/null@@ -1,38 +0,0 @@-<?xml version="1.0" encoding="utf-8"?>-<manifest xmlns:android="http://schemas.android.com/apk/res/android">-- <uses-feature- android:name="android.hardware.type.watch"- android:required="true" />- <uses-feature- android:name="android.hardware.touchscreen"- android:required="false" />-- <uses-permission android:name="android.permission.WAKE_LOCK" />-- <application- android:allowBackup="false"- android:icon="@mipmap/ic_launcher"- android:label="@string/app_name"- android:roundIcon="@mipmap/ic_launcher"- android:supportsRtl="true"- android:theme="@android:style/Theme.Material.NoActionBar">-- <!-- Paired with the phone app, not a standalone watch app. -->- <meta-data- android:name="com.google.android.wearable.standalone"- android:value="false" />-- <activity- android:name=".ui.WearMainActivity"- android:exported="true"- android:taskAffinity="">- <intent-filter>- <action android:name="android.intent.action.MAIN" />- <category android:name="android.intent.category.LAUNCHER" />- </intent-filter>- </activity>-- <!-- WearLink delivery is app-lifecycle-bound; no system listener service. -->- </application>-</manifest>
maps-wear/src/main/res/values/colors.xml
diff --git a/maps-wear/src/main/res/values/colors.xml b/maps-wear/src/main/res/values/colors.xmldeleted file mode 100644index bfc7025d71..0000000000--- a/maps-wear/src/main/res/values/colors.xml+++ /dev/null@@ -1,5 +0,0 @@-<?xml version="1.0" encoding="utf-8"?>-<!-- Background for the generated adaptive launcher icon (see LauncherIconGen). -->-<resources>- <color name="ic_launcher_background">#FFFFFF</color>-</resources>
maps-wear/src/test/java/com/vayunmathur/maps/wear/domain/WearMapsProtocolTest.kt
diff --git a/maps-wear/src/test/java/com/vayunmathur/maps/wear/domain/WearMapsProtocolTest.kt b/maps-wear/src/test/java/com/vayunmathur/maps/wear/domain/WearMapsProtocolTest.ktdeleted file mode 100644index 34b93d1970..0000000000--- a/maps-wear/src/test/java/com/vayunmathur/maps/wear/domain/WearMapsProtocolTest.kt+++ /dev/null@@ -1,153 +0,0 @@-package com.vayunmathur.maps.wear.domain--import com.vayunmathur.library.wearlink.maps.WearLineKind-import com.vayunmathur.library.wearlink.maps.WearMapLine-import com.vayunmathur.library.wearlink.maps.WearMapPoint-import com.vayunmathur.library.wearlink.maps.WearMapSnapshot-import com.vayunmathur.library.wearlink.maps.WearMapsProtocol-import com.vayunmathur.library.wearlink.maps.WearRouteState-import com.vayunmathur.library.wearlink.maps.WearSavedPlace-import com.vayunmathur.library.wearlink.maps.wearDequantize-import com.vayunmathur.library.wearlink.maps.wearQuantize-import kotlin.test.Test-import kotlin.test.assertEquals-import kotlin.test.assertFalse-import kotlin.test.assertTrue-import kotlinx.serialization.encodeToString--class WearMapsProtocolTest {-- @Test- fun goldenSnapshotJson() {- // Must match the phone copy's golden string byte-for-byte.- val snapshot = WearMapSnapshot(- generatedAtMillis = 1_000L,- centerLatE7 = 340_522_350,- centerLonE7 = -1_182_436_830,- lines = listOf(WearMapLine(WearLineKind.ROAD, listOf(0, 0, 10, 0))),- points = listOf(WearMapPoint(0, "Cafe", 5, -3)),- )- assertEquals(- """{"generatedAtMillis":1000,"centerLatE7":340522350,"centerLonE7":-1182436830,""" +- """"lines":[{"kind":"ROAD","pts":[0,0,10,0]}],""" +- """"points":[{"name":"Cafe","dx":5,"dy":-3}]}""",- WearMapsProtocol.json.encodeToString(snapshot),- )- }-- @Test- fun snapshotAndRouteRoundTrip() {- val snapshot = WearMapSnapshot(9L, 10, 20, saved = listOf(WearSavedPlace("Home", 1, 2)))- assertEquals(- snapshot,- WearMapsProtocol.json.decodeFromString<WearMapSnapshot>(- WearMapsProtocol.json.encodeToString(snapshot),- ),- )- val route = WearRouteState(active = true, destinationName = "Work", routePts = listOf(0, 0, 5, 5))- assertEquals(- route,- WearMapsProtocol.json.decodeFromString<WearRouteState>(- WearMapsProtocol.json.encodeToString(route),- ),- )- }-- @Test- fun quantizationRoundTripWithinHalfStep() {- for (meters in listOf(0.0, 1.0, 3.0, 57.0, -123.0, 599.0)) {- val back = wearDequantize(wearQuantize(meters))- assertTrue(kotlin.math.abs(back - meters) <= WearMapsProtocol.QUANT_STEP_M / 2 + 1e-9)- }- }-- @Test- fun projectionCentersNorthUpAndFitsRadius() {- val projection = WearMapProjection(viewportWidthPx = 400f, viewportHeightPx = 400f, radiusM = 600)- assertEquals(200f to 200f, projection.project(0.0, 0.0))- // North is up: +north metres -> smaller y, same x.- val (nx, ny) = projection.project(0.0, 300.0)- assertEquals(200f, nx)- assertTrue(ny < 200f)- // East edge of the region lands on the viewport edge.- val (ex, _) = projection.project(600.0, 0.0)- assertEquals(400f, ex)- assertTrue(projection.insideRegion(600.0, -600.0))- assertFalse(projection.insideRegion(601.0, 0.0))- }-- @Test- fun projectionRoundTripAndPanAndFollow() {- val base = WearMapProjection(viewportWidthPx = 300f, viewportHeightPx = 400f, radiusM = 600)- val (x, y) = base.project(120.0, -80.0)- val (east, north) = base.unproject(x, y)- assertTrue(kotlin.math.abs(east - 120.0) < 1e-6 && kotlin.math.abs(north + 80.0) < 1e-6)- // Following the user recentres: user offset projects to viewport centre.- val follow = base.copy(centerEastM = 120.0, centerNorthM = -80.0)- assertEquals(150f to 200f, follow.project(120.0, -80.0))- // Pan shifts everything by the pan amount.- val panned = base.copy(panEastM = 50.0)- val (px, _) = panned.project(0.0, 0.0)- assertTrue(px > 150f)- }-- @Test- fun routePointConversionAlignsOrigins() {- val snapshot = WearMapSnapshot(centerLatE7 = 0, centerLonE7 = 0, radiusM = 600)- val route = WearRouteState(- active = true,- routeOriginLatE7 = 0,- routeOriginLonE7 = (0.001 * 1e7).toInt(), // ~111 m east- )- val (east, north) = wearRoutePointInSnapshot(snapshot, route, dxUnits = 0, dyUnits = 0)- assertTrue(east in 100.0..125.0 && north == 0.0, "east=$east")- // A route with the same origin as the snapshot maps 1:1 after dequantize.- val same = wearRoutePointInSnapshot(snapshot, route.copy(routeOriginLonE7 = 0), 10, -5)- assertEquals(20.0 to -10.0, same)- }-- @Test- fun staleAfterWindowAndWhenMissing() {- val snapshot = WearMapSnapshot(generatedAtMillis = 1_000L)- assertFalse(wearIsStale(snapshot, 1_000L + WearMapsProtocol.STALE_AFTER_MS))- assertTrue(wearIsStale(snapshot, 1_001L + WearMapsProtocol.STALE_AFTER_MS))- assertTrue(wearIsStale(null, 0L))- }-- @Test- fun routeOverlayLifecycle() {- val active = WearRouteState(active = true, destinationName = "Work", nextText = "Turn left")- val applied = wearApplyRouteState(null, active)- assertEquals(active, applied)- // A newer active state replaces; an inactive state clears and stays cleared.- val newer = active.copy(nextText = "Turn right")- assertEquals(newer, wearApplyRouteState(applied, newer))- assertEquals(null, wearApplyRouteState(newer, WearRouteState(active = false)))- assertEquals(null, wearApplyRouteState(null, WearRouteState(active = false)))- }-- @Test- fun snapshotRouteLinesAreNeverBasemap() {- // Berlin centre; the baked-in ROUTE segment runs (0 m, 0 m) ->- // (100 m east, 0 m) in quantized units (50 units * 2 m).- val road = WearMapLine(WearLineKind.ROAD, listOf(0, 0, 10, 0))- val building = WearMapLine(WearLineKind.BUILDING, listOf(0, 0, 5, 0, 5, 5), closed = true)- val bakedRoute = WearMapLine(WearLineKind.ROUTE, listOf(0, 0, 50, 0))- val closedRoute = WearMapLine(WearLineKind.ROUTE, listOf(0, 0, 50, 0), closed = true)- val snapshot = WearMapSnapshot(- centerLatE7 = 525_200_000,- centerLonE7 = 134_050_000,- lines = listOf(road, bakedRoute, building, closedRoute),- )- // Cleared route (route == null after active=false) and reroute alike:- // only the live WearRouteState may draw a route, never the snapshot.- assertEquals(listOf(road, building), wearBasemapLines(snapshot))- }-- @Test- fun savedDistanceUsesUserPosition() {- val home = WearSavedPlace("Home", latE7 = 0, lonE7 = (0.01 * 1e7).toInt()) // ~1.1 km east- val distance = wearDistanceM(0, 0, home)- assertTrue(distance in 1_000.0..1_200.0, "distance=$distance")- }-}
maps/AGENTS.md
diff --git a/maps/AGENTS.md b/maps/AGENTS.mdindex e2e918defb..cc62b3c230 100644--- a/maps/AGENTS.md+++ b/maps/AGENTS.md@@ -4,9 +4,9 @@ _Install: ./install maps (dev by default)._ - Gradle: :maps / dir: maps/-- Package roots present: ui, data, domain, platform, service, intents, util (single JNI-exception file)-- Entry files: MainActivity.kt, Route.kt, Navigation.kt (`Route` + `Navigation` in their own files beside it)-- Deps: :library:map, :library:image, :library:network, :library:downloadservice+- Package roots present: ui, data, domain, platform, service, intents, sync, util (single JNI-exception file)+- 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+- Deps: :library:map, :library:image, :library:network, :library:downloadservice, :library:wearlink, :library:log, Wear Compose (material + foundation) - Metadata: metadata_data/maps.md (present) - Rust: yes / screenshotTest: yes @@ -20,6 +20,40 @@ _Install: ./install maps (dev by default)._ - Handles external `geo:` / `google.navigation:` / Google-Maps links from other apps **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. **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`.++## One APK, two form factors (phone + watch)+This module is the single Maps APK for phones and watches: same+`applicationId = "com.vayunmathur.maps"` and signing on both, as the+WearLink handshake requires. The manifest deliberately declares no+`android.hardware.type.watch` feature (required=true would block+phones; required=false is disallowed for this feature), plus+touchscreen not-required and+`com.google.android.wearable.standalone=false`; distribution is+sideload/F-Droid, not Play's watch channel, so the APK installs on+phones and watches alike. `platform/FormFactor.kt` reads+`PackageManager.FEATURE_WATCH` at runtime: `MainActivity` (the sole+launcher entry) forwards watches to `ui/WearMainActivity` before any+phone state loads; phones get the map UI. The phone sync+(`platform/WearMapsSync`) gates on the same signal and never starts+on a watch; the watch experience carries no manifest receivers, so no+receiver gating is needed.++## Wear sync (Watch companion, both sides in this module)+**Protocol:** shared wire types live in `:library:wearlink` at+`com.vayunmathur.library.wearlink.maps.WearMapsProtocol`; the+golden-JSON tests in this module pin the shared code's wire format.+- Region snapshot: WearLink 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+- Route overlay: WearLink data item (`/maps/route`, phone -> watch); `active=false` is the explicit clear when navigation ends+- Position: WearLink data item (`/maps/position`, phone -> watch)+- Watch state: WearLink data item (`/maps/watch-state`, watch -> phone)+- Fresh region: WearLink message (`/maps/request-region`), watch -> phone+- **Transport: WearLink (RFCOMM, no Play services)** — phone side `platform/WearMapsSync.kt`, watch side `sync/WearLinkBridge.kt`; app-lifecycle-bound. 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.++## Watch experience (in this module)+- `ui/WearMainActivity` (a `WearShellActivity`, `exported=false`, no launcher filter) routes `ui/WearRoute` over the rendered map home / route detail / saved-places glance.+- 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.+- Watch state persists in `data/WearMapsStore` (`wear-maps-*.json`); watch strings are in `res/values/wear_strings.xml`.+- 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. **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`. **Gotchas:** - 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@@ -32,6 +66,14 @@ _Install: ./install maps (dev by default)._ - com/vayunmathur/maps/MainActivity.kt — geo-link handling, archive gate - com/vayunmathur/maps/Route.kt — `Route` destinations incl. `…Dialog` routes - com/vayunmathur/maps/Navigation.kt — `MainNavigation` entries (`DialogPage()` dialog hosts)+### Watch experience (ui/ + platform/ + data/ + domain/ + sync/)+- com/vayunmathur/maps/ui/WearMainActivity.kt — watch entry (WearShellActivity)+- com/vayunmathur/maps/ui/WearRoute.kt, WearMapScreen.kt, WearMapCanvas.kt, WearRouteDetailScreen.kt, WearSavedScreen.kt+- com/vayunmathur/maps/platform/FormFactor.kt — watch detection (`FEATURE_WATCH`)+- com/vayunmathur/maps/platform/WearMapsSync.kt — phone sync publisher (gated to phones)+- com/vayunmathur/maps/sync/WearLinkBridge.kt — watch sync receiver + watch-state publisher+- com/vayunmathur/maps/data/WearMapsStore.kt — persisted watch region/route/position+- com/vayunmathur/maps/domain/WearMapProjection.kt — north-up Canvas projection + route/saved helpers ### platform/ — Android Auto surface - com/vayunmathur/maps/platform/MapsCarAppService.kt - com/vayunmathur/maps/platform/MapsSession.kt
maps/build.gradle.kts
diff --git a/maps/build.gradle.kts b/maps/build.gradle.ktsindex 0cd0b7ec52..15130ae1c4 100644--- a/maps/build.gradle.kts+++ b/maps/build.gradle.kts@@ -131,10 +131,17 @@ dependencies { // WorkManager: the map-overlay check worker outlives the settings screen. implementation(project(":library:work")) - // Phone side of the Wear OS companion (platform/WearMapsSync): region- // snapshot + route overlay to :maps:wear, which shares this app's- // applicationId and signing certificate.+ // Both sides of the Wear OS sync live in this one APK (same+ // applicationId and signing, as the WearLink handshake requires):+ // platform/WearMapsSync publishes the phone region/route/position,+ // sync/WearLinkBridge receives them on a watch. FormFactor picks+ // the side at runtime. implementation(project(":library:wearlink"))+ // Watch experience (ui/Wear*): Wear Compose + the repo log facade the+ // watch data/sync code writes through.+ implementation(libs.androidx.wear.compose.material)+ implementation(libs.androidx.wear.compose.foundation)+ implementation(project(":library:log")) // Manifest JSON parsing (pure JVM: unit-testable, unlike org.json). implementation(libs.kotlinx.serialization.json)
maps/src/main/AndroidManifest.xml
diff --git a/maps/src/main/AndroidManifest.xml b/maps/src/main/AndroidManifest.xmlindex 22f542c7ce..2113d779ec 100644--- a/maps/src/main/AndroidManifest.xml+++ b/maps/src/main/AndroidManifest.xml@@ -1,6 +1,23 @@ <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">+ <!-- Single APK for phone and watch. Deliberately NO+ android.hardware.type.watch uses-feature here: required="true"+ would block every phone install, and required="false" is+ disallowed for this feature (lint InvalidWearFeatureAttribute;+ Google's packaging model does not support one APK for Wear and+ non-Wear via Play). This app does not distribute through Play's+ watch channel — it is sideloaded / F-Droid-installed, where no+ feature declaration is needed to install on a watch — so the+ APK carries no watch feature filter at all and+ FormFactor.isWatch (PackageManager.FEATURE_WATCH, still+ reported by watch hardware at runtime) routes the experience. -->+ <uses-feature+ android:name="android.hardware.touchscreen"+ android:required="false" />+ <!-- The watch experience keeps the watch CPU awake while it renders. -->+ <uses-permission android:name="android.permission.WAKE_LOCK" />+ <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />@@ -54,6 +71,11 @@ android:roundIcon="@mipmap/ic_launcher" android:supportsRtl="true" android:theme="@style/Theme.General">++ <!-- Watch experience is paired with the phone app, not standalone. -->+ <meta-data+ android:name="com.google.android.wearable.standalone"+ android:value="false" /> <activity android:configChanges="mcc|mnc|colorMode|density|fontScale|fontWeightAdjustment|keyboard|keyboardHidden|layoutDirection|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode" android:name=".MainActivity"@@ -96,6 +118,15 @@ </intent-filter> </activity> + <!-- Watch experience: entered only via MainActivity's watch routing+ (no launcher filter of its own). Inert on a phone: it is reached+ only from the watch-routed launcher entry. -->+ <activity+ android:name=".ui.WearMainActivity"+ android:exported="false"+ android:taskAffinity=""+ android:theme="@android:style/Theme.Material.NoActionBar" />+ <activity android:name=".intents.DirectionsIntent" android:exported="true"
maps/src/main/java/com/vayunmathur/maps/MainActivity.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/MainActivity.kt b/maps/src/main/java/com/vayunmathur/maps/MainActivity.ktindex b640b2512a..1c04a9dc6e 100644--- a/maps/src/main/java/com/vayunmathur/maps/MainActivity.kt+++ b/maps/src/main/java/com/vayunmathur/maps/MainActivity.kt@@ -9,6 +9,7 @@ import com.vayunmathur.maps.platform.TransitStopsViewModel import android.Manifest import android.content.Intent import android.os.Build+import android.os.Bundle import androidx.activity.viewModels import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState@@ -49,6 +50,8 @@ import com.vayunmathur.maps.domain.RouteService import com.vayunmathur.maps.platform.SavedPlacesViewModel import com.vayunmathur.maps.platform.SelectedFeatureViewModel import com.vayunmathur.maps.platform.MapSettingsViewModel+import com.vayunmathur.maps.platform.FormFactor+import com.vayunmathur.maps.ui.WearMainActivity import com.vayunmathur.library.network.NetworkClient import com.vayunmathur.library.network.TrustBundle import kotlinx.coroutines.Dispatchers@@ -59,9 +62,28 @@ import kotlinx.serialization.Serializable import com.vayunmathur.library.map.GeoPoint import java.io.File -/** Main Activity: a ma activity implementation for main activity. */+/**+ * Sole launcher entry of the single merged Maps APK. On a watch (the+ * `android.hardware.type.watch` system feature, see [FormFactor]) it hands+ * off to [WearMainActivity] and finishes before any phone state (network+ * init, phone WearLink sync, archive gate, permission gate) is touched;+ * on a phone it owns the map/navigation UI and the phone side of the+ * watch sync.+ */ class MainActivity : MaActivity() { + /** True on a watch, where this activity only forwards to [WearMainActivity]. */+ private var routedToWear = false++ override fun onCreate(savedInstanceState: Bundle?) {+ routedToWear = FormFactor.isWatch(this)+ super.onCreate(savedInstanceState)+ if (routedToWear) {+ startActivity(Intent(this, WearMainActivity::class.java))+ finish()+ }+ }+ /** Shared constants and helpers for MainActivity. */ companion object { private const val TAG = "MapsIntent"@@ -84,6 +106,7 @@ class MainActivity : MaActivity() { private val searchVm: MapsSearchViewModel by viewModels() override fun onCreateBeforeContent() {+ if (routedToWear) return // FIRST_PARTY: data.maproj.org tiles + amenities + api.maproj.org -> ISRG+GTS NetworkClient.init(this, TrustBundle.FIRST_PARTY) // Wear watch companion (region snapshot + route overlay over@@ -120,6 +143,10 @@ class MainActivity : MaActivity() { @Composable override fun AppTheme(content: @Composable () -> Unit) {+ if (routedToWear) {+ content()+ return+ } val ds = DataStoreUtils.getInstance(this) val themeMode by ds.stringFlow(MapPreferences.KEY_THEME_MODE) .collectAsState(initial = ds.getString(MapPreferences.KEY_THEME_MODE))@@ -128,6 +155,9 @@ class MainActivity : MaActivity() { @Composable override fun Content() {+ // On a watch this activity is finishing towards WearMainActivity;+ // compose nothing (and touch no phone state) in the meantime.+ if (routedToWear) return val ds = DataStoreUtils.getInstance(this) // One download: the single-archive `.mamaps` carries the tiles // plus every former side file as sections (graph metadata /@@ -181,6 +211,7 @@ class MainActivity : MaActivity() { // Warm start: the app was already running when another app fired a geo:/maps/ // navigation intent at us. singleTop (see AndroidManifest) routes it here. override fun onNewIntent(intent: Intent) {+ if (routedToWear) return super.onNewIntent(intent) setIntent(intent) handleIntent(intent)
maps/src/main/java/com/vayunmathur/maps/data/WearMapsStore.kt
diff --git a/maps-wear/src/main/java/com/vayunmathur/maps/wear/data/WearMapsStore.kt b/maps/src/main/java/com/vayunmathur/maps/data/WearMapsStore.ktsimilarity index 95%rename from maps-wear/src/main/java/com/vayunmathur/maps/wear/data/WearMapsStore.ktrename to maps/src/main/java/com/vayunmathur/maps/data/WearMapsStore.ktindex 83418f5957..dfbbd7edb8 100644--- a/maps-wear/src/main/java/com/vayunmathur/maps/wear/data/WearMapsStore.kt+++ b/maps/src/main/java/com/vayunmathur/maps/data/WearMapsStore.kt@@ -1,4 +1,4 @@-package com.vayunmathur.maps.wear.data+package com.vayunmathur.maps.data import android.content.Context import com.vayunmathur.library.log.Log@@ -64,7 +64,7 @@ class WearMapsStore private constructor(private val context: Context) { /** Applies a route state; `active=false` clears the overlay (route ended). */ fun setRoute(state: WearRouteState) {- val applied = com.vayunmathur.maps.wear.domain.wearApplyRouteState(_route.value, state)+ val applied = com.vayunmathur.maps.domain.wearApplyRouteState(_route.value, state) _route.value = applied if (applied == null) { runCatching { routeFile.delete() }@@ -80,7 +80,7 @@ class WearMapsStore private constructor(private val context: Context) { } private fun publishWatchState() {- com.vayunmathur.maps.wear.sync.WearLinkBridge.publishWatchState(context)+ com.vayunmathur.maps.sync.WearLinkBridge.publishWatchState(context) } /** The watch-state document the bridge republishes on connect. */
maps/src/main/java/com/vayunmathur/maps/domain/WearMapProjection.kt
diff --git a/maps-wear/src/main/java/com/vayunmathur/maps/wear/domain/WearMapProjection.kt b/maps/src/main/java/com/vayunmathur/maps/domain/WearMapProjection.ktsimilarity index 99%rename from maps-wear/src/main/java/com/vayunmathur/maps/wear/domain/WearMapProjection.ktrename to maps/src/main/java/com/vayunmathur/maps/domain/WearMapProjection.ktindex 123c26f662..cdc98e64e8 100644--- a/maps-wear/src/main/java/com/vayunmathur/maps/wear/domain/WearMapProjection.kt+++ b/maps/src/main/java/com/vayunmathur/maps/domain/WearMapProjection.kt@@ -1,4 +1,4 @@-package com.vayunmathur.maps.wear.domain+package com.vayunmathur.maps.domain import com.vayunmathur.library.wearlink.maps.WearLineKind import com.vayunmathur.library.wearlink.maps.WearMapLine
maps/src/main/java/com/vayunmathur/maps/platform/FormFactor.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/platform/FormFactor.kt b/maps/src/main/java/com/vayunmathur/maps/platform/FormFactor.ktnew file mode 100644index 0000000000..0a5f68fc71--- /dev/null+++ b/maps/src/main/java/com/vayunmathur/maps/platform/FormFactor.kt@@ -0,0 +1,25 @@+package com.vayunmathur.maps.platform++import android.content.Context+import android.content.pm.PackageManager++/**+ * Runtime form-factor detection for the single merged Maps APK.+ *+ * One APK ships to phones and watches (same applicationId and signing, as+ * the WearLink handshake requires). [PackageManager.FEATURE_WATCH] is the+ * canonical signal: Wear OS devices report the `android.hardware.type.watch`+ * system feature, phones and tablets do not. The manifest deliberately+ * declares no such uses-feature (required=true would block phones,+ * required=false is disallowed for this feature), so the same APK+ * installs on both; this runtime check is what routes the experience.+ */+object FormFactor {++ /** True when this device reports the watch system feature. */+ fun isWatch(context: Context): Boolean =+ isWatch(context.packageManager.hasSystemFeature(PackageManager.FEATURE_WATCH))++ /** Pure core of [isWatch], split out so unit tests need no Android runtime. */+ fun isWatch(hasWatchSystemFeature: Boolean): Boolean = hasWatchSystemFeature+}
maps/src/main/java/com/vayunmathur/maps/platform/WearMapsSync.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/platform/WearMapsSync.kt b/maps/src/main/java/com/vayunmathur/maps/platform/WearMapsSync.ktindex 99440ac0b0..f1ec4cee5e 100644--- a/maps/src/main/java/com/vayunmathur/maps/platform/WearMapsSync.kt+++ b/maps/src/main/java/com/vayunmathur/maps/platform/WearMapsSync.kt@@ -80,6 +80,9 @@ object WearMapsSync { private var routeWasActive = false fun start(context: Context) {+ // Phone experience only: on a watch the sync/WearLinkBridge side+ // receives the region/route/position instead of publishing them.+ if (FormFactor.isWatch(context)) return val appContext = context.applicationContext if (node != null) return synchronized(this) {
maps/src/main/java/com/vayunmathur/maps/sync/WearLinkBridge.kt
diff --git a/maps-wear/src/main/java/com/vayunmathur/maps/wear/sync/WearLinkBridge.kt b/maps/src/main/java/com/vayunmathur/maps/sync/WearLinkBridge.ktsimilarity index 97%rename from maps-wear/src/main/java/com/vayunmathur/maps/wear/sync/WearLinkBridge.ktrename to maps/src/main/java/com/vayunmathur/maps/sync/WearLinkBridge.ktindex 83793f2628..e8cd945b66 100644--- a/maps-wear/src/main/java/com/vayunmathur/maps/wear/sync/WearLinkBridge.kt+++ b/maps/src/main/java/com/vayunmathur/maps/sync/WearLinkBridge.kt@@ -1,11 +1,11 @@-package com.vayunmathur.maps.wear.sync+package com.vayunmathur.maps.sync import android.content.Context import com.vayunmathur.library.log.Log import com.vayunmathur.library.wearlink.WearLinkListener import com.vayunmathur.library.wearlink.WearLinkNode import com.vayunmathur.library.wearlink.WearLinkState-import com.vayunmathur.maps.wear.data.WearMapsStore+import com.vayunmathur.maps.data.WearMapsStore import com.vayunmathur.library.wearlink.maps.WearMapSnapshot import com.vayunmathur.library.wearlink.maps.WearMapsProtocol import com.vayunmathur.library.wearlink.maps.WearPosition
maps/src/main/java/com/vayunmathur/maps/ui/WearMainActivity.kt
diff --git a/maps-wear/src/main/java/com/vayunmathur/maps/wear/ui/WearMainActivity.kt b/maps/src/main/java/com/vayunmathur/maps/ui/WearMainActivity.ktsimilarity index 89%rename from maps-wear/src/main/java/com/vayunmathur/maps/wear/ui/WearMainActivity.ktrename to maps/src/main/java/com/vayunmathur/maps/ui/WearMainActivity.ktindex 2b1fa86749..23a179493a 100644--- a/maps-wear/src/main/java/com/vayunmathur/maps/wear/ui/WearMainActivity.kt+++ b/maps/src/main/java/com/vayunmathur/maps/ui/WearMainActivity.kt@@ -1,9 +1,9 @@-package com.vayunmathur.maps.wear.ui+package com.vayunmathur.maps.ui import androidx.compose.runtime.Composable import com.vayunmathur.library.wearlink.WearShellActivity-import com.vayunmathur.maps.wear.data.WearMapsStore-import com.vayunmathur.maps.wear.sync.WearLinkBridge+import com.vayunmathur.maps.data.WearMapsStore+import com.vayunmathur.maps.sync.WearLinkBridge /** * Watch maps entry: the rendered map home, route detail and saved glance,
maps/src/main/java/com/vayunmathur/maps/ui/WearMapCanvas.kt
diff --git a/maps-wear/src/main/java/com/vayunmathur/maps/wear/ui/WearMapCanvas.kt b/maps/src/main/java/com/vayunmathur/maps/ui/WearMapCanvas.ktsimilarity index 95%rename from maps-wear/src/main/java/com/vayunmathur/maps/wear/ui/WearMapCanvas.ktrename to maps/src/main/java/com/vayunmathur/maps/ui/WearMapCanvas.ktindex 26fa4580b2..e977729485 100644--- a/maps-wear/src/main/java/com/vayunmathur/maps/wear/ui/WearMapCanvas.kt+++ b/maps/src/main/java/com/vayunmathur/maps/ui/WearMapCanvas.kt@@ -1,4 +1,4 @@-package com.vayunmathur.maps.wear.ui+package com.vayunmathur.maps.ui import androidx.compose.foundation.Canvas import androidx.compose.foundation.layout.fillMaxSize@@ -14,10 +14,10 @@ import com.vayunmathur.library.wearlink.maps.WearMapSnapshot import com.vayunmathur.library.wearlink.maps.WearPosition import com.vayunmathur.library.wearlink.maps.WearRouteState import com.vayunmathur.library.wearlink.maps.wearDequantize-import com.vayunmathur.maps.wear.domain.WearMapProjection-import com.vayunmathur.maps.wear.domain.wearBasemapLines-import com.vayunmathur.maps.wear.domain.wearOffsetInSnapshot-import com.vayunmathur.maps.wear.domain.wearRoutePointInSnapshot+import com.vayunmathur.maps.domain.WearMapProjection+import com.vayunmathur.maps.domain.wearBasemapLines+import com.vayunmathur.maps.domain.wearOffsetInSnapshot+import com.vayunmathur.maps.domain.wearRoutePointInSnapshot import kotlin.math.cos import kotlin.math.sin
maps/src/main/java/com/vayunmathur/maps/ui/WearMapScreen.kt
diff --git a/maps-wear/src/main/java/com/vayunmathur/maps/wear/ui/WearMapScreen.kt b/maps/src/main/java/com/vayunmathur/maps/ui/WearMapScreen.ktsimilarity index 96%rename from maps-wear/src/main/java/com/vayunmathur/maps/wear/ui/WearMapScreen.ktrename to maps/src/main/java/com/vayunmathur/maps/ui/WearMapScreen.ktindex 3b3aadc7e0..0cb6bdd566 100644--- a/maps-wear/src/main/java/com/vayunmathur/maps/wear/ui/WearMapScreen.kt+++ b/maps/src/main/java/com/vayunmathur/maps/ui/WearMapScreen.kt@@ -1,4 +1,4 @@-package com.vayunmathur.maps.wear.ui+package com.vayunmathur.maps.ui import androidx.compose.foundation.layout.Box import androidx.compose.foundation.lazy.LazyRow@@ -23,10 +23,10 @@ import androidx.wear.compose.material.Chip import androidx.wear.compose.material.ChipDefaults import androidx.wear.compose.material.MaterialTheme import androidx.wear.compose.material.Text-import com.vayunmathur.maps.wear.R-import com.vayunmathur.maps.wear.data.WearMapsStore-import com.vayunmathur.maps.wear.domain.wearIsStale-import com.vayunmathur.maps.wear.sync.WearLinkBridge+import com.vayunmathur.maps.R+import com.vayunmathur.maps.data.WearMapsStore+import com.vayunmathur.maps.domain.wearIsStale+import com.vayunmathur.maps.sync.WearLinkBridge import kotlinx.coroutines.launch /**
maps/src/main/java/com/vayunmathur/maps/ui/WearRoute.kt
diff --git a/maps-wear/src/main/java/com/vayunmathur/maps/wear/ui/WearRoute.kt b/maps/src/main/java/com/vayunmathur/maps/ui/WearRoute.ktsimilarity index 91%rename from maps-wear/src/main/java/com/vayunmathur/maps/wear/ui/WearRoute.ktrename to maps/src/main/java/com/vayunmathur/maps/ui/WearRoute.ktindex c3fc4fbd92..a501cbd767 100644--- a/maps-wear/src/main/java/com/vayunmathur/maps/wear/ui/WearRoute.kt+++ b/maps/src/main/java/com/vayunmathur/maps/ui/WearRoute.kt@@ -1,4 +1,4 @@-package com.vayunmathur.maps.wear.ui+package com.vayunmathur.maps.ui /** Watch navigation destinations mirroring the phone IA: map home, route detail, saved glance. */ sealed interface WearRoute {
maps/src/main/java/com/vayunmathur/maps/ui/WearRouteDetailScreen.kt
diff --git a/maps-wear/src/main/java/com/vayunmathur/maps/wear/ui/WearRouteDetailScreen.kt b/maps/src/main/java/com/vayunmathur/maps/ui/WearRouteDetailScreen.ktsimilarity index 96%rename from maps-wear/src/main/java/com/vayunmathur/maps/wear/ui/WearRouteDetailScreen.ktrename to maps/src/main/java/com/vayunmathur/maps/ui/WearRouteDetailScreen.ktindex ed87023cbb..943b244c62 100644--- a/maps-wear/src/main/java/com/vayunmathur/maps/wear/ui/WearRouteDetailScreen.kt+++ b/maps/src/main/java/com/vayunmathur/maps/ui/WearRouteDetailScreen.kt@@ -1,4 +1,4 @@-package com.vayunmathur.maps.wear.ui+package com.vayunmathur.maps.ui import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding@@ -16,8 +16,8 @@ import androidx.wear.compose.material.Chip import androidx.wear.compose.material.ChipDefaults import androidx.wear.compose.material.MaterialTheme import androidx.wear.compose.material.Text-import com.vayunmathur.maps.wear.R-import com.vayunmathur.maps.wear.data.WearMapsStore+import com.vayunmathur.maps.R+import com.vayunmathur.maps.data.WearMapsStore /** Route detail page: next maneuver plus the phone's maneuver list, or the no-route honesty. */ @Composable
maps/src/main/java/com/vayunmathur/maps/ui/WearSavedScreen.kt
diff --git a/maps-wear/src/main/java/com/vayunmathur/maps/wear/ui/WearSavedScreen.kt b/maps/src/main/java/com/vayunmathur/maps/ui/WearSavedScreen.ktsimilarity index 95%rename from maps-wear/src/main/java/com/vayunmathur/maps/wear/ui/WearSavedScreen.ktrename to maps/src/main/java/com/vayunmathur/maps/ui/WearSavedScreen.ktindex 66ea29cfab..7644b1028b 100644--- a/maps-wear/src/main/java/com/vayunmathur/maps/wear/ui/WearSavedScreen.kt+++ b/maps/src/main/java/com/vayunmathur/maps/ui/WearSavedScreen.kt@@ -1,4 +1,4 @@-package com.vayunmathur.maps.wear.ui+package com.vayunmathur.maps.ui import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding@@ -16,9 +16,9 @@ import androidx.wear.compose.material.Chip import androidx.wear.compose.material.ChipDefaults import androidx.wear.compose.material.MaterialTheme import androidx.wear.compose.material.Text-import com.vayunmathur.maps.wear.R-import com.vayunmathur.maps.wear.data.WearMapsStore-import com.vayunmathur.maps.wear.domain.wearDistanceM+import com.vayunmathur.maps.R+import com.vayunmathur.maps.data.WearMapsStore+import com.vayunmathur.maps.domain.wearDistanceM /** * Saved places glance: name + distance from the user (phone position, or
maps/src/main/res/values/wear_strings.xml
diff --git a/maps-wear/src/main/res/values/strings.xml b/maps/src/main/res/values/wear_strings.xmlsimilarity index 95%rename from maps-wear/src/main/res/values/strings.xmlrename to maps/src/main/res/values/wear_strings.xmlindex 4c476d7c80..29ac7a7bb1 100644--- a/maps-wear/src/main/res/values/strings.xml+++ b/maps/src/main/res/values/wear_strings.xml@@ -1,6 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> <resources>- <string name="app_name">Maps</string> <string name="wear_no_region">No map synced yet. Open Maps on your phone to sync this watch.</string> <string name="wear_stale">Stale · last map from your phone</string> <string name="wear_offline">Offline · showing the last map</string>
maps/src/screenshotTest/kotlin/com/vayunmathur/maps/ui/WearMetadataPreviews.kt
diff --git a/maps-wear/src/screenshotTest/kotlin/com/vayunmathur/maps/wear/ui/MetadataPreviews.kt b/maps/src/screenshotTest/kotlin/com/vayunmathur/maps/ui/WearMetadataPreviews.ktsimilarity index 93%rename from maps-wear/src/screenshotTest/kotlin/com/vayunmathur/maps/wear/ui/MetadataPreviews.ktrename to maps/src/screenshotTest/kotlin/com/vayunmathur/maps/ui/WearMetadataPreviews.ktindex 5f86b69daf..47cc7c54b2 100644--- a/maps-wear/src/screenshotTest/kotlin/com/vayunmathur/maps/wear/ui/MetadataPreviews.kt+++ b/maps/src/screenshotTest/kotlin/com/vayunmathur/maps/ui/WearMetadataPreviews.kt@@ -1,4 +1,4 @@-package com.vayunmathur.maps.wear.ui+package com.vayunmathur.maps.ui import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box@@ -56,11 +56,11 @@ private val fixtureRoute = WearRouteState( ) /**- * Store listing images for `:maps:wear` — every top-level screen/route (map, route detail, saved).+ * Store listing images for the watch experience of `:maps` — every top-level screen/route (map, route detail, saved). * The map capture renders the real Canvas vector renderer over a literal snapshot fixture.- * `./gradlew :maps:wear:metadata` copies renders into `metadata_data/photos/maps-wear/wear/`.+ * `./gradlew :maps:metadata` copies renders into `metadata_data/photos/maps/wear/`. */-class MetadataPreviews {+class WearMetadataPreviews { @PreviewTest @Preview(name = "1-map-round", device = ROUND, group = "wear")
maps/src/test/java/com/vayunmathur/maps/domain/WearMapsProtocolTest.kt
diff --git a/maps/src/test/java/com/vayunmathur/maps/domain/WearMapsProtocolTest.kt b/maps/src/test/java/com/vayunmathur/maps/domain/WearMapsProtocolTest.ktindex a911e7d0ee..1d00128e7f 100644--- a/maps/src/test/java/com/vayunmathur/maps/domain/WearMapsProtocolTest.kt+++ b/maps/src/test/java/com/vayunmathur/maps/domain/WearMapsProtocolTest.kt@@ -11,6 +11,7 @@ import com.vayunmathur.library.wearlink.maps.wearDequantize import com.vayunmathur.library.wearlink.maps.wearQuantize import kotlin.test.Test import kotlin.test.assertEquals+import kotlin.test.assertFalse import kotlin.test.assertTrue import kotlinx.serialization.encodeToString @@ -18,7 +19,7 @@ class WearMapsProtocolTest { @Test fun goldenSnapshotJson() {- // Must match the wear copy's golden string byte-for-byte.+ // The single merged-APK copy: pins the shared protocol's golden JSON. val snapshot = WearMapSnapshot( generatedAtMillis = 1_000L, centerLatE7 = 340_522_350,@@ -59,4 +60,94 @@ class WearMapsProtocolTest { assertTrue(kotlin.math.abs(back - meters) <= WearMapsProtocol.QUANT_STEP_M / 2 + 1e-9) } }++ @Test+ fun projectionCentersNorthUpAndFitsRadius() {+ val projection = WearMapProjection(viewportWidthPx = 400f, viewportHeightPx = 400f, radiusM = 600)+ assertEquals(200f to 200f, projection.project(0.0, 0.0))+ // North is up: +north metres -> smaller y, same x.+ val (nx, ny) = projection.project(0.0, 300.0)+ assertEquals(200f, nx)+ assertTrue(ny < 200f)+ // East edge of the region lands on the viewport edge.+ val (ex, _) = projection.project(600.0, 0.0)+ assertEquals(400f, ex)+ assertTrue(projection.insideRegion(600.0, -600.0))+ assertFalse(projection.insideRegion(601.0, 0.0))+ }++ @Test+ fun projectionRoundTripAndPanAndFollow() {+ val base = WearMapProjection(viewportWidthPx = 300f, viewportHeightPx = 400f, radiusM = 600)+ val (x, y) = base.project(120.0, -80.0)+ val (east, north) = base.unproject(x, y)+ assertTrue(kotlin.math.abs(east - 120.0) < 1e-6 && kotlin.math.abs(north + 80.0) < 1e-6)+ // Following the user recentres: user offset projects to viewport centre.+ val follow = base.copy(centerEastM = 120.0, centerNorthM = -80.0)+ assertEquals(150f to 200f, follow.project(120.0, -80.0))+ // Pan shifts everything by the pan amount.+ val panned = base.copy(panEastM = 50.0)+ val (px, _) = panned.project(0.0, 0.0)+ assertTrue(px > 150f)+ }++ @Test+ fun routePointConversionAlignsOrigins() {+ val snapshot = WearMapSnapshot(centerLatE7 = 0, centerLonE7 = 0, radiusM = 600)+ val route = WearRouteState(+ active = true,+ routeOriginLatE7 = 0,+ routeOriginLonE7 = (0.001 * 1e7).toInt(), // ~111 m east+ )+ val (east, north) = wearRoutePointInSnapshot(snapshot, route, dxUnits = 0, dyUnits = 0)+ assertTrue(east in 100.0..125.0 && north == 0.0, "east=$east")+ // A route with the same origin as the snapshot maps 1:1 after dequantize.+ val same = wearRoutePointInSnapshot(snapshot, route.copy(routeOriginLonE7 = 0), 10, -5)+ assertEquals(20.0 to -10.0, same)+ }++ @Test+ fun staleAfterWindowAndWhenMissing() {+ val snapshot = WearMapSnapshot(generatedAtMillis = 1_000L)+ assertFalse(wearIsStale(snapshot, 1_000L + WearMapsProtocol.STALE_AFTER_MS))+ assertTrue(wearIsStale(snapshot, 1_001L + WearMapsProtocol.STALE_AFTER_MS))+ assertTrue(wearIsStale(null, 0L))+ }++ @Test+ fun routeOverlayLifecycle() {+ val active = WearRouteState(active = true, destinationName = "Work", nextText = "Turn left")+ val applied = wearApplyRouteState(null, active)+ assertEquals(active, applied)+ // A newer active state replaces; an inactive state clears and stays cleared.+ val newer = active.copy(nextText = "Turn right")+ assertEquals(newer, wearApplyRouteState(applied, newer))+ assertEquals(null, wearApplyRouteState(newer, WearRouteState(active = false)))+ assertEquals(null, wearApplyRouteState(null, WearRouteState(active = false)))+ }++ @Test+ fun snapshotRouteLinesAreNeverBasemap() {+ // Berlin centre; the baked-in ROUTE segment runs (0 m, 0 m) ->+ // (100 m east, 0 m) in quantized units (50 units * 2 m).+ val road = WearMapLine(WearLineKind.ROAD, listOf(0, 0, 10, 0))+ val building = WearMapLine(WearLineKind.BUILDING, listOf(0, 0, 5, 0, 5, 5), closed = true)+ val bakedRoute = WearMapLine(WearLineKind.ROUTE, listOf(0, 0, 50, 0))+ val closedRoute = WearMapLine(WearLineKind.ROUTE, listOf(0, 0, 50, 0), closed = true)+ val snapshot = WearMapSnapshot(+ centerLatE7 = 525_200_000,+ centerLonE7 = 134_050_000,+ lines = listOf(road, bakedRoute, building, closedRoute),+ )+ // Cleared route (route == null after active=false) and reroute alike:+ // only the live WearRouteState may draw a route, never the snapshot.+ assertEquals(listOf(road, building), wearBasemapLines(snapshot))+ }++ @Test+ fun savedDistanceUsesUserPosition() {+ val home = WearSavedPlace("Home", latE7 = 0, lonE7 = (0.01 * 1e7).toInt()) // ~1.1 km east+ val distance = wearDistanceM(0, 0, home)+ assertTrue(distance in 1_000.0..1_200.0, "distance=$distance")+ } }
maps/src/test/java/com/vayunmathur/maps/platform/FormFactorTest.kt
diff --git a/maps/src/test/java/com/vayunmathur/maps/platform/FormFactorTest.kt b/maps/src/test/java/com/vayunmathur/maps/platform/FormFactorTest.ktnew file mode 100644index 0000000000..6504d8892f--- /dev/null+++ b/maps/src/test/java/com/vayunmathur/maps/platform/FormFactorTest.kt@@ -0,0 +1,19 @@+package com.vayunmathur.maps.platform++import kotlin.test.Test+import kotlin.test.assertFalse+import kotlin.test.assertTrue++/** The watch system feature is the single-APK routing signal. */+class FormFactorTest {++ @Test+ fun watchFeatureMeansWatch() {+ assertTrue(FormFactor.isWatch(hasWatchSystemFeature = true))+ }++ @Test+ fun noWatchFeatureMeansPhone() {+ assertFalse(FormFactor.isWatch(hasWatchSystemFeature = false))+ }+}
metadata_data/photos/maps/wear/1.png
diff --git a/metadata_data/photos/maps-wear/wear/1.png b/metadata_data/photos/maps/wear/1.pngsimilarity index 100%rename from metadata_data/photos/maps-wear/wear/1.pngrename to metadata_data/photos/maps/wear/1.png
metadata_data/photos/maps/wear/2.png
diff --git a/metadata_data/photos/maps-wear/wear/2.png b/metadata_data/photos/maps/wear/2.pngsimilarity index 100%rename from metadata_data/photos/maps-wear/wear/2.pngrename to metadata_data/photos/maps/wear/2.png
metadata_data/photos/maps/wear/3.png
diff --git a/metadata_data/photos/maps-wear/wear/3.png b/metadata_data/photos/maps/wear/3.pngsimilarity index 100%rename from metadata_data/photos/maps-wear/wear/3.pngrename to metadata_data/photos/maps/wear/3.png
settings.gradle.kts
diff --git a/settings.gradle.kts b/settings.gradle.ktsindex ddf128cf2e..d0a0e13321 100644--- a/settings.gradle.kts+++ b/settings.gradle.kts@@ -106,8 +106,6 @@ include(":uniflix") include(":findfamily") include(":findfamily-wear") include(":maps")-include(":maps:wear")-project(":maps:wear").projectDir = file("maps-wear") include(":games:chess") include(":games:unblockjam") include(":games:wordmaker")