fix(android): photo thumbnails inside single map markers #1135
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/map-marker-thumbnails"
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
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'srepresentativeMarker, then the first member that carries a photo.MarkerIconCache— byte-bounded access-order LRU (8 MB) keyed bymarkerIconCacheKey(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— Coilexecute()throughSingletonImageLoader(the app's bearer-authenticated OkHttp loader): 160 px square decode, ARGB_8888 software bitmap,crossfade(0), null on failure.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.MarkerIconDrawablereports exact pixel intrinsic size: osmdroid sizes and hit-tests markers fromgetIntrinsicWidth/Height, andBitmapDrawablewould 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 beforesetIcon. Tap handlers are untouched.MapViewModel:MapClusterUinow carriesrepresentativeMarker(already present inMapClusterDto, server-computed) with the usual server-URL prefixing.Version
0.4.0/versionCode 15—0.3.1/14was 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 newMarkerThumbnailsTest+ 1 newMapViewModelTestcase)../gradlew :app:lintDebug— 18 errors, 34 warnings; baseline onorigin/mainis 18 errors, 35 warnings. All 18 errors are the pre-existing ones inui/timelineand strings; this branch removes oneUseKtxwarning (the moved badge renderer now uses KTXcreateBitmap) and adds none.Risks / notes
MapCanvascomposition, so switching tabs recreates it; Coil's shared memory/disk caches make that rebuild network-free.representativeMarker: nullsimply fall back to member photos, or to the unchanged count circle.