uploading media displays a pie chart (need to add the statistic)

This commit is contained in:
ylecollen 2015-01-08 18:25:43 +01:00
parent 8d5f726303
commit 7a0edfa63c
4 changed files with 20 additions and 37 deletions

BIN
matrixConsole/View/.DS_Store vendored Normal file

Binary file not shown.

View file

@ -51,7 +51,7 @@
@interface OutgoingMessageTableCell : RoomMessageTableCell
-(void)startAnimating;
-(void)startUploadAnimating;
-(void)stopAnimating;
@end

View file

@ -36,7 +36,9 @@
NSMutableString* text = [[NSMutableString alloc] init];
if (progressString) {
[text appendString:progressString];
}
if (remaingTime) {
[text appendFormat:@" (%@)", remaingTime];
@ -141,7 +143,6 @@
@end
@interface OutgoingMessageTableCell () {
PieChartView* pieChartView;
}
@property (weak, nonatomic) IBOutlet UIActivityIndicatorView *activityIndicator;
@ -153,21 +154,17 @@
[self stopAnimating];
}
-(void)startAnimating {
-(void)startUploadAnimating {
[[NSNotificationCenter defaultCenter] removeObserver:self name:kMediaUploadProgressNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onUploadProgress:) name:kMediaUploadProgressNotification object:nil];
self.activityIndicator.hidden = NO;
[self.activityIndicator startAnimating];
[self updateUploadProgressTo:self.message.uploadProgress];
[self initUploadProgressTo:self.message.uploadProgress];
}
-(void)stopAnimating {
// remove any pie chart
[pieChartView removeFromSuperview];
pieChartView = nil;
[[NSNotificationCenter defaultCenter] removeObserver:self name:kMediaUploadProgressNotification object:nil];
[self.activityIndicator stopAnimating];
}
@ -178,36 +175,20 @@
NSString* url = notif.object;
if ([url isEqualToString:self.message.thumbnailURL] || [url isEqualToString:self.message.attachmentURL]) {
NSNumber* progressNumber = [notif.userInfo valueForKey:kMediaManagerProgressRateKey];
if (progressNumber) {
[self updateUploadProgressTo:progressNumber.floatValue];
}
[self updateProgressUI:notif.userInfo];
}
}
}
- (void) updateUploadProgressTo:(CGFloat)progress {
- (void) initUploadProgressTo:(CGFloat)progress {
// nothing to display
if (progress <= 0) {
[pieChartView removeFromSuperview];
pieChartView = nil;
self.activityIndicator.hidden = NO;
} else {
if (!pieChartView) {
pieChartView = [[PieChartView alloc] init];
pieChartView.frame = self.activityIndicator.frame;
pieChartView.progress = 0;
pieChartView.progressColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:0.5];
pieChartView.unprogressColor = [UIColor clearColor];
[self.contentView addSubview:pieChartView];
}
self.message.uploadProgress = progress;
self.activityIndicator.hidden = YES;
pieChartView.progress = progress;
self.progressView.hidden = NO;
self.progressChartView.progress = progress;
}
}

View file

@ -1394,13 +1394,7 @@ NSString *const kCmdResetUserPowerLevel = @"/deop";
frame.size.width = contentSize.width;
frame.size.height = contentSize.height;
cell.attachmentView.frame = frame;
// Fade attachments during upload
if (message.isUploadInProgress) {
[((OutgoingMessageTableCell*)cell) startAnimating];
cell.attachmentView.hideActivityIndicator = YES;
} else {
cell.attachmentView.hideActivityIndicator = NO;
}
NSString *url = message.thumbnailURL;
if (message.messageType == RoomMessageTypeVideo) {
cell.playIconView.hidden = NO;
@ -1425,6 +1419,14 @@ NSString *const kCmdResetUserPowerLevel = @"/deop";
[cell startProgressUI];
// wait after upload info
if (message.isUploadInProgress) {
[((OutgoingMessageTableCell*)cell) startUploadAnimating];
cell.attachmentView.hideActivityIndicator = YES;
} else {
cell.attachmentView.hideActivityIndicator = NO;
}
// Adjust Attachment width constant
cell.attachViewWidthConstraint.constant = contentSize.width;
} else {