Merge branch 'charlesmchen/cameraVsAttachmentApproval'

pull/1/head
Matthew Chen 8 years ago
commit a68d76168f

@ -2203,6 +2203,7 @@ typedef enum : NSUInteger {
} }
#pragma mark UIDocumentPickerDelegate #pragma mark UIDocumentPickerDelegate
- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentAtURL:(NSURL *)url - (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentAtURL:(NSURL *)url
{ {
DDLogDebug(@"%@ Picked document at url: %@", self.tag, url); DDLogDebug(@"%@ Picked document at url: %@", self.tag, url);
@ -2382,10 +2383,13 @@ typedef enum : NSUInteger {
if ([mediaType isEqualToString:(__bridge NSString *)kUTTypeMovie]) { if ([mediaType isEqualToString:(__bridge NSString *)kUTTypeMovie]) {
// Video picked from library or captured with camera // Video picked from library or captured with camera
BOOL isFromCamera = picker.sourceType == UIImagePickerControllerSourceTypeCamera;
NSURL *videoURL = info[UIImagePickerControllerMediaURL]; NSURL *videoURL = info[UIImagePickerControllerMediaURL];
[self dismissViewControllerAnimated:YES [self dismissViewControllerAnimated:YES
completion:^{ completion:^{
[self sendQualityAdjustedAttachmentForVideo:videoURL filename:filename]; [self sendQualityAdjustedAttachmentForVideo:videoURL
filename:filename
skipApprovalDialog:isFromCamera];
}]; }];
} else if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) { } else if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) {
// Static Image captured from camera // Static Image captured from camera
@ -2410,7 +2414,7 @@ typedef enum : NSUInteger {
[self showErrorAlertForAttachment:attachment]; [self showErrorAlertForAttachment:attachment];
failedToPickAttachment(nil); failedToPickAttachment(nil);
} else { } else {
[self tryToSendAttachmentIfApproved:attachment]; [self tryToSendAttachmentIfApproved:attachment skipApprovalDialog:YES];
} }
} else { } else {
failedToPickAttachment(nil); failedToPickAttachment(nil);
@ -2491,7 +2495,9 @@ typedef enum : NSUInteger {
return [NSURL fileURLWithPath:basePath]; return [NSURL fileURLWithPath:basePath];
} }
- (void)sendQualityAdjustedAttachmentForVideo:(NSURL *)movieURL filename:(NSString *)filename - (void)sendQualityAdjustedAttachmentForVideo:(NSURL *)movieURL
filename:(NSString *)filename
skipApprovalDialog:(BOOL)skipApprovalDialog
{ {
AVAsset *video = [AVAsset assetWithURL:movieURL]; AVAsset *video = [AVAsset assetWithURL:movieURL];
AVAssetExportSession *exportSession = AVAssetExportSession *exportSession =
@ -2517,7 +2523,7 @@ typedef enum : NSUInteger {
attachment ? [attachment errorName] : @"Missing data"); attachment ? [attachment errorName] : @"Missing data");
[self showErrorAlertForAttachment:attachment]; [self showErrorAlertForAttachment:attachment];
} else { } else {
[self tryToSendAttachmentIfApproved:attachment]; [self tryToSendAttachmentIfApproved:attachment skipApprovalDialog:skipApprovalDialog];
} }
NSError *error; NSError *error;
@ -2987,6 +2993,12 @@ typedef enum : NSUInteger {
} }
- (void)tryToSendAttachmentIfApproved:(SignalAttachment *_Nullable)attachment - (void)tryToSendAttachmentIfApproved:(SignalAttachment *_Nullable)attachment
{
[self tryToSendAttachmentIfApproved:attachment skipApprovalDialog:NO];
}
- (void)tryToSendAttachmentIfApproved:(SignalAttachment *_Nullable)attachment
skipApprovalDialog:(BOOL)skipApprovalDialog
{ {
DDLogError(@"%@ %s", self.tag, __PRETTY_FUNCTION__); DDLogError(@"%@ %s", self.tag, __PRETTY_FUNCTION__);
@ -3007,6 +3019,8 @@ typedef enum : NSUInteger {
__PRETTY_FUNCTION__, __PRETTY_FUNCTION__,
attachment ? [attachment errorName] : @"Missing data"); attachment ? [attachment errorName] : @"Missing data");
[self showErrorAlertForAttachment:attachment]; [self showErrorAlertForAttachment:attachment];
} else if (skipApprovalDialog) {
[self sendMessageAttachment:attachment];
} else { } else {
__weak MessagesViewController *weakSelf = self; __weak MessagesViewController *weakSelf = self;
UIViewController *viewController = UIViewController *viewController =

Loading…
Cancel
Save