localization: update GPS settings messages and improve handling of custom variables

This commit is contained in:
zjs81 2026-01-19 18:56:06 -07:00
parent 8387304d2a
commit 3fef594fe5
2 changed files with 10 additions and 10 deletions

View file

@ -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",

View file

@ -433,16 +433,17 @@ class _SettingsScreenState extends State<SettingsScreen> {
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<SettingsScreen> {
}
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(