Merge branch 'charlesmchen/tapAlbumWithFailedImage2' into release/2.34.0

pull/1/head
Matthew Chen 6 years ago
commit a372e00ab3

@ -1,5 +1,5 @@
// //
// Copyright (c) 2018 Open Whisper Systems. All rights reserved. // Copyright (c) 2019 Open Whisper Systems. All rights reserved.
// //
import Foundation import Foundation

@ -1,5 +1,5 @@
// //
// Copyright (c) 2018 Open Whisper Systems. All rights reserved. // Copyright (c) 2019 Open Whisper Systems. All rights reserved.
// //
import Foundation import Foundation
@ -11,6 +11,9 @@ public class MediaAlbumCellView: UIStackView {
@objc @objc
public let itemViews: [ConversationMediaView] public let itemViews: [ConversationMediaView]
@objc
public var moreItemsView: ConversationMediaView?
private static let kSpacingPts: CGFloat = 2 private static let kSpacingPts: CGFloat = 2
private static let kMaxItems = 5 private static let kMaxItems = 5
@ -41,8 +44,6 @@ public class MediaAlbumCellView: UIStackView {
} }
private func createContents(maxMessageWidth: CGFloat) { private func createContents(maxMessageWidth: CGFloat) {
var moreItemViews = [ConversationMediaView]()
switch itemViews.count { switch itemViews.count {
case 0: case 0:
owsFailDebug("No item views.") owsFailDebug("No item views.")
@ -129,7 +130,7 @@ public class MediaAlbumCellView: UIStackView {
return return
} }
moreItemViews.append(lastView) moreItemsView = lastView
let tintView = UIView() let tintView = UIView()
tintView.backgroundColor = UIColor(white: 0, alpha: 0.4) tintView.backgroundColor = UIColor(white: 0, alpha: 0.4)
@ -151,7 +152,7 @@ public class MediaAlbumCellView: UIStackView {
} }
for itemView in itemViews { for itemView in itemViews {
guard !moreItemViews.contains(itemView) else { guard moreItemsView != itemView else {
// Don't display the caption indicator on // Don't display the caption indicator on
// the "more" item, if any. // the "more" item, if any.
continue continue
@ -277,4 +278,9 @@ public class MediaAlbumCellView: UIStackView {
} }
return bestMediaView return bestMediaView
} }
@objc
public func isMoreItemsView(mediaView: ConversationMediaView) -> Bool {
return moreItemsView == mediaView
}
} }

@ -1,5 +1,5 @@
// //
// Copyright (c) 2018 Open Whisper Systems. All rights reserved. // Copyright (c) 2019 Open Whisper Systems. All rights reserved.
// //
#import "OWSMessageBubbleView.h" #import "OWSMessageBubbleView.h"
@ -1376,10 +1376,6 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
OWSAssertDebug(self.bodyMediaView); OWSAssertDebug(self.bodyMediaView);
OWSAssertDebug(self.viewItem.mediaAlbumItems.count > 0); OWSAssertDebug(self.viewItem.mediaAlbumItems.count > 0);
if (self.viewItem.mediaAlbumHasFailedAttachment) {
[self.delegate didTapFailedIncomingAttachment:self.viewItem];
return;
}
if (![self.bodyMediaView isKindOfClass:[OWSMediaAlbumCellView class]]) { if (![self.bodyMediaView isKindOfClass:[OWSMediaAlbumCellView class]]) {
OWSFailDebug(@"Unexpected body media view: %@", self.bodyMediaView.class); OWSFailDebug(@"Unexpected body media view: %@", self.bodyMediaView.class);
return; return;
@ -1392,8 +1388,21 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
return; return;
} }
if ([mediaAlbumCellView isMoreItemsViewWithMediaView:mediaView]
&& self.viewItem.mediaAlbumHasFailedAttachment) {
[self.delegate didTapFailedIncomingAttachment:self.viewItem];
return;
}
TSAttachment *attachment = mediaView.attachment; TSAttachment *attachment = mediaView.attachment;
if (![attachment isKindOfClass:[TSAttachmentStream class]]) { if ([attachment isKindOfClass:[TSAttachmentPointer class]]) {
TSAttachmentPointer *attachmentPointer = (TSAttachmentPointer *)attachment;
if (attachmentPointer.state == TSAttachmentPointerStateFailed) {
// Treat the tap as a "retry" tap if the user taps on a failed download.
[self.delegate didTapFailedIncomingAttachment:self.viewItem];
return;
}
} else if (![attachment isKindOfClass:[TSAttachmentStream class]]) {
OWSLogWarn(@"Media attachment not yet downloaded."); OWSLogWarn(@"Media attachment not yet downloaded.");
return; return;
} }

@ -1,5 +1,5 @@
// //
// Copyright (c) 2018 Open Whisper Systems. All rights reserved. // Copyright (c) 2019 Open Whisper Systems. All rights reserved.
// //
#import "ConversationViewLayout.h" #import "ConversationViewLayout.h"
@ -47,6 +47,8 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType);
@property (nonatomic, readonly, nullable) NSString *caption; @property (nonatomic, readonly, nullable) NSString *caption;
@property (nonatomic, readonly) BOOL isFailedDownload;
@end @end
#pragma mark - #pragma mark -

@ -1,5 +1,5 @@
// //
// Copyright (c) 2018 Open Whisper Systems. All rights reserved. // Copyright (c) 2019 Open Whisper Systems. All rights reserved.
// //
#import "ConversationViewItem.h" #import "ConversationViewItem.h"
@ -64,6 +64,16 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
return self; return self;
} }
- (BOOL)isFailedDownload
{
if (![self.attachment isKindOfClass:[TSAttachmentPointer class]]) {
return NO;
}
TSAttachmentPointer *attachmentPointer = (TSAttachmentPointer *)self.attachment;
return attachmentPointer.state == TSAttachmentPointerStateFailed;
}
@end @end
#pragma mark - #pragma mark -
@ -1080,13 +1090,10 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
OWSAssertDebug(self.mediaAlbumItems.count > 0); OWSAssertDebug(self.mediaAlbumItems.count > 0);
for (ConversationMediaAlbumItem *mediaAlbumItem in self.mediaAlbumItems) { for (ConversationMediaAlbumItem *mediaAlbumItem in self.mediaAlbumItems) {
if ([mediaAlbumItem.attachment isKindOfClass:[TSAttachmentPointer class]]) { if (mediaAlbumItem.isFailedDownload) {
TSAttachmentPointer *attachmentPointer = (TSAttachmentPointer *)mediaAlbumItem.attachment;
if (attachmentPointer.state == TSAttachmentPointerStateFailed) {
return YES; return YES;
} }
} }
}
return NO; return NO;
} }

Loading…
Cancel
Save