From 7f2d7cd14e8fda748c5254dfab3ddd58c34d54c8 Mon Sep 17 00:00:00 2001 From: giomfo Date: Fri, 26 Feb 2016 10:10:32 +0100 Subject: [PATCH] Media Picker: fix layout issues - Enlarge the touch area of the 'Close' and 'Camera switch' button. - Crop album thumbnail to fit the display box. - Remove the thumbnail of 'Recently Deleted' album. - Fix simultaneous asset selection. Only the first selected asset is considered. - Fix multiple selfies capture. Only one selfie is captured at once. --- .../MediaPickerViewController.m | 31 +++++++++++- .../MediaPickerViewController.xib | 50 ++++++++++++------- .../Views/MediaAlbum/MediaAlbumTableCell.xib | 6 +-- 3 files changed, 65 insertions(+), 22 deletions(-) diff --git a/Vector/ViewController/MediaPickerViewController.m b/Vector/ViewController/MediaPickerViewController.m index 0f54a73e0..bb1fe4743 100644 --- a/Vector/ViewController/MediaPickerViewController.m +++ b/Vector/ViewController/MediaPickerViewController.m @@ -65,6 +65,8 @@ static void *RecordingContext = &RecordingContext; MPMoviePlayerController *videoPlayer; UIButton *videoPlayerControl; + + BOOL isValidationInProgress; } @property (nonatomic) UIBackgroundTaskIdentifier backgroundRecordingID; @@ -541,6 +543,13 @@ static void *RecordingContext = &RecordingContext; - (void)didSelectAsset:(PHAsset *)asset { + // Check whether a selection is already in progress + if (isValidationInProgress) + { + return; + } + + isValidationInProgress = YES; PHContentEditingInputRequestOptions *editOptions = [[PHContentEditingInputRequestOptions alloc] init]; [asset requestContentEditingInputWithOptions:editOptions @@ -563,9 +572,13 @@ static void *RecordingContext = &RecordingContext; [self.delegate mediaPickerController:self didSelectImage:image withURL:contentEditingInput.fullSizeImageURL]; } + isValidationInProgress = NO; + }]; }); + + return; } else if (contentEditingInput.mediaType == PHAssetMediaTypeVideo) { @@ -583,15 +596,21 @@ static void *RecordingContext = &RecordingContext; [self.delegate mediaPickerController:self didSelectVideo:[avURLAsset URL]]; } + isValidationInProgress = NO; + }]; }); + + return; } else { NSLog(@"[MediaPickerVC] Selected video asset is not initialized from an URL!"); } } + + isValidationInProgress = NO; }]; } @@ -904,6 +923,7 @@ static void *RecordingContext = &RecordingContext; dispatch_async(dispatch_get_main_queue(), ^{ [[cameraPreviewLayer connection] setVideoOrientation:(AVCaptureVideoOrientation)[[UIApplication sharedApplication] statusBarOrientation]]; + [cameraPreviewLayer connection].videoScaleAndCropFactor = 1.0; cameraPreviewLayer.frame = self.cameraPreviewContainerView.bounds; cameraPreviewLayer.hidden = YES; @@ -1136,6 +1156,8 @@ static void *RecordingContext = &RecordingContext; - (void)snapStillImage { + self.cameraCaptureButton.enabled = NO; + dispatch_async(cameraQueue, ^{ // Update the orientation on the still image output video connection before capturing. [[stillImageOutput connectionWithMediaType:AVMediaTypeVideo] setVideoOrientation:[[cameraPreviewLayer connection] videoOrientation]]; @@ -1421,8 +1443,8 @@ static void *RecordingContext = &RecordingContext; PHFetchResult *assets = [PHAsset fetchAssetsInAssetCollection:collection options:options]; cell.albumCountLabel.text = [NSString stringWithFormat:@"%tu", assets.count]; - // Report first asset thumbnail - if (assets.count) + // Report first asset thumbnail (except for 'Recently Deleted' album) + if (assets.count && collection.assetCollectionSubtype != 1000000201) { PHAsset *asset = assets[0]; @@ -1438,6 +1460,11 @@ static void *RecordingContext = &RecordingContext; }]; } + else + { + cell.albumThumbnail.image = nil; + cell.albumThumbnail.backgroundColor = [UIColor lightGrayColor]; + } } return cell; diff --git a/Vector/ViewController/MediaPickerViewController.xib b/Vector/ViewController/MediaPickerViewController.xib index 8b45af583..7806bd710 100644 --- a/Vector/ViewController/MediaPickerViewController.xib +++ b/Vector/ViewController/MediaPickerViewController.xib @@ -1,8 +1,8 @@ - + - + @@ -41,33 +41,45 @@ - + + + + + + + @@ -87,18 +99,22 @@ - + + + + + - - + + - + diff --git a/Vector/Views/MediaAlbum/MediaAlbumTableCell.xib b/Vector/Views/MediaAlbum/MediaAlbumTableCell.xib index ca542bdf7..1cf6ddeaa 100644 --- a/Vector/Views/MediaAlbum/MediaAlbumTableCell.xib +++ b/Vector/Views/MediaAlbum/MediaAlbumTableCell.xib @@ -1,8 +1,8 @@ - + - + @@ -14,7 +14,7 @@ - +