forked from mirrors/linphone-iphone
Manual download fixes
This commit is contained in:
parent
dbf1859657
commit
190a7d83e1
7 changed files with 53 additions and 23 deletions
|
|
@ -531,7 +531,7 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
BOOL basic = [ChatConversationView isBasicChatRoom:_chatRoom];
|
||||
if (message && message.length > 0) {
|
||||
if (!basic)
|
||||
linphone_chat_message_add_utf8_text_content(msg, message.UTF8String);
|
||||
linphone_chat_message_add_utf8_text_content(msg, message.UTF8String);
|
||||
}
|
||||
|
||||
if (externalUrl) {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="19529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
|
||||
<device id="retina4_7" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19519"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
|
|
|
|||
|
|
@ -277,22 +277,15 @@
|
|||
if (!is_outgoing) {
|
||||
LinphoneChatMessageState state = linphone_chat_message_get_state(self.message);
|
||||
if (state != LinphoneChatMessageStateFileTransferDone && state != LinphoneChatMessageStateDisplayed) {
|
||||
if (state == LinphoneChatMessageStateFileTransferInProgress) {
|
||||
_cancelButton.hidden = _fileTransferProgress.hidden = NO;
|
||||
_downloadButton.hidden = YES;
|
||||
_playButton.hidden = YES;
|
||||
_fileName.hidden = _fileView.hidden = _fileButton.hidden =YES;
|
||||
} else {
|
||||
_downloadButton.hidden = YES;
|
||||
UIChatContentView * contentView = [[UIChatContentView alloc] init];
|
||||
[contentView setContent:fileContent message:self.message];
|
||||
contentView.position = 0;
|
||||
[_contentViews addObject:contentView];
|
||||
_cancelButton.hidden = _fileTransferProgress.hidden = YES;
|
||||
_playButton.hidden = YES;
|
||||
_fileName.hidden = _fileView.hidden = _fileButton.hidden = YES;
|
||||
[self layoutSubviews];
|
||||
}
|
||||
_downloadButton.hidden = YES;
|
||||
UIChatContentView * contentView = [[UIChatContentView alloc] init];
|
||||
[contentView setContent:fileContent message:self.message];
|
||||
contentView.position = 0;
|
||||
[_contentViews addObject:contentView];
|
||||
_cancelButton.hidden = _fileTransferProgress.hidden = YES;
|
||||
_playButton.hidden = YES;
|
||||
_fileName.hidden = _fileView.hidden = _fileButton.hidden = YES;
|
||||
[self layoutSubviews];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -314,6 +314,9 @@
|
|||
#pragma mark - State changed handling
|
||||
static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState state) {
|
||||
LOGI(@"State for message [%p] changed to %s", msg, linphone_chat_message_state_to_string(state));
|
||||
if (state == LinphoneChatMessageStateFileTransferInProgress)
|
||||
return;
|
||||
|
||||
if (!linphone_chat_message_is_outgoing(msg) || (state != LinphoneChatMessageStateFileTransferDone && state != LinphoneChatMessageStateFileTransferInProgress)) {
|
||||
LinphoneEventLog *event = (LinphoneEventLog *)linphone_chat_message_cbs_get_user_data(linphone_chat_message_get_callbacks(msg));
|
||||
ChatConversationView *view = VIEW(ChatConversationView);
|
||||
|
|
@ -373,10 +376,8 @@ static const CGFloat REPLY_OR_FORWARD_TAG_HEIGHT = 18;
|
|||
|
||||
CGSize cached = [SwiftUtil getCachedMessageHeightWithCmessage:chat];
|
||||
if (cached.height != 0) {
|
||||
LOGI(@"ViewHeightForMessage - found cached value %f",cached.height);
|
||||
return cached;
|
||||
}
|
||||
LOGI(@"ViewHeightForMessage - computing value");
|
||||
|
||||
CGSize size = [self ViewHeightForMessageText:chat withWidth:width textForImdn:nil];
|
||||
size.height += linphone_chat_message_is_forward(chat) || linphone_chat_message_is_reply(chat) ? REPLY_OR_FORWARD_TAG_HEIGHT : 0;
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@
|
|||
@property(readonly, nonatomic) LinphoneChatMessage *message;
|
||||
@property(nonatomic) UIButton *downloadButton;
|
||||
@property(nonatomic) NSString *filePath;
|
||||
@property(nonatomic) UIProgressView *progress;
|
||||
|
||||
|
||||
- (void)setContent:(LinphoneContent *)content message:(LinphoneChatMessage *)message;
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,13 @@
|
|||
|
||||
@implementation UIChatContentView
|
||||
|
||||
static NSMutableDictionary<NSString *, UIChatContentView *> *instances;
|
||||
|
||||
- (void)setContent:(LinphoneContent *)content message:(LinphoneChatMessage *)message {
|
||||
|
||||
if (!instances)
|
||||
instances = [[NSMutableDictionary alloc] init];
|
||||
|
||||
_content = content;
|
||||
_message = message;
|
||||
self.userInteractionEnabled = YES;
|
||||
|
|
@ -41,11 +47,14 @@
|
|||
UIFont *boldFont = [UIFont systemFontOfSize:12];
|
||||
NSMutableParagraphStyle * paragraphStyle = [[NSMutableParagraphStyle alloc] init];
|
||||
paragraphStyle.alignment = NSTextAlignmentCenter;
|
||||
|
||||
NSMutableAttributedString *boldText = [[NSMutableAttributedString alloc] initWithString:@"Download" attributes:@{ NSFontAttributeName : boldFont, NSParagraphStyleAttributeName:paragraphStyle,NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle) }];
|
||||
[_downloadButton setAttributedTitle:boldText forState:UIControlStateNormal];
|
||||
_downloadButton.frame = CGRectMake(0, 90, 120, 30);
|
||||
[self addSubview:_downloadButton];
|
||||
_progress = [[UIProgressView alloc] initWithFrame:CGRectMake(5, 75, 110, 30)];
|
||||
_progress.tintColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"color_A.png"]];
|
||||
_progress.hidden = true;
|
||||
[self addSubview:_progress];
|
||||
} else {
|
||||
if (_filePath == NULL) {
|
||||
NSString *name = [NSString stringWithUTF8String:linphone_content_get_name(content)];
|
||||
|
|
@ -70,8 +79,27 @@
|
|||
-(IBAction)onDownloadClick:(id)sender {
|
||||
_downloadButton.enabled = NO;
|
||||
linphone_content_set_file_path(_content, [[LinphoneManager imagesDirectory] stringByAppendingPathComponent:[NSString stringWithUTF8String:linphone_content_get_name(_content)]].UTF8String);
|
||||
linphone_chat_message_cbs_set_file_transfer_progress_indication(linphone_chat_message_get_callbacks(_message), file_transfer_progress_indication_recv);
|
||||
_progress.hidden = false;
|
||||
_downloadButton.enabled = false;
|
||||
[instances setValue:self forKey:[NSString stringWithUTF8String:linphone_content_get_name(_content)]];
|
||||
|
||||
linphone_chat_message_download_content(_message, _content);
|
||||
}
|
||||
|
||||
static void file_transfer_progress_indication_recv(LinphoneChatMessage *message, LinphoneContent* content, size_t offset, size_t total) {
|
||||
CGFloat p = offset * 1.f / total;
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
UIChatContentView *thiz = [instances objectForKey:[NSString stringWithUTF8String:linphone_content_get_name(content)]];
|
||||
if (offset == total) {
|
||||
thiz.progress.hidden = true;
|
||||
} else {
|
||||
thiz.progress.hidden = false;
|
||||
thiz.progress.progress = p;
|
||||
LOGD(@"Transfer of %s (%d bytes): already %ld recv progress = %f", linphone_content_get_name(content), total, p);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
|||
|
|
@ -105,10 +105,16 @@ import linphonesw
|
|||
cacheMessageSize[message.messageId] = size
|
||||
}
|
||||
|
||||
@objc static func removeCachedMessageHeight(cmessage:OpaquePointer) {
|
||||
let message = ChatMessage.getSwiftObject(cObject: cmessage)
|
||||
cacheMessageSize.removeValue(forKey: message.messageId)
|
||||
}
|
||||
|
||||
@objc static func messageHeightCanBeCached(cmessage:OpaquePointer) -> Bool {
|
||||
let message = ChatMessage.getSwiftObject(cObject: cmessage)
|
||||
return (message.isOutgoing && [.Delivered, .DeliveredToUser, .Displayed].contains(message.state)) || (!message.isOutgoing && ![.InProgress, .FileTransferInProgress, .FileTransferError].contains(message.state))
|
||||
return (message.isOutgoing && [.Delivered, .DeliveredToUser, .Displayed].contains(message.state)) || (!message.isOutgoing && [.Displayed].contains(message.state))
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue