mirror of https://github.com/oxen-io/session-ios
Attachments handling
- Sends image rotated - If message is delete, delete the attachment db object and file - Delete attachment from detail viewpull/1/head
parent
f2217cacd7
commit
402df72306
@ -0,0 +1,15 @@
|
||||
//
|
||||
// UIImage+normalizeImage.h
|
||||
// Signal
|
||||
//
|
||||
// Created by Frederic Jacobs on 26/12/14.
|
||||
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface UIImage (normalizeImage)
|
||||
|
||||
- (UIImage *)normalizedImage;
|
||||
|
||||
@end
|
@ -0,0 +1,23 @@
|
||||
//
|
||||
// UIImage+normalizeImage.m
|
||||
// Signal
|
||||
//
|
||||
// Created by Frederic Jacobs on 26/12/14.
|
||||
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "UIImage+normalizeImage.h"
|
||||
|
||||
@implementation UIImage (normalizeImage)
|
||||
|
||||
- (UIImage *)normalizedImage {
|
||||
if (self.imageOrientation == UIImageOrientationUp) return self;
|
||||
|
||||
UIGraphicsBeginImageContextWithOptions(self.size, NO, self.scale);
|
||||
[self drawInRect:(CGRect){0, 0, self.size}];
|
||||
UIImage *normalizedImage = UIGraphicsGetImageFromCurrentImageContext();
|
||||
UIGraphicsEndImageContext();
|
||||
return normalizedImage;
|
||||
}
|
||||
|
||||
@end
|
@ -0,0 +1,13 @@
|
||||
//
|
||||
// JSQMessagesCollectionViewCell+menuBarItems.h
|
||||
// Signal
|
||||
//
|
||||
// Created by Frederic Jacobs on 26/12/14.
|
||||
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "JSQMessagesCollectionViewCell.h"
|
||||
|
||||
@interface JSQMessagesCollectionViewCell (menuBarItems)
|
||||
|
||||
@end
|
@ -0,0 +1,49 @@
|
||||
//
|
||||
// JSQMessagesCollectionViewCell+menuBarItems.m
|
||||
// Signal
|
||||
//
|
||||
// Created by Frederic Jacobs on 26/12/14.
|
||||
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "JSQMessagesCollectionViewCell+menuBarItems.h"
|
||||
|
||||
@implementation JSQMessagesCollectionViewCell (menuBarItems)
|
||||
|
||||
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
|
||||
{
|
||||
if (action == @selector(delete:)) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
return [super canPerformAction:action withSender:sender];
|
||||
}
|
||||
|
||||
- (void)delete:(id)sender
|
||||
{
|
||||
[self performSelectorOnParentCollectionView:@selector(delete:)
|
||||
withSender:sender];
|
||||
}
|
||||
|
||||
- (void)performSelectorOnParentCollectionView:(SEL)selector
|
||||
withSender:(id)sender {
|
||||
UIView *view = self;
|
||||
do {
|
||||
view = view.superview;
|
||||
} while (![view isKindOfClass:[UICollectionView class]]);
|
||||
UICollectionView *collectionView = (UICollectionView *)view;
|
||||
NSIndexPath *indexPath = [collectionView indexPathForCell:self];
|
||||
|
||||
if (collectionView.delegate &&
|
||||
[collectionView.delegate respondsToSelector:@selector(collectionView:
|
||||
performAction:
|
||||
forItemAtIndexPath:
|
||||
withSender:)])
|
||||
|
||||
[collectionView.delegate collectionView:collectionView
|
||||
performAction:selector
|
||||
forItemAtIndexPath:indexPath
|
||||
withSender:sender];
|
||||
}
|
||||
|
||||
@end
|
Loading…
Reference in New Issue