diff --git a/ui/flutter/android/app/src/main/AndroidManifest.xml b/ui/flutter/android/app/src/main/AndroidManifest.xml index 721bb303..0485d35c 100644 --- a/ui/flutter/android/app/src/main/AndroidManifest.xml +++ b/ui/flutter/android/app/src/main/AndroidManifest.xml @@ -2,9 +2,15 @@ package="com.gopeed"> + + + + + { if (index == 0) { return false; } - // Check write permission + final downloadDir = (await DownloadsPath.downloadsDirectory())?.path; if (downloadDir == null) { return true; } + + // Check and request external storage permission when sdk version < 30 (android 11) + if ((await deviceInfo.androidInfo).version.sdkInt < 30) { + var status = await Permission.storage.status; + if (!status.isGranted) { + status = await Permission.storage.request(); + if (!status.isGranted) { + showErrorMessage('noStoragePermission'.tr); + return true; + } + } + } + + // Check write permission final fileRandomeName = "test_${DateTime.now().millisecondsSinceEpoch}.tmp"; final testFile = File('$downloadDir/Gopeed/$fileRandomeName'); diff --git a/ui/flutter/pubspec.lock b/ui/flutter/pubspec.lock index bcfc4ad0..bde04e09 100644 --- a/ui/flutter/pubspec.lock +++ b/ui/flutter/pubspec.lock @@ -241,6 +241,22 @@ packages: url: "https://pub.dev" source: hosted version: "0.4.4" + device_info_plus: + dependency: "direct main" + description: + name: device_info_plus + sha256: "77f757b789ff68e4eaf9c56d1752309bd9f7ad557cb105b938a7f8eb89e59110" + url: "https://pub.dev" + source: hosted + version: "9.1.2" + device_info_plus_platform_interface: + dependency: transitive + description: + name: device_info_plus_platform_interface + sha256: "282d3cf731045a2feb66abfe61bbc40870ae50a3ed10a4d3d217556c35c8c2ba" + url: "https://pub.dev" + source: hosted + version: "7.0.1" dio: dependency: "direct main" description: @@ -709,6 +725,54 @@ packages: url: "https://pub.dev" source: hosted version: "2.3.0" + permission_handler: + dependency: "direct main" + description: + name: permission_handler + sha256: "18bf33f7fefbd812f37e72091a15575e72d5318854877e0e4035a24ac1113ecb" + url: "https://pub.dev" + source: hosted + version: "11.3.1" + permission_handler_android: + dependency: transitive + description: + name: permission_handler_android + sha256: "76e4ab092c1b240d31177bb64d2b0bea43f43d0e23541ec866151b9f7b2490fa" + url: "https://pub.dev" + source: hosted + version: "12.0.12" + permission_handler_apple: + dependency: transitive + description: + name: permission_handler_apple + sha256: e6f6d73b12438ef13e648c4ae56bd106ec60d17e90a59c4545db6781229082a0 + url: "https://pub.dev" + source: hosted + version: "9.4.5" + permission_handler_html: + dependency: transitive + description: + name: permission_handler_html + sha256: "54bf176b90f6eddd4ece307e2c06cf977fb3973719c35a93b85cc7093eb6070d" + url: "https://pub.dev" + source: hosted + version: "0.1.1" + permission_handler_platform_interface: + dependency: transitive + description: + name: permission_handler_platform_interface + sha256: fe0ffe274d665be8e34f9c59705441a7d248edebbe5d9e3ec2665f88b79358ea + url: "https://pub.dev" + source: hosted + version: "4.2.2" + permission_handler_windows: + dependency: transitive + description: + name: permission_handler_windows + sha256: "1a790728016f79a41216d88672dbc5df30e686e811ad4e698bfc51f76ad91f1e" + url: "https://pub.dev" + source: hosted + version: "0.2.1" petitparser: dependency: transitive description: diff --git a/ui/flutter/pubspec.yaml b/ui/flutter/pubspec.yaml index b71132e4..3a538952 100644 --- a/ui/flutter/pubspec.yaml +++ b/ui/flutter/pubspec.yaml @@ -67,6 +67,8 @@ dependencies: launch_at_startup: ^0.2.2 args: ^2.5.0 toggle_switch: ^2.3.0 + permission_handler: ^11.3.1 + device_info_plus: ^9.1.2 dev_dependencies: flutter_test: sdk: flutter