From 3fef594fe579ce373dfbe40bff904db12714500c Mon Sep 17 00:00:00 2001 From: zjs81 Date: Mon, 19 Jan 2026 18:56:06 -0700 Subject: [PATCH] localization: update GPS settings messages and improve handling of custom variables --- lib/l10n/app_en.arb | 3 +-- lib/screens/settings_screen.dart | 17 +++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 7224b22..cc47077 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -83,14 +83,13 @@ "settings_radioSettingsUpdated": "Radio settings updated", "settings_location": "Location", "settings_locationSubtitle": "GPS coordinates", - "settings_locationUpdated": "Location updated", + "settings_locationUpdated": "Location and GPS settings updated", "settings_locationBothRequired": "Enter both latitude and longitude.", "settings_locationInvalid": "Invalid latitude or longitude.", "settings_locationGPSEnable": "GPS Enable", "settings_locationGPSEnableSubtitle": "Enables GPS to automatically update location.", "settings_locationIntervalSec": "Interval for GPS (Seconds)", "settings_locationIntervalInvalid": "Interval must be at least 60 seconds, and less than 86400 seconds.", - "settings_locationUpdated": "GPS settings updated.", "settings_latitude": "Latitude", "settings_longitude": "Longitude", "settings_privacyMode": "Privacy Mode", diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dart index c4ce483..c6a85d7 100644 --- a/lib/screens/settings_screen.dart +++ b/lib/screens/settings_screen.dart @@ -433,16 +433,17 @@ class _SettingsScreenState extends State { final latController = TextEditingController(); final lonController = TextEditingController(); final intervalController = TextEditingController(); - intervalController.text = "900"; latController.text = connector.selfLatitude?.toStringAsFixed(6) ?? ''; lonController.text = connector.selfLongitude?.toStringAsFixed(6) ?? ''; - bool hasGPS = connector.currentCustomVars!.isNotEmpty - ? connector.currentCustomVars!.containsKey("gps") - : false; - bool isGPSEnabled = hasGPS - ? connector.currentCustomVars!["gps"] == "1" - : false; + // Safe access to custom vars - may be null before device responds + final customVars = connector.currentCustomVars ?? {}; + final bool hasGPS = customVars.containsKey("gps"); + bool isGPSEnabled = customVars["gps"] == "1"; + + // Read current interval or default to 900 (15 minutes) + final currentInterval = int.tryParse(customVars["gps_interval"] ?? "") ?? 900; + intervalController.text = currentInterval.toString(); showDialog( context: context, @@ -521,7 +522,7 @@ class _SettingsScreenState extends State { } final interval = int.tryParse(intervalText); - if (interval == null || interval < 60) { + if (interval == null || interval < 60 || interval >= 86400) { if (!context.mounted) return; ScaffoldMessenger.of(context).showSnackBar( SnackBar(