From 160fda0f729d18b58b9e460bed2246ddec269595 Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Sat, 18 Nov 2023 20:53:29 -0500 Subject: [PATCH] Change image saver to write to galleries not files on mobile --- android/app/src/main/AndroidManifest.xml | 57 +++++++++++++----------- ios/Podfile.lock | 8 +++- lib/screens/media_viewer_screen.dart | 13 +++--- pubspec.lock | 8 ++++ pubspec.yaml | 1 + 5 files changed, 53 insertions(+), 34 deletions(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 0b8d3d9..99c545a 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,53 +1,56 @@ + package="social.myportal.relatica"> + android:name="${applicationName}" + android:icon="@mipmap/ic_launcher_round" + android:label="Relatica" + android:requestLegacyExternalStorage="true"> + android:name=".MainActivity" + android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" + android:exported="true" + android:hardwareAccelerated="true" + android:launchMode="singleTop" + android:theme="@style/LaunchTheme" + android:windowSoftInputMode="adjustResize"> + android:name="io.flutter.embedding.android.NormalTheme" + android:resource="@style/NormalTheme" /> - - + + + android:name="com.linusu.flutter_web_auth_2.CallbackActivity" + android:exported="true"> - - - - + + + + + + + android:name="flutterEmbedding" + android:value="2" /> - - + + - - + + diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 7384f9c..e4472cc 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -45,6 +45,8 @@ PODS: - FMDB (2.7.5): - FMDB/standard (= 2.7.5) - FMDB/standard (2.7.5) + - image_gallery_saver (2.0.2): + - Flutter - image_picker_ios (0.0.1): - Flutter - media_kit_libs_ios_video (1.0.4): @@ -90,6 +92,7 @@ DEPENDENCIES: - flutter_file_dialog (from `.symlinks/plugins/flutter_file_dialog/ios`) - flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`) - flutter_web_auth_2 (from `.symlinks/plugins/flutter_web_auth_2/ios`) + - image_gallery_saver (from `.symlinks/plugins/image_gallery_saver/ios`) - image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`) - media_kit_libs_ios_video (from `.symlinks/plugins/media_kit_libs_ios_video/ios`) - media_kit_native_event_loop (from `.symlinks/plugins/media_kit_native_event_loop/ios`) @@ -127,6 +130,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/flutter_secure_storage/ios" flutter_web_auth_2: :path: ".symlinks/plugins/flutter_web_auth_2/ios" + image_gallery_saver: + :path: ".symlinks/plugins/image_gallery_saver/ios" image_picker_ios: :path: ".symlinks/plugins/image_picker_ios/ios" media_kit_libs_ios_video: @@ -166,6 +171,7 @@ SPEC CHECKSUMS: flutter_secure_storage: 23fc622d89d073675f2eaa109381aefbcf5a49be flutter_web_auth_2: 051cf9f5dc366f31b5dcc4e2952c2b954767be8a FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a + image_gallery_saver: cb43cc43141711190510e92c460eb1655cd343cb image_picker_ios: 4a8aadfbb6dc30ad5141a2ce3832af9214a705b5 media_kit_libs_ios_video: a5fe24bc7875ccd6378a0978c13185e1344651c1 media_kit_native_event_loop: e6b2ab20cf0746eb1c33be961fcf79667304fa2a @@ -186,4 +192,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 1df1bb3ed89ef4be6115286519e24a9fad12e640 -COCOAPODS: 1.10.2 +COCOAPODS: 1.14.2 diff --git a/lib/screens/media_viewer_screen.dart b/lib/screens/media_viewer_screen.dart index af03d95..74c094a 100644 --- a/lib/screens/media_viewer_screen.dart +++ b/lib/screens/media_viewer_screen.dart @@ -2,7 +2,7 @@ import 'dart:io'; import 'package:file_picker/file_picker.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_file_dialog/flutter_file_dialog.dart'; +import 'package:image_gallery_saver/image_gallery_saver.dart'; import 'package:path/path.dart' as p; import 'package:path_provider/path_provider.dart'; @@ -74,11 +74,12 @@ class _MediaViewerScreenState extends State { } if (Platform.isAndroid || Platform.isIOS) { - final params = SaveFileDialogParams( - data: bytesResult.value, - fileName: filename, - ); - await FlutterFileDialog.saveFile(params: params); + final saveResult = await ImageGallerySaver.saveImage(bytesResult.value); + if (saveResult['isSuccess']) { + buildSnackbar(context, 'Image saved to gallery'); + } else { + buildSnackbar(context, 'Unable to save to gallery, check permissions'); + } } else { final location = await FilePicker.platform.saveFile( dialogTitle: 'Save Image', diff --git a/pubspec.lock b/pubspec.lock index 08f9923..a5d46cb 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -629,6 +629,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.1.3" + image_gallery_saver: + dependency: "direct main" + description: + name: image_gallery_saver + sha256: "0aba74216a4d9b0561510cb968015d56b701ba1bd94aace26aacdd8ae5761816" + url: "https://pub.dev" + source: hosted + version: "2.0.3" image_picker: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index f7839cc..155c0f7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -54,6 +54,7 @@ dependencies: uuid: ^4.1.0 video_player: ^2.4.10 flutter_svg: ^2.0.5 + image_gallery_saver: ^2.0.3 dev_dependencies: