Agregados permisos de aplicación para carpetas

parent 38e38526
......@@ -4,4 +4,8 @@
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO"/>
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO"/>
</manifest>
......@@ -4,6 +4,7 @@ import 'package:file_picker/file_picker.dart';
import 'package:provider/provider.dart';
import 'package:prueba_multimedia/modelo/modelo.dart';
import 'package:prueba_multimedia/widgets/widgets.dart';
import 'package:permission_handler/permission_handler.dart';
class ConVertexFabBar extends StatefulWidget {
const ConVertexFabBar({super.key});
......@@ -148,6 +149,23 @@ class _ConVertexFabBarState extends State<ConVertexFabBar> {
ActionButton(
tipoBoton: ActionButtonTypes.carpeta,
onPressed: () async {
// Comprobación de permisos
final granted = await Permission.manageExternalStorage.isGranted;
if(!granted){
final permanently = await Permission.manageExternalStorage.isPermanentlyDenied;
if(permanently){
_mostrarNotificacion('El acceso al almacenamiento del dispositivo ha sido denegado permanentemente.\n¿Desea abrir la configuración para modificar el permiso?', true);
return;
}
else{
await _mostrarNotificacion('ConVertex no tiene permiso para acceder a sus archivos. Por favor, para usar esta función, active el permiso a continuación.', false);
if(await Permission.manageExternalStorage.request().isDenied){
_mostrarNotificacion('Se ha denegado el permiso de acceso al almacenamiento. Sin dicho permiso, ConVertex no puede acceder a los archivos dentro de sus carpetas.\nPor favor, ceda el permiso para usar esta función.', false);
return;
}
}
}
String? path = await FilePicker.platform.getDirectoryPath();
if (path != null) {
var directory = Directory(path);
......@@ -170,4 +188,28 @@ class _ConVertexFabBarState extends State<ConVertexFabBar> {
];
return buttons;
}
Future<void> _mostrarNotificacion(String text, bool opcion) async{
await showDialog(
context: context,
builder: (context) {
return AlertDialog(
content: Text(text),
actions: [
if(opcion) TextButton(
onPressed: () {
Navigator.of(context).pop();
openAppSettings();
},
child: const Text('SÍ'),
),
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: (opcion)? const Text('NO') : const Text('OK'),
)
]
);
}
);
}
}
......@@ -216,6 +216,54 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.9.0"
permission_handler:
dependency: "direct main"
description:
name: permission_handler
sha256: "2d070d8684b68efb580a5997eb62f675e8a885ef0be6e754fb9ef489c177470f"
url: "https://pub.dev"
source: hosted
version: "12.0.0+1"
permission_handler_android:
dependency: transitive
description:
name: permission_handler_android
sha256: "1e3bc410ca1bf84662104b100eb126e066cb55791b7451307f9708d4007350e6"
url: "https://pub.dev"
source: hosted
version: "13.0.1"
permission_handler_apple:
dependency: transitive
description:
name: permission_handler_apple
sha256: f000131e755c54cf4d84a5d8bd6e4149e262cc31c5a8b1d698de1ac85fa41023
url: "https://pub.dev"
source: hosted
version: "9.4.7"
permission_handler_html:
dependency: transitive
description:
name: permission_handler_html
sha256: "38f000e83355abb3392140f6bc3030660cfaef189e1f87824facb76300b4ff24"
url: "https://pub.dev"
source: hosted
version: "0.1.3+5"
permission_handler_platform_interface:
dependency: transitive
description:
name: permission_handler_platform_interface
sha256: eb99b295153abce5d683cac8c02e22faab63e50679b937fa1bf67d58bb282878
url: "https://pub.dev"
source: hosted
version: "4.3.0"
permission_handler_windows:
dependency: transitive
description:
name: permission_handler_windows
sha256: "1a790728016f79a41216d88672dbc5df30e686e811ad4e698bfc51f76ad91f1e"
url: "https://pub.dev"
source: hosted
version: "0.2.1"
plugin_platform_interface:
dependency: transitive
description:
......
......@@ -38,6 +38,7 @@ dependencies:
file_picker: ^9.0.2
uuid: ^4.5.1
ffmpeg_kit_flutter: ^6.0.3
permission_handler: ^12.0.0+1
dev_dependencies:
flutter_test:
......
......@@ -6,6 +6,9 @@
#include "generated_plugin_registrant.h"
#include <permission_handler_windows/permission_handler_windows_plugin.h>
void RegisterPlugins(flutter::PluginRegistry* registry) {
PermissionHandlerWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
}
......@@ -3,6 +3,7 @@
#
list(APPEND FLUTTER_PLUGIN_LIST
permission_handler_windows
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment