No min interval on highest

This commit is contained in:
Anton Tananaev 2025-06-17 07:23:03 -07:00
parent 8a36922c78
commit dc6be06738
2 changed files with 6 additions and 5 deletions

View file

@ -62,18 +62,19 @@ class GeolocationService {
final lastLocation = LocationCache.get();
if (lastLocation == null) return false;
final isHighestAccuracy = Preferences.instance.getString(Preferences.accuracy) == 'highest';
final duration = DateTime.parse(location.timestamp).difference(DateTime.parse(lastLocation.timestamp)).inSeconds;
final fastestInterval = Preferences.instance.getInt(Preferences.fastestInterval);
if (fastestInterval != null && duration < fastestInterval) return true;
if (!isHighestAccuracy) {
final fastestInterval = Preferences.instance.getInt(Preferences.fastestInterval);
if (fastestInterval != null && duration < fastestInterval) return true;
}
final distance = _distance(lastLocation, location);
final distanceFilter = Preferences.instance.getInt(Preferences.distance) ?? 0;
if (distanceFilter > 0 && distance >= distanceFilter) return false;
final isHighestAccuracy = Preferences.instance.getString(Preferences.accuracy) == 'highest';
if (distanceFilter == 0 || isHighestAccuracy) {
final intervalFilter = Preferences.instance.getInt(Preferences.interval) ?? 0;
if (intervalFilter > 0 && duration >= intervalFilter) return false;

View file

@ -104,7 +104,7 @@ class Preferences {
disableElasticity: true,
disableStopDetection: instance.getBool(stopDetection) == false,
pausesLocationUpdatesAutomatically: instance.getBool(stopDetection) == false,
fastestLocationUpdateInterval: fastestLocationUpdateInterval > 0 ? fastestLocationUpdateInterval : null,
fastestLocationUpdateInterval: isHighestAccuracy ? 0 : fastestLocationUpdateInterval,
backgroundPermissionRationale: bg.PermissionRationale(
title: 'Allow {applicationName} to access this device\'s location in the background',
message: 'For reliable tracking, please enable {backgroundPermissionOptionLabel} location access.',