diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 7ac4caf..3317fbf 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -20,7 +20,7 @@ "distanceLabel": "Distance (meters)", "heartbeatLabel": "Stationary heartbeat (seconds)", "bufferLabel": "Offline buffering", - "disableElasticityLabel": "Disable elasticity", + "wakelockLabel": "Wake lock", "stopDetectionLabel": "Stop detection", "trackingLabel": "Continuous tracking", "motionLabel": "Active movement", diff --git a/lib/preferences.dart b/lib/preferences.dart index 7b0c174..eff5550 100644 --- a/lib/preferences.dart +++ b/lib/preferences.dart @@ -15,6 +15,7 @@ class Preferences { static const String distance = 'distance'; static const String heartbeat = 'heartbeat'; static const String buffer = 'buffer'; + static const String wakelock = 'wakelock'; static const String stopDetection = 'stop_detection'; static const String fastestInterval = 'fastest_interval'; @@ -25,7 +26,7 @@ class Preferences { : SharedPreferencesOptions(), cacheOptions: SharedPreferencesWithCacheOptions( allowList: { - id, url, accuracy, interval, distance, buffer, heartbeat, stopDetection, fastestInterval, + id, url, accuracy, interval, distance, buffer, heartbeat, wakelock, stopDetection, fastestInterval, 'device_id_preference', 'server_url_preference', 'accuracy_preference', 'frequency_preference', 'distance_preference', 'buffer_preference', }, diff --git a/lib/settings_screen.dart b/lib/settings_screen.dart index f95a8fc..e1c83e4 100644 --- a/lib/settings_screen.dart +++ b/lib/settings_screen.dart @@ -15,9 +15,10 @@ class SettingsScreen extends StatefulWidget { } class _SettingsScreenState extends State { - bool buffering = true; - bool stopDetection = false; bool advanced = false; + bool buffering = true; + bool wakelock = false; + bool stopDetection = true; @override void initState() { @@ -28,6 +29,7 @@ class _SettingsScreenState extends State { void _initState() async { setState(() { buffering = Preferences.instance.getBool(Preferences.buffer) ?? true; + wakelock = Preferences.instance.getBool(Preferences.wakelock) ?? false; stopDetection = Preferences.instance.getBool(Preferences.stopDetection) ?? true; }); } @@ -171,6 +173,15 @@ class _SettingsScreenState extends State { setState(() => buffering = value); }, ), + if (advanced && Platform.isAndroid) + SwitchListTile( + title: Text(AppLocalizations.of(context)!.wakelockLabel), + value: wakelock, + onChanged: (value) async { + await Preferences.instance.setBool(Preferences.wakelock, value); + setState(() => wakelock = value); + }, + ), if (advanced) SwitchListTile( title: Text(AppLocalizations.of(context)!.stopDetectionLabel),