From 16348739373350c4081dfbadaf232a3bcb075b26 Mon Sep 17 00:00:00 2001 From: derTuca Date: Mon, 9 Sep 2019 15:37:28 +0300 Subject: [PATCH 01/16] Added maxDuration property to pickVideo method This way, we can limit the length of recorded video to a certain number of seconds. --- AUTHORS | 3 +- packages/image_picker/CHANGELOG.md | 4 ++ .../imagepicker/ImagePickerDelegate.java | 4 ++ packages/image_picker/example/lib/main.dart | 3 +- .../ios/Classes/ImagePickerPlugin.m | 5 ++ packages/image_picker/lib/image_picker.dart | 8 ++-- packages/image_picker/pubspec.yaml | 2 +- .../image_picker/test/image_picker_test.dart | 48 +++++++++++++++++++ 8 files changed, 71 insertions(+), 6 deletions(-) diff --git a/AUTHORS b/AUTHORS index ed6942ae1a6e..389ca912da3e 100644 --- a/AUTHORS +++ b/AUTHORS @@ -43,4 +43,5 @@ Audrius Karosevicius Lukasz Piliszczuk SoundReply Solutions GmbH Rafal Wachol -Pau Picas \ No newline at end of file +Pau Picas +Alexandru Tuca \ No newline at end of file diff --git a/packages/image_picker/CHANGELOG.md b/packages/image_picker/CHANGELOG.md index 78d44e594eb5..9baa362a3cc3 100644 --- a/packages/image_picker/CHANGELOG.md +++ b/packages/image_picker/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.6.2 + +* New feature : Set maximum duration for video recording. + ## 0.6.1+4 * Android: Fix a regression where the `retrieveLostImage` does not work anymore. diff --git a/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java b/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java index f9318e9c5760..3db71bff82f7 100644 --- a/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java +++ b/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java @@ -273,6 +273,10 @@ public void takeVideoWithCamera(MethodCall methodCall, MethodChannel.Result resu private void launchTakeVideoWithCameraIntent() { Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); + if (this.methodCall != null && this.methodCall.argument("maxDuration") != null) { + int maxSeconds = this.methodCall.argument("maxDuration"); + intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, maxSeconds); + } boolean canTakePhotos = intentResolver.resolveActivity(intent); if (!canTakePhotos) { diff --git a/packages/image_picker/example/lib/main.dart b/packages/image_picker/example/lib/main.dart index a2175c098f17..22448aeea04d 100755 --- a/packages/image_picker/example/lib/main.dart +++ b/packages/image_picker/example/lib/main.dart @@ -56,7 +56,8 @@ class _MyHomePageState extends State { await _controller.setVolume(0.0); } if (isVideo) { - final File file = await ImagePicker.pickVideo(source: source); + final File file = await ImagePicker.pickVideo( + source: source, maxDuration: Duration(seconds: 10)); await _playVideo(file); } else { try { diff --git a/packages/image_picker/ios/Classes/ImagePickerPlugin.m b/packages/image_picker/ios/Classes/ImagePickerPlugin.m index a23e13918148..fb123514e390 100644 --- a/packages/image_picker/ios/Classes/ImagePickerPlugin.m +++ b/packages/image_picker/ios/Classes/ImagePickerPlugin.m @@ -93,6 +93,11 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result _arguments = call.arguments; int imageSource = [[_arguments objectForKey:@"source"] intValue]; + if ([_arguments objectForKey:@"maxDuration"]) { + double max = [[_arguments objectForKey:@"maxDuration"] doubleValue]; + _imagePickerController.videoMaximumDuration = max; + } + switch (imageSource) { case SOURCE_CAMERA: diff --git a/packages/image_picker/lib/image_picker.dart b/packages/image_picker/lib/image_picker.dart index bbe5157f4274..720d40451de2 100755 --- a/packages/image_picker/lib/image_picker.dart +++ b/packages/image_picker/lib/image_picker.dart @@ -74,16 +74,18 @@ class ImagePicker { /// The [source] argument controls where the video comes from. This can /// be either [ImageSource.camera] or [ImageSource.gallery]. /// + /// The [maxDuration] argument specifies the maximum duration of the captured video. + /// /// In Android, the MainActivity can be destroyed for various fo reasons. If that happens, the result will be lost /// in this call. You can then call [retrieveLostData] when your app relaunches to retrieve the lost data. - static Future pickVideo({ - @required ImageSource source, - }) async { + static Future pickVideo( + {@required ImageSource source, Duration maxDuration}) async { assert(source != null); final String path = await _channel.invokeMethod( 'pickVideo', { 'source': source.index, + 'maxDuration': maxDuration?.inSeconds, }, ); return path == null ? null : File(path); diff --git a/packages/image_picker/pubspec.yaml b/packages/image_picker/pubspec.yaml index c5d1647bb410..bca5a9df2059 100755 --- a/packages/image_picker/pubspec.yaml +++ b/packages/image_picker/pubspec.yaml @@ -5,7 +5,7 @@ authors: - Flutter Team - Rhodes Davis Jr. homepage: https://github.com/flutter/plugins/tree/master/packages/image_picker -version: 0.6.1+4 +version: 0.6.2 flutter: plugin: diff --git a/packages/image_picker/test/image_picker_test.dart b/packages/image_picker/test/image_picker_test.dart index 1a40e11d76e1..713bbc913ed0 100644 --- a/packages/image_picker/test/image_picker_test.dart +++ b/packages/image_picker/test/image_picker_test.dart @@ -143,6 +143,54 @@ void main() { }); }); + group('#pickVideo', () { + test('passes the image source argument correctly', () async { + await ImagePicker.pickVideo(source: ImageSource.camera); + await ImagePicker.pickVideo(source: ImageSource.gallery); + + expect( + log, + [ + isMethodCall('pickVideo', + arguments: {'source': 0, 'maxDuration': null}), + isMethodCall('pickVideo', + arguments: {'source': 1, 'maxDuration': null}), + ], + ); + }); + + test('passes the duration argument correctly', () async { + await ImagePicker.pickVideo(source: ImageSource.camera); + await ImagePicker.pickVideo( + source: ImageSource.camera, maxDuration: Duration(seconds: 10)); + await ImagePicker.pickVideo( + source: ImageSource.camera, maxDuration: Duration(minutes: 1)); + await ImagePicker.pickVideo( + source: ImageSource.camera, maxDuration: Duration(hours: 1)); + expect( + log, + [ + isMethodCall('pickVideo', + arguments: {'source': 0, 'maxDuration': null}), + isMethodCall('pickVideo', + arguments: {'source': 0, 'maxDuration': 10}), + isMethodCall('pickVideo', + arguments: {'source': 0, 'maxDuration': 60}), + isMethodCall('pickVideo', + arguments: {'source': 0, 'maxDuration': 3600}), + ], + ); + }); + + test('handles a null video path response gracefully', () async { + channel.setMockMethodCallHandler((MethodCall methodCall) => null); + + expect( + await ImagePicker.pickVideo(source: ImageSource.gallery), isNull); + expect(await ImagePicker.pickVideo(source: ImageSource.camera), isNull); + }); + }); + group('#retrieveLostData', () { test('retrieveLostData get success response', () async { channel.setMockMethodCallHandler((MethodCall methodCall) async { From b3e452f8d1f307d95f64df18ca643398c3e74274 Mon Sep 17 00:00:00 2001 From: derTuca Date: Mon, 16 Sep 2019 12:29:08 +0200 Subject: [PATCH 02/16] Added additional comment on maxDuration purpose Replaced double with NSTimeInterval --- .../example/ios/Runner.xcodeproj/project.pbxproj | 5 +---- packages/image_picker/ios/Classes/ImagePickerPlugin.m | 2 +- packages/image_picker/lib/image_picker.dart | 3 ++- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/image_picker/example/ios/Runner.xcodeproj/project.pbxproj b/packages/image_picker/example/ios/Runner.xcodeproj/project.pbxproj index bb359ccfca5c..6a3daaf22d4e 100644 --- a/packages/image_picker/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/image_picker/example/ios/Runner.xcodeproj/project.pbxproj @@ -340,16 +340,13 @@ files = ( ); inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", - "${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; 9740EEB61CF901F6004384FC /* Run Script */ = { diff --git a/packages/image_picker/ios/Classes/ImagePickerPlugin.m b/packages/image_picker/ios/Classes/ImagePickerPlugin.m index fb123514e390..c7c3ed91881a 100644 --- a/packages/image_picker/ios/Classes/ImagePickerPlugin.m +++ b/packages/image_picker/ios/Classes/ImagePickerPlugin.m @@ -94,7 +94,7 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result int imageSource = [[_arguments objectForKey:@"source"] intValue]; if ([_arguments objectForKey:@"maxDuration"]) { - double max = [[_arguments objectForKey:@"maxDuration"] doubleValue]; + NSTimeInterval max = [[_arguments objectForKey:@"maxDuration"] doubleValue]; _imagePickerController.videoMaximumDuration = max; } diff --git a/packages/image_picker/lib/image_picker.dart b/packages/image_picker/lib/image_picker.dart index 720d40451de2..2681d91bc6ae 100755 --- a/packages/image_picker/lib/image_picker.dart +++ b/packages/image_picker/lib/image_picker.dart @@ -74,7 +74,8 @@ class ImagePicker { /// The [source] argument controls where the video comes from. This can /// be either [ImageSource.camera] or [ImageSource.gallery]. /// - /// The [maxDuration] argument specifies the maximum duration of the captured video. + /// The [maxDuration] argument specifies the maximum duration of the captured video. If no [maxDuration] is specified, + /// the maximum duration will be infinite. /// /// In Android, the MainActivity can be destroyed for various fo reasons. If that happens, the result will be lost /// in this call. You can then call [retrieveLostData] when your app relaunches to retrieve the lost data. From 953f22aa9b09f0ac5af5c7ae0bea72a7b0f35870 Mon Sep 17 00:00:00 2001 From: derTuca Date: Thu, 19 Sep 2019 13:16:33 +0300 Subject: [PATCH 03/16] Changed pick intent to open gallery instead of documents on Android --- .../io/flutter/plugins/imagepicker/ImagePickerDelegate.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java b/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java index 3db71bff82f7..f74fa5d0df31 100644 --- a/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java +++ b/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java @@ -249,7 +249,7 @@ public void chooseVideoFromGallery(MethodCall methodCall, MethodChannel.Result r } private void launchPickVideoFromGalleryIntent() { - Intent pickVideoIntent = new Intent(Intent.ACTION_GET_CONTENT); + Intent pickVideoIntent = new Intent(Intent.ACTION_PICK, MediaStore.Video.Media.EXTERNAL_CONTENT_URI); pickVideoIntent.setType("video/*"); activity.startActivityForResult(pickVideoIntent, REQUEST_CODE_CHOOSE_VIDEO_FROM_GALLERY); @@ -310,7 +310,7 @@ public void chooseImageFromGallery(MethodCall methodCall, MethodChannel.Result r } private void launchPickImageFromGalleryIntent() { - Intent pickImageIntent = new Intent(Intent.ACTION_GET_CONTENT); + Intent pickImageIntent = new Intent(Intent.ACTION_PICK, MediaStore.Video.Media.EXTERNAL_CONTENT_URI); pickImageIntent.setType("image/*"); activity.startActivityForResult(pickImageIntent, REQUEST_CODE_CHOOSE_IMAGE_FROM_GALLERY); From 46e550730114cf2bf78daa464c7fbc60a1ff1525 Mon Sep 17 00:00:00 2001 From: derTuca Date: Thu, 19 Sep 2019 13:20:32 +0300 Subject: [PATCH 04/16] Replaced copy-pasted video ref to image --- .../io/flutter/plugins/imagepicker/ImagePickerDelegate.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java b/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java index f74fa5d0df31..59ee6358ebed 100644 --- a/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java +++ b/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java @@ -310,7 +310,7 @@ public void chooseImageFromGallery(MethodCall methodCall, MethodChannel.Result r } private void launchPickImageFromGalleryIntent() { - Intent pickImageIntent = new Intent(Intent.ACTION_PICK, MediaStore.Video.Media.EXTERNAL_CONTENT_URI); + Intent pickImageIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); pickImageIntent.setType("image/*"); activity.startActivityForResult(pickImageIntent, REQUEST_CODE_CHOOSE_IMAGE_FROM_GALLERY); From 09bead971649450853474c7dae6bba18fd9ee0ff Mon Sep 17 00:00:00 2001 From: derTuca Date: Fri, 15 Nov 2019 08:21:45 +0100 Subject: [PATCH 05/16] Revert "Changed pick intent to open gallery instead of documents on Android" This reverts commit 953f22aa9b09f0ac5af5c7ae0bea72a7b0f35870. --- .../io/flutter/plugins/imagepicker/ImagePickerDelegate.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java b/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java index 59ee6358ebed..3db71bff82f7 100644 --- a/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java +++ b/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java @@ -249,7 +249,7 @@ public void chooseVideoFromGallery(MethodCall methodCall, MethodChannel.Result r } private void launchPickVideoFromGalleryIntent() { - Intent pickVideoIntent = new Intent(Intent.ACTION_PICK, MediaStore.Video.Media.EXTERNAL_CONTENT_URI); + Intent pickVideoIntent = new Intent(Intent.ACTION_GET_CONTENT); pickVideoIntent.setType("video/*"); activity.startActivityForResult(pickVideoIntent, REQUEST_CODE_CHOOSE_VIDEO_FROM_GALLERY); @@ -310,7 +310,7 @@ public void chooseImageFromGallery(MethodCall methodCall, MethodChannel.Result r } private void launchPickImageFromGalleryIntent() { - Intent pickImageIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); + Intent pickImageIntent = new Intent(Intent.ACTION_GET_CONTENT); pickImageIntent.setType("image/*"); activity.startActivityForResult(pickImageIntent, REQUEST_CODE_CHOOSE_IMAGE_FROM_GALLERY); From 6e6feeecb85d6b660a23e24708cd2af642a48783 Mon Sep 17 00:00:00 2001 From: derTuca Date: Fri, 15 Nov 2019 08:24:09 +0100 Subject: [PATCH 06/16] Revert project.pbxproj --- .../example/ios/Runner.xcodeproj/project.pbxproj | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/image_picker/example/ios/Runner.xcodeproj/project.pbxproj b/packages/image_picker/example/ios/Runner.xcodeproj/project.pbxproj index 6a3daaf22d4e..bb359ccfca5c 100644 --- a/packages/image_picker/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/image_picker/example/ios/Runner.xcodeproj/project.pbxproj @@ -340,13 +340,16 @@ files = ( ); inputPaths = ( + "${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", + "${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; 9740EEB61CF901F6004384FC /* Run Script */ = { From 9a449b7b11a255acfbf66847985e0a4856fad410 Mon Sep 17 00:00:00 2001 From: derTuca Date: Fri, 15 Nov 2019 08:32:17 +0100 Subject: [PATCH 07/16] Add iskindof check for argument --- packages/image_picker/ios/Classes/ImagePickerPlugin.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/image_picker/ios/Classes/ImagePickerPlugin.m b/packages/image_picker/ios/Classes/ImagePickerPlugin.m index c7c3ed91881a..3531701d59ba 100644 --- a/packages/image_picker/ios/Classes/ImagePickerPlugin.m +++ b/packages/image_picker/ios/Classes/ImagePickerPlugin.m @@ -93,7 +93,7 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result _arguments = call.arguments; int imageSource = [[_arguments objectForKey:@"source"] intValue]; - if ([_arguments objectForKey:@"maxDuration"]) { + if ([[_arguments objectForKey:@"maxDuration"] isKindOfClass:[NSNumber class]]) { NSTimeInterval max = [[_arguments objectForKey:@"maxDuration"] doubleValue]; _imagePickerController.videoMaximumDuration = max; } From 254ffd0d61eb96468b94202a74fefd5a05d2d3a2 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Wed, 20 Nov 2019 12:36:10 -0800 Subject: [PATCH 08/16] Update AUTHORS --- AUTHORS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index 389ca912da3e..adadd0ac20b1 100644 --- a/AUTHORS +++ b/AUTHORS @@ -44,4 +44,4 @@ Lukasz Piliszczuk SoundReply Solutions GmbH Rafal Wachol Pau Picas -Alexandru Tuca \ No newline at end of file +Alexandru Tuca From 2e03c762ef099be78d5c488a213e2d61c36f9295 Mon Sep 17 00:00:00 2001 From: derTuca Date: Tue, 26 Nov 2019 21:57:06 +0200 Subject: [PATCH 09/16] Added const initializers for Duation --- packages/image_picker/example/lib/main.dart | 2 +- packages/image_picker/test/image_picker_test.dart | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/image_picker/example/lib/main.dart b/packages/image_picker/example/lib/main.dart index 8402d097d5ed..8d554795fd50 100755 --- a/packages/image_picker/example/lib/main.dart +++ b/packages/image_picker/example/lib/main.dart @@ -59,7 +59,7 @@ class _MyHomePageState extends State { } if (isVideo) { final File file = await ImagePicker.pickVideo( - source: source, maxDuration: Duration(seconds: 10)); + source: source, maxDuration: const Duration(seconds: 10)); await _playVideo(file); } else { try { diff --git a/packages/image_picker/test/image_picker_test.dart b/packages/image_picker/test/image_picker_test.dart index 713bbc913ed0..5bd300b481b8 100644 --- a/packages/image_picker/test/image_picker_test.dart +++ b/packages/image_picker/test/image_picker_test.dart @@ -162,11 +162,11 @@ void main() { test('passes the duration argument correctly', () async { await ImagePicker.pickVideo(source: ImageSource.camera); await ImagePicker.pickVideo( - source: ImageSource.camera, maxDuration: Duration(seconds: 10)); + source: ImageSource.camera, maxDuration: const Duration(seconds: 10)); await ImagePicker.pickVideo( - source: ImageSource.camera, maxDuration: Duration(minutes: 1)); + source: ImageSource.camera, maxDuration: const Duration(minutes: 1)); await ImagePicker.pickVideo( - source: ImageSource.camera, maxDuration: Duration(hours: 1)); + source: ImageSource.camera, maxDuration: const Duration(hours: 1)); expect( log, [ From 5a88cee5e882e4fb1de0f008684a845f3658ef9a Mon Sep 17 00:00:00 2001 From: derTuca Date: Tue, 26 Nov 2019 22:00:37 +0200 Subject: [PATCH 10/16] Formatted code using tool --- packages/image_picker/test/image_picker_test.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/image_picker/test/image_picker_test.dart b/packages/image_picker/test/image_picker_test.dart index 5bd300b481b8..505ad3051e0a 100644 --- a/packages/image_picker/test/image_picker_test.dart +++ b/packages/image_picker/test/image_picker_test.dart @@ -162,9 +162,11 @@ void main() { test('passes the duration argument correctly', () async { await ImagePicker.pickVideo(source: ImageSource.camera); await ImagePicker.pickVideo( - source: ImageSource.camera, maxDuration: const Duration(seconds: 10)); + source: ImageSource.camera, + maxDuration: const Duration(seconds: 10)); await ImagePicker.pickVideo( - source: ImageSource.camera, maxDuration: const Duration(minutes: 1)); + source: ImageSource.camera, + maxDuration: const Duration(minutes: 1)); await ImagePicker.pickVideo( source: ImageSource.camera, maxDuration: const Duration(hours: 1)); expect( From 5c9e4778c3cdd04278e6de7a94db65e107b989e4 Mon Sep 17 00:00:00 2001 From: derTuca Date: Tue, 26 Nov 2019 22:12:03 +0200 Subject: [PATCH 11/16] Fixed iOS formatting --- packages/image_picker/ios/Classes/ImagePickerPlugin.m | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/image_picker/ios/Classes/ImagePickerPlugin.m b/packages/image_picker/ios/Classes/ImagePickerPlugin.m index 422d865e8615..dc2408e62ffc 100644 --- a/packages/image_picker/ios/Classes/ImagePickerPlugin.m +++ b/packages/image_picker/ios/Classes/ImagePickerPlugin.m @@ -94,10 +94,9 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result int imageSource = [[_arguments objectForKey:@"source"] intValue]; if ([[_arguments objectForKey:@"maxDuration"] isKindOfClass:[NSNumber class]]) { - NSTimeInterval max = [[_arguments objectForKey:@"maxDuration"] doubleValue]; - _imagePickerController.videoMaximumDuration = max; + NSTimeInterval max = [[_arguments objectForKey:@"maxDuration"] doubleValue]; + _imagePickerController.videoMaximumDuration = max; } - switch (imageSource) { case SOURCE_CAMERA: From c901384b7e3df534b9bf2436bc9b14ec8b49c1c8 Mon Sep 17 00:00:00 2001 From: derTuca Date: Fri, 6 Dec 2019 19:27:28 +0200 Subject: [PATCH 12/16] Reverted changelog accidental replace and added author to pubspec --- packages/image_picker/CHANGELOG.md | 200 ++++++++++++++--------------- packages/image_picker/pubspec.yaml | 1 + 2 files changed, 101 insertions(+), 100 deletions(-) diff --git a/packages/image_picker/CHANGELOG.md b/packages/image_picker/CHANGELOG.md index 7ed20be69943..ed435c923c19 100644 --- a/packages/image_picker/CHANGELOG.md +++ b/packages/image_picker/CHANGELOG.md @@ -1,233 +1,233 @@ ## 0.6.3 -- New feature : Set maximum duration for video recording. +* New feature : Set maximum duration for video recording. ## 0.6.2+1 -- Android: Fix a crash when a non-image file is picked. -- Android: Fix unwanted bitmap scaling. +* Android: Fix a crash when a non*image file is picked. +* Android: Fix unwanted bitmap scaling. ## 0.6.2 -- iOS: Fixes an issue where picking content from Gallery would result in a crash on iOS 13. +* iOS: Fixes an issue where picking content from Gallery would result in a crash on iOS 13. ## 0.6.1+11 -- Stability and Maintainability: update documentations, add unit tests. +* Stability and Maintainability: update documentations, add unit tests. ## 0.6.1+10 -- iOS: Fix image orientation problems when scaling images. +* iOS: Fix image orientation problems when scaling images. ## 0.6.1+9 -- Remove AndroidX warning. +* Remove AndroidX warning. ## 0.6.1+8 -- Fix iOS build and analyzer warnings. +* Fix iOS build and analyzer warnings. ## 0.6.1+7 -- Android: Fix ImagePickerPlugin#onCreate casting context which causes exception. +* Android: Fix ImagePickerPlugin#onCreate casting context which causes exception. ## 0.6.1+6 -- Define clang module for iOS +* Define clang module for iOS ## 0.6.1+5 -- Update and migrate iOS example project. +* Update and migrate iOS example project. ## 0.6.1+4 -- Android: Fix a regression where the `retrieveLostImage` does not work anymore. -- Set up Android unit test to test `ImagePickerCache` and added image quality caching tests. +* Android: Fix a regression where the `retrieveLostImage` does not work anymore. +* Set up Android unit test to test `ImagePickerCache` and added image quality caching tests. ## 0.6.1+3 -- Bugfix iOS: Fix orientation of the picked image after scaling. -- Remove unnecessary code that tried to normalize the orientation. -- Trivial XCTest code fix. +* Bugfix iOS: Fix orientation of the picked image after scaling. +* Remove unnecessary code that tried to normalize the orientation. +* Trivial XCTest code fix. ## 0.6.1+2 -- Replace dependency on `androidx.legacy:legacy-support-v4:1.0.0` with `androidx.core:core:1.0.2` +* Replace dependency on `androidx.legacy:legacy*support*v4:1.0.0` with `androidx.core:core:1.0.2` ## 0.6.1+1 -- Add dependency on `androidx.annotation:annotation:1.0.0`. +* Add dependency on `androidx.annotation:annotation:1.0.0`. ## 0.6.1 -- New feature : Get images with custom quality. While picking images, user can pass `imageQuality` +* New feature : Get images with custom quality. While picking images, user can pass `imageQuality` parameter to compress image. ## 0.6.0+20 -- Android: Migrated information cache methods to use instance methods. +* Android: Migrated information cache methods to use instance methods. ## 0.6.0+19 -- Android: Fix memory leak due not unregistering ActivityLifecycleCallbacks. +* Android: Fix memory leak due not unregistering ActivityLifecycleCallbacks. ## 0.6.0+18 -- Fix video play in example and update video_player plugin dependency. +* Fix video play in example and update video_player plugin dependency. ## 0.6.0+17 -- iOS: Fix a crash when user captures image from the camera with devices under iOS 11. +* iOS: Fix a crash when user captures image from the camera with devices under iOS 11. ## 0.6.0+16 -- iOS Simulator: fix hang after trying to take an image from the non-existent camera. +* iOS Simulator: fix hang after trying to take an image from the non-existent camera. ## 0.6.0+15 -- Android: throws an exception when permissions denied instead of ignoring. +* Android: throws an exception when permissions denied instead of ignoring. ## 0.6.0+14 -- Fix typo in README. +* Fix typo in README. ## 0.6.0+13 -- Bugfix Android: Fix a crash occurs in some scenarios when user picks up image from gallery. +* Bugfix Android: Fix a crash occurs in some scenarios when user picks up image from gallery. ## 0.6.0+12 -- Use class instead of struct for `GIFInfo` in iOS implementation. +* Use class instead of struct for `GIFInfo` in iOS implementation. ## 0.6.0+11 -- Don't use module imports. +* Don't use module imports. ## 0.6.0+10 -- iOS: support picking GIF from gallery. +* iOS: support picking GIF from gallery. ## 0.6.0+9 -- Add missing template type parameter to `invokeMethod` calls. -- Bump minimum Flutter version to 1.5.0. -- Replace invokeMethod with invokeMapMethod wherever necessary. +* Add missing template type parameter to `invokeMethod` calls. +* Bump minimum Flutter version to 1.5.0. +* Replace invokeMethod with invokeMapMethod wherever necessary. ## 0.6.0+8 -- Bugfix: Add missed return statement into the image_picker example. +* Bugfix: Add missed return statement into the image_picker example. ## 0.6.0+7 -- iOS: Rename objects to follow Objective-C naming convention to avoid conflicts with other iOS library/frameworks. +* iOS: Rename objects to follow Objective*C naming convention to avoid conflicts with other iOS library/frameworks. ## 0.6.0+6 -- iOS: Picked image now has all the correct meta data from the original image, includes GPS, orientation and etc. +* iOS: Picked image now has all the correct meta data from the original image, includes GPS, orientation and etc. ## 0.6.0+5 -- iOS: Add missing import. +* iOS: Add missing import. ## 0.6.0+4 -- iOS: Using first byte to determine original image type. -- iOS: Added XCTest target. -- iOS: The picked image now has the correct EXIF data copied from the original image. +* iOS: Using first byte to determine original image type. +* iOS: Added XCTest target. +* iOS: The picked image now has the correct EXIF data copied from the original image. ## 0.6.0+3 -- Android: fixed assertion failures due to reply messages that were sent on the wrong thread. +* Android: fixed assertion failures due to reply messages that were sent on the wrong thread. ## 0.6.0+2 -- Android: images are saved with their real extension instead of always using `.jpg`. +* Android: images are saved with their real extension instead of always using `.jpg`. ## 0.6.0+1 -- Android: Using correct suffix syntax when picking image from remote url. +* Android: Using correct suffix syntax when picking image from remote url. ## 0.6.0 -- Breaking change iOS: Returned `File` objects when picking videos now always holds the correct path. Before this change, the path returned could have `file://` prepended to it. +* Breaking change iOS: Returned `File` objects when picking videos now always holds the correct path. Before this change, the path returned could have `file://` prepended to it. ## 0.5.4+3 -- Fix the example app failing to load picked video. +* Fix the example app failing to load picked video. ## 0.5.4+2 -- Request Camera permission if it present in Manifest on Android >= M. +* Request Camera permission if it present in Manifest on Android >= M. ## 0.5.4+1 -- Bugfix iOS: Cancel button not visible in gallery, if camera was accessed first. +* Bugfix iOS: Cancel button not visible in gallery, if camera was accessed first. ## 0.5.4 -- Add `retrieveLostData` to retrieve lost data after MainActivity is killed. +* Add `retrieveLostData` to retrieve lost data after MainActivity is killed. ## 0.5.3+2 -- Android: fix a crash when the MainActivity is destroyed after selecting the image/video. +* Android: fix a crash when the MainActivity is destroyed after selecting the image/video. ## 0.5.3+1 -- Update minimum deploy iOS version to 8.0. +* Update minimum deploy iOS version to 8.0. ## 0.5.3 -- Fixed incorrect path being returned from Google Photos on Android. +* Fixed incorrect path being returned from Google Photos on Android. ## 0.5.2 -- Check iOS camera authorizationStatus and return an error, if the access was +* Check iOS camera authorizationStatus and return an error, if the access was denied. ## 0.5.1 -- Android: Do not delete original image after scaling if the image is from gallery. +* Android: Do not delete original image after scaling if the image is from gallery. ## 0.5.0+9 -- Remove unnecessary temp video file path. +* Remove unnecessary temp video file path. ## 0.5.0+8 -- Fixed wrong GooglePhotos authority of image Uri. +* Fixed wrong GooglePhotos authority of image Uri. ## 0.5.0+7 -- Fix a crash when selecting images from yandex.disk and dropbox. +* Fix a crash when selecting images from yandex.disk and dropbox. ## 0.5.0+6 -- Delete the original image if it was scaled. +* Delete the original image if it was scaled. ## 0.5.0+5 -- Remove unnecessary camera permission. +* Remove unnecessary camera permission. ## 0.5.0+4 -- Preserve transparency when saving images. +* Preserve transparency when saving images. ## 0.5.0+3 -- Fixed an Android crash when Image Picker is registered without an activity. +* Fixed an Android crash when Image Picker is registered without an activity. ## 0.5.0+2 -- Log a more detailed warning at build time about the previous AndroidX +* Log a more detailed warning at build time about the previous AndroidX migration. ## 0.5.0+1 -- Fix a crash when user calls the plugin in quick succession on Android. +* Fix a crash when user calls the plugin in quick succession on Android. ## 0.5.0 -- **Breaking change**. Migrate from the deprecated original Android Support +* **Breaking change**. Migrate from the deprecated original Android Support Library to AndroidX. This shouldn't result in any functional changes, but it requires any Android apps using this plugin to [also migrate](https://developer.android.com/jetpack/androidx/migrate) if they're @@ -235,114 +235,114 @@ ## 0.4.12+1 -- Fix a crash when selecting downloaded images from image picker on certain devices. +* Fix a crash when selecting downloaded images from image picker on certain devices. ## 0.4.12 -- Fix a crash when user tap the image mutiple times. +* Fix a crash when user tap the image mutiple times. ## 0.4.11 -- Use `api` to define `support-v4` dependency to allow automatic version resolution. +* Use `api` to define `support-v4` dependency to allow automatic version resolution. ## 0.4.10 -- Depend on full `support-v4` library for ease of use (fixes conflicts with Firebase and libraries) +* Depend on full `support-v4` library for ease of use (fixes conflicts with Firebase and libraries) ## 0.4.9 -- Bugfix: on iOS prevent to appear one pixel white line on resized image. +* Bugfix: on iOS prevent to appear one pixel white line on resized image. ## 0.4.8 -- Replace the full `com.android.support:appcompat-v7` dependency with `com.android.support:support-core-utils`, which results in smaller APK sizes. -- Upgrade support library to 27.1.1 +* Replace the full `com.android.support:appcompat-v7` dependency with `com.android.support:support-core-utils`, which results in smaller APK sizes. +* Upgrade support library to 27.1.1 ## 0.4.7 -- Added missing video_player package dev dependency. +* Added missing video_player package dev dependency. ## 0.4.6 -- Added support for picking remote images. +* Added support for picking remote images. ## 0.4.5 -- Bugfixes, code cleanup, more test coverage. +* Bugfixes, code cleanup, more test coverage. ## 0.4.4 -- Updated Gradle tooling to match Android Studio 3.1.2. +* Updated Gradle tooling to match Android Studio 3.1.2. ## 0.4.3 -- Bugfix: on iOS the `pickVideo` method will now return null when the user cancels picking a video. +* Bugfix: on iOS the `pickVideo` method will now return null when the user cancels picking a video. ## 0.4.2 -- Added support for picking videos. -- Updated example app to show video preview. +* Added support for picking videos. +* Updated example app to show video preview. ## 0.4.1 -- Bugfix: the `pickImage` method will now return null when the user cancels picking the image, instead of hanging indefinitely. -- Removed the third party library dependency for taking pictures with the camera. +* Bugfix: the `pickImage` method will now return null when the user cancels picking the image, instead of hanging indefinitely. +* Removed the third party library dependency for taking pictures with the camera. ## 0.4.0 -- **Breaking change**. The `source` parameter for the `pickImage` is now required. Also, the `ImageSource.any` option doesn't exist anymore. -- Use the native Android image gallery for picking images instead of a custom UI. +* **Breaking change**. The `source` parameter for the `pickImage` is now required. Also, the `ImageSource.any` option doesn't exist anymore. +* Use the native Android image gallery for picking images instead of a custom UI. ## 0.3.1 -- Bugfix: Android version correctly asks for runtime camera permission when using `ImageSource.camera`. +* Bugfix: Android version correctly asks for runtime camera permission when using `ImageSource.camera`. ## 0.3.0 -- **Breaking change**. Set SDK constraints to match the Flutter beta release. +* **Breaking change**. Set SDK constraints to match the Flutter beta release. ## 0.2.1 -- Simplified and upgraded Android project template to Android SDK 27. -- Updated package description. +* Simplified and upgraded Android project template to Android SDK 27. +* Updated package description. ## 0.2.0 -- **Breaking change**. Upgraded to Gradle 4.1 and Android Studio Gradle plugin +* **Breaking change**. Upgraded to Gradle 4.1 and Android Studio Gradle plugin 3.0.1. Older Flutter projects need to upgrade their Gradle setup as well in order to use this version of the plugin. Instructions can be found [here](https://github.com/flutter/flutter/wiki/Updating-Flutter-projects-to-Gradle-4.1-and-Android-Studio-Gradle-plugin-3.0.1). ## 0.1.5 -- Added FLT prefix to iOS types +* Added FLT prefix to iOS types ## 0.1.4 -- Bugfix: canceling image picking threw exception. -- Bugfix: errors in plugin state management. +* Bugfix: canceling image picking threw exception. +* Bugfix: errors in plugin state management. ## 0.1.3 -- Added optional source argument to pickImage for controlling where the image comes from. +* Added optional source argument to pickImage for controlling where the image comes from. ## 0.1.2 -- Added optional maxWidth and maxHeight arguments to pickImage. +* Added optional maxWidth and maxHeight arguments to pickImage. ## 0.1.1 -- Updated Gradle repositories declaration to avoid the need for manual configuration +* Updated Gradle repositories declaration to avoid the need for manual configuration in the consuming app. ## 0.1.0+1 -- Updated readme and description in pubspec.yaml +* Updated readme and description in pubspec.yaml ## 0.1.0 -- Updated dependencies -- **Breaking Change**: You need to add a maven section with the "https://maven.google.com" endpoint to the repository section of your `android/build.gradle`. For example: +* Updated dependencies +* **Breaking Change**: You need to add a maven section with the "https://maven.google.com" endpoint to the repository section of your `android/build.gradle`. For example: ```gradle allprojects { @@ -357,20 +357,20 @@ allprojects { ## 0.0.3 -- Fix for crash on iPad when showing the Camera/Gallery selection dialog +* Fix for crash on iPad when showing the Camera/Gallery selection dialog ## 0.0.2+2 -- Updated README +* Updated README ## 0.0.2+1 -- Updated README +* Updated README ## 0.0.2 -- Fix crash when trying to access camera on a device without camera (e.g. the Simulator) +* Fix crash when trying to access camera on a device without camera (e.g. the Simulator) ## 0.0.1 -- Initial Release +* Initial Release diff --git a/packages/image_picker/pubspec.yaml b/packages/image_picker/pubspec.yaml index c49cc174a9b5..370ac4567a2f 100755 --- a/packages/image_picker/pubspec.yaml +++ b/packages/image_picker/pubspec.yaml @@ -4,6 +4,7 @@ description: Flutter plugin for selecting images from the Android and iOS image authors: - Flutter Team - Rhodes Davis Jr. + - Alexandru Tuca homepage: https://github.com/flutter/plugins/tree/master/packages/image_picker version: 0.6.3 From 50a1170936290bc8eab2c72b1f0446ee4ac85085 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Tue, 17 Dec 2019 09:56:22 -0800 Subject: [PATCH 13/16] Update CHANGELOG.md --- packages/image_picker/CHANGELOG.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/image_picker/CHANGELOG.md b/packages/image_picker/CHANGELOG.md index ed435c923c19..5970185ab862 100644 --- a/packages/image_picker/CHANGELOG.md +++ b/packages/image_picker/CHANGELOG.md @@ -4,7 +4,7 @@ ## 0.6.2+1 -* Android: Fix a crash when a non*image file is picked. +* Android: Fix a crash when a non-image file is picked. * Android: Fix unwanted bitmap scaling. ## 0.6.2 @@ -52,7 +52,7 @@ ## 0.6.1+2 -* Replace dependency on `androidx.legacy:legacy*support*v4:1.0.0` with `androidx.core:core:1.0.2` +* Replace dependency on `androidx.legacy:legacy-support-v4:1.0.0` with `androidx.core:core:1.0.2` ## 0.6.1+1 @@ -119,7 +119,7 @@ ## 0.6.0+7 -* iOS: Rename objects to follow Objective*C naming convention to avoid conflicts with other iOS library/frameworks. +* iOS: Rename objects to follow Objective-C naming convention to avoid conflicts with other iOS library/frameworks. ## 0.6.0+6 @@ -343,7 +343,6 @@ * Updated dependencies * **Breaking Change**: You need to add a maven section with the "https://maven.google.com" endpoint to the repository section of your `android/build.gradle`. For example: - ```gradle allprojects { repositories { From c83d9ee548a83ba520ec15484eb9c6b244db023d Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Tue, 17 Dec 2019 09:57:17 -0800 Subject: [PATCH 14/16] Update CHANGELOG.md --- packages/image_picker/CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/image_picker/CHANGELOG.md b/packages/image_picker/CHANGELOG.md index 5970185ab862..15149a3ff04c 100644 --- a/packages/image_picker/CHANGELOG.md +++ b/packages/image_picker/CHANGELOG.md @@ -60,8 +60,7 @@ ## 0.6.1 -* New feature : Get images with custom quality. While picking images, user can pass `imageQuality` - parameter to compress image. +* New feature : Get images with custom quality. While picking images, user can pass `imageQuality` parameter to compress image. ## 0.6.0+20 From 1c8c81656d23060711412c4231667ac21b6c40a1 Mon Sep 17 00:00:00 2001 From: derTuca Date: Sun, 2 Feb 2020 22:21:52 +0200 Subject: [PATCH 15/16] Added JUnit test for max duration --- .../imagepicker/ImagePickerDelegateTest.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/image_picker/example/android/app/src/test/java/io/flutter/plugins/imagepicker/ImagePickerDelegateTest.java b/packages/image_picker/example/android/app/src/test/java/io/flutter/plugins/imagepicker/ImagePickerDelegateTest.java index 88fa3372766f..aa9b00521f53 100644 --- a/packages/image_picker/example/android/app/src/test/java/io/flutter/plugins/imagepicker/ImagePickerDelegateTest.java +++ b/packages/image_picker/example/android/app/src/test/java/io/flutter/plugins/imagepicker/ImagePickerDelegateTest.java @@ -26,6 +26,7 @@ public class ImagePickerDelegateTest { private static final Double WIDTH = 10.0; private static final Double HEIGHT = 10.0; + private static final Double MAX_DURATION = 10.0; private static final Integer IMAGE_QUALITY = 90; @Mock Activity mockActivity; @@ -373,6 +374,19 @@ public void onActivityResult_WhenImageTakenWithCamera_AndNoResizeNeeded_Finishes verifyNoMoreInteractions(mockResult); } + @Test + public void + onActivityResult_WhenVideoTakenWithCamera_AndMaxDurationParametersSupplied_FinishesWithFilePath() { + when(mockMethodCall.argument("maxDuration")).thenReturn(MAX_DURATION); + + ImagePickerDelegate delegate = createDelegateWithPendingResultAndMethodCall(); + delegate.onActivityResult( + ImagePickerDelegate.REQUEST_CODE_TAKE_VIDEO_WITH_CAMERA, Activity.RESULT_OK, mockIntent); + + verify(mockResult).success("pathFromUri"); + verifyNoMoreInteractions(mockResult); + } + private ImagePickerDelegate createDelegate() { return new ImagePickerDelegate( mockActivity, From 8822565531354d570ba96e40f657248cf12fd0cb Mon Sep 17 00:00:00 2001 From: derTuca Date: Tue, 18 Feb 2020 15:51:04 +0200 Subject: [PATCH 16/16] Updated changelog and pubspec version --- packages/image_picker/CHANGELOG.md | 7 ++++--- packages/image_picker/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/image_picker/CHANGELOG.md b/packages/image_picker/CHANGELOG.md index dc96db2e4034..394c0e9e94dc 100644 --- a/packages/image_picker/CHANGELOG.md +++ b/packages/image_picker/CHANGELOG.md @@ -1,6 +1,6 @@ -## 0.6.3+3 +## 0.6.4 -* New feature : Set maximum duration for video recording. +* Set maximum duration for video recording. ## 0.6.3+2 @@ -84,7 +84,8 @@ ## 0.6.1 -* New feature : Get images with custom quality. While picking images, user can pass `imageQuality` parameter to compress image. +* New feature : Get images with custom quality. While picking images, user can pass `imageQuality` +parameter to compress image. ## 0.6.0+20 diff --git a/packages/image_picker/pubspec.yaml b/packages/image_picker/pubspec.yaml index 02b3de19acd3..0d99970d4fbe 100755 --- a/packages/image_picker/pubspec.yaml +++ b/packages/image_picker/pubspec.yaml @@ -2,7 +2,7 @@ name: image_picker description: Flutter plugin for selecting images from the Android and iOS image library, and taking new pictures with the camera. homepage: https://github.com/flutter/plugins/tree/master/packages/image_picker -version: 0.6.3+3 +version: 0.6.4 flutter: plugin: