From e63c6fc2d2f4a091d79a09a285a8a1574e9f5140 Mon Sep 17 00:00:00 2001 From: jld3103 Date: Sat, 15 Jul 2023 08:29:54 +0200 Subject: [PATCH 1/3] neon_news,neon_notes: Use wakelock_plus --- packages/app/pubspec.lock | 41 ++++--------------- packages/app/pubspec.yaml | 7 ---- packages/app/pubspec_overrides.yaml | 7 +--- packages/neon/neon/pubspec.yaml | 7 ---- packages/neon/neon/pubspec_overrides.yaml | 7 +--- packages/neon/neon_news/lib/neon_news.dart | 2 +- .../neon/neon_news/lib/pages/article.dart | 4 +- packages/neon/neon_news/pubspec.yaml | 9 +--- .../neon/neon_news/pubspec_overrides.yaml | 7 +--- packages/neon/neon_notes/lib/neon_notes.dart | 2 +- packages/neon/neon_notes/lib/pages/note.dart | 4 +- packages/neon/neon_notes/pubspec.yaml | 9 +--- .../neon/neon_notes/pubspec_overrides.yaml | 7 +--- 13 files changed, 20 insertions(+), 93 deletions(-) diff --git a/packages/app/pubspec.lock b/packages/app/pubspec.lock index 09d8b682..10a17114 100644 --- a/packages/app/pubspec.lock +++ b/packages/app/pubspec.lock @@ -1425,47 +1425,22 @@ packages: url: "https://pub.dev" source: hosted version: "11.3.0" - wakelock: + wakelock_plus: dependency: transitive description: - name: wakelock - sha256: "769ecf42eb2d07128407b50cb93d7c10bd2ee48f0276ef0119db1d25cc2f87db" + name: wakelock_plus + sha256: aac3f3258f01781ec9212df94eecef1eb9ba9350e106728def405baa096ba413 url: "https://pub.dev" source: hosted - version: "0.6.2" - wakelock_macos: - dependency: transitive - description: - name: wakelock_macos - sha256: "047c6be2f88cb6b76d02553bca5a3a3b95323b15d30867eca53a19a0a319d4cd" - url: "https://pub.dev" - source: hosted - version: "0.4.0" - wakelock_platform_interface: - dependency: transitive - description: - name: wakelock_platform_interface - sha256: "1f4aeb81fb592b863da83d2d0f7b8196067451e4df91046c26b54a403f9de621" - url: "https://pub.dev" - source: hosted - version: "0.3.0" - wakelock_web: + version: "1.1.1" + wakelock_plus_platform_interface: dependency: transitive description: - name: wakelock_web - sha256: "1b256b811ee3f0834888efddfe03da8d18d0819317f20f6193e2922b41a501b5" + name: wakelock_plus_platform_interface + sha256: "40fabed5da06caff0796dc638e1f07ee395fb18801fbff3255a2372db2d80385" url: "https://pub.dev" source: hosted - version: "0.4.0" - wakelock_windows: - dependency: "direct overridden" - description: - path: wakelock_windows - ref: "269e1dba6bca6975a0bc44da6a42e56ca7428da9" - resolved-ref: "269e1dba6bca6975a0bc44da6a42e56ca7428da9" - url: "https://github.com/fikretonuresen/wakelock" - source: git - version: "0.2.2" + version: "1.1.0" webdriver: dependency: transitive description: diff --git a/packages/app/pubspec.yaml b/packages/app/pubspec.yaml index 6e138a2a..4e96fdf4 100644 --- a/packages/app/pubspec.yaml +++ b/packages/app/pubspec.yaml @@ -44,13 +44,6 @@ dev_dependencies: url: https://github.com/stack11/dart_nit_picking ref: 0b2ee0d -dependency_overrides: - wakelock_windows: # TODO: https://github.com/creativecreatorormaybenot/wakelock/pull/195 - git: - url: https://github.com/fikretonuresen/wakelock - path: wakelock_windows - ref: 269e1dba6bca6975a0bc44da6a42e56ca7428da9 - flutter: uses-material-design: true assets: diff --git a/packages/app/pubspec_overrides.yaml b/packages/app/pubspec_overrides.yaml index 769385c2..42527add 100644 --- a/packages/app/pubspec_overrides.yaml +++ b/packages/app/pubspec_overrides.yaml @@ -1,4 +1,4 @@ -# melos_managed_dependency_overrides: dynamite_runtime,file_icons,neon,neon_files,neon_news,neon_notes,neon_notifications,nextcloud,sort_box,wakelock_windows +# melos_managed_dependency_overrides: dynamite_runtime,file_icons,neon,neon_files,neon_news,neon_notes,neon_notifications,nextcloud,sort_box dependency_overrides: dynamite_runtime: path: ../dynamite/dynamite_runtime @@ -18,8 +18,3 @@ dependency_overrides: path: ../nextcloud sort_box: path: ../sort_box - wakelock_windows: - git: - url: https://github.com/fikretonuresen/wakelock - ref: 269e1dba6bca6975a0bc44da6a42e56ca7428da9 - path: wakelock_windows diff --git a/packages/neon/neon/pubspec.yaml b/packages/neon/neon/pubspec.yaml index 93ab4173..0479da47 100644 --- a/packages/neon/neon/pubspec.yaml +++ b/packages/neon/neon/pubspec.yaml @@ -66,13 +66,6 @@ dev_dependencies: ref: 0b2ee0d test: ^1.24.3 -dependency_overrides: - wakelock_windows: # TODO: https://github.com/creativecreatorormaybenot/wakelock/pull/195 - git: - url: https://github.com/fikretonuresen/wakelock - path: wakelock_windows - ref: 269e1dba6bca6975a0bc44da6a42e56ca7428da9 - flutter: uses-material-design: true assets: diff --git a/packages/neon/neon/pubspec_overrides.yaml b/packages/neon/neon/pubspec_overrides.yaml index fa3b7c95..2e927e31 100644 --- a/packages/neon/neon/pubspec_overrides.yaml +++ b/packages/neon/neon/pubspec_overrides.yaml @@ -1,4 +1,4 @@ -# melos_managed_dependency_overrides: dynamite_runtime,nextcloud,sort_box,wakelock_windows +# melos_managed_dependency_overrides: dynamite_runtime,nextcloud,sort_box dependency_overrides: dynamite_runtime: path: ../../dynamite/dynamite_runtime @@ -6,8 +6,3 @@ dependency_overrides: path: ../../nextcloud sort_box: path: ../../sort_box - wakelock_windows: - git: - url: https://github.com/fikretonuresen/wakelock - ref: 269e1dba6bca6975a0bc44da6a42e56ca7428da9 - path: wakelock_windows diff --git a/packages/neon/neon_news/lib/neon_news.dart b/packages/neon/neon_news/lib/neon_news.dart index 3a534290..9b9863ea 100644 --- a/packages/neon/neon_news/lib/neon_news.dart +++ b/packages/neon/neon_news/lib/neon_news.dart @@ -23,7 +23,7 @@ import 'package:provider/provider.dart'; import 'package:rxdart/rxdart.dart'; import 'package:share_plus/share_plus.dart'; import 'package:url_launcher/url_launcher_string.dart'; -import 'package:wakelock/wakelock.dart'; +import 'package:wakelock_plus/wakelock_plus.dart'; import 'package:webview_flutter/webview_flutter.dart'; part 'blocs/article.dart'; diff --git a/packages/neon/neon_news/lib/pages/article.dart b/packages/neon/neon_news/lib/pages/article.dart index eaa2d232..1aaf4766 100644 --- a/packages/neon/neon_news/lib/pages/article.dart +++ b/packages/neon/neon_news/lib/pages/article.dart @@ -35,7 +35,7 @@ class _NewsArticlePageState extends State { WidgetsBinding.instance.addPostFrameCallback((final _) async { if (Provider.of(context, listen: false).canUseWakelock) { - await Wakelock.enable(); + await WakelockPlus.enable(); } }); @@ -103,7 +103,7 @@ class _NewsArticlePageState extends State { } if (mounted && Provider.of(context, listen: false).canUseWakelock) { - await Wakelock.disable(); + await WakelockPlus.disable(); } return false; }, diff --git a/packages/neon/neon_news/pubspec.yaml b/packages/neon/neon_news/pubspec.yaml index c4c3a2c0..d0c003ac 100644 --- a/packages/neon/neon_news/pubspec.yaml +++ b/packages/neon/neon_news/pubspec.yaml @@ -25,7 +25,7 @@ dependencies: rxdart: ^0.27.7 share_plus: ^7.0.0 url_launcher: ^6.1.11 - wakelock: ^0.6.2 + wakelock_plus: ^1.1.1 webview_flutter: ^4.2.0 dev_dependencies: @@ -36,13 +36,6 @@ dev_dependencies: url: https://github.com/stack11/dart_nit_picking ref: 0b2ee0d -dependency_overrides: - wakelock_windows: # TODO: https://github.com/creativecreatorormaybenot/wakelock/pull/195 - git: - url: https://github.com/fikretonuresen/wakelock - path: wakelock_windows - ref: 269e1dba6bca6975a0bc44da6a42e56ca7428da9 - flutter: uses-material-design: true assets: diff --git a/packages/neon/neon_news/pubspec_overrides.yaml b/packages/neon/neon_news/pubspec_overrides.yaml index 807ec964..bc921fe9 100644 --- a/packages/neon/neon_news/pubspec_overrides.yaml +++ b/packages/neon/neon_news/pubspec_overrides.yaml @@ -1,4 +1,4 @@ -# melos_managed_dependency_overrides: dynamite_runtime,neon,nextcloud,sort_box,wakelock_windows +# melos_managed_dependency_overrides: dynamite_runtime,neon,nextcloud,sort_box dependency_overrides: dynamite_runtime: path: ../../dynamite/dynamite_runtime @@ -8,8 +8,3 @@ dependency_overrides: path: ../../nextcloud sort_box: path: ../../sort_box - wakelock_windows: - git: - url: https://github.com/fikretonuresen/wakelock - ref: 269e1dba6bca6975a0bc44da6a42e56ca7428da9 - path: wakelock_windows diff --git a/packages/neon/neon_notes/lib/neon_notes.dart b/packages/neon/neon_notes/lib/neon_notes.dart index a5c29136..7547558d 100644 --- a/packages/neon/neon_notes/lib/neon_notes.dart +++ b/packages/neon/neon_notes/lib/neon_notes.dart @@ -23,7 +23,7 @@ import 'package:provider/provider.dart'; import 'package:queue/queue.dart'; import 'package:rxdart/rxdart.dart'; import 'package:url_launcher/url_launcher_string.dart'; -import 'package:wakelock/wakelock.dart'; +import 'package:wakelock_plus/wakelock_plus.dart'; part 'blocs/note.dart'; part 'blocs/notes.dart'; diff --git a/packages/neon/neon_notes/lib/pages/note.dart b/packages/neon/neon_notes/lib/pages/note.dart index 16ed07ce..06e40bdc 100644 --- a/packages/neon/neon_notes/lib/pages/note.dart +++ b/packages/neon/neon_notes/lib/pages/note.dart @@ -43,7 +43,7 @@ class _NotesNotePageState extends State { WidgetsBinding.instance.addPostFrameCallback((final _) async { if (Provider.of(context, listen: false).canUseWakelock) { - await Wakelock.enable(); + await WakelockPlus.enable(); } if (widget.bloc.options.defaultNoteViewTypeOption.value == DefaultNoteViewType.edit || widget.bloc.initialContent.isEmpty) { @@ -66,7 +66,7 @@ class _NotesNotePageState extends State { Widget build(final BuildContext context) => BackButtonListener( onBackButtonPressed: () async { if (Provider.of(context, listen: false).canUseWakelock) { - await Wakelock.disable(); + await WakelockPlus.disable(); } return false; }, diff --git a/packages/neon/neon_notes/pubspec.yaml b/packages/neon/neon_notes/pubspec.yaml index 6319ea2b..e151e5a6 100644 --- a/packages/neon/neon_notes/pubspec.yaml +++ b/packages/neon/neon_notes/pubspec.yaml @@ -26,7 +26,7 @@ dependencies: queue: ^3.1.0+2 rxdart: ^0.27.7 url_launcher: ^6.1.11 - wakelock: ^0.6.2 + wakelock_plus: ^1.1.1 dev_dependencies: build_runner: ^2.4.4 @@ -36,13 +36,6 @@ dev_dependencies: url: https://github.com/stack11/dart_nit_picking ref: 0b2ee0d -dependency_overrides: - wakelock_windows: # TODO: https://github.com/creativecreatorormaybenot/wakelock/pull/195 - git: - url: https://github.com/fikretonuresen/wakelock - path: wakelock_windows - ref: 269e1dba6bca6975a0bc44da6a42e56ca7428da9 - flutter: uses-material-design: true assets: diff --git a/packages/neon/neon_notes/pubspec_overrides.yaml b/packages/neon/neon_notes/pubspec_overrides.yaml index 807ec964..bc921fe9 100644 --- a/packages/neon/neon_notes/pubspec_overrides.yaml +++ b/packages/neon/neon_notes/pubspec_overrides.yaml @@ -1,4 +1,4 @@ -# melos_managed_dependency_overrides: dynamite_runtime,neon,nextcloud,sort_box,wakelock_windows +# melos_managed_dependency_overrides: dynamite_runtime,neon,nextcloud,sort_box dependency_overrides: dynamite_runtime: path: ../../dynamite/dynamite_runtime @@ -8,8 +8,3 @@ dependency_overrides: path: ../../nextcloud sort_box: path: ../../sort_box - wakelock_windows: - git: - url: https://github.com/fikretonuresen/wakelock - ref: 269e1dba6bca6975a0bc44da6a42e56ca7428da9 - path: wakelock_windows From 7ca345de69756350f844d63f7b060fbfdae07cd1 Mon Sep 17 00:00:00 2001 From: jld3103 Date: Sat, 15 Jul 2023 08:37:09 +0200 Subject: [PATCH 2/3] neon_news,neon_notes: Do not await wakelock operations --- packages/neon/neon_news/lib/pages/article.dart | 6 +++--- packages/neon/neon_notes/lib/pages/note.dart | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/neon/neon_news/lib/pages/article.dart b/packages/neon/neon_news/lib/pages/article.dart index 1aaf4766..d6413630 100644 --- a/packages/neon/neon_news/lib/pages/article.dart +++ b/packages/neon/neon_news/lib/pages/article.dart @@ -33,9 +33,9 @@ class _NewsArticlePageState extends State { NeonException.showSnackbar(context, error); }); - WidgetsBinding.instance.addPostFrameCallback((final _) async { + WidgetsBinding.instance.addPostFrameCallback((final _) { if (Provider.of(context, listen: false).canUseWakelock) { - await WakelockPlus.enable(); + unawaited(WakelockPlus.enable()); } }); @@ -103,7 +103,7 @@ class _NewsArticlePageState extends State { } if (mounted && Provider.of(context, listen: false).canUseWakelock) { - await WakelockPlus.disable(); + unawaited(WakelockPlus.disable()); } return false; }, diff --git a/packages/neon/neon_notes/lib/pages/note.dart b/packages/neon/neon_notes/lib/pages/note.dart index 06e40bdc..9a247d50 100644 --- a/packages/neon/neon_notes/lib/pages/note.dart +++ b/packages/neon/neon_notes/lib/pages/note.dart @@ -41,9 +41,9 @@ class _NotesNotePageState extends State { _contentController.addListener(() => _contentStreamController.add(_contentController.text)); _titleController.addListener(() => _titleStreamController.add(_titleController.text)); - WidgetsBinding.instance.addPostFrameCallback((final _) async { + WidgetsBinding.instance.addPostFrameCallback((final _) { if (Provider.of(context, listen: false).canUseWakelock) { - await WakelockPlus.enable(); + unawaited(WakelockPlus.enable()); } if (widget.bloc.options.defaultNoteViewTypeOption.value == DefaultNoteViewType.edit || widget.bloc.initialContent.isEmpty) { @@ -66,7 +66,7 @@ class _NotesNotePageState extends State { Widget build(final BuildContext context) => BackButtonListener( onBackButtonPressed: () async { if (Provider.of(context, listen: false).canUseWakelock) { - await WakelockPlus.disable(); + unawaited(WakelockPlus.disable()); } return false; }, From 50fc20507080a9f104e8d084393e0eea89742786 Mon Sep 17 00:00:00 2001 From: jld3103 Date: Sat, 15 Jul 2023 08:39:44 +0200 Subject: [PATCH 3/3] neon,neon_news,neon_notes: Wakelock is supported on every platform --- packages/neon/neon/lib/src/platform/android.dart | 1 - packages/neon/neon/lib/src/platform/linux.dart | 1 - packages/neon/neon/lib/src/platform/platform.dart | 3 --- packages/neon/neon_news/lib/pages/article.dart | 9 +++------ packages/neon/neon_notes/lib/neon_notes.dart | 1 - packages/neon/neon_notes/lib/pages/note.dart | 10 ++++------ 6 files changed, 7 insertions(+), 18 deletions(-) diff --git a/packages/neon/neon/lib/src/platform/android.dart b/packages/neon/neon/lib/src/platform/android.dart index 53f96543..90dbf997 100644 --- a/packages/neon/neon/lib/src/platform/android.dart +++ b/packages/neon/neon/lib/src/platform/android.dart @@ -10,7 +10,6 @@ class AndroidNeonPlatform extends NeonPlatform { AndroidNeonPlatform() : super( canUseWebView: true, - canUseWakelock: true, canUseQuickActions: true, canUseSystemTray: false, canUseWindowManager: false, diff --git a/packages/neon/neon/lib/src/platform/linux.dart b/packages/neon/neon/lib/src/platform/linux.dart index 471c8db1..49fb669c 100644 --- a/packages/neon/neon/lib/src/platform/linux.dart +++ b/packages/neon/neon/lib/src/platform/linux.dart @@ -11,7 +11,6 @@ class LinuxNeonPlatform extends NeonPlatform { LinuxNeonPlatform() : super( canUseWebView: false, - canUseWakelock: false, canUseQuickActions: false, canUseSystemTray: true, canUseWindowManager: true, diff --git a/packages/neon/neon/lib/src/platform/platform.dart b/packages/neon/neon/lib/src/platform/platform.dart index 1466c866..e41f67ba 100644 --- a/packages/neon/neon/lib/src/platform/platform.dart +++ b/packages/neon/neon/lib/src/platform/platform.dart @@ -23,7 +23,6 @@ Future getNeonPlatform() async { abstract class NeonPlatform { NeonPlatform({ required this.canUseWebView, - required this.canUseWakelock, required this.canUseQuickActions, required this.canUseSystemTray, required this.canUseWindowManager, @@ -36,8 +35,6 @@ abstract class NeonPlatform { final bool canUseWebView; - final bool canUseWakelock; - final bool canUseQuickActions; final bool canUseSystemTray; diff --git a/packages/neon/neon_news/lib/pages/article.dart b/packages/neon/neon_news/lib/pages/article.dart index d6413630..e2ccda80 100644 --- a/packages/neon/neon_news/lib/pages/article.dart +++ b/packages/neon/neon_news/lib/pages/article.dart @@ -34,9 +34,7 @@ class _NewsArticlePageState extends State { }); WidgetsBinding.instance.addPostFrameCallback((final _) { - if (Provider.of(context, listen: false).canUseWakelock) { - unawaited(WakelockPlus.enable()); - } + unawaited(WakelockPlus.enable()); }); if (widget.useWebView) { @@ -102,9 +100,8 @@ class _NewsArticlePageState extends State { return true; } - if (mounted && Provider.of(context, listen: false).canUseWakelock) { - unawaited(WakelockPlus.disable()); - } + unawaited(WakelockPlus.disable()); + return false; }, child: Scaffold( diff --git a/packages/neon/neon_notes/lib/neon_notes.dart b/packages/neon/neon_notes/lib/neon_notes.dart index 7547558d..7478f852 100644 --- a/packages/neon/neon_notes/lib/neon_notes.dart +++ b/packages/neon/neon_notes/lib/neon_notes.dart @@ -11,7 +11,6 @@ import 'package:go_router/go_router.dart'; import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; import 'package:neon/blocs.dart'; import 'package:neon/models.dart'; -import 'package:neon/platform.dart'; import 'package:neon/settings.dart'; import 'package:neon/sort_box.dart'; import 'package:neon/utils.dart'; diff --git a/packages/neon/neon_notes/lib/pages/note.dart b/packages/neon/neon_notes/lib/pages/note.dart index 9a247d50..f5336f83 100644 --- a/packages/neon/neon_notes/lib/pages/note.dart +++ b/packages/neon/neon_notes/lib/pages/note.dart @@ -42,9 +42,8 @@ class _NotesNotePageState extends State { _titleController.addListener(() => _titleStreamController.add(_titleController.text)); WidgetsBinding.instance.addPostFrameCallback((final _) { - if (Provider.of(context, listen: false).canUseWakelock) { - unawaited(WakelockPlus.enable()); - } + unawaited(WakelockPlus.enable()); + if (widget.bloc.options.defaultNoteViewTypeOption.value == DefaultNoteViewType.edit || widget.bloc.initialContent.isEmpty) { setState(() { @@ -65,9 +64,8 @@ class _NotesNotePageState extends State { @override Widget build(final BuildContext context) => BackButtonListener( onBackButtonPressed: () async { - if (Provider.of(context, listen: false).canUseWakelock) { - unawaited(WakelockPlus.disable()); - } + unawaited(WakelockPlus.disable()); + return false; }, child: Scaffold(