feat(android): map polish — zoom-to-fit, photo markers at every count, bigger tiles, faster caching #1151
Loading…
Reference in a new issue
No description provided.
Delete branch "ux-android-map-polish"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Four KARTE-tab polish items from user feedback, in priority order.
1. Zoom-to-fit on open + re-fit on scope chip change
What the bug actually was (chain verified against osmdroid 6.1.20 bytecode):
AndroidViewupdate runs pre-layout and re-applied the tile source through a throwawayarrayOfNulls(1)key →setTileSource→MapView.setTileLevel→setZoomLevelunconditionally dispatches aZoomEventto ourMapListener.emitViewportanswered by reading the bounding box of the not-yet-laid-out (0×0) projection → a degenerate world box at zoom 2.lastViewport, sosavedCamera()returned non-null garbage that shadowedstate.initialCamerain the camera block.zoomToSpan(0.0, 0.0)is a silent no-op in osmdroid (anylatSpan <= 0returns early) andanimateTo((0, 0))no-ops too → the camera sat at the factory's world zoom (2.0) at (0,0) forever, and every re-entry stayed poisoned until the user manually panned.Fix: a pure
fitToBounds(south, west, north, east, width, height, padding, minZoom, maxZoom)in Web-Mercator (newMapCameraFit.kt, JVM-tested inMapCameraFitTest: binding axis, padding, clamps, Mercator centre, date-line wrap) applied atomically assetZoom+setCenterafter layout (doOnLayout).emitViewportrefuses zero-size views, and the factory seeds the sharedappliedTileKeyso the first update cannot re-apply the source.MapUiState.cameraEpochis bumped whenever new bounds land, so the screen fits exactly once per epoch: the first fit prefers the remembered viewport, a scope-chip refit (setScope→ newrefitBounds()) fits the new box only; a failed refit keeps the camera quietly (the viewport re-cluster/banner still tells the user the scope changed).Constants: 48 dp fit padding, min zoom = world (2.0), max = drill max (18). Drill-down untouched: tap still zooms +2 levels / opens the sheet; the larger icons make larger tap targets.
2. Photo thumbnails on EVERY marker, readable count on big clusters
MarkerThumbnails.ktplan/cache/render structure; cache keys gained the pill height so a resize can't hand back a stale bitmap.3. Bigger markers, sizes named in one place
All in
MarkerThumbnails.kt: photo tile 44 → 72 dp (radius 12 → 18), cluster photo 40 → 64 dp, corner badge 18 → 24 dp, new 26 dp count pill, new 48 dp placeholder badge (was a local40.dpin the screen), new 72 dp neutral tile, decode target 160 → 256 px, icon bitmap cache 8 → 24 MB.4. Faster tiles: explicit cache config + bounded prefetch
New
MapTileCache.kt(configureOsmdroid, run before the firstMapView):filesDir/osmdroid/tiles, notcacheDir— private, always mounted, and survives cacheDir sweeps; a warm tile cache costs real data to rebuild. osmdroid's default (external storage) can be unmounted and sits in a shared tree.Configuration.loadrewrites the paths from shared preferences and lets persisted thread counts win over in-memory values → everything is set afterload, correct on first run and every run after.TileDownloadersets none;IConfigurationProviderhas no setters). A stalled socket is bounded only by the queue — noted in code instead of faked.CacheManager.loadTilereturns as soon as the file orSqlTileWriterknows the tile, before any download, and download failures are swallowed per tile by osmdroid (never surface as app exceptions).ensureActive()between tiles — each applied fit cancels the previous warm-up, leaving the tab cancels the last; 6 consecutive failures (airplane mode, server down) abort.tile.openstreetmap.orgthat is shared etiquette. A self-hosted tile server is the follow-up — deliberately not implemented here. No settings UI, per scope.Verification
cd apps/android && ./gradlew :app:testDebugUnitTest :app:assembleDebug→ green: 400 tests, 0 failures (+9MapCameraFitTest, +3 scope-refitMapViewModelTest, marker plan/key coverage extended for NeutralTile / all-count ClusterPhoto / pill keys). Rebased onto latestorigin/mainand re-verified after. Lint untouched (pre-existing baseline). No new user-facing strings, so nores/or locale changes (de/da/en unchanged).Risks
Commits:
fixcamera fit →featmarker plans/sizes →perfcache + prefetch →featscreen wiring →choreversion bump (16/0.4.1 → 17/0.4.2, ledger updated).