Resolves #576 Fix location tracking migration
This commit is contained in:
parent
2126bc4f02
commit
01b8ec9b97
@ -75,21 +75,21 @@ class AppSettings {
|
||||
bool oldLocationTrackingEnabled = prefs.getBool("location-enabled") ?? false;
|
||||
if (oldLocationTrackingEnabled) {
|
||||
await platform.invokeMethod('cancelOldLocationWorker');
|
||||
await prefs.setInt("location-updates-state", 2); //Setting new location tracking mode to worker
|
||||
await prefs.setInt("location-updates-priority", 100); //Setting location accuracy to high
|
||||
int oldLocationTrackingInterval = prefs.getInt("location-interval") ?? 0;
|
||||
if (oldLocationTrackingInterval < 15) {
|
||||
oldLocationTrackingInterval = 15;
|
||||
}
|
||||
await prefs.setInt("location-updates-interval", oldLocationTrackingInterval * 60); //moving old interval in minutes to new interval in seconds
|
||||
try {
|
||||
await platform.invokeMethod('startLocationService');
|
||||
} catch (e) {
|
||||
await prefs.setInt("location-updates-state", 0); //Disabling location tracking if can't start
|
||||
await platform.invokeMethod('startLocationService', <String, dynamic>{
|
||||
'location-updates-interval': oldLocationTrackingInterval * 60 * 1000,
|
||||
'location-updates-priority': 100,
|
||||
'location-updates-show-notification': true
|
||||
});
|
||||
} catch (e, stack) {
|
||||
Logger.e("[MIGRATION] Can't start new location tracking: $e", stacktrace: stack);
|
||||
}
|
||||
} else {
|
||||
Logger.d("[MIGRATION] Old location tracking was disabled");
|
||||
await prefs.setInt("location-updates-state", 0); //Setting new location tracking mode to disabled
|
||||
}
|
||||
await prefs.setBool("location-tracking-migrated", true);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ class _IntegrationSettingsPageState extends State<IntegrationSettingsPage> {
|
||||
bool _locationTrackingEnabled = false;
|
||||
bool _wait = false;
|
||||
bool _showNotification = true;
|
||||
int _accuracy = 102;
|
||||
int _accuracy = 100;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -35,7 +35,7 @@ class _IntegrationSettingsPageState extends State<IntegrationSettingsPage> {
|
||||
await prefs.reload();
|
||||
SharedPreferences.getInstance().then((prefs) {
|
||||
setState(() {
|
||||
_accuracy = prefs.getInt("location-updates-priority") ?? 102;
|
||||
_accuracy = prefs.getInt("location-updates-priority") ?? 100;
|
||||
_locationTrackingEnabled = (prefs.getInt("location-updates-state") ?? 0) > 0;
|
||||
_showNotification = prefs.getBool("location-updates-show-notification") ?? true;
|
||||
_locationInterval = Duration(milliseconds: prefs.getInt("location-updates-interval") ??
|
||||
|
@ -1,7 +1,7 @@
|
||||
name: hass_client
|
||||
description: Home Assistant Android Client
|
||||
|
||||
version: 1.3.0+1304
|
||||
version: 1.3.0+1305
|
||||
|
||||
|
||||
environment:
|
||||
|
Reference in New Issue
Block a user