From 4195c301de293b969a2c91c1f2e540091c9f8cee Mon Sep 17 00:00:00 2001 From: ylecollen Date: Wed, 7 Jan 2015 09:11:21 +0100 Subject: [PATCH] MXHTTPClient::requestWithMethod has two new blocks to track the upload/download progress. --- matrixConsole/View/RoomMessageTableCell.h | 4 +++- matrixConsole/View/RoomMessageTableCell.m | 17 +++++++++++++++++ .../ViewController/RoomViewController.m | 9 +++++++-- .../ViewController/SettingsViewController.m | 2 ++ 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/matrixConsole/View/RoomMessageTableCell.h b/matrixConsole/View/RoomMessageTableCell.h index c4341154a..a15e2393d 100644 --- a/matrixConsole/View/RoomMessageTableCell.h +++ b/matrixConsole/View/RoomMessageTableCell.h @@ -39,6 +39,8 @@ @end @interface OutgoingMessageTableCell : RoomMessageTableCell -@property (weak, nonatomic) IBOutlet UIActivityIndicatorView *activityIndicator; + +-(void)startAnimating; +-(void)stopAnimating; @end diff --git a/matrixConsole/View/RoomMessageTableCell.m b/matrixConsole/View/RoomMessageTableCell.m index 36ef96486..43bfa51c0 100644 --- a/matrixConsole/View/RoomMessageTableCell.m +++ b/matrixConsole/View/RoomMessageTableCell.m @@ -16,6 +16,8 @@ #import "RoomMessageTableCell.h" #import "MediaManager.h" +#import "PieChartView.h" + @implementation RoomMessageTableCell @end @@ -24,8 +26,23 @@ @implementation IncomingMessageTableCell @end +@interface OutgoingMessageTableCell () { + PieChartView* pieChartView; +} + +@property (weak, nonatomic) IBOutlet UIActivityIndicatorView *activityIndicator; +@end @implementation OutgoingMessageTableCell + +-(void)startAnimating { + [self.activityIndicator startAnimating]; +} + +-(void)stopAnimating { + [self.activityIndicator stopAnimating]; +} + - (void)layoutSubviews { [super layoutSubviews]; diff --git a/matrixConsole/ViewController/RoomViewController.m b/matrixConsole/ViewController/RoomViewController.m index aff3a6b89..a2d736bcf 100644 --- a/matrixConsole/ViewController/RoomViewController.m +++ b/matrixConsole/ViewController/RoomViewController.m @@ -1018,6 +1018,8 @@ NSString *const kCmdResetUserPowerLevel = @"/deop"; [self sendMessage:videoContent withLocalEvent:localEvent]; } failure:^(NSError *error) { [self handleError:error forLocalEvent:localEvent]; + } uploadProgress:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) { + }]; } else { NSLog(@"Video is too large"); @@ -1038,6 +1040,8 @@ NSString *const kCmdResetUserPowerLevel = @"/deop"; } failure:^(NSError *error) { NSLog(@"Video thumbnail upload failed"); [self handleError:error forLocalEvent:localEvent]; + } uploadProgress:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) { + }]; } @@ -1242,7 +1246,7 @@ NSString *const kCmdResetUserPowerLevel = @"/deop"; cell = [tableView dequeueReusableCellWithIdentifier:@"OutgoingMessageCell" forIndexPath:indexPath]; OutgoingMessageTableCell* outgoingMsgCell = (OutgoingMessageTableCell*)cell; // Hide potential loading wheel - [outgoingMsgCell.activityIndicator stopAnimating]; + [outgoingMsgCell stopAnimating]; } else { cell = [tableView dequeueReusableCellWithIdentifier:@"IncomingMessageCell" forIndexPath:indexPath]; isIncomingMsg = YES; @@ -1337,7 +1341,7 @@ NSString *const kCmdResetUserPowerLevel = @"/deop"; // Fade attachments during upload if (message.isUploadInProgress) { cell.attachmentView.alpha = 0.5; - [((OutgoingMessageTableCell*)cell).activityIndicator startAnimating]; + [((OutgoingMessageTableCell*)cell) startAnimating]; cell.attachmentView.hideActivityIndicator = YES; } else { cell.attachmentView.alpha = 1; @@ -2189,6 +2193,7 @@ NSString *const kCmdResetUserPowerLevel = @"/deop"; [self sendMessage:imageMessage withLocalEvent:localEvent]; } failure:^(NSError *error) { [self handleError:error forLocalEvent:localEvent]; + } uploadProgress:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) { }]; } diff --git a/matrixConsole/ViewController/SettingsViewController.m b/matrixConsole/ViewController/SettingsViewController.m index 9db5e96e8..704857679 100644 --- a/matrixConsole/ViewController/SettingsViewController.m +++ b/matrixConsole/ViewController/SettingsViewController.m @@ -371,6 +371,8 @@ NSString* const kCommandsDescriptionText = @"The following commands are availabl _userPicture.enabled = YES; isAvatarUploading = NO; [self handleErrorDuringPictureSaving:error]; + } uploadProgress:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) { + // need to display the progress ? }]; } else { [mxHandler.mxSession.myUser setAvatarUrl:uploadedPictureURL