Skip to content

Add minimum GPS accuracy preference for logging #670

Open
Andyporras wants to merge 4 commits intolabexp:developfrom
Andyporras:min_distance
Open

Add minimum GPS accuracy preference for logging #670
Andyporras wants to merge 4 commits intolabexp:developfrom
Andyporras:min_distance

Conversation

@Andyporras
Copy link
Member

Introduces a new user preference to set the minimum required GPS accuracy before starting to record track points. Updates the GPSLogger service to wait until the specified accuracy is achieved, and adds relevant UI strings and preference entry.

📝 Feat: Settings: minimum GPS accuracy to start recording track

🛠️ Issue

🛠️ Related issues (if applicable)

  • N/A

📖 Description

This PR introduces a new user preference to set the minimum required GPS accuracy before starting to record track points.

Changes:

  • Preferences UI: Added a new EditTextPreference in the GPS Settings menu (prefs_gps_min_accuracy) allowing users to input a value in meters (e.g., 10). Default is 0 (disabled).

  • Logic Implementation: Updated GPSLogger.java to read this preference.

    • Added a "latch" mechanism (isAccuracySatisfied).
    • The service now ignores incoming location updates until one arrives with an accuracy better than or equal to the configured value.
    • Once the accuracy is met, recording starts normally for all subsequent points.
  • Strings: Added necessary string resources for the new setting.

Rationale: This prevents the recording of widely inaccurate points (jumping) that often occur immediately after starting the GPS, significantly improving the quality of the track's start, especially for vertical distance computation.

🖼️ Screenshots (if applicable)

image

✅ Pull Request Checklist

  • The PR is proposed to the DEVELOP branch.
  • The changes have been tested on the target Android API and minimum Android API.
  • Automated tests have been added (if applicable).
  • The feature is well documented.
  • There is a reference to the original ISSUE and related work.

📝 Additional Notes

The logic ensures that we only wait once at the beginning. If the GPS accuracy degrades later (e.g., entering a tunnel), the recording continues uninterrupted to avoid gaps in the track, satisfying the requirement to "wait before starting".

Introduces a new user preference to set the minimum required GPS accuracy (in meters) before starting to record track points. Updates the GPSLogger service to respect this setting, waiting until the specified accuracy is achieved before logging locations. Adds relevant strings and preference UI elements.
Copy link
Member

@jamescr jamescr left a comment

Choose a reason for hiding this comment

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

Move preference keys and default values to OSMTracker. Preferences class. Check this commit for an example.

Min accuracy preference is numeric; consider using the setupEditTextNum() method from Preference Activity to force numeric inputs and add an option to reset to default value.

Introduced a new GPS minimum accuracy preference key and default value in OSMTracker. Updated Preferences activity to allow user configuration of minimum GPS accuracy. Refactored GPSLogger to use the new preference key and default, and removed the old constant from OpenStreetMapConstants.
@Andyporras
Copy link
Member Author

Thanks @jamescr for the review. I've just refactored the code to move the constants to OSMTracker.Preferences and implemented setupEditTextNum() for the input field validation. Ready for another look!

@jamescr jamescr added this to the 2026.08 milestone Feb 6, 2026
@jamescr
Copy link
Member

jamescr commented Feb 20, 2026

Andy, I reviewed the PR again, this time with more detail. You can see my suggestions in this branch.

In general, the code was reordered, and some variables were renamed to keep consistency with the style of the files and project. I add a new string in strings-preferences.xml to avoid reusing a string with another purpose.

