Skip to content

Fix(#721): keep waypoint track id when restoring text note dialog - #722

Merged
jamescr merged 1 commit into
labexp:developfrom
vmiklos:lost-waypoints-fix
Oct 31, 2026
Merged

jamescr merged 1 commit into
labexp:developfrom
vmiklos:lost-waypoints-fix

Conversation

@vmiklos

@vmiklos vmiklos commented Oct 29, 2026

Copy link
Copy Markdown

Fix: keep waypoint track id when restoring text note dialog

🛠️ Issue

📖 Description

Add a text note, then let Android recreate the tracking screen
twice without opening the text note dialog in between, e.g. rotate
to landscape and back: notes added after that are saved, but their
waypoints are missing from the track and from the GPX export, because
they're created with a track id of 0.

It seems this went wrong in commit
3f86c52 (Feature: Use Text Note
preferences to save the note, 2026-01-18), the direct problem is that
TextNoteDialog.onSaveInstanceState() only saves the waypoint track id if
saveAsWayPoint is true, but that flag is only set in onStart(), once the
dialog is shown. The first recreation restores the dialog without
showing it, so the second recreation saves no track id at all, and then
onRestoreInstanceState() turns the missing key into 0. Notes are not
affected, since noteTrackId is never restored.

Fix the problem by always saving the waypoint track id. Also fall
back to the track id from the constructor in onRestoreInstanceState(),
in case the saved state has no track id.

✅ Pull Request Checklist

  • The PR is proposed to the DEVELOP branch.
  • The changes have been tested on my phone.
  • An automated test have been added.
  • There is a reference to the original ISSUE and related work.

📝 Additional Notes

Thanks for taking your time to review this.

Add a text note, then let Android recreate the tracking screen
twice without opening the text note dialog in between, e.g. rotate
to landscape and back: notes added after that are saved, but their
waypoints are missing from the track and from the GPX export, because
they're created with a track id of 0.

It seems this went wrong in commit
3f86c52 (Feature: Use Text Note
preferences to save the note, 2026-01-18), the direct problem is that
TextNoteDialog.onSaveInstanceState() only saves the waypoint track id if
saveAsWayPoint is true, but that flag is only set in onStart(), once the
dialog is shown. The first recreation restores the dialog without
showing it, so the second recreation saves no track id at all, and then
onRestoreInstanceState() turns the missing key into 0. Notes are not
affected, since noteTrackId is never restored.

Fix the problem by always saving the waypoint track id. Also fall
back to the track id from the constructor in onRestoreInstanceState(),
in case the saved state has no track id.
@vmiklos

vmiklos commented Oct 30, 2026

Copy link
Copy Markdown
Author

@jamescr could you please approve this workflow, so I can see if CI is happy with the changes? I guess that's needed as this would be my first PR for the project. Thanks.

@jamescr
jamescr merged commit b3da12f into labexp:develop Oct 31, 2026
2 checks passed
@jamescr

jamescr commented Oct 31, 2026

Copy link
Copy Markdown
Member

Welcome to OSMTracker and thanks for contributing. The change is well-scoped and simplifies the review. I also appreciate that the PR includes a unit test that gives us confidence that the fix won't regress.

I hope this is the first of many contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants