From bdcd937d6e75cf58a3035d6bdf4ce24cc53eed47 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BF=B5?= <3209752489@qq.com>
Date: Mon, 13 Jan 2025 21:33:24 +0800
Subject: [PATCH] =?UTF-8?q?feat(Power):=20=E6=B7=BB=E5=8A=A0=E6=9D=83?=
=?UTF-8?q?=E9=99=90=E7=94=B3=E8=AF=B7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
android/app/src/debug/AndroidManifest.xml | 5 ++
android/app/src/main/AndroidManifest.xml | 11 +--
android/app/src/profile/AndroidManifest.xml | 5 ++
ios/Podfile | 68 +++++++++++++++++++
ios/Runner/Info.plist | 4 ++
lib/helpers/power.dart | 10 +++
lib/main.dart | 2 +
pubspec.lock | 48 +++++++++++++
pubspec.yaml | 1 +
.../flutter/generated_plugin_registrant.cc | 3 +
windows/flutter/generated_plugins.cmake | 1 +
11 files changed, 154 insertions(+), 4 deletions(-)
create mode 100644 ios/Podfile
create mode 100644 lib/helpers/power.dart
diff --git a/android/app/src/debug/AndroidManifest.xml b/android/app/src/debug/AndroidManifest.xml
index 399f698..fdf762a 100644
--- a/android/app/src/debug/AndroidManifest.xml
+++ b/android/app/src/debug/AndroidManifest.xml
@@ -4,4 +4,9 @@
to allow setting breakpoints, to provide hot reload, etc.
-->
+
+
+
+
+
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index edf0bc8..dcf6a90 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -2,6 +2,7 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ios/Podfile b/ios/Podfile
new file mode 100644
index 0000000..1b4ba6f
--- /dev/null
+++ b/ios/Podfile
@@ -0,0 +1,68 @@
+post_install do |installer|
+ installer.pods_project.targets.each do |target|
+ flutter_additional_ios_build_settings(target)
+
+ target.build_configurations.each do |config|
+ # You can remove unused permissions here
+ # for more information: https://github.com/BaseflowIT/flutter-permission-handler/blob/master/permission_handler/ios/Classes/PermissionHandlerEnums.h
+ # e.g. when you don't need camera permission, just add 'PERMISSION_CAMERA=0'
+ config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
+ '$(inherited)',
+
+ ## dart: PermissionGroup.calendar
+ 'PERMISSION_EVENTS=1',
+
+ ## dart: PermissionGroup.calendarFullAccess
+ 'PERMISSION_EVENTS_FULL_ACCESS=1',
+
+ ## dart: PermissionGroup.reminders
+ #'PERMISSION_REMINDERS=1',
+
+ ## dart: PermissionGroup.contacts
+ #'PERMISSION_CONTACTS=1',
+
+ ## dart: PermissionGroup.camera
+ #'PERMISSION_CAMERA=1',
+
+ ## dart: PermissionGroup.microphone
+ #'PERMISSION_MICROPHONE=1',
+
+ ## dart: PermissionGroup.speech
+ #'PERMISSION_SPEECH_RECOGNIZER=1',
+
+ ## dart: PermissionGroup.photos
+ 'PERMISSION_PHOTOS=1',
+
+ ## The 'PERMISSION_LOCATION' macro enables the `locationWhenInUse` and `locationAlways` permission. If
+ ## the application only requires `locationWhenInUse`, only specify the `PERMISSION_LOCATION_WHENINUSE`
+ ## macro.
+ ##
+ ## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
+ #'PERMISSION_LOCATION=1',
+ #'PERMISSION_LOCATION_WHENINUSE=0',
+
+ ## dart: PermissionGroup.notification
+ 'PERMISSION_NOTIFICATIONS=1',
+
+ ## dart: PermissionGroup.mediaLibrary
+ 'PERMISSION_MEDIA_LIBRARY=1',
+
+ ## dart: PermissionGroup.sensors
+ #'PERMISSION_SENSORS=1',
+
+ ## dart: PermissionGroup.bluetooth
+ #'PERMISSION_BLUETOOTH=1',
+
+ ## dart: PermissionGroup.appTrackingTransparency
+ #'PERMISSION_APP_TRACKING_TRANSPARENCY=1',
+
+ ## dart: PermissionGroup.criticalAlerts
+ #'PERMISSION_CRITICAL_ALERTS=1',
+
+ ## dart: PermissionGroup.criticalAlerts
+ #'PERMISSION_ASSISTANT=1',
+ ]
+
+ end
+ end
+end
\ No newline at end of file
diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist
index 3f6a3f4..8b7c072 100644
--- a/ios/Runner/Info.plist
+++ b/ios/Runner/Info.plist
@@ -60,5 +60,9 @@
Example usage description
NSPhotoLibraryUsageDescription
Example usage description
+ NSAppleMusicUsageDescription
+ Apple Music Usage Description
+ kTCCServiceMedia
+ kTCC Service Media
diff --git a/lib/helpers/power.dart b/lib/helpers/power.dart
new file mode 100644
index 0000000..91bc9cc
--- /dev/null
+++ b/lib/helpers/power.dart
@@ -0,0 +1,10 @@
+import 'package:permission_handler/permission_handler.dart' show Permission, PermissionActions;
+
+/// 权限
+class Power {
+ /// 请求权限
+ static Future request() async {
+ await Permission.storage.request();
+ await Permission.manageExternalStorage.request();
+ }
+}
diff --git a/lib/main.dart b/lib/main.dart
index 8c23fda..2cc132c 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -8,6 +8,7 @@ import 'package:glidea/controller/site/site.dart';
import 'package:glidea/helpers/constants.dart';
import 'package:glidea/helpers/json.dart';
import 'package:glidea/helpers/log.dart';
+import 'package:glidea/helpers/power.dart';
import 'package:glidea/helpers/theme.dart';
import 'package:glidea/helpers/windows.dart';
import 'package:glidea/lang/translations.dart';
@@ -27,6 +28,7 @@ class App extends StatelessWidget {
/// [App] 初始化
static Future initialized() async {
WidgetsFlutterBinding.ensureInitialized();
+ await Power.request();
Background.initialized();
await Log.initialized();
JsonHelp.initialized();
diff --git a/pubspec.lock b/pubspec.lock
index 0d5fde6..84f11cf 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -841,6 +841,54 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.3.0"
+ permission_handler:
+ dependency: "direct main"
+ description:
+ name: permission_handler
+ sha256: "18bf33f7fefbd812f37e72091a15575e72d5318854877e0e4035a24ac1113ecb"
+ url: "https://pub.flutter-io.cn"
+ source: hosted
+ version: "11.3.1"
+ permission_handler_android:
+ dependency: transitive
+ description:
+ name: permission_handler_android
+ sha256: "71bbecfee799e65aff7c744761a57e817e73b738fedf62ab7afd5593da21f9f1"
+ url: "https://pub.flutter-io.cn"
+ source: hosted
+ version: "12.0.13"
+ permission_handler_apple:
+ dependency: transitive
+ description:
+ name: permission_handler_apple
+ sha256: e6f6d73b12438ef13e648c4ae56bd106ec60d17e90a59c4545db6781229082a0
+ url: "https://pub.flutter-io.cn"
+ source: hosted
+ version: "9.4.5"
+ permission_handler_html:
+ dependency: transitive
+ description:
+ name: permission_handler_html
+ sha256: "38f000e83355abb3392140f6bc3030660cfaef189e1f87824facb76300b4ff24"
+ url: "https://pub.flutter-io.cn"
+ source: hosted
+ version: "0.1.3+5"
+ permission_handler_platform_interface:
+ dependency: transitive
+ description:
+ name: permission_handler_platform_interface
+ sha256: e9c8eadee926c4532d0305dff94b85bf961f16759c3af791486613152af4b4f9
+ url: "https://pub.flutter-io.cn"
+ source: hosted
+ version: "4.2.3"
+ permission_handler_windows:
+ dependency: transitive
+ description:
+ name: permission_handler_windows
+ sha256: "1a790728016f79a41216d88672dbc5df30e686e811ad4e698bfc51f76ad91f1e"
+ url: "https://pub.flutter-io.cn"
+ source: hosted
+ version: "0.2.1"
petitparser:
dependency: transitive
description:
diff --git a/pubspec.yaml b/pubspec.yaml
index 520db46..0b3bf22 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -75,6 +75,7 @@ dependencies:
process_runner: ^4.2.0
re_editor: ^0.6.0
re_highlight: ^0.0.3
+ permission_handler: ^11.3.1
dev_dependencies:
flutter_test:
diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc
index 6767d8d..316373d 100644
--- a/windows/flutter/generated_plugin_registrant.cc
+++ b/windows/flutter/generated_plugin_registrant.cc
@@ -7,6 +7,7 @@
#include "generated_plugin_registrant.h"
#include
+#include
#include
#include
#include
@@ -14,6 +15,8 @@
void RegisterPlugins(flutter::PluginRegistry* registry) {
EmojiPickerFlutterPluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("EmojiPickerFlutterPluginCApi"));
+ PermissionHandlerWindowsPluginRegisterWithRegistrar(
+ registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
ScreenRetrieverWindowsPluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("ScreenRetrieverWindowsPluginCApi"));
UrlLauncherWindowsRegisterWithRegistrar(
diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake
index b08b0f7..900a8df 100644
--- a/windows/flutter/generated_plugins.cmake
+++ b/windows/flutter/generated_plugins.cmake
@@ -4,6 +4,7 @@
list(APPEND FLUTTER_PLUGIN_LIST
emoji_picker_flutter
+ permission_handler_windows
screen_retriever_windows
url_launcher_windows
window_manager