From f3aa7b45550e47ff3c372b6cfdca24bc7860f645 Mon Sep 17 00:00:00 2001 From: Danmei Chen Date: Tue, 21 Aug 2018 16:37:37 +0200 Subject: [PATCH] optimization of file sharing --- Classes/ChatConversationView.m | 2 +- .../Base.lproj/UIChatBubblePhotoCell.xib | 42 ++++++++++++------- Classes/LinphoneUI/UIChatBubblePhotoCell.h | 6 +-- Classes/LinphoneUI/UIChatBubblePhotoCell.m | 20 ++++----- 4 files changed, 39 insertions(+), 31 deletions(-) diff --git a/Classes/ChatConversationView.m b/Classes/ChatConversationView.m index cd0d3edd4..30a91a3b7 100644 --- a/Classes/ChatConversationView.m +++ b/Classes/ChatConversationView.m @@ -913,7 +913,7 @@ void on_chat_room_conference_left(LinphoneChatRoom *cr, const LinphoneEventLog * inMode:UIDocumentPickerModeImport]; _documentPicker.delegate = self; - _documentPicker.modalPresentationStyle = UIModalPresentationFormSheet; + _documentPicker.modalPresentationStyle = UIModalPresentationOverCurrentContext ; [self presentViewController:_documentPicker animated:YES completion:nil]; } diff --git a/Classes/LinphoneUI/Base.lproj/UIChatBubblePhotoCell.xib b/Classes/LinphoneUI/Base.lproj/UIChatBubblePhotoCell.xib index 50403d66f..c453ff689 100644 --- a/Classes/LinphoneUI/Base.lproj/UIChatBubblePhotoCell.xib +++ b/Classes/LinphoneUI/Base.lproj/UIChatBubblePhotoCell.xib @@ -19,8 +19,10 @@ - + + + @@ -29,7 +31,6 @@ - @@ -74,14 +75,6 @@ - @@ -144,7 +137,6 @@ - @@ -179,6 +171,29 @@ + + + + + + + + @@ -200,11 +215,6 @@ - - - - - diff --git a/Classes/LinphoneUI/UIChatBubblePhotoCell.h b/Classes/LinphoneUI/UIChatBubblePhotoCell.h index 1aa697eec..c39967456 100644 --- a/Classes/LinphoneUI/UIChatBubblePhotoCell.h +++ b/Classes/LinphoneUI/UIChatBubblePhotoCell.h @@ -34,11 +34,12 @@ @property(weak, nonatomic) IBOutlet UIProgressView *fileTransferProgress; @property(weak, nonatomic) IBOutlet UIButton *cancelButton; @property(weak, nonatomic) IBOutlet UIView *imageSubView; -@property (strong, nonatomic) IBOutlet UITapGestureRecognizer *openRecognizer; @property(weak, nonatomic) IBOutlet UIView *totalView; @property (weak, nonatomic) IBOutlet UIView *finalAssetView; @property (weak, nonatomic) IBOutlet UIImageView *finalImage; @property(strong, nonatomic) IBOutlet UITapGestureRecognizer *imageGestureRecognizer; +@property (weak, nonatomic) IBOutlet UIButton *fileButton; +@property (weak, nonatomic) IBOutlet UIView *fileView; - (void)setEvent:(LinphoneEventLog *)event; - (void)setChatMessage:(LinphoneChatMessage *)message; @@ -48,8 +49,7 @@ - (IBAction)onCancelClick:(id)sender; - (IBAction)onResendClick:(id)event; - (IBAction)onPlayClick:(id)sender; -- (IBAction)onOpenClick:(id)event; - +- (IBAction)onFileClick:(id)sender; @end diff --git a/Classes/LinphoneUI/UIChatBubblePhotoCell.m b/Classes/LinphoneUI/UIChatBubblePhotoCell.m index ca81111a7..18fe351d4 100644 --- a/Classes/LinphoneUI/UIChatBubblePhotoCell.m +++ b/Classes/LinphoneUI/UIChatBubblePhotoCell.m @@ -72,7 +72,6 @@ - (void)setChatMessage:(LinphoneChatMessage *)amessage { _imageGestureRecognizer.enabled = NO; - _openRecognizer.enabled = NO; _messageImageView.image = nil; _finalImage.image = nil; _finalImage.hidden = TRUE; @@ -131,9 +130,8 @@ - (void) loadFileAsset { dispatch_async(dispatch_get_main_queue(), ^{ - _fileName.hidden = NO; + _fileName.hidden = _fileView.hidden = _fileButton.hidden = NO; _imageGestureRecognizer.enabled = NO; - _openRecognizer.enabled = YES; }); } @@ -167,14 +165,14 @@ if (!(localImage || localVideo || localFile)) { _playButton.hidden = YES; - _fileName.hidden = YES; + _fileName.hidden = _fileView.hidden = _fileButton.hidden = YES; _messageImageView.hidden = _cancelButton.hidden = (_ftd.message == nil); _downloadButton.hidden = !_cancelButton.hidden; _fileTransferProgress.hidden = NO; } else { // file is being saved on device - just wait for it if ([localImage isEqualToString:@"saving..."] || [localVideo isEqualToString:@"saving..."] || [localFile isEqualToString:@"saving..."]) { - _cancelButton.hidden = _fileTransferProgress.hidden = _downloadButton.hidden = _playButton.hidden = _fileName.hidden = YES; + _cancelButton.hidden = _fileTransferProgress.hidden = _downloadButton.hidden = _playButton.hidden = _fileName.hidden = _fileView.hidden = _fileButton.hidden = YES; fullScreenImage = YES; } else if(!assetIsLoaded) { assetIsLoaded = TRUE; @@ -191,7 +189,7 @@ } } else if (localFile) { - NSString *text = [NSString stringWithFormat:@"📎 %@",localFile]; + NSString *text = [NSString stringWithFormat:@"📎 %@",localFile]; _fileName.text = text; [self loadFileAsset]; } @@ -202,12 +200,12 @@ _fileTransferProgress.hidden = NO; _downloadButton.hidden = YES; _playButton.hidden = YES; - _fileName.hidden = YES; + _fileName.hidden = _fileView.hidden = _fileButton.hidden =YES; } else { _cancelButton.hidden = _fileTransferProgress.hidden = _downloadButton.hidden = YES; fullScreenImage = YES; _playButton.hidden = localVideo ? NO : YES; - _fileName.hidden = localFile ? NO : YES; + _fileName.hidden = _fileView.hidden = _fileButton.hidden = localFile ? NO : YES; // Should fix cell not resizing after doanloading image. [self layoutSubviews]; } @@ -250,7 +248,7 @@ _cancelButton.hidden = NO; _downloadButton.hidden = YES; _playButton.hidden = YES; - _fileName.hidden = YES; + _fileName.hidden = _fileView.hidden = _fileButton.hidden = YES; } - (IBAction)onPlayClick:(id)sender { @@ -271,7 +269,7 @@ }]; } -- (IBAction)onOpenClick:(id)event { +- (IBAction)onFileClick:(id)sender { ChatConversationView *view = VIEW(ChatConversationView); NSString *cachedFile = [LinphoneManager getMessageAppDataForKey:@"cachedfile" inMessage:self.message]; if (cachedFile) { @@ -401,7 +399,7 @@ } bubbleFrame.origin.x = origin_x; - + super.bubbleView.frame = bubbleFrame; // Resizing Image view