From 5aaba5e33e09f389191b85e5ac552f7cce7ffbb1 Mon Sep 17 00:00:00 2001 From: richard Date: Fri, 9 Aug 2024 20:55:05 +0200 Subject: [PATCH 1/2] feat: ask to remove battery optimization --- android/app/build.gradle | 4 ++-- android/app/src/main/AndroidManifest.xml | 2 +- .../yuotube_downloader/MainActivity.kt | 2 +- ios/Runner.xcodeproj/project.pbxproj | 12 +++++----- lib/app.dart | 5 ++++ lib/main.dart | 2 ++ lib/services/audios_storage_service.dart | 1 + .../battery_optimization_service.dart | 23 +++++++++++++++++++ .../device_permissions_storage_service.dart | 20 ++++++++++++++++ lib/services/services.dart | 2 ++ linux/CMakeLists.txt | 2 +- macos/Runner.xcodeproj/project.pbxproj | 6 ++--- macos/Runner/Configs/AppInfo.xcconfig | 4 ++-- pubspec.lock | 8 +++++++ pubspec.yaml | 1 + windows/runner/Runner.rc | 4 ++-- 16 files changed, 80 insertions(+), 18 deletions(-) create mode 100644 lib/services/battery_optimization_service.dart create mode 100644 lib/services/device_permissions_storage_service.dart diff --git a/android/app/build.gradle b/android/app/build.gradle index 3930a4a..1c04747 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - namespace "com.example.youtube_downloader" + namespace "com.richard.youtube_downloader" compileSdkVersion flutter.compileSdkVersion ndkVersion flutter.ndkVersion @@ -47,7 +47,7 @@ android { defaultConfig { multiDexEnabled true // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). - applicationId "com.example.youtube_downloader" + applicationId "com.richard.youtube_downloader" // You can update the following values to match your application needs. // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. minSdkVersion 24// flutter.minSdkVersion diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index f4db871..a79c763 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -10,7 +10,7 @@ - + (); + batteryOptimizationService.askToDisableOptimization(); + return KeyboardDismissOnTap( child: GetMaterialApp( title: 'Flutter YouTube Downloader & Converter', diff --git a/lib/main.dart b/lib/main.dart index 23e7419..0cd268f 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -16,6 +16,8 @@ Future _injectServices() async { Get.lazyPut(() => FileSystemService()); Get.lazyPut(() => AudiosStorageService()); Get.lazyPut(() => SettingsStorageService()); + Get.lazyPut(() => DevicePermissionsStorageService()); + Get.lazyPut(() => BatteryOptimizationService()); Get.lazyPut(() => PlayerService()); Get.lazyPut(() => YouTubeService()); Get.lazyPut(() => SponsorblockService()); diff --git a/lib/services/audios_storage_service.dart b/lib/services/audios_storage_service.dart index 0b0b588..e06105b 100644 --- a/lib/services/audios_storage_service.dart +++ b/lib/services/audios_storage_service.dart @@ -4,6 +4,7 @@ import 'package:youtube_downloader/models/models.dart'; class AudiosStorageService { static const String _audioKey = 'audios'; + Future storeAudios(List