mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-03-06 16:30:55 +00:00
+ Some corrections regarding the display and loading of attachments.
- Attachments are no longer displayed in a cell if the system indicates that they cannot be displayed. - Fixed a bug that prevented devices running iOS6 from displaying attachments in the Overview List.
This commit is contained in:
@@ -210,7 +210,7 @@
|
||||
[imageView addTarget:self action:@selector(imageButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
|
||||
|
||||
[self.attachmentViews addObject:imageView];
|
||||
[self addSubview:imageView];
|
||||
//[self addSubview:imageView];
|
||||
|
||||
|
||||
}
|
||||
@@ -289,7 +289,7 @@
|
||||
for ( BITActivityIndicatorButton *imageButton in self.attachmentViews){
|
||||
imageButton.contentMode = UIViewContentModeScaleAspectFit;
|
||||
imageButton.imageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
|
||||
|
||||
if ( !_message.userMessage){
|
||||
imageButton.frame = CGRectMake(FRAME_SIDE_BORDER + (FRAME_SIDE_BORDER + ATTACHMENT_SIZE) * (i%(int)attachmentsPerRow) , floor(i/attachmentsPerRow)*(FRAME_SIDE_BORDER + ATTACHMENT_SIZE) + baseOffsetOfText , ATTACHMENT_SIZE, ATTACHMENT_SIZE);
|
||||
} else {
|
||||
@@ -297,7 +297,11 @@
|
||||
}
|
||||
|
||||
if (!imageButton.superview){
|
||||
[self addSubview:imageButton];
|
||||
if (self.accessoryBackgroundView.superview){
|
||||
[self insertSubview:imageButton aboveSubview:self.accessoryBackgroundView];
|
||||
} else {
|
||||
[self addSubview:imageButton];
|
||||
}
|
||||
}
|
||||
|
||||
i++;
|
||||
|
||||
@@ -637,7 +637,7 @@
|
||||
cell.labelText.delegate = self;
|
||||
cell.labelText.userInteractionEnabled = YES;
|
||||
cell.delegate = self;
|
||||
[cell setAttachments:message.attachments];
|
||||
[cell setAttachments:message.previewableAttachments];
|
||||
|
||||
for (BITFeedbackMessageAttachment *attachment in message.attachments){
|
||||
if (attachment.needsLoadingFromURL && !attachment.isLoading){
|
||||
@@ -812,12 +812,7 @@
|
||||
|
||||
for (int i = 0; i<self.manager.numberOfMessages;i++){
|
||||
BITFeedbackMessage *message = [self.manager messageAtIndex:i];
|
||||
for (BITFeedbackMessageAttachment *attachment in message.attachments){
|
||||
if ([QLPreviewController canPreviewItem:attachment]){
|
||||
[collectedAttachments addObject:attachment];
|
||||
|
||||
}
|
||||
}
|
||||
[collectedAttachments addObjectsFromArray:message.previewableAttachments];
|
||||
}
|
||||
|
||||
self.cachedPreviewItems = collectedAttachments;
|
||||
@@ -832,15 +827,20 @@
|
||||
|
||||
- (id <QLPreviewItem>) previewController: (QLPreviewController *) controller previewItemAtIndex: (NSInteger) index {
|
||||
if (index>=0){
|
||||
__weak QLPreviewController* blockController = controller;
|
||||
BITFeedbackMessageAttachment *attachment = self.cachedPreviewItems[index];
|
||||
if (attachment.needsLoadingFromURL && !attachment.isLoading){
|
||||
attachment.isLoading = YES;
|
||||
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:attachment.sourceURL]];
|
||||
[NSURLConnection sendAsynchronousRequest:request queue:self.thumbnailQueue completionHandler:^(NSURLResponse *response, NSData *responseData, NSError *err) {
|
||||
attachment.isLoading = NO;
|
||||
if (responseData.length){
|
||||
[attachment replaceData:responseData];
|
||||
[controller reloadData];
|
||||
[[BITHockeyManager sharedHockeyManager].feedbackManager saveMessages];
|
||||
[blockController reloadData];
|
||||
|
||||
[[BITHockeyManager sharedHockeyManager].feedbackManager saveMessages];
|
||||
} else {
|
||||
[blockController reloadData];
|
||||
}
|
||||
}];
|
||||
return attachment;
|
||||
|
||||
@@ -83,5 +83,11 @@ typedef NS_ENUM(NSInteger, BITFeedbackMessageStatus) {
|
||||
|
||||
-(void)addAttachmentsObject:(BITFeedbackMessageAttachment *)object;
|
||||
|
||||
/**
|
||||
* Returns an array of attachment objects that may be previewed on this device.
|
||||
*/
|
||||
- (NSArray *)previewableAttachments;
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@@ -90,6 +90,19 @@
|
||||
[attachment deleteContents];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSArray *)previewableAttachments {
|
||||
NSMutableArray *returnArray = [NSMutableArray new];
|
||||
|
||||
for (BITFeedbackMessageAttachment *attachment in self.attachments){
|
||||
if ([QLPreviewController canPreviewItem:attachment ]){
|
||||
[returnArray addObject:attachment];
|
||||
}
|
||||
}
|
||||
|
||||
return returnArray;
|
||||
}
|
||||
|
||||
-(void)addAttachmentsObject:(BITFeedbackMessageAttachment *)object{
|
||||
if (!self.attachments){
|
||||
self.attachments = [NSArray array];
|
||||
|
||||
Reference in New Issue
Block a user