From 65e55429e740535fa5574405d18b9aaf7befb368 Mon Sep 17 00:00:00 2001 From: James Frost Date: Thu, 9 Mar 2017 18:26:36 +0000 Subject: [PATCH 1/7] Don't show a preview if no custom preview VC is returned. --- Pod/Classes/WPMediaPickerViewController.m | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/Pod/Classes/WPMediaPickerViewController.m b/Pod/Classes/WPMediaPickerViewController.m index 03c63e1d..247b9674 100644 --- a/Pod/Classes/WPMediaPickerViewController.m +++ b/Pod/Classes/WPMediaPickerViewController.m @@ -709,18 +709,12 @@ - (nullable UIViewController *)previewControllerForTouchLocation:(CGPoint)locati - (UIViewController *)previewViewControllerForAsset:(id )asset { - UIViewController *previewViewController = nil; - if ([self.mediaPickerDelegate respondsToSelector:@selector(mediaPickerController:previewViewControllerForAsset:)]) { - previewViewController = [self.mediaPickerDelegate mediaPickerController:self - previewViewControllerForAsset:asset]; - } - - if (!previewViewController) { - previewViewController = [self defaultPreviewViewControllerForAsset:asset]; + return [self.mediaPickerDelegate mediaPickerController:self + previewViewControllerForAsset:asset]; } - return previewViewController; + return [self defaultPreviewViewControllerForAsset:asset]; } - (UIViewController *)defaultPreviewViewControllerForAsset:(id )asset From 413bdc33e3004b6ac84fbb44aaffe79311e0b663 Mon Sep 17 00:00:00 2001 From: James Frost Date: Thu, 9 Mar 2017 18:27:03 +0000 Subject: [PATCH 2/7] Pass changes to allowsMultipleSelection through to the collectionView. --- Pod/Classes/WPMediaPickerViewController.m | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Pod/Classes/WPMediaPickerViewController.m b/Pod/Classes/WPMediaPickerViewController.m index 247b9674..f59f9ab9 100644 --- a/Pod/Classes/WPMediaPickerViewController.m +++ b/Pod/Classes/WPMediaPickerViewController.m @@ -139,6 +139,15 @@ - (BOOL)isShowingCaptureCell return self.allowCaptureOfMedia && [self isMediaDeviceAvailable] && !self.refreshGroupFirstTime; } +- (void)setAllowMultipleSelection:(BOOL)allowMultipleSelection +{ + _allowMultipleSelection = allowMultipleSelection; + + if (self.isViewLoaded) { + self.collectionView.allowsMultipleSelection = allowMultipleSelection; + } +} + #pragma mark - UICollectionViewDataSource -(void)updateDataWithRemoved:(NSIndexSet *)removed inserted:(NSIndexSet *)inserted changed:(NSIndexSet *)changed moved:(NSArray> *)moves { From d28774f6f02a7c9a7c9b59804e0e0bfb1c675574 Mon Sep 17 00:00:00 2001 From: James Frost Date: Thu, 9 Mar 2017 18:27:37 +0000 Subject: [PATCH 3/7] Update doc comment for preview view controller change. --- Pod/Classes/WPMediaPickerViewController.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Pod/Classes/WPMediaPickerViewController.h b/Pod/Classes/WPMediaPickerViewController.h index 902e6e79..234cc19a 100644 --- a/Pod/Classes/WPMediaPickerViewController.h +++ b/Pod/Classes/WPMediaPickerViewController.h @@ -111,7 +111,8 @@ /** * Asks the delegate for a view controller to push when previewing the specified asset. - * If this method isn't implemented or returns nil, the default view controller will be used. + * If this method isn't implemented, the default view controller will be used. + * If it returns nil, no preview will be displayed. * * @param picker The controller object managing the assets picker interface. * @param asset The asset to be previewed. From ebce520e5418472ab85d7080b20946cb410ba9c5 Mon Sep 17 00:00:00 2001 From: James Frost Date: Thu, 9 Mar 2017 18:27:47 +0000 Subject: [PATCH 4/7] Adds method to clear current asset selection. --- Pod/Classes/WPMediaPickerViewController.h | 5 +++++ Pod/Classes/WPMediaPickerViewController.m | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/Pod/Classes/WPMediaPickerViewController.h b/Pod/Classes/WPMediaPickerViewController.h index 234cc19a..bd51732d 100644 --- a/Pod/Classes/WPMediaPickerViewController.h +++ b/Pod/Classes/WPMediaPickerViewController.h @@ -165,5 +165,10 @@ */ - (void)setGroup:(nonnull id)group; +/** + * Clears the current asset selection in the picker. + */ +- (void)clearSelectedAssets:(BOOL)animated; + @end diff --git a/Pod/Classes/WPMediaPickerViewController.m b/Pod/Classes/WPMediaPickerViewController.m index f59f9ab9..3d9512bc 100644 --- a/Pod/Classes/WPMediaPickerViewController.m +++ b/Pod/Classes/WPMediaPickerViewController.m @@ -148,6 +148,15 @@ - (void)setAllowMultipleSelection:(BOOL)allowMultipleSelection } } +- (void)clearSelectedAssets:(BOOL)animated +{ + for (NSIndexPath *indexPath in [self.collectionView indexPathsForSelectedItems]) { + [self.collectionView deselectItemAtIndexPath:indexPath animated:animated]; + } + + [self.selectedAssets removeAllObjects]; +} + #pragma mark - UICollectionViewDataSource -(void)updateDataWithRemoved:(NSIndexSet *)removed inserted:(NSIndexSet *)inserted changed:(NSIndexSet *)changed moved:(NSArray> *)moves { From a0f3f67367fd32fda6f8d1798a5315343a39133c Mon Sep 17 00:00:00 2001 From: James Frost Date: Tue, 14 Mar 2017 10:04:39 +0000 Subject: [PATCH 5/7] Fixes #135: Don't silently pass through face up/down device orientations --- Pod/Classes/WPMediaCapturePreviewCollectionView.m | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Pod/Classes/WPMediaCapturePreviewCollectionView.m b/Pod/Classes/WPMediaCapturePreviewCollectionView.m index 3e50d57f..68be1aca 100644 --- a/Pod/Classes/WPMediaCapturePreviewCollectionView.m +++ b/Pod/Classes/WPMediaCapturePreviewCollectionView.m @@ -100,7 +100,7 @@ - (void)startCapture self.captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:self.session]; self.captureVideoPreviewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill; self.captureVideoPreviewLayer.frame = viewLayer.bounds; - self.captureVideoPreviewLayer.connection.videoOrientation = (AVCaptureVideoOrientation)[[UIDevice currentDevice] orientation]; + self.captureVideoPreviewLayer.connection.videoOrientation = [self videoOrientationForDeviceOrientation:[[UIDevice currentDevice] orientation]]; [viewLayer addSublayer:_captureVideoPreviewLayer]; }); } @@ -110,10 +110,19 @@ - (void)startCapture - (void)deviceOrientationDidChange:(NSNotification *)notification { if (self.captureVideoPreviewLayer.connection.supportsVideoOrientation) { - self.captureVideoPreviewLayer.connection.videoOrientation = (AVCaptureVideoOrientation)[[UIDevice currentDevice] orientation]; + self.captureVideoPreviewLayer.connection.videoOrientation = [self videoOrientationForDeviceOrientation:[[UIDevice currentDevice] orientation]]; } } +- (AVCaptureVideoOrientation)videoOrientationForDeviceOrientation:(UIDeviceOrientation)orientation +{ + if (orientation == UIDeviceOrientationFaceUp || orientation == UIDeviceOrientationFaceDown) { + return AVCaptureVideoOrientationPortrait; + } + + return (AVCaptureVideoOrientation)orientation; +} + - (BOOL)isAccessibilityElement { return YES; From cb1974c0d03f41dea01cd57a97911fbb9111aceb Mon Sep 17 00:00:00 2001 From: James Frost Date: Tue, 14 Mar 2017 12:25:53 +0000 Subject: [PATCH 6/7] Updated orientation changes to use UIInterfaceOrientation. --- .../WPMediaCapturePreviewCollectionView.m | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Pod/Classes/WPMediaCapturePreviewCollectionView.m b/Pod/Classes/WPMediaCapturePreviewCollectionView.m index 68be1aca..1c234bf6 100644 --- a/Pod/Classes/WPMediaCapturePreviewCollectionView.m +++ b/Pod/Classes/WPMediaCapturePreviewCollectionView.m @@ -100,7 +100,7 @@ - (void)startCapture self.captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:self.session]; self.captureVideoPreviewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill; self.captureVideoPreviewLayer.frame = viewLayer.bounds; - self.captureVideoPreviewLayer.connection.videoOrientation = [self videoOrientationForDeviceOrientation:[[UIDevice currentDevice] orientation]]; + self.captureVideoPreviewLayer.connection.videoOrientation = [self videoOrientationForInterfaceOrientation:[[UIApplication sharedApplication] statusBarOrientation]]; [viewLayer addSublayer:_captureVideoPreviewLayer]; }); } @@ -110,17 +110,23 @@ - (void)startCapture - (void)deviceOrientationDidChange:(NSNotification *)notification { if (self.captureVideoPreviewLayer.connection.supportsVideoOrientation) { - self.captureVideoPreviewLayer.connection.videoOrientation = [self videoOrientationForDeviceOrientation:[[UIDevice currentDevice] orientation]]; + self.captureVideoPreviewLayer.connection.videoOrientation = [self videoOrientationForInterfaceOrientation:[[UIApplication sharedApplication] statusBarOrientation]]; } } -- (AVCaptureVideoOrientation)videoOrientationForDeviceOrientation:(UIDeviceOrientation)orientation +- (AVCaptureVideoOrientation)videoOrientationForInterfaceOrientation:(UIInterfaceOrientation)orientation { - if (orientation == UIDeviceOrientationFaceUp || orientation == UIDeviceOrientationFaceDown) { - return AVCaptureVideoOrientationPortrait; + switch (orientation) { + case UIInterfaceOrientationPortrait: + return AVCaptureVideoOrientationPortrait; + case UIInterfaceOrientationPortraitUpsideDown: + return AVCaptureVideoOrientationPortraitUpsideDown; + case UIInterfaceOrientationLandscapeLeft: + return AVCaptureVideoOrientationLandscapeLeft; + case UIInterfaceOrientationLandscapeRight: + return AVCaptureVideoOrientationLandscapeRight; + default:return AVCaptureVideoOrientationPortrait; } - - return (AVCaptureVideoOrientation)orientation; } - (BOOL)isAccessibilityElement From 659a8c714464bc8027f895b0ecebb22b8e8c8162 Mon Sep 17 00:00:00 2001 From: James Frost Date: Tue, 14 Mar 2017 16:19:43 +0000 Subject: [PATCH 7/7] Bumped to version 0.13 --- Example/Podfile.lock | 4 ++-- WPMediaPicker.podspec | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Example/Podfile.lock b/Example/Podfile.lock index f35bd512..985e2a03 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -1,5 +1,5 @@ PODS: - - WPMediaPicker (0.12) + - WPMediaPicker (0.13) DEPENDENCIES: - WPMediaPicker (from `../`) @@ -9,7 +9,7 @@ EXTERNAL SOURCES: :path: "../" SPEC CHECKSUMS: - WPMediaPicker: d4ce8e9db98b60ab44e7154151dbad135f8e7ff6 + WPMediaPicker: 5f39880ac799dbbf41a99f73567a95ab5297dc93 PODFILE CHECKSUM: 7855568785f801c5559f8e70856ad87de227dc95 diff --git a/WPMediaPicker.podspec b/WPMediaPicker.podspec index 24eb2d71..16a6188a 100644 --- a/WPMediaPicker.podspec +++ b/WPMediaPicker.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "WPMediaPicker" - s.version = "0.12" + s.version = "0.13" s.summary = "WPMediaPicker is an iOS controller that allows capture and picking of media assets." s.description = <<-DESC WPMediaPicker is an iOS controller that allows capture and picking of media assets.