forked from mirrors/linphone-iphone
Add support for multiple image and text + image sending
This commit is contained in:
parent
03a4c7174a
commit
40eb0d5208
11 changed files with 377 additions and 10 deletions
|
|
@ -18,6 +18,8 @@
|
|||
<outlet property="chatView" destination="49" id="Rxt-Zy-19x"/>
|
||||
<outlet property="composeIndicatorView" destination="fx4-ao-53M" id="xk5-nK-lur"/>
|
||||
<outlet property="composeLabel" destination="fpY-Fv-ht2" id="4L6-ik-ZAe"/>
|
||||
<outlet property="imagesCollectionView" destination="JGQ-p2-HCX" id="6dt-1f-jpa"/>
|
||||
<outlet property="imagesView" destination="3qd-ys-t2L" id="f9L-FU-PMI"/>
|
||||
<outlet property="infoButton" destination="Vqb-Un-4xv" id="pa1-Iz-5QQ"/>
|
||||
<outlet property="landscapeView" destination="VoU-7Q-fgp" id="iRJ-sh-thF"/>
|
||||
<outlet property="listSwipeGestureRecognizer" destination="dzw-n4-l9i" id="JVP-Vl-lIa"/>
|
||||
|
|
@ -269,6 +271,28 @@
|
|||
</view>
|
||||
</subviews>
|
||||
</view>
|
||||
<view contentMode="scaleToFill" misplaced="YES" id="3qd-ys-t2L" userLabel="imagesView">
|
||||
<rect key="frame" x="0.0" y="427" width="375" height="0.0"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
|
||||
<subviews>
|
||||
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" image="color_F.png" id="B6X-D7-Bak" userLabel="backgroundColor">
|
||||
<rect key="frame" x="2" y="1" width="375" height="0.0"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
</imageView>
|
||||
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" misplaced="YES" showsVerticalScrollIndicator="NO" dataMode="none" id="JGQ-p2-HCX" userLabel="imagesCollectionView">
|
||||
<rect key="frame" x="2" y="0.0" width="374" height="0.0"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" red="0.98780487804878048" green="1" blue="1" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<collectionViewFlowLayout key="collectionViewLayout" scrollDirection="horizontal" minimumLineSpacing="10" minimumInteritemSpacing="10" id="c7z-F2-r1y">
|
||||
<size key="itemSize" width="50" height="100"/>
|
||||
<size key="headerReferenceSize" width="0.0" height="0.0"/>
|
||||
<size key="footerReferenceSize" width="0.0" height="0.0"/>
|
||||
<inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
|
||||
</collectionViewFlowLayout>
|
||||
</collectionView>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
</view>
|
||||
</subviews>
|
||||
</view>
|
||||
</subviews>
|
||||
|
|
|
|||
|
|
@ -27,12 +27,13 @@
|
|||
#import "UIRoundedImageView.h"
|
||||
#import "UIBackToCallButton.h"
|
||||
#import "Utils/HPGrowingTextView/HPGrowingTextView.h"
|
||||
#import "UIImageViewDeletable.h"
|
||||
|
||||
#include "linphone/linphonecore.h"
|
||||
|
||||
@interface ChatConversationView
|
||||
: TPMultiLayoutViewController <HPGrowingTextViewDelegate, UICompositeViewDelegate, ImagePickerDelegate, ChatConversationDelegate,
|
||||
UIDocumentInteractionControllerDelegate, UISearchBarDelegate> {
|
||||
UIDocumentInteractionControllerDelegate, UISearchBarDelegate, UIImageViewDeletableDelegate, UICollectionViewDataSource> {
|
||||
OrderedDictionary *imageQualities;
|
||||
BOOL scrollOnGrowingEnabled;
|
||||
BOOL composingVisible;
|
||||
|
|
@ -60,6 +61,12 @@
|
|||
@property (weak, nonatomic) IBOutlet UIIconButton *infoButton;
|
||||
@property (weak, nonatomic) IBOutlet UILabel *particpantsLabel;
|
||||
@property (nonatomic, strong) UIDocumentInteractionController *documentInteractionController;
|
||||
@property NSMutableArray <UIImage *> *imagesArray;
|
||||
@property NSMutableArray <NSString *> *assetIdsArray;
|
||||
@property NSMutableArray <NSNumber *> *qualitySettingsArray;
|
||||
@property (weak, nonatomic) IBOutlet UICollectionView *imagesCollectionView;
|
||||
@property (weak, nonatomic) IBOutlet UIView *imagesView;
|
||||
|
||||
+ (void)markAsRead:(LinphoneChatRoom *)chatRoom;
|
||||
|
||||
- (void)configureForRoom:(BOOL)editing;
|
||||
|
|
@ -74,5 +81,6 @@
|
|||
- (IBAction)onEditionChangeClick:(id)sender;
|
||||
- (void)update;
|
||||
- (void)openResults:(NSString *) filePath;
|
||||
- (void)clearMessageView;
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -101,6 +101,8 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
_messageField.contentInset = UIEdgeInsetsMake(-15, 0, 0, 0);
|
||||
// _messageField.internalTextView.scrollIndicatorInsets = UIEdgeInsetsMake(0, 0, 0, 10);
|
||||
[_tableController setChatRoomDelegate:self];
|
||||
[_imagesCollectionView registerClass:[UIImageViewDeletable class] forCellWithReuseIdentifier:NSStringFromClass([UIImageViewDeletable class])];
|
||||
[_imagesCollectionView setDataSource:self];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated {
|
||||
|
|
@ -125,6 +127,24 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
selector:@selector(callUpdateEvent:)
|
||||
name:kLinphoneCallUpdate
|
||||
object:nil];
|
||||
|
||||
if ([_imagesArray count] > 0) {
|
||||
[UIView animateWithDuration:0
|
||||
delay:0
|
||||
options:UIViewAnimationOptionBeginFromCurrentState
|
||||
animations:^{
|
||||
// resizing imagesView
|
||||
CGRect imagesFrame = [_imagesView frame];
|
||||
imagesFrame.origin.y = [_messageView frame].origin.y - 100;
|
||||
imagesFrame.size.height = 100;
|
||||
[_imagesView setFrame:imagesFrame];
|
||||
// resizing chatTable
|
||||
CGRect tableViewFrame = [_tableController.tableView frame];
|
||||
tableViewFrame.size.height -= 100;
|
||||
[_tableController.tableView setFrame:tableViewFrame];
|
||||
}
|
||||
completion:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)viewWillDisappear:(BOOL)animated {
|
||||
|
|
@ -203,7 +223,6 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
_messageField.editable = !linphone_chat_room_has_been_left(_chatRoom);
|
||||
_pictureButton.enabled = !linphone_chat_room_has_been_left(_chatRoom);
|
||||
_messageView.userInteractionEnabled = !linphone_chat_room_has_been_left(_chatRoom);
|
||||
[_messageField setText:@""];
|
||||
[_tableController setChatRoom:_chatRoom];
|
||||
|
||||
_chatView.hidden = NO;
|
||||
|
|
@ -222,7 +241,12 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
//share photo
|
||||
NSData *data = dict[@"nsData"];
|
||||
UIImage *image = [[UIImage alloc] initWithData:data];
|
||||
[self chooseImageQuality:image assetId:nil];
|
||||
NSString *filename = dict[@"url"];
|
||||
if (filename) {
|
||||
NSMutableDictionary <NSString *, PHAsset *> * assetDict = [LinphoneUtils photoAssetsDictionary];
|
||||
[self chooseImageQuality:image assetId:[[assetDict objectForKey:filename] localIdentifier]];
|
||||
} else
|
||||
[self chooseImageQuality:image assetId:@""];
|
||||
[defaults removeObjectForKey:@"img"];
|
||||
} else if (dictWeb) {
|
||||
//share url, if local file, then upload file
|
||||
|
|
@ -311,7 +335,11 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
}
|
||||
|
||||
- (void)saveAndSend:(UIImage *)image assetId:(NSString *)phAssetId withQuality:(float)quality{
|
||||
[self startImageUpload:image assetId:phAssetId withQuality:quality];
|
||||
|
||||
[_imagesArray addObject:image];
|
||||
[_assetIdsArray addObject:phAssetId];
|
||||
[_qualitySettingsArray addObject:@(quality)];
|
||||
[self addImageToDrawer:image withAssetId:phAssetId];
|
||||
}
|
||||
|
||||
- (void)chooseImageQuality:(UIImage *)image assetId:(NSString *)phAssetId {
|
||||
|
|
@ -456,6 +484,12 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
messageRect.size.height += diff;
|
||||
[_messageView setFrame:messageRect];
|
||||
|
||||
if ([_imagesArray count] > 0) {
|
||||
CGRect _imagesRect = [_imagesView frame];
|
||||
_imagesRect.origin.y -= diff;
|
||||
[_imagesView setFrame:_imagesRect];
|
||||
}
|
||||
|
||||
// Always stay at bottom
|
||||
if (scrollOnGrowingEnabled) {
|
||||
CGRect tableFrame = [_tableController.view frame];
|
||||
|
|
@ -493,6 +527,15 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
}
|
||||
|
||||
- (IBAction)onSendClick:(id)event {
|
||||
if ([_imagesArray count] > 0) {
|
||||
int i = 0;
|
||||
for (i = 0; i < [_imagesArray count] - 1; ++i) {
|
||||
[self startImageUpload:[_imagesArray objectAtIndex:i] assetId:[_assetIdsArray objectAtIndex:i] withQuality:[_qualitySettingsArray objectAtIndex:i].floatValue];
|
||||
}
|
||||
[self startImageUpload:[_imagesArray objectAtIndex:i] assetId:[_assetIdsArray objectAtIndex:i] withQuality:[_qualitySettingsArray objectAtIndex:i].floatValue andMessage:[self.messageField text]];
|
||||
[self clearMessageView];
|
||||
return;
|
||||
}
|
||||
if ([self sendMessage:[_messageField text] withExterlBodyUrl:nil withInternalURL:nil]) {
|
||||
scrollOnGrowingEnabled = FALSE;
|
||||
[_messageField setText:@""];
|
||||
|
|
@ -583,6 +626,14 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
- (BOOL)startImageUpload:(UIImage *)image assetId:(NSString *)phAssetId withQuality:(float)quality andMessage:(NSString *)message {
|
||||
FileTransferDelegate *fileTransfer = [[FileTransferDelegate alloc] init];
|
||||
[fileTransfer setText:message];
|
||||
[fileTransfer upload:image withassetId:phAssetId forChatRoom:_chatRoom withQuality:quality];
|
||||
[_tableController scrollToBottom:true];
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
- (BOOL)startFileUpload:(NSData *)data withUrl:(NSURL *)url {
|
||||
FileTransferDelegate *fileTransfer = [[FileTransferDelegate alloc] init];
|
||||
[fileTransfer uploadFile:data forChatRoom:_chatRoom withUrl:url];
|
||||
|
|
@ -611,6 +662,28 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
[VIEW(ImagePickerView).popoverController dismissPopoverAnimated:TRUE];
|
||||
}
|
||||
[self chooseImageQuality:image assetId:phAssetId];
|
||||
//[self chooseImageQuality:image assetId:phAssetId];
|
||||
}
|
||||
|
||||
- (void)addImageToDrawer:(UIImage *)img withAssetId:(NSString *)assetId {
|
||||
if ([_imagesArray count] == 1) { // We resize chatView to display the image
|
||||
[UIView animateWithDuration:0
|
||||
delay:0
|
||||
options:UIViewAnimationOptionBeginFromCurrentState
|
||||
animations:^{
|
||||
// resizing imagesView
|
||||
CGRect imagesFrame = [_imagesView frame];
|
||||
imagesFrame.origin.y = [_messageView frame].origin.y - 100;
|
||||
imagesFrame.size.height = 100;
|
||||
[_imagesView setFrame:imagesFrame];
|
||||
// resizing chatTable
|
||||
CGRect tableViewFrame = [_tableController.tableView frame];
|
||||
tableViewFrame.size.height -= 100;
|
||||
[_tableController.tableView setFrame:tableViewFrame];
|
||||
}
|
||||
completion:nil];
|
||||
}
|
||||
[_imagesCollectionView reloadData];
|
||||
}
|
||||
|
||||
- (void)tableViewIsScrolling {
|
||||
|
|
@ -667,6 +740,19 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ([_imagesArray count] > 0){
|
||||
// resizing imagesView
|
||||
CGRect imagesFrame = [_imagesView frame];
|
||||
imagesFrame.origin.y = [_messageView frame].origin.y - 100;
|
||||
imagesFrame.size.height = 100;
|
||||
[_imagesView setFrame:imagesFrame];
|
||||
// resizing chatTable
|
||||
CGRect tableViewFrame = [_tableController.tableView frame];
|
||||
tableViewFrame.size.height -= 100;
|
||||
[_tableController.tableView setFrame:tableViewFrame];
|
||||
}
|
||||
}
|
||||
completion:^(BOOL finished){
|
||||
|
||||
|
|
@ -722,6 +808,18 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
[_messageView frame].origin.y - tableFrame.origin.y - composeIndicatorCompensation;
|
||||
[_tableController.view setFrame:tableFrame];
|
||||
}
|
||||
|
||||
if ([_imagesArray count] > 0){
|
||||
// resizing imagesView
|
||||
CGRect imagesFrame = [_imagesView frame];
|
||||
imagesFrame.origin.y = [_messageView frame].origin.y - 100;
|
||||
imagesFrame.size.height = 100;
|
||||
[_imagesView setFrame:imagesFrame];
|
||||
// resizing chatTable
|
||||
CGRect tableViewFrame = [_tableController.tableView frame];
|
||||
tableViewFrame.size.height -= 100;
|
||||
[_tableController.tableView setFrame:tableViewFrame];
|
||||
}
|
||||
|
||||
// Scroll
|
||||
NSInteger lastSection = [_tableController.tableView numberOfSections] - 1;
|
||||
|
|
@ -734,6 +832,7 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
animated:FALSE];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
completion:^(BOOL finished){
|
||||
}];
|
||||
|
|
@ -839,4 +938,70 @@ void on_chat_room_conference_left(LinphoneChatRoom *cr, const LinphoneEventLog *
|
|||
}
|
||||
}
|
||||
|
||||
- (void)deleteImageWithAssetId:(NSString *)assetId {
|
||||
NSUInteger key = [_assetIdsArray indexOfObject:assetId];
|
||||
[_imagesArray removeObjectAtIndex:key];
|
||||
[_assetIdsArray removeObjectAtIndex:key];
|
||||
if ([_imagesArray count] == 0) {
|
||||
[UIView animateWithDuration:0
|
||||
delay:0
|
||||
options:UIViewAnimationOptionBeginFromCurrentState
|
||||
animations:^{
|
||||
// resizing imagesView
|
||||
CGRect imagesFrame = [_imagesView frame];
|
||||
imagesFrame.origin.y = [_messageView frame].origin.y;
|
||||
imagesFrame.size.height = 0;
|
||||
[_imagesView setFrame:imagesFrame];
|
||||
// resizing chatTable
|
||||
CGRect tableViewFrame = [_tableController.tableView frame];
|
||||
tableViewFrame.size.height += 100;
|
||||
[_tableController.tableView setFrame:tableViewFrame];
|
||||
}
|
||||
completion:nil];
|
||||
|
||||
[_sendButton setEnabled:FALSE];
|
||||
}
|
||||
[_imagesCollectionView reloadData];
|
||||
}
|
||||
|
||||
- (void)clearMessageView {
|
||||
[_messageField setText:@""];
|
||||
_imagesArray = [NSMutableArray array];
|
||||
_assetIdsArray = [NSMutableArray array];
|
||||
|
||||
// resizing imagesView
|
||||
[UIView animateWithDuration:0
|
||||
delay:0
|
||||
options:UIViewAnimationOptionBeginFromCurrentState
|
||||
animations:^{
|
||||
// resizing imagesView
|
||||
CGRect imagesFrame = [_imagesView frame];
|
||||
imagesFrame.origin.y = [_messageView frame].origin.y;
|
||||
imagesFrame.size.height = 0;
|
||||
[_imagesView setFrame:imagesFrame];
|
||||
|
||||
// resizing chatTable
|
||||
CGRect tableViewFrame = [_tableController.tableView frame];
|
||||
CGFloat composeIndicatorCompensation = composingVisible ? _composeIndicatorView.frame.size.height : 0.0f;
|
||||
tableViewFrame.size.height = [_messageView frame].origin.y - tableViewFrame.origin.y - composeIndicatorCompensation;
|
||||
[_tableController.tableView setFrame:tableViewFrame];
|
||||
}
|
||||
completion:nil];
|
||||
|
||||
[_imagesCollectionView reloadData];
|
||||
}
|
||||
|
||||
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
|
||||
return [_imagesArray count];
|
||||
}
|
||||
|
||||
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
|
||||
UIImageViewDeletable *imgView = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([UIImageViewDeletable class]) forIndexPath:indexPath];
|
||||
[imgView.image setImage:[UIImage resizeImage:[_imagesArray objectAtIndex:[indexPath item]] withMaxWidth:50 andMaxHeight:100]];
|
||||
[imgView setAssetId:[_assetIdsArray objectAtIndex:[indexPath item]]];
|
||||
[imgView setDeleteDelegate:self];
|
||||
[_sendButton setEnabled:TRUE];
|
||||
return imgView;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@
|
|||
|
||||
- (id)initWithIdentifier:(NSString *)identifier {
|
||||
if ((self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier]) != nil) {
|
||||
// TODO: remove text cell subview
|
||||
NSArray *arrayOfViews =
|
||||
[[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self.class) owner:self options:nil];
|
||||
// resize cell to match .nib size. It is needed when resized the cell to
|
||||
|
|
@ -119,7 +118,7 @@
|
|||
[[PHImageManager defaultManager] requestImageForAsset:asset targetSize:PHImageManagerMaximumSize contentMode:PHImageContentModeDefault options:options
|
||||
resultHandler:^(UIImage *image, NSDictionary * info) {
|
||||
if (image) {
|
||||
imageSize = [UIChatBubbleTextCell getMediaMessageSizefromOriginalSize:[image size] withWidth:chatTableView.tableView.frame.size.width];
|
||||
imageSize = [UIChatBubbleTextCell getMediaMessageSizefromOriginalSize:[image size] withWidth:chatTableView.tableView.frame.size.width - 40];
|
||||
UIImage *newImage = [UIImage UIImageResize:image toSize:imageSize];
|
||||
[chatTableView.imagesInChatroom setObject:newImage forKey:[asset localIdentifier]];
|
||||
[self loadImageAsset:asset image:newImage];
|
||||
|
|
@ -167,13 +166,24 @@
|
|||
});
|
||||
}
|
||||
|
||||
- (void) loadPlaceholder {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
//[_finalImage setImage:image];
|
||||
//[_messageImageView setAsset:asset];
|
||||
[_messageImageView stopLoading];
|
||||
_messageImageView.hidden = YES;
|
||||
_imageGestureRecognizer.enabled = YES;
|
||||
_finalImage.hidden = NO;
|
||||
[self layoutSubviews];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)update {
|
||||
if (self.message == nil) {
|
||||
LOGW(@"Cannot update message room cell: NULL message");
|
||||
return;
|
||||
}
|
||||
[super update];
|
||||
|
||||
[super update];
|
||||
const char *url = linphone_chat_message_get_external_body_url(self.message);
|
||||
BOOL is_external =
|
||||
(url && (strstr(url, "http") == url)) || linphone_chat_message_get_file_transfer_information(self.message);
|
||||
|
|
@ -203,7 +213,7 @@
|
|||
PHFetchResult<PHAsset *> *assets = [PHAsset fetchAssetsWithLocalIdentifiers:[NSArray arrayWithObject:localImage] options:nil];
|
||||
UIImage *img = [chatTableView.imagesInChatroom objectForKey:localImage];
|
||||
if (![assets firstObject])
|
||||
return;
|
||||
[self loadPlaceholder];
|
||||
PHAsset *asset = [assets firstObject];
|
||||
if (img)
|
||||
[self loadImageAsset:asset image:img];
|
||||
|
|
@ -415,6 +425,28 @@
|
|||
bubbleFrame.origin.x = origin_x;
|
||||
|
||||
super.bubbleView.frame = bubbleFrame;
|
||||
|
||||
// Resizing Image view
|
||||
if (_finalImage.image) {
|
||||
CGRect imgFrame = self.finalAssetView.frame;
|
||||
imgFrame.size = [UIChatBubbleTextCell getMediaMessageSizefromOriginalSize:[_finalImage.image size] withWidth:chatTableView.tableView.frame.size.width - 40];
|
||||
imgFrame.origin.x = (bubbleFrame.size.width - imgFrame.size.width)/2;
|
||||
self.finalAssetView.frame = imgFrame;
|
||||
|
||||
// Positioning text message
|
||||
const char *utf8Text = linphone_chat_message_get_text_content(self.message);
|
||||
|
||||
CGRect textFrame = self.messageText.frame;
|
||||
textFrame.origin = CGPointMake(textFrame.origin.x, self.finalAssetView.frame.origin.y + self.finalAssetView.frame.size.height);
|
||||
if (!utf8Text) {
|
||||
textFrame.size.height = 0;
|
||||
} else {
|
||||
textFrame.size.height = bubbleFrame.size.height - textFrame.origin.x;
|
||||
}
|
||||
|
||||
self.messageText.frame = textFrame;
|
||||
LOGD([NSString stringWithFormat:@"Text of the photoCell: %@, size of the text of the photoCell: %@", [self.messageText text], NSStringFromCGSize(textFrame.size)]);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
|||
26
Classes/LinphoneUI/UIImageViewDeletable.h
Normal file
26
Classes/LinphoneUI/UIImageViewDeletable.h
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
//
|
||||
// UIImageViewDeletable.h
|
||||
// linphone
|
||||
//
|
||||
// Created by benjamin_verdier on 28/06/2018.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@protocol UIImageViewDeletableDelegate
|
||||
|
||||
@required
|
||||
|
||||
- (void)deleteImageWithAssetId:(NSString *)assetId;
|
||||
|
||||
@end
|
||||
|
||||
@interface UIImageViewDeletable : UICollectionViewCell
|
||||
|
||||
@property NSString *assetId;
|
||||
@property(nonatomic, strong) id<UIImageViewDeletableDelegate> deleteDelegate;
|
||||
@property (weak, nonatomic) IBOutlet UIImageView *image;
|
||||
|
||||
- (IBAction)onDeletePressed;
|
||||
|
||||
@end
|
||||
59
Classes/LinphoneUI/UIImageViewDeletable.m
Normal file
59
Classes/LinphoneUI/UIImageViewDeletable.m
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
//
|
||||
// UIImageViewDeletable.m
|
||||
// linphone
|
||||
//
|
||||
// Created by benjamin_verdier on 28/06/2018.
|
||||
//
|
||||
|
||||
#import "UIImageViewDeletable.h"
|
||||
|
||||
@interface UIImageViewDeletable ()
|
||||
|
||||
@end
|
||||
|
||||
@implementation UIImageViewDeletable
|
||||
|
||||
- (UIImageViewDeletable *)init {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
NSArray *arrayOfViews =
|
||||
[[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self.class) owner:self options:nil];
|
||||
// resize cell to match .nib size. It is needed when resized the cell to
|
||||
// correctly adapt its height too
|
||||
UIView *sub = ((UIView *)[arrayOfViews objectAtIndex:arrayOfViews.count - 1]);
|
||||
[self setFrame:CGRectMake(0, 0, sub.frame.size.width, sub.frame.size.height)];
|
||||
[self addSubview:sub];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- (UIImageViewDeletable *)initWithFrame:(CGRect)frame {
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
NSArray *arrayOfViews =
|
||||
[[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self.class) owner:self options:nil];
|
||||
// resize cell to match .nib size. It is needed when resized the cell to
|
||||
// correctly adapt its height too
|
||||
UIView *sub = ((UIView *)[arrayOfViews objectAtIndex:arrayOfViews.count - 1]);
|
||||
[self setFrame:frame];
|
||||
[self addSubview:sub];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (IBAction)onDeletePressed {
|
||||
[_deleteDelegate deleteImageWithAssetId:_assetId];
|
||||
}
|
||||
|
||||
/*
|
||||
#pragma mark - Navigation
|
||||
|
||||
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
||||
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
||||
// Get the new view controller using [segue destinationViewController].
|
||||
// Pass the selected object to the new view controller.
|
||||
}
|
||||
*/
|
||||
|
||||
@end
|
||||
50
Classes/LinphoneUI/UIImageViewDeletable.xib
Normal file
50
Classes/LinphoneUI/UIImageViewDeletable.xib
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
|
||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="UIImageViewDeletable">
|
||||
<connections>
|
||||
<outlet property="image" destination="y2f-LK-bVa" id="VPy-6D-kNb"/>
|
||||
</connections>
|
||||
</placeholder>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
|
||||
<view clipsSubviews="YES" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
|
||||
<rect key="frame" x="0.0" y="0.0" width="50" height="100"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="y2f-LK-bVa">
|
||||
<rect key="frame" x="0.0" y="0.0" width="50" height="100"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
</imageView>
|
||||
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="J60-eT-n9R">
|
||||
<rect key="frame" x="30" y="0.0" width="20" height="20"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
|
||||
<accessibility key="accessibilityConfiguration">
|
||||
<accessibilityTraits key="traits" button="YES" image="YES"/>
|
||||
</accessibility>
|
||||
<state key="normal" image="delete_img.png"/>
|
||||
<connections>
|
||||
<action selector="onDeletePressed" destination="-1" eventType="touchUpInside" id="cmV-ac-rq7"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="simulatedTopBarMetrics"/>
|
||||
<nil key="simulatedBottomBarMetrics"/>
|
||||
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
|
||||
<viewLayoutGuide key="safeArea" id="Q5M-cg-NOt"/>
|
||||
<point key="canvasLocation" x="7" y="47"/>
|
||||
</view>
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="delete_img.png" width="50" height="50"/>
|
||||
</resources>
|
||||
</document>
|
||||
|
|
@ -934,6 +934,8 @@ static RootViewManager *rootViewManagerInstance = nil;
|
|||
linphone_chat_room_remove_callbacks(view.chatRoom, view.chatRoomCbs);
|
||||
|
||||
view.chatRoomCbs = NULL;
|
||||
if (view.chatRoom != cr)
|
||||
[view clearMessageView];
|
||||
view.chatRoom = cr;
|
||||
self.currentRoom = view.chatRoom;
|
||||
if (PhoneMainView.instance.currentView == view.compositeViewDescription)
|
||||
|
|
|
|||
|
|
@ -19,4 +19,5 @@
|
|||
- (void)stopAndDestroy;
|
||||
|
||||
@property() LinphoneChatMessage *message;
|
||||
@property() NSString *text;
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -208,8 +208,8 @@ static LinphoneBuffer *linphone_iphone_file_transfer_send(LinphoneChatMessage *m
|
|||
linphone_content_set_subtype(content, [subtype UTF8String]);
|
||||
linphone_content_set_name(content, [name UTF8String]);
|
||||
linphone_content_set_size(content, _data.length);
|
||||
|
||||
_message = linphone_chat_room_create_file_transfer_message(chatRoom, content);
|
||||
linphone_chat_message_add_text_content(_message, [_text UTF8String]);
|
||||
linphone_content_unref(content);
|
||||
|
||||
linphone_chat_message_cbs_set_file_transfer_send(linphone_chat_message_get_callbacks(_message),
|
||||
|
|
|
|||
BIN
Resources/images/delete_img.png
Normal file
BIN
Resources/images/delete_img.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
Loading…
Add table
Reference in a new issue