Skip to content

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

Open
rubo77 wants to merge 3 commits into
parawanderer:mainfrom
rubo77:fix/map-opening-camera
Open

rubo77 wants to merge 3 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
@rubo77
rubo77 deployed to Android Build October 15, 2026 17:10 — with GitHub Actions Active
@rubo77
rubo77 deployed to Android Build October 15, 2026 17:10 — with GitHub Actions Active

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.

Comment thread app/src/main/java/dev/wander/android/opentagviewer/MapsActivity.java Outdated
- 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>
@rubo77
rubo77 deployed to Android Build October 15, 2026 20:25 — with GitHub Actions Active
@rubo77
rubo77 deployed to Android Build October 15, 2026 20:25 — with GitHub Actions Active
- 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>
@rubo77
rubo77 deployed to Android Build October 15, 2026 20:29 — with GitHub Actions Active
@rubo77
rubo77 deployed to Android Build October 15, 2026 20:29 — with GitHub Actions Active

This branch was successfully deployed

1 active deployment
Android Build — 1ca9c33c Deployed Oct 15, 2026 by rubo77 via Instrumented tests (emulator) #341
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.

2 participants