fix(android): photo thumbnails inside single map markers #1135

Merged
chris merged 2 commits from fix/map-marker-thumbnails into main 2026-10-12 10:59:18 +02:00
Owner

What

Single map markers rendered as a solid osmdroid pin with no photo, while the web map shows the actual thumbnail. This gives every single-media marker a real photo thumbnail, small clusters (≤9) the server's representative photo behind a count badge, and keeps the current placeholders as the loading/failure state.

Rendering approach

  • MarkerThumbnails.kt (new, ui/map):
    • markerIconPlan(cluster) — pure decision: PhotoTile (single with a photo URL), ClusterPhoto (count ≤ 9 with a photo), CountCircle (larger or photo-less clusters), Pin (single without any photo URL). The photo always belongs to the item a tap opens: singles take their one member; clusters prefer the server's representativeMarker, then the first member that carries a photo.
    • MarkerIconCache — byte-bounded access-order LRU (8 MB) keyed by markerIconCacheKey (media id + URL + rendered size, plus count/badge colour for cluster photos), so viewport refetches re-use rendered icon bitmaps instead of re-decoding. Pure JVM and fully tested.
    • loadMarkerThumbnail — Coil execute() through SingletonImageLoader (the app's bearer-authenticated OkHttp loader): 160 px square decode, ARGB_8888 software bitmap, crossfade(0), null on failure.
    • Renderers: centre-cropped photo in a 44 dp rounded tile / 40 dp circle, a 2 dp near-white ring in rgb(236 253 245) (the web map's exact border colour), one radial-gradient drop shadow (no blur mask — those do not survive accelerated canvases), and a white-ringed count badge riding the cluster photo.
    • MarkerIconDrawable reports exact pixel intrinsic size: osmdroid sizes and hit-tests markers from getIntrinsicWidth/Height, and BitmapDrawable would reinterpret bitmap density.
  • MapScreen: the existing marker-rebuild effect queues icon loads after building the markers. Cache hit → icon swaps in immediately; miss → the placeholder stays (stock pin for singles, count circle for clusters); each load is a child of the effect, so a viewport change cancels it; on success the marker is re-checked against the overlay folder before setIcon. Tap handlers are untouched.
  • MapViewModel: MapClusterUi now carries representativeMarker (already present in MapClusterDto, server-computed) with the usual server-URL prefixing.

Version

0.4.0 / versionCode 15 — 0.3.1 / 14 was taken by the viewer app-scope PR (#1132), so this takes the next free minor.

Verification

  • cd apps/android && ./gradlew :app:testDebugUnitTest :app:assembleDebug — BUILD SUCCESSFUL, 377 tests, 0 failures (16 new MarkerThumbnailsTest + 1 new MapViewModelTest case).
  • ./gradlew :app:lintDebug — 18 errors, 34 warnings; baseline on origin/main is 18 errors, 35 warnings. All 18 errors are the pre-existing ones in ui/timeline and strings; this branch removes one UseKtx warning (the moved badge renderer now uses KTX createBitmap) and adds none.

Risks / notes

  • Bitmap rendering itself is not JVM-tested — Canvas/osmdroid drawing is instrumented territory (ISSUE-132); the decision, cache-key and eviction logic is covered. A quick on-device smoke test of the map tab before release is recommended.
  • The icon cache lives in the MapCanvas composition, so switching tabs recreates it; Coil's shared memory/disk caches make that rebuild network-free.
  • A zoomed-out viewport can queue many small thumbnail fetches at once; this is bounded by the shared image client (16 requests / 4 per host), the 8 MB icon LRU, and is cancelled wholesale on the next viewport change.
  • Servers that send representativeMarker: null simply fall back to member photos, or to the unchanged count circle.
## What Single map markers rendered as a solid osmdroid pin with no photo, while the web map shows the actual thumbnail. This gives every single-media marker a real photo thumbnail, small clusters (≤9) the server's representative photo behind a count badge, and keeps the current placeholders as the loading/failure state. ## Rendering approach - **`MarkerThumbnails.kt`** (new, `ui/map`): - `markerIconPlan(cluster)` — pure decision: `PhotoTile` (single with a photo URL), `ClusterPhoto` (count ≤ 9 with a photo), `CountCircle` (larger or photo-less clusters), `Pin` (single without any photo URL). The photo always belongs to the item a tap opens: singles take their one member; clusters prefer the server's `representativeMarker`, then the first member that carries a photo. - `MarkerIconCache` — byte-bounded access-order LRU (8 MB) keyed by `markerIconCacheKey` (media id + URL + rendered size, plus count/badge colour for cluster photos), so viewport refetches re-use rendered icon bitmaps instead of re-decoding. Pure JVM and fully tested. - `loadMarkerThumbnail` — Coil `execute()` through `SingletonImageLoader` (the app's bearer-authenticated OkHttp loader): 160 px square decode, ARGB_8888 software bitmap, `crossfade(0)`, null on failure. - Renderers: centre-cropped photo in a 44 dp rounded tile / 40 dp circle, a 2 dp near-white ring in `rgb(236 253 245)` (the web map's exact border colour), one radial-gradient drop shadow (no blur mask — those do not survive accelerated canvases), and a white-ringed count badge riding the cluster photo. - `MarkerIconDrawable` reports exact pixel intrinsic size: osmdroid sizes and hit-tests markers from `getIntrinsicWidth/Height`, and `BitmapDrawable` would reinterpret bitmap density. - **`MapScreen`**: the existing marker-rebuild effect queues icon loads after building the markers. Cache hit → icon swaps in immediately; miss → the placeholder stays (stock pin for singles, count circle for clusters); each load is a child of the effect, so a viewport change cancels it; on success the marker is re-checked against the overlay folder before `setIcon`. Tap handlers are untouched. - **`MapViewModel`**: `MapClusterUi` now carries `representativeMarker` (already present in `MapClusterDto`, server-computed) with the usual server-URL prefixing. ## Version `0.4.0` / `versionCode 15` — `0.3.1` / `14` was taken by the viewer app-scope PR (#1132), so this takes the next free minor. ## Verification - `cd apps/android && ./gradlew :app:testDebugUnitTest :app:assembleDebug` — **BUILD SUCCESSFUL**, 377 tests, 0 failures (16 new `MarkerThumbnailsTest` + 1 new `MapViewModelTest` case). - `./gradlew :app:lintDebug` — **18 errors, 34 warnings**; baseline on `origin/main` is 18 errors, 35 warnings. All 18 errors are the pre-existing ones in `ui/timeline` and strings; this branch removes one `UseKtx` warning (the moved badge renderer now uses KTX `createBitmap`) and adds none. ## Risks / notes - **Bitmap rendering itself is not JVM-tested** — Canvas/osmdroid drawing is instrumented territory (ISSUE-132); the decision, cache-key and eviction logic is covered. A quick on-device smoke test of the map tab before release is recommended. - The icon cache lives in the `MapCanvas` composition, so switching tabs recreates it; Coil's shared memory/disk caches make that rebuild network-free. - A zoomed-out viewport can queue many small thumbnail fetches at once; this is bounded by the shared image client (16 requests / 4 per host), the 8 MB icon LRU, and is cancelled wholesale on the next viewport change. - Servers that send `representativeMarker: null` simply fall back to member photos, or to the unchanged count circle.
Single-marker clusters rendered as a solid osmdroid pin with no photo,
while the web map shows the actual thumbnail. Give singles a ~44dp rounded
photo tile loaded through Coil's shared, bearer-authenticated loader:

- MarkerThumbnails.kt: pure icon plans (single tile vs representative
  cluster photo vs count circle vs pin) with JVM-tested cache keys, a
  byte-bounded LRU of rendered icons for viewport refetches, a Coil fetch
  path (ARGB_8888, software, 160px, no crossfade) that fails to null, and
  the renderers: centre-cropped photo, near-white hairline ring
  (rgb(236 253 245), web parity), cheap radial-gradient shadow, plus a
  ringed count badge on cluster photos for clusters of <=9
- MarkerIconDrawable reports exact pixel intrinsic size so osmdroid
  hit-tests and scales markers without BitmapDrawable density surprises
- MapScreen queues loads in the marker-rebuild effect: cache hits swap in
  immediately, misses keep the placeholder (pin / count circle), a new
  viewport answer cancels in-flight loads, and a failed load never
  removes the placeholder; tap behaviour is unchanged
- MapClusterUi now carries the server's representativeMarker so cluster
  photos match the member a drill-down would centre on

Bitmap rendering itself is Canvas/osmdroid territory and not
JVM-testable (ISSUE-132); the decision and cache logic is covered by
MarkerThumbnailsTest (16 tests).
chore(android): bump to 0.4.0 (versionCode 15)
All checks were successful
Wiki Sync / Sync wiki from docs (push) Has been skipped
Build and Deploy / Detect changed services and test scopes (push) Successful in 3s
Build and Deploy / Smoke API and media worker (push) Has been skipped
Build and Deploy / Smoke web (push) Has been skipped
Build and Deploy / Smoke ML worker (push) Has been skipped
Build and Deploy / Smoke people worker (push) Has been skipped
Build and Deploy / Build postgres image (push) Has been skipped
Build and Deploy / Build plants worker image (push) Has been skipped
Build and Deploy / Build converter worker image (push) Has been skipped
Build and Deploy / Deploy postgres (push) Has been skipped
Build and Deploy / Build API image (push) Has been skipped
Build and Deploy / Build media worker image (push) Has been skipped
Build and Deploy / Build ML worker image (push) Has been skipped
Build and Deploy / Build people worker image (push) Has been skipped
Build and Deploy / Build web image (push) Has been skipped
Build and Deploy / Deploy API (push) Has been skipped
Build and Deploy / Run scoped PR tests (push) Successful in 6s
Build and Deploy / Deploy web (push) Has been skipped
Build and Deploy / Deploy media worker (push) Has been skipped
Build and Deploy / Deploy ML worker (push) Has been skipped
Build and Deploy / Deploy plants worker (push) Has been skipped
Build and Deploy / Deploy people worker (push) Has been skipped
Build and Deploy / Deploy converter worker (push) Has been skipped
Build and Deploy / Clean Docker build artifacts (push) Has been skipped
Build and Deploy / Android unit tests and debug APK (push) Successful in 3m25s
4a15e0724c
0.3.1 (14) is taken by the viewer app-scope lane (#1132); this takes the
next free minor for the map marker photo thumbnails.
chris merged commit c28a796342 into main 2026-10-12 10:59:18 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
chris/memories!1135
No description provided.