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