Add wake lock settings
This commit is contained in:
parent
b903d7ab6f
commit
e0f2bde919
3 changed files with 16 additions and 4 deletions
|
|
@ -20,7 +20,7 @@
|
||||||
"distanceLabel": "Distance (meters)",
|
"distanceLabel": "Distance (meters)",
|
||||||
"heartbeatLabel": "Stationary heartbeat (seconds)",
|
"heartbeatLabel": "Stationary heartbeat (seconds)",
|
||||||
"bufferLabel": "Offline buffering",
|
"bufferLabel": "Offline buffering",
|
||||||
"disableElasticityLabel": "Disable elasticity",
|
"wakelockLabel": "Wake lock",
|
||||||
"stopDetectionLabel": "Stop detection",
|
"stopDetectionLabel": "Stop detection",
|
||||||
"trackingLabel": "Continuous tracking",
|
"trackingLabel": "Continuous tracking",
|
||||||
"motionLabel": "Active movement",
|
"motionLabel": "Active movement",
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ class Preferences {
|
||||||
static const String distance = 'distance';
|
static const String distance = 'distance';
|
||||||
static const String heartbeat = 'heartbeat';
|
static const String heartbeat = 'heartbeat';
|
||||||
static const String buffer = 'buffer';
|
static const String buffer = 'buffer';
|
||||||
|
static const String wakelock = 'wakelock';
|
||||||
static const String stopDetection = 'stop_detection';
|
static const String stopDetection = 'stop_detection';
|
||||||
static const String fastestInterval = 'fastest_interval';
|
static const String fastestInterval = 'fastest_interval';
|
||||||
|
|
||||||
|
|
@ -25,7 +26,7 @@ class Preferences {
|
||||||
: SharedPreferencesOptions(),
|
: SharedPreferencesOptions(),
|
||||||
cacheOptions: SharedPreferencesWithCacheOptions(
|
cacheOptions: SharedPreferencesWithCacheOptions(
|
||||||
allowList: {
|
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',
|
'device_id_preference', 'server_url_preference', 'accuracy_preference',
|
||||||
'frequency_preference', 'distance_preference', 'buffer_preference',
|
'frequency_preference', 'distance_preference', 'buffer_preference',
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,10 @@ class SettingsScreen extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _SettingsScreenState extends State<SettingsScreen> {
|
class _SettingsScreenState extends State<SettingsScreen> {
|
||||||
bool buffering = true;
|
|
||||||
bool stopDetection = false;
|
|
||||||
bool advanced = false;
|
bool advanced = false;
|
||||||
|
bool buffering = true;
|
||||||
|
bool wakelock = false;
|
||||||
|
bool stopDetection = true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
|
@ -28,6 +29,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||||
void _initState() async {
|
void _initState() async {
|
||||||
setState(() {
|
setState(() {
|
||||||
buffering = Preferences.instance.getBool(Preferences.buffer) ?? true;
|
buffering = Preferences.instance.getBool(Preferences.buffer) ?? true;
|
||||||
|
wakelock = Preferences.instance.getBool(Preferences.wakelock) ?? false;
|
||||||
stopDetection = Preferences.instance.getBool(Preferences.stopDetection) ?? true;
|
stopDetection = Preferences.instance.getBool(Preferences.stopDetection) ?? true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -171,6 +173,15 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||||
setState(() => buffering = value);
|
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)
|
if (advanced)
|
||||||
SwitchListTile(
|
SwitchListTile(
|
||||||
title: Text(AppLocalizations.of(context)!.stopDetectionLabel),
|
title: Text(AppLocalizations.of(context)!.stopDetectionLabel),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue