Add UI setting to keep device awake
This commit is contained in:
parent
4e5cadcda6
commit
57c838dbf6
4 changed files with 38 additions and 2 deletions
|
@ -30,6 +30,7 @@ import 'package:photos/services/sync_service.dart';
|
|||
import 'package:photos/utils/crypto_util.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
import 'package:wakelock/wakelock.dart';
|
||||
|
||||
class Configuration {
|
||||
Configuration._privateConstructor();
|
||||
|
@ -43,6 +44,10 @@ class Configuration {
|
|||
static const keyKey = "key";
|
||||
static const keyShouldBackupOverMobileData = "should_backup_over_mobile_data";
|
||||
static const keyShouldBackupVideos = "should_backup_videos";
|
||||
|
||||
// keyShouldKeepDeviceAwake is used to determine whether the device screen
|
||||
// should be kept on while the app is in foreground.
|
||||
static const keyShouldKeepDeviceAwake = "should_keep_device_awake";
|
||||
static const keyShouldHideFromRecents = "should_hide_from_recents";
|
||||
static const keyShouldShowLockScreen = "should_show_lock_screen";
|
||||
static const keyHasSkippedBackupFolderSelection =
|
||||
|
@ -494,6 +499,15 @@ class Configuration {
|
|||
}
|
||||
}
|
||||
|
||||
bool shouldKeepDeviceAwake() {
|
||||
return _preferences.get(keyShouldKeepDeviceAwake) ?? false;
|
||||
}
|
||||
|
||||
Future<void> setShouldKeepDeviceAwake(bool value) async {
|
||||
await _preferences.setBool(keyShouldKeepDeviceAwake, value);
|
||||
Wakelock.toggle(enable: value);
|
||||
}
|
||||
|
||||
Future<void> setShouldBackupVideos(bool value) async {
|
||||
await _preferences.setBool(keyShouldBackupVideos, value);
|
||||
if (value) {
|
||||
|
|
|
@ -96,6 +96,26 @@ class BackupSectionWidgetState extends State<BackupSectionWidget> {
|
|||
),
|
||||
),
|
||||
SectionOptionDivider,
|
||||
SizedBox(
|
||||
height: 48,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Keep device awake",
|
||||
style: Theme.of(context).textTheme.subtitle1,
|
||||
),
|
||||
Switch.adaptive(
|
||||
value: Configuration.instance.shouldKeepDeviceAwake(),
|
||||
onChanged: (value) async {
|
||||
Configuration.instance.setShouldKeepDeviceAwake(value);
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SectionOptionDivider,
|
||||
GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () async {
|
||||
|
|
|
@ -1417,12 +1417,12 @@ packages:
|
|||
source: hosted
|
||||
version: "0.2.2"
|
||||
wakelock:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: wakelock
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.5.6"
|
||||
version: "0.6.1+2"
|
||||
wakelock_macos:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
@ -112,10 +112,12 @@ dependencies:
|
|||
path: thirdparty/plugins/packages/video_player/video_player
|
||||
video_thumbnail: ^0.4.3
|
||||
visibility_detector: ^0.2.2
|
||||
wakelock: ^0.6.1+2
|
||||
wallpaper_manager_flutter: ^0.0.2
|
||||
|
||||
dependency_overrides:
|
||||
provider: ^6.0.1 # for chewie 1.2.2 https://github.com/brianegan/chewie/issues/530
|
||||
wakelock: ^0.6.1+2
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
|
Loading…
Add table
Reference in a new issue