Skip to content
This repository was archived by the owner on Jun 19, 2025. It is now read-only.

Commit ceace39

Browse files
authored
Merge pull request #157 from wordpress-mobile/release/0.13
Release/0.13
2 parents dcdb4fc + 659a8c7 commit ceace39

File tree

5 files changed

+48
-15
lines changed

5 files changed

+48
-15
lines changed

Example/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PODS:
2-
- WPMediaPicker (0.12)
2+
- WPMediaPicker (0.13)
33

44
DEPENDENCIES:
55
- WPMediaPicker (from `../`)
@@ -9,7 +9,7 @@ EXTERNAL SOURCES:
99
:path: "../"
1010

1111
SPEC CHECKSUMS:
12-
WPMediaPicker: d4ce8e9db98b60ab44e7154151dbad135f8e7ff6
12+
WPMediaPicker: 5f39880ac799dbbf41a99f73567a95ab5297dc93
1313

1414
PODFILE CHECKSUM: 7855568785f801c5559f8e70856ad87de227dc95
1515

Pod/Classes/WPMediaCapturePreviewCollectionView.m

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ - (void)startCapture
100100
self.captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:self.session];
101101
self.captureVideoPreviewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
102102
self.captureVideoPreviewLayer.frame = viewLayer.bounds;
103-
self.captureVideoPreviewLayer.connection.videoOrientation = (AVCaptureVideoOrientation)[[UIDevice currentDevice] orientation];
103+
self.captureVideoPreviewLayer.connection.videoOrientation = [self videoOrientationForInterfaceOrientation:[[UIApplication sharedApplication] statusBarOrientation]];
104104
[viewLayer addSublayer:_captureVideoPreviewLayer];
105105
});
106106
}
@@ -110,7 +110,22 @@ - (void)startCapture
110110
- (void)deviceOrientationDidChange:(NSNotification *)notification
111111
{
112112
if (self.captureVideoPreviewLayer.connection.supportsVideoOrientation) {
113-
self.captureVideoPreviewLayer.connection.videoOrientation = (AVCaptureVideoOrientation)[[UIDevice currentDevice] orientation];
113+
self.captureVideoPreviewLayer.connection.videoOrientation = [self videoOrientationForInterfaceOrientation:[[UIApplication sharedApplication] statusBarOrientation]];
114+
}
115+
}
116+
117+
- (AVCaptureVideoOrientation)videoOrientationForInterfaceOrientation:(UIInterfaceOrientation)orientation
118+
{
119+
switch (orientation) {
120+
case UIInterfaceOrientationPortrait:
121+
return AVCaptureVideoOrientationPortrait;
122+
case UIInterfaceOrientationPortraitUpsideDown:
123+
return AVCaptureVideoOrientationPortraitUpsideDown;
124+
case UIInterfaceOrientationLandscapeLeft:
125+
return AVCaptureVideoOrientationLandscapeLeft;
126+
case UIInterfaceOrientationLandscapeRight:
127+
return AVCaptureVideoOrientationLandscapeRight;
128+
default:return AVCaptureVideoOrientationPortrait;
114129
}
115130
}
116131

Pod/Classes/WPMediaPickerViewController.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@
111111

112112
/**
113113
* Asks the delegate for a view controller to push when previewing the specified asset.
114-
* If this method isn't implemented or returns nil, the default view controller will be used.
114+
* If this method isn't implemented, the default view controller will be used.
115+
* If it returns nil, no preview will be displayed.
115116
*
116117
* @param picker The controller object managing the assets picker interface.
117118
* @param asset The asset to be previewed.
@@ -164,5 +165,10 @@
164165
*/
165166
- (void)setGroup:(nonnull id<WPMediaGroup>)group;
166167

168+
/**
169+
* Clears the current asset selection in the picker.
170+
*/
171+
- (void)clearSelectedAssets:(BOOL)animated;
172+
167173
@end
168174

Pod/Classes/WPMediaPickerViewController.m

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,24 @@ - (BOOL)isShowingCaptureCell
139139
return self.allowCaptureOfMedia && [self isMediaDeviceAvailable] && !self.refreshGroupFirstTime;
140140
}
141141

142+
- (void)setAllowMultipleSelection:(BOOL)allowMultipleSelection
143+
{
144+
_allowMultipleSelection = allowMultipleSelection;
145+
146+
if (self.isViewLoaded) {
147+
self.collectionView.allowsMultipleSelection = allowMultipleSelection;
148+
}
149+
}
150+
151+
- (void)clearSelectedAssets:(BOOL)animated
152+
{
153+
for (NSIndexPath *indexPath in [self.collectionView indexPathsForSelectedItems]) {
154+
[self.collectionView deselectItemAtIndexPath:indexPath animated:animated];
155+
}
156+
157+
[self.selectedAssets removeAllObjects];
158+
}
159+
142160
#pragma mark - UICollectionViewDataSource
143161

144162
-(void)updateDataWithRemoved:(NSIndexSet *)removed inserted:(NSIndexSet *)inserted changed:(NSIndexSet *)changed moved:(NSArray<id<WPMediaMove>> *)moves {
@@ -709,18 +727,12 @@ - (nullable UIViewController *)previewControllerForTouchLocation:(CGPoint)locati
709727

710728
- (UIViewController *)previewViewControllerForAsset:(id <WPMediaAsset>)asset
711729
{
712-
UIViewController *previewViewController = nil;
713-
714730
if ([self.mediaPickerDelegate respondsToSelector:@selector(mediaPickerController:previewViewControllerForAsset:)]) {
715-
previewViewController = [self.mediaPickerDelegate mediaPickerController:self
716-
previewViewControllerForAsset:asset];
717-
}
718-
719-
if (!previewViewController) {
720-
previewViewController = [self defaultPreviewViewControllerForAsset:asset];
731+
return [self.mediaPickerDelegate mediaPickerController:self
732+
previewViewControllerForAsset:asset];
721733
}
722734

723-
return previewViewController;
735+
return [self defaultPreviewViewControllerForAsset:asset];
724736
}
725737

726738
- (UIViewController *)defaultPreviewViewControllerForAsset:(id <WPMediaAsset>)asset

WPMediaPicker.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "WPMediaPicker"
3-
s.version = "0.12"
3+
s.version = "0.13"
44
s.summary = "WPMediaPicker is an iOS controller that allows capture and picking of media assets."
55
s.description = <<-DESC
66
WPMediaPicker is an iOS controller that allows capture and picking of media assets.

0 commit comments

Comments
 (0)