Add animated image preview to attachment approval dialog.

// FREEBIE
pull/1/head
Matthew Chen 7 years ago
parent 5d79f43970
commit fc33b00830

@ -7,6 +7,7 @@
#import "Asserts.h"
#import "AttachmentSharing.h"
#import "Environment.h"
#import "FLAnimatedImage.h"
#import "NotificationsManager.h"
#import "OWSAnyTouchGestureRecognizer.h"
#import "OWSCallNotificationsAdaptee.h"

@ -63,7 +63,9 @@ class AttachmentApprovalViewController: UIViewController {
createButtonRow(attachmentPreviewView:attachmentPreviewView)
if attachment.isImage {
if attachment.isAnimatedImage {
createAnimatedPreview(attachmentPreviewView:attachmentPreviewView)
} else if attachment.isImage {
createImagePreview(attachmentPreviewView:attachmentPreviewView)
} else if attachment.isVideo {
createVideoPreview(attachmentPreviewView:attachmentPreviewView)
@ -72,6 +74,20 @@ class AttachmentApprovalViewController: UIViewController {
}
}
private func createAnimatedPreview(attachmentPreviewView: UIView) {
// Use Flipboard FLAnimatedImage library to display gifs
guard let animatedImage = FLAnimatedImage(gifData:attachment.data) else {
createGenericPreview(attachmentPreviewView:attachmentPreviewView)
return
}
let animatedImageView = FLAnimatedImageView()
animatedImageView.animatedImage = animatedImage
animatedImageView.contentMode = .scaleAspectFit
attachmentPreviewView.addSubview(animatedImageView)
animatedImageView.autoPinWidthToSuperview()
animatedImageView.autoPinHeightToSuperview()
}
private func createImagePreview(attachmentPreviewView: UIView) {
var image = attachment.image
if image == nil {

@ -110,12 +110,9 @@ typedef enum : NSUInteger {
}
- (BOOL)pasteBoardHasPossibleAttachment {
if ([SignalAttachment pasteboardHasPossibleAttachment]) {
// We don't want to load/convert images more than once so we
// only do a cursory validation pass at this time.
return YES;
}
return NO;
// We don't want to load/convert images more than once so we
// only do a cursory validation pass at this time.
return [SignalAttachment pasteboardHasPossibleAttachment];
}
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {

@ -262,6 +262,10 @@ class SignalAttachment: NSObject {
return SignalAttachment.outputImageUTISet.contains(dataUTI)
}
public var isAnimatedImage: Bool {
return SignalAttachment.animatedImageUTISet.contains(dataUTI)
}
public var isVideo: Bool {
return SignalAttachment.videoUTISet.contains(dataUTI)
}

Loading…
Cancel
Save