maps: reach every planet from the globe body switch
- Commit
f3a30ea174c558fe490350204bb4b3d04f335a4d- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-04 23:50 UTC (1 day ago)
- Parents
cf46052
The body dropdown already iterates MapBody.entries, so the new bodies appear beside Earth and the Moon with no new settings: labels for all nine bodies, MapPage loads the selected body's raster set via BodyAssetLoader (any non-Earth body), and the switch stays on screen for any non-Earth body. Body selection stays session-only, exactly like the Moon. Gesture/tilt handling is untouched. BodyDropdownSlice2Test now scrolls the nine-item menu to reach the Moon. AGENTS.md files document the body globes. Verified: :maps:lint, :maps:lintVitalRelease, :maps:testDevUnitTest (977 tests) with the library suite above.
Diff
maps/AGENTS.md
diff --git a/maps/AGENTS.md b/maps/AGENTS.mdindex c4a67053d3..7ac2d44fb5 100644--- a/maps/AGENTS.md+++ b/maps/AGENTS.md@@ -16,6 +16,7 @@ _Install: ./install maps (dev by default)._ - On-device routing (drive/walk/bike/transit) over a single packed `.mamaps` archive, downloaded once on first launch; viewed areas keep working offline - Turn-by-turn navigation with voice (TTS), lane guidance, speed-limit widget, and elevation; Android Auto via `platform/` - 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)+- 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 - 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 - 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.@@ -191,6 +192,7 @@ golden-JSON tests in this module pin the shared code's wire format. - com/vayunmathur/maps/ui/theme/BasemapPalette.kt - com/vayunmathur/maps/ui/theme/MapChromeMetrics.kt ### platform/ + data/ + domain/ + service/ — ViewModels, offline router, navigation service+- com/vayunmathur/maps/platform/BodyAssetLoader.kt — per-body bundled raster specs + loader (assets/<body>/) - com/vayunmathur/maps/platform/SelectedFeatureViewModel.kt - com/vayunmathur/maps/platform/MapsSearchViewModel.kt - com/vayunmathur/maps/platform/MapsUiContract.kt
maps/src/main/java/com/vayunmathur/maps/ui/BodyDropdown.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/ui/BodyDropdown.kt b/maps/src/main/java/com/vayunmathur/maps/ui/BodyDropdown.ktindex 6f2c52bd88..55194914e2 100644--- a/maps/src/main/java/com/vayunmathur/maps/ui/BodyDropdown.kt+++ b/maps/src/main/java/com/vayunmathur/maps/ui/BodyDropdown.kt@@ -24,12 +24,12 @@ import com.vayunmathur.library.ui.rememberHaptics import com.vayunmathur.maps.R /**- * Earth/Moon body switch, shown INSTEAD of [CategoryChips] when the globe is- * zoomed all the way out.+ * Body switch, shown INSTEAD of [CategoryChips] when the globe is zoomed all+ * the way out. *- * One chip reading the current body ("Earth" by default) that opens a two-item- * menu. Selecting Moon swaps the globe to the NASA SVS raster pair (LROC color- * + LOLA elevation); Earth restores the vector basemap. Session-only — a+ * One chip reading the current body ("Earth" by default) that opens a menu of+ * every body. Selecting a non-Earth body swaps the globe to that body's+ * bundled raster set; Earth restores the vector basemap. Session-only — a * restart resets to Earth (see `MapChromeState.body`). * * Styled like a category chip (same container fill) so the swap reads as the@@ -77,5 +77,12 @@ fun BodyDropdown( private val MapBody.labelRes: Int get() = when (this) { MapBody.Earth -> R.string.body_earth+ MapBody.Mercury -> R.string.body_mercury+ MapBody.Venus -> R.string.body_venus+ MapBody.Mars -> R.string.body_mars+ MapBody.Jupiter -> R.string.body_jupiter+ MapBody.Saturn -> R.string.body_saturn+ MapBody.Uranus -> R.string.body_uranus+ MapBody.Neptune -> R.string.body_neptune MapBody.Moon -> R.string.body_moon }
maps/src/main/java/com/vayunmathur/maps/ui/MapContentBox.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/ui/MapContentBox.kt b/maps/src/main/java/com/vayunmathur/maps/ui/MapContentBox.ktindex 2420442001..b9c3a09235 100644--- a/maps/src/main/java/com/vayunmathur/maps/ui/MapContentBox.kt+++ b/maps/src/main/java/com/vayunmathur/maps/ui/MapContentBox.kt@@ -64,7 +64,7 @@ internal fun MapPageScope.MapContentBox( // flag invalidates this scope only when the answer flips at the detail threshold. val showBodySwitch by remember(camera, globeEnabled, body) { derivedStateOf {- globeEnabled && camera.position.zoom < GLOBE_DETAIL_ZOOM || body == MapBody.Moon+ globeEnabled && camera.position.zoom < GLOBE_DETAIL_ZOOM || body != MapBody.Earth } } // No app bar. The map is the whole screen and every piece of chrome floats over it,
maps/src/main/java/com/vayunmathur/maps/ui/MapPage.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/ui/MapPage.kt b/maps/src/main/java/com/vayunmathur/maps/ui/MapPage.ktindex 2449fb868c..756be332d9 100644--- a/maps/src/main/java/com/vayunmathur/maps/ui/MapPage.kt+++ b/maps/src/main/java/com/vayunmathur/maps/ui/MapPage.kt@@ -41,7 +41,7 @@ import com.vayunmathur.maps.ui.map.NavigationCameraFollow import com.vayunmathur.maps.ui.map.rememberMapChromeState import com.vayunmathur.maps.platform.PoiMapViewModel import com.vayunmathur.maps.platform.MapSettingsViewModel-import com.vayunmathur.maps.platform.MoonAssetLoader+import com.vayunmathur.maps.platform.BodyAssetLoader import com.vayunmathur.maps.platform.NavigationSessionManager import com.vayunmathur.maps.platform.SearchUiState import com.vayunmathur.maps.platform.SelectedFeatureViewModel@@ -151,12 +151,12 @@ fun MapPage( } } - // The Moon raster pair, loaded on Moon select (never for Earth sessions) and dropped- // again when the body goes back to Earth, so ~37MB of heap and ~40MB of GPU images are- // only held while the Moon is actually shown.+ // The body raster set, loaded on body select (never for Earth sessions) and dropped+ // again when the body goes back to Earth, so its heap and GPU images are+ // only held while that body is actually shown. var moonTextures by remember { mutableStateOf<MoonTextures?>(null) } LaunchedEffect(chrome.body) {- moonTextures = if (chrome.body == MapBody.Moon) MoonAssetLoader.load(context) else null+ moonTextures = if (chrome.body != MapBody.Earth) BodyAssetLoader.load(context, chrome.body) else null } // Resolve the P6 map-theme setting against the OS the same way DynamicTheme does, so the map
maps/src/main/java/com/vayunmathur/maps/ui/map/MapChromeState.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/ui/map/MapChromeState.kt b/maps/src/main/java/com/vayunmathur/maps/ui/map/MapChromeState.ktindex b5d381520f..9d2b87c6a6 100644--- a/maps/src/main/java/com/vayunmathur/maps/ui/map/MapChromeState.kt+++ b/maps/src/main/java/com/vayunmathur/maps/ui/map/MapChromeState.kt@@ -43,7 +43,7 @@ class MapChromeState internal constructor( var selectedCategory by selectedCategoryState /**- * Which body the globe draws: Earth (vector basemap) or Moon (NASA SVS+ * Which body the globe draws: Earth (vector basemap) or a bundled raster body (Moon: NASA SVS * raster pair). Session-only — deliberately `remember`, not `retain`: * rotation keeps it (same composition), but a process restart resets to * Earth. A view, not a setting.
maps/src/main/res/values/strings.xml
diff --git a/maps/src/main/res/values/strings.xml b/maps/src/main/res/values/strings.xmlindex ceda40ab49..106081185c 100644--- a/maps/src/main/res/values/strings.xml+++ b/maps/src/main/res/values/strings.xml@@ -395,6 +395,13 @@ <string name="body_earth">Earth</string> <!-- Body switch: Moon option. Noun. --> <string name="body_moon">Moon</string>+ <string name="body_mercury">Mercury</string>+ <string name="body_venus">Venus</string>+ <string name="body_mars">Mars</string>+ <string name="body_jupiter">Jupiter</string>+ <string name="body_saturn">Saturn</string>+ <string name="body_uranus">Uranus</string>+ <string name="body_neptune">Neptune</string> <!-- SavedPlacesPage: screen title. Noun. --> <string name="saved_places_title">Saved places</string>
maps/src/test/java/com/vayunmathur/maps/ui/BodyDropdownSlice2Test.kt
diff --git a/maps/src/test/java/com/vayunmathur/maps/ui/BodyDropdownSlice2Test.kt b/maps/src/test/java/com/vayunmathur/maps/ui/BodyDropdownSlice2Test.ktindex 2cda5296a0..fbb55ad78b 100644--- a/maps/src/test/java/com/vayunmathur/maps/ui/BodyDropdownSlice2Test.kt+++ b/maps/src/test/java/com/vayunmathur/maps/ui/BodyDropdownSlice2Test.kt@@ -3,7 +3,10 @@ package com.vayunmathur.maps.ui import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onNodeWithText+import androidx.compose.ui.test.hasScrollAction+import androidx.compose.ui.test.hasText import androidx.compose.ui.test.performClick+import androidx.compose.ui.test.performScrollToNode import androidx.test.ext.junit.runners.AndroidJUnit4 import com.vayunmathur.library.map.MapBody import kotlin.test.Test@@ -12,7 +15,7 @@ import org.junit.Rule import org.junit.runner.RunWith /**- * The Earth/Moon body switch.+ * The body switch (Earth, the seven other planets, and the Moon). * Slice-2 coverage for maps (basename B, outside the slice-1 dirs). */ @RunWith(AndroidJUnit4::class)@@ -28,9 +31,11 @@ class BodyDropdownSlice2Test { } @Test- fun `opening the menu offers both bodies`() {+ fun `opening the menu offers the other bodies`() { rule.setContent { BodyDropdown(selected = MapBody.Earth, onSelect = {}) } rule.onNodeWithText("Earth").performClick()+ rule.onNodeWithText("Mercury").assertIsDisplayed()+ rule.onNode(hasScrollAction()).performScrollToNode(hasText("Moon")) rule.onNodeWithText("Moon").assertIsDisplayed() } @@ -39,6 +44,7 @@ class BodyDropdownSlice2Test { var selected: MapBody? = null rule.setContent { BodyDropdown(selected = MapBody.Earth, onSelect = { selected = it }) } rule.onNodeWithText("Earth").performClick()+ rule.onNode(hasScrollAction()).performScrollToNode(hasText("Moon")) rule.onNodeWithText("Moon").performClick() assertEquals(MapBody.Moon, selected) }