Using 0 as the default value for the GPS logging accuracy is a bad practice because it could be interpreted by a user as the highest precision (0 m precision). One possible way to manage this could be with 2 preferences, one that enabled the GPS logging accuracy value and another that set the value (like the case of the background map prefs). But, we still have to consider a default value for the pref. A low value (let's say 2m) could take longer to be acquired, and the user could have the perception the app stops working. So a UI indicator will be needed to avoid the wrong perception.

My point of view is that it probably would be better to have accuracy ranges and not a value. I mean, with this, something like High Precision (1m-10m), Standard (10m-30m) and Low Precision (30m+). And the default could be Standard.

I open a PR to your repo just in case. The code in the branch is rebased. In Preferences.java I change a typo and delete an unused lib that was not part of your code.

* Feature: Show note count in tracks list

* Feature: Add a What's New slide to the App intro.

* [Transifex] Updates for project OSMTracker for Android™

* [Transifex] Updates for project OSMTracker for Android™ (labexp#679)

* Translate strings.xml in el

82% of minimum 80% translated source file: 'strings.xml'
on 'el'.

Sync of partially translated files: 
untranslated content is included with an empty translation 
or source language content depending on file format

* Translate strings.xml in sk

82% of minimum 80% translated source file: 'strings.xml'
on 'sk'.

Sync of partially translated files: 
untranslated content is included with an empty translation 
or source language content depending on file format

* Translate strings.xml in pl

91% of minimum 80% translated source file: 'strings.xml'
on 'pl'.

Sync of partially translated files: 
untranslated content is included with an empty translation 
or source language content depending on file format

* Translate strings.xml in es

99% of minimum 80% translated source file: 'strings.xml'
on 'es'.

Sync of partially translated files: 
untranslated content is included with an empty translation 
or source language content depending on file format

* Translate strings.xml in zh_TW

99% of minimum 80% translated source file: 'strings.xml'
on 'zh_TW'.

Sync of partially translated files: 
untranslated content is included with an empty translation 
or source language content depending on file format

* Translate strings.xml in pt_BR

99% of minimum 80% translated source file: 'strings.xml'
on 'pt_BR'.

Sync of partially translated files: 
untranslated content is included with an empty translation 
or source language content depending on file format

* Translate strings.xml in sv

93% of minimum 80% translated source file: 'strings.xml'
on 'sv'.

Sync of partially translated files: 
untranslated content is included with an empty translation 
or source language content depending on file format

* Translate strings.xml in nl

93% of minimum 80% translated source file: 'strings.xml'
on 'nl'.

Sync of partially translated files: 
untranslated content is included with an empty translation 
or source language content depending on file format

* Translate strings.xml in ru

93% of minimum 80% translated source file: 'strings.xml'
on 'ru'.

Sync of partially translated files: 
untranslated content is included with an empty translation 
or source language content depending on file format

* Translate strings.xml in es

100% translated source file: 'strings.xml'
on 'es'.

* Translate strings.xml in pt_BR

100% translated source file: 'strings.xml'
on 'pt_BR'.

* Translate strings.xml in zh_TW

100% translated source file: 'strings.xml'
on 'zh_TW'.

---------

Co-authored-by: transifex-integration[bot] <43880903+transifex-integration[bot]@users.noreply.github.com>

* Increases version number to 72

* Fix: Add fallback when pref value is not set

* Translate strings-preferences.xml in es

100% translated source file: 'strings-preferences.xml'
on 'es'.

* Translate strings-preferences.xml in pt_BR

100% translated source file: 'strings-preferences.xml'
on 'pt_BR'.

* Translate strings-preferences.xml in zh_TW

98% of minimum 80% translated source file: 'strings-preferences.xml'
on 'zh_TW'.

Sync of partially translated files: 
untranslated content is included with an empty translation 
or source language content depending on file format

* Increase version code to 73

* Increase version code to 74

* Translate strings-preferences.xml in zh_TW

100% translated source file: 'strings-preferences.xml'
on 'zh_TW'.

* Add minimum GPS accuracy preference for logging

Introduces a new user preference to set the minimum required GPS accuracy (in meters) before starting to record track points. Updates the GPSLogger service to respect this setting, waiting until the specified accuracy is achieved before logging locations. Adds relevant strings and preference UI elements.

# Conflicts:
#	app/src/main/res/values/strings-preferences.xml
#	app/src/main/res/xml/preferences.xml

* Add GPS minimum accuracy preference and refactor usage

Introduced a new GPS minimum accuracy preference key and default value in OSMTracker. Updated Preferences activity to allow user configuration of minimum GPS accuracy. Refactored GPSLogger to use the new preference key and default, and removed the old constant from OpenStreetMapConstants.

* Refactor and review of PR670

---------

Co-authored-by: transifex-integration[bot] <43880903+transifex-integration[bot]@users.noreply.github.com>
Co-authored-by: Andy Porras <andyporras6@gmail.com>
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