Repository navigation
Fix(#721): keep waypoint track id when restoring text note dialog - #722
Merged
Merged
Conversation
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.
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. |
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
📝 Additional Notes
Thanks for taking your time to review this.