Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Screen does not stay on #781 #858

Merged
merged 13 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:finamp/services/keep_screen_on_helper.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:hive/hive.dart';
Expand Down
4 changes: 2 additions & 2 deletions lib/models/finamp_models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2191,11 +2191,11 @@ enum LyricsFontSize {
@HiveType(typeId: 72)
enum KeepScreenOnOption {
@HiveField(0)
disabled,
whileLyrics,
@HiveField(1)
whilePlaying,
@HiveField(2)
whileLyrics;
disabled;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this doesn't actually change the default, just in which order the options appear. You can keep the order how it was, starting with disabled.
To change the default, change it here: https://github.com/jmshrv/finamp/pull/858/files#diff-00fd4ef72cab57c7db5c49ff8cd257918492ca5650d72bec14b3ee8560fcad54R114

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea, I looked up how to set default and I guess it's something like calling a constructor with the value?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no way to set the default of an enum. But we use the enum as a value for a setting, and there's a place in finamp_models.dart where we specify the default settings value to be used, if no value has been selected yet.
This will not change the selected value after the first start, unless you clear the app data and thereby delete the database.


/// Human-readable version of this enum. I've written longer descriptions on
/// enums like [TabContentType], and I can't be bothered to copy and paste it
Expand Down
6 changes: 3 additions & 3 deletions lib/services/keep_screen_on_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import 'package:finamp/services/finamp_settings_helper.dart';
import 'package:finamp/services/music_player_background_task.dart';
import 'package:flutter/material.dart';
import 'package:get_it/get_it.dart';
import 'package:keep_screen_on/keep_screen_on.dart';
import 'package:logging/logging.dart';
import 'package:wakelock_plus/wakelock_plus.dart';

/// Implements ability to keep screen on according to various conditions
class KeepScreenOnHelper {
Expand Down Expand Up @@ -92,14 +92,14 @@ class KeepScreenOnHelper {
static void _turnOn() {
if (!keepingScreenOn) {
keepingScreenOn = true;
KeepScreenOn.turnOn();
WakelockPlus.enable();
}
}

static void _turnOff() {
if (keepingScreenOn) {
keepingScreenOn = false;
KeepScreenOn.turnOff();
WakelockPlus.disable();
}
}
}
Expand Down
32 changes: 16 additions & 16 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -815,22 +815,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.4.11"
keep_screen_on:
dependency: "direct main"
description:
name: keep_screen_on
sha256: "374405358a3229b0e1041b6e390ff4c74e73fbd21075298042044e0c84b5574c"
url: "https://pub.dev"
source: hosted
version: "3.0.0"
keep_screen_on_platform_interface:
dependency: transitive
description:
name: keep_screen_on_platform_interface
sha256: "065a0811407a970027c7530f9b8f36d11c89f36aab85b4b5acdacfe2cf3a8568"
url: "https://pub.dev"
source: hosted
version: "3.0.0"
leak_tracker:
dependency: transitive
description:
Expand Down Expand Up @@ -1623,6 +1607,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "14.2.5"
wakelock_plus:
dependency: "direct main"
description:
name: wakelock_plus
sha256: bf4ee6f17a2fa373ed3753ad0e602b7603f8c75af006d5b9bdade263928c0484
url: "https://pub.dev"
source: hosted
version: "1.2.8"
wakelock_plus_platform_interface:
dependency: transitive
description:
name: wakelock_plus_platform_interface
sha256: "422d1cdbb448079a8a62a5a770b69baa489f8f7ca21aef47800c726d404f9d16"
url: "https://pub.dev"
source: hosted
version: "1.2.1"
watcher:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ dependencies:
scroll_to_index: ^3.0.1
window_manager: ^0.3.8
url_launcher: ^6.2.6
keep_screen_on: ^3.0.0
wakelock_plus: ^1.2.8
battery_plus: ^6.0.2

dev_dependencies:
Expand Down