Skip to content

Restore the stored camera view, and open somewhere sensible without one - #266

Merged
parawanderer merged 6 commits into
parawanderer:mainfrom
rubo77:fix/map-opening-camera
Nov 21, 2026
Merged

parawanderer merged 6 commits into
parawanderer:mainfrom
rubo77:fix/map-opening-camera

Conversation

@rubo77

@rubo77 rubo77 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Opening the map could ignore the camera position saved on the previous
visit, and a first-run map opened fully zoomed out with the world tiled
by the provider's default. Two causes, both in MapsActivity:

  • The stored camera position was loaded asynchronously and applied via
    pos.ifPresent(...) gated on mapProvider != null. When the datastore
    answered before onMapReady, the saved view was silently dropped.
    applyOpeningCameraIfReady() now waits until both the provider and the
    loaded value have arrived and decides exactly once.
  • showBeaconOnMap() navigated to the first marker on every rebuild
    (currentMarkers.size() == 1), stomping a restored view whenever a
    single marker existed. A stored camera now wins over marker
    auto-navigation.

When nothing is stored, the fallback is: existing markers keep owning
the opening view, then the phone's own fix when permission allows, then
a country-scale frame chosen by the app language (DACH), then a zoom
that shows the world once rather than tiled.

Test plan

  • Open the map, pan/zoom to a spot, leave, reopen: the same view
    comes back
  • Fresh install (no stored position): the map no longer opens on a
    tiled world map
  • With a beacon that has a location, the map still opens on it

Generated with Devin

Update: a second commit covers the osmdroid provider, where the same
opening move ran on a zero-sized MapView - initialize() calls
onMapReady before the first layout, and osmdroid scrolls in pixels,
so the restored view opened half a screen off to the side. Camera calls
now wait for the first layout via addOnFirstLayoutListener.

- The datastore could answer before onMapReady; the saved position was then
  silently dropped and the map opened at the provider's world-tiled default.
  applyOpeningCameraIfReady waits for both sides and decides exactly once.
- With nothing stored: markers that exist keep owning the opening view,
  otherwise the phone's fix when permission allows, else a country-scale
  frame for the app language (DACH), else a zoom that shows the world once.
- A stored view now wins over the first-marker auto-navigation, which used
  to stomp the restored position at every open.

Co-Authored-By: Devin/SWE-2 <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 15, 2026 17:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Location callback ordering, failed location requests, and regionless German locales leave opening-camera behavior incorrect.

3 open findings
What changed in this PR

Improves the map’s opening view by coordinating saved-camera restoration and adding defaults when no position is stored.

Changes:

  • Waits for both the map provider and stored camera data.
  • Prevents marker auto-navigation from overriding a restored view.
  • Adds phone-location, regional, and world-view fallbacks.
File Description
app/​src/​main/​java/​dev/​wander/​android/​opentagviewer/​MapsActivity.java Coordinates camera restoration, marker priority, and opening-view fallbacks.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

- onMapReady fires out of initialize() before the MapView's first
  layout, so the stored-camera restore ran setCenter on a zero-sized
  view: osmdroid scrolls in pixels and the opening view landed half a
  screen off to the side
- Defer moveCamera/animateCamera via addOnFirstLayoutListener until the
  view has been measured; calls after layout run immediately

Co-Authored-By: Devin/SWE-2 <158243242+devin-ai-integration[bot]@users.noreply.github.com>
- The phone-fix callback rechecks currentMarkers: the request fires
  before showLastDeviceLocations runs, and a fix landing afterwards
  would stomp the marker view that just claimed the opening
- A failed getLastLocation now falls back to the locale view unless
  markers arrived meanwhile - before, the map could stay at the
  provider's world default with openingCameraApplied already consumed
- The locale fallback matches the configured locale's language ("de")
  instead of Locale.getDefault()'s region: the app's German locale has
  no country component, so the DACH frame was never reached

Co-Authored-By: Devin/SWE-2 <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@parawanderer parawanderer self-assigned this Oct 26, 2026
parawanderer and others added 2 commits November 21, 2026 12:01
The remembered camera is where the user last looked, not necessarily
where they are now. Asked for: open at the last view, keeping its zoom,
then move to the user's location. Without location permission or a fix,
the restored view stays as it is. The My Location button keeps its own
zoom.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@parawanderer

Copy link
Copy Markdown
Owner

Thanks for this. I pushed two commits on top of your branch:

  • a0e39a7: merged main into it. It was 44 commits behind, including Sign in as an emulated Mac: Apple's macOS CoreADI under Unicorn, on the phone #274. No conflicts.
  • 970b3b9: after the stored view is restored, the map now animates to the phone's current location, keeping the restored zoom. @parawanderer asked for "open at the last view, then move to where I am", so restoring alone wasn't the whole of it. Without location permission or a fix, the restored view stays put. The My Location button still uses initialZoom(). To do this, animateCameraToMyLocation got an overload that takes the zoom.

Your fallback chain for when nothing is stored, and the osmdroid first-layout fix, are unchanged.

@parawanderer tested it by hand on the emulator: closing and reopening the app restores the view, then it moves to the current location.

Drafted by Claude Code

@parawanderer
parawanderer merged commit b477423 into parawanderer:main Nov 21, 2026
4 checks passed

This branch was previously deployed

1 inactive deployment
Android Build — 970b3b9a Deployed Nov 21, 2026 by parawanderer via Instrumented tests (emulator) #372
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants