Skip attachment approval dialog for image and video shot by camera.
// FREEBIE
This commit is contained in:
parent
700bd6e08a
commit
6ae3a5395e
|
@ -2203,6 +2203,7 @@ typedef enum : NSUInteger {
|
|||
}
|
||||
|
||||
#pragma mark UIDocumentPickerDelegate
|
||||
|
||||
- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentAtURL:(NSURL *)url
|
||||
{
|
||||
DDLogDebug(@"%@ Picked document at url: %@", self.tag, url);
|
||||
|
@ -2382,10 +2383,13 @@ typedef enum : NSUInteger {
|
|||
if ([mediaType isEqualToString:(__bridge NSString *)kUTTypeMovie]) {
|
||||
// Video picked from library or captured with camera
|
||||
|
||||
BOOL isFromCamera = picker.sourceType == UIImagePickerControllerSourceTypeCamera;
|
||||
NSURL *videoURL = info[UIImagePickerControllerMediaURL];
|
||||
[self dismissViewControllerAnimated:YES
|
||||
completion:^{
|
||||
[self sendQualityAdjustedAttachmentForVideo:videoURL filename:filename];
|
||||
[self sendQualityAdjustedAttachmentForVideo:videoURL
|
||||
filename:filename
|
||||
skipApprovalDialog:isFromCamera];
|
||||
}];
|
||||
} else if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) {
|
||||
// Static Image captured from camera
|
||||
|
@ -2410,7 +2414,7 @@ typedef enum : NSUInteger {
|
|||
[self showErrorAlertForAttachment:attachment];
|
||||
failedToPickAttachment(nil);
|
||||
} else {
|
||||
[self tryToSendAttachmentIfApproved:attachment];
|
||||
[self tryToSendAttachmentIfApproved:attachment skipApprovalDialog:YES];
|
||||
}
|
||||
} else {
|
||||
failedToPickAttachment(nil);
|
||||
|
@ -2491,7 +2495,9 @@ typedef enum : NSUInteger {
|
|||
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];
|
||||
AVAssetExportSession *exportSession =
|
||||
|
@ -2517,7 +2523,7 @@ typedef enum : NSUInteger {
|
|||
attachment ? [attachment errorName] : @"Missing data");
|
||||
[self showErrorAlertForAttachment:attachment];
|
||||
} else {
|
||||
[self tryToSendAttachmentIfApproved:attachment];
|
||||
[self tryToSendAttachmentIfApproved:attachment skipApprovalDialog:skipApprovalDialog];
|
||||
}
|
||||
|
||||
NSError *error;
|
||||
|
@ -2987,6 +2993,12 @@ typedef enum : NSUInteger {
|
|||
}
|
||||
|
||||
- (void)tryToSendAttachmentIfApproved:(SignalAttachment *_Nullable)attachment
|
||||
{
|
||||
[self tryToSendAttachmentIfApproved:attachment skipApprovalDialog:NO];
|
||||
}
|
||||
|
||||
- (void)tryToSendAttachmentIfApproved:(SignalAttachment *_Nullable)attachment
|
||||
skipApprovalDialog:(BOOL)skipApprovalDialog
|
||||
{
|
||||
DDLogError(@"%@ %s", self.tag, __PRETTY_FUNCTION__);
|
||||
|
||||
|
@ -3007,6 +3019,8 @@ typedef enum : NSUInteger {
|
|||
__PRETTY_FUNCTION__,
|
||||
attachment ? [attachment errorName] : @"Missing data");
|
||||
[self showErrorAlertForAttachment:attachment];
|
||||
} else if (skipApprovalDialog) {
|
||||
[self sendMessageAttachment:attachment];
|
||||
} else {
|
||||
__weak MessagesViewController *weakSelf = self;
|
||||
UIViewController *viewController =
|
||||
|
|
Loading…
Reference in New Issue