From d6fdbc06524e81c8b25a6630b759a330a77925ed Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 13 Jun 2025 15:11:58 -0700 Subject: [PATCH] Automatic prevent suspend --- lib/l10n/app_en.arb | 1 - lib/preferences.dart | 5 ++--- lib/settings_screen.dart | 12 ------------ 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 5a9d3e7..8b0d297 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -18,7 +18,6 @@ "distanceLabel": "Distance (meters)", "heartbeatLabel": "Heartbeat (seconds)", "bufferLabel": "Offline buffering", - "preventSuspendLabel": "Prevent suspend", "disableElasticityLabel": "Disable elasticity", "stopDetectionLabel": "Stop detection", "trackingLabel": "Continuous tracking", diff --git a/lib/preferences.dart b/lib/preferences.dart index 94fd8b8..eb6ac61 100644 --- a/lib/preferences.dart +++ b/lib/preferences.dart @@ -15,7 +15,6 @@ class Preferences { static const String distance = 'distance'; static const String heartbeat = 'heartbeat'; static const String buffer = 'buffer'; - static const String preventSuspend = 'prevent_suspend'; static const String stopDetection = 'stop_detection'; static Future init() async { @@ -25,7 +24,7 @@ class Preferences { : SharedPreferencesOptions(), cacheOptions: SharedPreferencesWithCacheOptions( allowList: { - id, url, accuracy, interval, distance, buffer, heartbeat, preventSuspend, stopDetection, + id, url, accuracy, interval, distance, buffer, heartbeat, stopDetection, 'device_id_preference', 'server_url_preference', 'accuracy_preference', 'frequency_preference', 'distance_preference', 'buffer_preference', }, @@ -75,7 +74,7 @@ class Preferences { logMaxDays: 1, locationTemplate: _locationTemplate(), showsBackgroundLocationIndicator: false, - preventSuspend: instance.getBool(preventSuspend), + preventSuspend: heartbeatInterval > 0, disableElasticity: true, disableStopDetection: instance.getBool(stopDetection) == false, pausesLocationUpdatesAutomatically: instance.getBool(stopDetection) == false, diff --git a/lib/settings_screen.dart b/lib/settings_screen.dart index 89f163f..4c778d8 100644 --- a/lib/settings_screen.dart +++ b/lib/settings_screen.dart @@ -16,7 +16,6 @@ class SettingsScreen extends StatefulWidget { class _SettingsScreenState extends State { bool buffering = true; - bool preventSuspend = false; bool stopDetection = false; bool advanced = false; @@ -29,7 +28,6 @@ class _SettingsScreenState extends State { void _initState() async { setState(() { buffering = Preferences.instance.getBool(Preferences.buffer) ?? true; - preventSuspend = Preferences.instance.getBool(Preferences.preventSuspend) ?? false; stopDetection = Preferences.instance.getBool(Preferences.stopDetection) ?? true; }); } @@ -171,16 +169,6 @@ class _SettingsScreenState extends State { setState(() => stopDetection = value); }, ), - if (advanced && Platform.isIOS) - SwitchListTile( - title: Text(AppLocalizations.of(context)!.preventSuspendLabel), - value: preventSuspend, - onChanged: (value) async { - await Preferences.instance.setBool(Preferences.preventSuspend, value); - await bg.BackgroundGeolocation.setConfig(Preferences.geolocationConfig()); - setState(() => preventSuspend = value); - }, - ), ], ), );