mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Merge branch 'charlesmchen/mediaAlbumRename'
This commit is contained in:
commit
2c50e34606
9 changed files with 132 additions and 132 deletions
|
@ -156,7 +156,7 @@
|
|||
3496744F2076ACD000080B5F /* LongTextViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3496744E2076ACCE00080B5F /* LongTextViewController.swift */; };
|
||||
349EA07C2162AEA800F7B17F /* OWS111UDAttributesMigration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 349EA07B2162AEA700F7B17F /* OWS111UDAttributesMigration.swift */; };
|
||||
34A55F3720485465002CC6DE /* OWS2FARegistrationViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34A55F3520485464002CC6DE /* OWS2FARegistrationViewController.m */; };
|
||||
34A8B3512190A40E00218A25 /* MediaGalleryCellView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34A8B3502190A40E00218A25 /* MediaGalleryCellView.swift */; };
|
||||
34A8B3512190A40E00218A25 /* MediaAlbumCellView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34A8B3502190A40E00218A25 /* MediaAlbumCellView.swift */; };
|
||||
34A910601FFEB114000C4745 /* OWSBackup.m in Sources */ = {isa = PBXBuildFile; fileRef = 34A9105F1FFEB114000C4745 /* OWSBackup.m */; };
|
||||
34ABB2C42090C59700C727A6 /* OWSResaveCollectionDBMigration.m in Sources */ = {isa = PBXBuildFile; fileRef = 34ABB2C22090C59600C727A6 /* OWSResaveCollectionDBMigration.m */; };
|
||||
34ABB2C52090C59700C727A6 /* OWSResaveCollectionDBMigration.h in Headers */ = {isa = PBXBuildFile; fileRef = 34ABB2C32090C59700C727A6 /* OWSResaveCollectionDBMigration.h */; };
|
||||
|
@ -805,7 +805,7 @@
|
|||
349EA07B2162AEA700F7B17F /* OWS111UDAttributesMigration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OWS111UDAttributesMigration.swift; sourceTree = "<group>"; };
|
||||
34A55F3520485464002CC6DE /* OWS2FARegistrationViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWS2FARegistrationViewController.m; sourceTree = "<group>"; };
|
||||
34A55F3620485464002CC6DE /* OWS2FARegistrationViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWS2FARegistrationViewController.h; sourceTree = "<group>"; };
|
||||
34A8B3502190A40E00218A25 /* MediaGalleryCellView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MediaGalleryCellView.swift; sourceTree = "<group>"; };
|
||||
34A8B3502190A40E00218A25 /* MediaAlbumCellView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MediaAlbumCellView.swift; sourceTree = "<group>"; };
|
||||
34A9105E1FFEB113000C4745 /* OWSBackup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSBackup.h; sourceTree = "<group>"; };
|
||||
34A9105F1FFEB114000C4745 /* OWSBackup.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSBackup.m; sourceTree = "<group>"; };
|
||||
34ABB2C22090C59600C727A6 /* OWSResaveCollectionDBMigration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSResaveCollectionDBMigration.m; sourceTree = "<group>"; };
|
||||
|
@ -1830,7 +1830,7 @@
|
|||
3488F9352191CC4000E524CC /* ConversationMediaView.swift */,
|
||||
34D1F0961F867BFC0066283D /* ConversationViewCell.h */,
|
||||
34D1F0971F867BFC0066283D /* ConversationViewCell.m */,
|
||||
34A8B3502190A40E00218A25 /* MediaGalleryCellView.swift */,
|
||||
34A8B3502190A40E00218A25 /* MediaAlbumCellView.swift */,
|
||||
34D1F0B81F8800D90066283D /* OWSAudioMessageView.h */,
|
||||
34D1F0B91F8800D90066283D /* OWSAudioMessageView.m */,
|
||||
34DBF005206C3CB100025978 /* OWSBubbleShapeView.h */,
|
||||
|
@ -3369,7 +3369,7 @@
|
|||
3403B95D20EA9527001A1F44 /* OWSContactShareButtonsView.m in Sources */,
|
||||
34B0796D1FCF46B100E248C2 /* MainAppContext.m in Sources */,
|
||||
34E3EF101EFC2684007F6822 /* DebugUIPage.m in Sources */,
|
||||
34A8B3512190A40E00218A25 /* MediaGalleryCellView.swift in Sources */,
|
||||
34A8B3512190A40E00218A25 /* MediaAlbumCellView.swift in Sources */,
|
||||
340FC8CD20518C77007AEB0F /* OWSBackupJob.m in Sources */,
|
||||
34D1F0AE1F867BFC0066283D /* OWSMessageCell.m in Sources */,
|
||||
4C4AEC4520EC343B0020E72B /* DismissableTextField.swift in Sources */,
|
||||
|
|
|
@ -339,7 +339,7 @@ private class MockConversationViewItem: NSObject, ConversationViewItem {
|
|||
var authorConversationColorName: String?
|
||||
var hasBodyTextActionContent: Bool = false
|
||||
var hasMediaActionContent: Bool = false
|
||||
var mediaGalleryItems: [ConversationMediaGalleryItem]?
|
||||
var mediaAlbumItems: [ConversationMediaAlbumItem]?
|
||||
|
||||
override init() {
|
||||
super.init()
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
|
||||
import Foundation
|
||||
|
||||
@objc(OWSMediaGalleryCellView)
|
||||
public class MediaGalleryCellView: UIStackView {
|
||||
private let items: [ConversationMediaGalleryItem]
|
||||
@objc(OWSMediaAlbumCellView)
|
||||
public class MediaAlbumCellView: UIStackView {
|
||||
private let items: [ConversationMediaAlbumItem]
|
||||
|
||||
@objc
|
||||
public let itemViews: [ConversationMediaView]
|
||||
|
@ -21,10 +21,10 @@ public class MediaGalleryCellView: UIStackView {
|
|||
|
||||
@objc
|
||||
public required init(mediaCache: NSCache<NSString, AnyObject>,
|
||||
items: [ConversationMediaGalleryItem],
|
||||
items: [ConversationMediaAlbumItem],
|
||||
maxMessageWidth: CGFloat) {
|
||||
self.items = items
|
||||
self.itemViews = MediaGalleryCellView.itemsToDisplay(forItems: items).map {
|
||||
self.itemViews = MediaAlbumCellView.itemsToDisplay(forItems: items).map {
|
||||
ConversationMediaView(mediaCache: mediaCache,
|
||||
attachment: $0.attachment)
|
||||
}
|
||||
|
@ -55,19 +55,19 @@ public class MediaGalleryCellView: UIStackView {
|
|||
case 2:
|
||||
// X X
|
||||
// side-by-side.
|
||||
let imageSize = (maxMessageWidth - MediaGalleryCellView.kSpacingPts) / 2
|
||||
let imageSize = (maxMessageWidth - MediaAlbumCellView.kSpacingPts) / 2
|
||||
autoSet(viewSize: imageSize, ofViews: itemViews)
|
||||
for itemView in itemViews {
|
||||
addArrangedSubview(itemView)
|
||||
}
|
||||
self.axis = .horizontal
|
||||
self.spacing = MediaGalleryCellView.kSpacingPts
|
||||
self.spacing = MediaAlbumCellView.kSpacingPts
|
||||
case 3:
|
||||
// x
|
||||
// X x
|
||||
// Big on left, 2 small on right.
|
||||
let smallImageSize = (maxMessageWidth - MediaGalleryCellView.kSpacingPts * 2) / 3
|
||||
let bigImageSize = smallImageSize * 2 + MediaGalleryCellView.kSpacingPts
|
||||
let smallImageSize = (maxMessageWidth - MediaAlbumCellView.kSpacingPts * 2) / 3
|
||||
let bigImageSize = smallImageSize * 2 + MediaAlbumCellView.kSpacingPts
|
||||
|
||||
guard let leftItemView = itemViews.first else {
|
||||
owsFailDebug("Missing view")
|
||||
|
@ -81,12 +81,12 @@ public class MediaGalleryCellView: UIStackView {
|
|||
axis: .vertical,
|
||||
viewSize: smallImageSize))
|
||||
self.axis = .horizontal
|
||||
self.spacing = MediaGalleryCellView.kSpacingPts
|
||||
self.spacing = MediaAlbumCellView.kSpacingPts
|
||||
case 4:
|
||||
// X X
|
||||
// X X
|
||||
// Square
|
||||
let imageSize = (maxMessageWidth - MediaGalleryCellView.kSpacingPts) / 2
|
||||
let imageSize = (maxMessageWidth - MediaAlbumCellView.kSpacingPts) / 2
|
||||
|
||||
let topViews = Array(itemViews[0..<2])
|
||||
addArrangedSubview(newRow(rowViews: topViews,
|
||||
|
@ -99,13 +99,13 @@ public class MediaGalleryCellView: UIStackView {
|
|||
viewSize: imageSize))
|
||||
|
||||
self.axis = .vertical
|
||||
self.spacing = MediaGalleryCellView.kSpacingPts
|
||||
self.spacing = MediaAlbumCellView.kSpacingPts
|
||||
default:
|
||||
// X X
|
||||
// xxx
|
||||
// 2 big on top, 3 small on bottom.
|
||||
let bigImageSize = (maxMessageWidth - MediaGalleryCellView.kSpacingPts) / 2
|
||||
let smallImageSize = (maxMessageWidth - MediaGalleryCellView.kSpacingPts * 2) / 3
|
||||
let bigImageSize = (maxMessageWidth - MediaAlbumCellView.kSpacingPts) / 2
|
||||
let smallImageSize = (maxMessageWidth - MediaAlbumCellView.kSpacingPts * 2) / 3
|
||||
|
||||
let topViews = Array(itemViews[0..<2])
|
||||
addArrangedSubview(newRow(rowViews: topViews,
|
||||
|
@ -118,9 +118,9 @@ public class MediaGalleryCellView: UIStackView {
|
|||
viewSize: smallImageSize))
|
||||
|
||||
self.axis = .vertical
|
||||
self.spacing = MediaGalleryCellView.kSpacingPts
|
||||
self.spacing = MediaAlbumCellView.kSpacingPts
|
||||
|
||||
if items.count > MediaGalleryCellView.kMaxItems {
|
||||
if items.count > MediaAlbumCellView.kMaxItems {
|
||||
guard let lastView = bottomViews.last else {
|
||||
owsFailDebug("Missing lastView")
|
||||
return
|
||||
|
@ -133,7 +133,7 @@ public class MediaGalleryCellView: UIStackView {
|
|||
lastView.addSubview(tintView)
|
||||
tintView.autoPinEdgesToSuperviewEdges()
|
||||
|
||||
let moreCount = max(1, items.count - MediaGalleryCellView.kMaxItems)
|
||||
let moreCount = max(1, items.count - MediaAlbumCellView.kMaxItems)
|
||||
let moreCountText = OWSFormat.formatInt(Int32(moreCount))
|
||||
let moreText = String(format: NSLocalizedString("MEDIA_GALLERY_MORE_ITEMS_FORMAT",
|
||||
comment: "Format for the 'more items' indicator for media galleries. Embeds {{the number of additional items}}."), moreCountText)
|
||||
|
@ -195,7 +195,7 @@ public class MediaGalleryCellView: UIStackView {
|
|||
axis: UILayoutConstraintAxis) -> UIStackView {
|
||||
let stackView = UIStackView(arrangedSubviews: rowViews)
|
||||
stackView.axis = axis
|
||||
stackView.spacing = MediaGalleryCellView.kSpacingPts
|
||||
stackView.spacing = MediaAlbumCellView.kSpacingPts
|
||||
return stackView
|
||||
}
|
||||
|
||||
|
@ -213,7 +213,7 @@ public class MediaGalleryCellView: UIStackView {
|
|||
}
|
||||
}
|
||||
|
||||
private class func itemsToDisplay(forItems items: [ConversationMediaGalleryItem]) -> [ConversationMediaGalleryItem] {
|
||||
private class func itemsToDisplay(forItems items: [ConversationMediaAlbumItem]) -> [ConversationMediaAlbumItem] {
|
||||
// TODO: Unless design changes, we want to display
|
||||
// items which are still downloading and invalid
|
||||
// items.
|
||||
|
@ -226,7 +226,7 @@ public class MediaGalleryCellView: UIStackView {
|
|||
|
||||
@objc
|
||||
public class func layoutSize(forMaxMessageWidth maxMessageWidth: CGFloat,
|
||||
items: [ConversationMediaGalleryItem]) -> CGSize {
|
||||
items: [ConversationMediaAlbumItem]) -> CGSize {
|
||||
let itemCount = itemsToDisplay(forItems: items).count
|
||||
switch itemCount {
|
||||
case 0, 1, 4:
|
|
@ -240,7 +240,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
|
|||
return self.hasBodyText;
|
||||
case OWSMessageCellType_ContactShare:
|
||||
return NO;
|
||||
case OWSMessageCellType_MediaGallery:
|
||||
case OWSMessageCellType_MediaAlbum:
|
||||
// Is there a gallery title?
|
||||
return self.hasBodyText;
|
||||
}
|
||||
|
@ -324,8 +324,8 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
|
|||
case OWSMessageCellType_ContactShare:
|
||||
bodyMediaView = [self loadViewForContactShare];
|
||||
break;
|
||||
case OWSMessageCellType_MediaGallery:
|
||||
bodyMediaView = [self loadViewForMediaGallery];
|
||||
case OWSMessageCellType_MediaAlbum:
|
||||
bodyMediaView = [self loadViewForMediaAlbum];
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -604,7 +604,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
|
|||
case OWSMessageCellType_DownloadingAttachment:
|
||||
case OWSMessageCellType_ContactShare:
|
||||
return NO;
|
||||
case OWSMessageCellType_MediaGallery:
|
||||
case OWSMessageCellType_MediaAlbum:
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
@ -612,7 +612,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
|
|||
- (BOOL)hasFullWidthMediaView
|
||||
{
|
||||
return (self.hasBodyMediaWithThumbnail || self.cellType == OWSMessageCellType_ContactShare
|
||||
|| self.cellType == OWSMessageCellType_MediaGallery);
|
||||
|| self.cellType == OWSMessageCellType_MediaAlbum);
|
||||
}
|
||||
|
||||
- (BOOL)canFooterOverlayMedia
|
||||
|
@ -780,19 +780,19 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
|
|||
return tapForMoreLabel;
|
||||
}
|
||||
|
||||
- (UIView *)loadViewForMediaGallery
|
||||
- (UIView *)loadViewForMediaAlbum
|
||||
{
|
||||
OWSAssertDebug(self.viewItem.mediaGalleryItems);
|
||||
OWSAssertDebug(self.viewItem.mediaAlbumItems);
|
||||
|
||||
OWSMediaGalleryCellView *galleryView =
|
||||
[[OWSMediaGalleryCellView alloc] initWithMediaCache:self.cellMediaCache
|
||||
items:self.viewItem.mediaGalleryItems
|
||||
maxMessageWidth:self.conversationStyle.maxMessageWidth];
|
||||
OWSMediaAlbumCellView *albumView =
|
||||
[[OWSMediaAlbumCellView alloc] initWithMediaCache:self.cellMediaCache
|
||||
items:self.viewItem.mediaAlbumItems
|
||||
maxMessageWidth:self.conversationStyle.maxMessageWidth];
|
||||
self.loadCellContentBlock = ^{
|
||||
[galleryView loadMedia];
|
||||
[albumView loadMedia];
|
||||
};
|
||||
self.unloadCellContentBlock = ^{
|
||||
[galleryView unloadMedia];
|
||||
[albumView unloadMedia];
|
||||
};
|
||||
for (UIView *itemView in galleryView.itemViews) {
|
||||
OWSBubbleShapeView *strokeView = [[OWSBubbleShapeView alloc] initDraw];
|
||||
|
@ -803,7 +803,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
|
|||
[self.viewConstraints addObjectsFromArray:[strokeView ows_autoPinToSuperviewEdges]];
|
||||
}
|
||||
|
||||
return galleryView;
|
||||
return albumView;
|
||||
}
|
||||
|
||||
- (UIView *)loadViewForMedia
|
||||
|
@ -1050,9 +1050,9 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
|
|||
|
||||
result = CGSizeMake(maxMessageWidth, [OWSContactShareView bubbleHeight]);
|
||||
break;
|
||||
case OWSMessageCellType_MediaGallery:
|
||||
result = [OWSMediaGalleryCellView layoutSizeForMaxMessageWidth:maxMessageWidth
|
||||
items:self.viewItem.mediaGalleryItems];
|
||||
case OWSMessageCellType_MediaAlbum:
|
||||
result = [OWSMediaAlbumCellView layoutSizeForMaxMessageWidth:maxMessageWidth
|
||||
items:self.viewItem.mediaAlbumItems];
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1417,9 +1417,9 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
|
|||
case OWSMessageCellType_ContactShare:
|
||||
[self.delegate didTapContactShareViewItem:self.viewItem];
|
||||
break;
|
||||
case OWSMessageCellType_MediaGallery:
|
||||
case OWSMessageCellType_MediaAlbum:
|
||||
OWSAssertDebug(self.bodyMediaView);
|
||||
OWSAssertDebug(self.viewItem.mediaGalleryItems.count > 0);
|
||||
OWSAssertDebug(self.viewItem.mediaAlbumItems.count > 0);
|
||||
|
||||
// For now, use first valid attachment.
|
||||
TSAttachmentStream *_Nullable attachmentStream = self.viewItem.firstValidGalleryAttachment;
|
||||
|
|
|
@ -18,7 +18,7 @@ typedef NS_ENUM(NSInteger, OWSMessageCellType) {
|
|||
OWSMessageCellType_GenericAttachment,
|
||||
OWSMessageCellType_DownloadingAttachment,
|
||||
OWSMessageCellType_ContactShare,
|
||||
OWSMessageCellType_MediaGallery,
|
||||
OWSMessageCellType_MediaAlbum,
|
||||
};
|
||||
|
||||
NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType);
|
||||
|
@ -38,7 +38,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType);
|
|||
@class TSThread;
|
||||
@class YapDatabaseReadTransaction;
|
||||
|
||||
@interface ConversationMediaGalleryItem : NSObject
|
||||
@interface ConversationMediaAlbumItem : NSObject
|
||||
|
||||
@property (nonatomic, readonly) TSAttachment *attachment;
|
||||
|
||||
|
@ -109,7 +109,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType);
|
|||
@property (nonatomic, readonly, nullable) TSAttachmentStream *attachmentStream;
|
||||
@property (nonatomic, readonly, nullable) TSAttachmentPointer *attachmentPointer;
|
||||
@property (nonatomic, readonly) CGSize mediaSize;
|
||||
@property (nonatomic, readonly, nullable) NSArray<ConversationMediaGalleryItem *> *mediaGalleryItems;
|
||||
@property (nonatomic, readonly, nullable) NSArray<ConversationMediaAlbumItem *> *mediaAlbumItems;
|
||||
|
||||
@property (nonatomic, readonly, nullable) DisplayableText *displayableQuotedText;
|
||||
@property (nonatomic, readonly, nullable) NSString *quotedAttachmentMimetype;
|
||||
|
|
|
@ -41,14 +41,14 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|||
return @"OWSMessageCellType_Unknown";
|
||||
case OWSMessageCellType_ContactShare:
|
||||
return @"OWSMessageCellType_ContactShare";
|
||||
case OWSMessageCellType_MediaGallery:
|
||||
return @"OWSMessageCellType_MediaGallery";
|
||||
case OWSMessageCellType_MediaAlbum:
|
||||
return @"OWSMessageCellType_MediaAlbum";
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
@implementation ConversationMediaGalleryItem
|
||||
@implementation ConversationMediaAlbumItem
|
||||
|
||||
- (instancetype)initWithAttachment:(TSAttachment *)attachment
|
||||
attachmentStream:(nullable TSAttachmentStream *)attachmentStream
|
||||
|
@ -95,7 +95,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|||
@property (nonatomic, nullable) TSAttachmentPointer *attachmentPointer;
|
||||
@property (nonatomic, nullable) ContactShareViewModel *contactShare;
|
||||
@property (nonatomic) CGSize mediaSize;
|
||||
@property (nonatomic, nullable) NSArray<ConversationMediaGalleryItem *> *mediaGalleryItems;
|
||||
@property (nonatomic, nullable) NSArray<ConversationMediaAlbumItem *> *mediaAlbumItems;
|
||||
@property (nonatomic, nullable) NSString *systemMessageText;
|
||||
@property (nonatomic, nullable) TSThread *incomingMessageAuthorThread;
|
||||
@property (nonatomic, nullable) NSString *authorConversationColorName;
|
||||
|
@ -160,7 +160,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|||
self.displayableQuotedText = nil;
|
||||
self.quotedReply = nil;
|
||||
self.systemMessageText = nil;
|
||||
self.mediaGalleryItems = nil;
|
||||
self.mediaAlbumItems = nil;
|
||||
|
||||
[self updateAuthorConversationColorNameWithTransaction:transaction];
|
||||
|
||||
|
@ -411,13 +411,13 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|||
|
||||
- (nullable TSAttachmentStream *)firstValidGalleryAttachment
|
||||
{
|
||||
OWSAssertDebug(self.mediaGalleryItems.count > 0);
|
||||
OWSAssertDebug(self.mediaAlbumItems.count > 0);
|
||||
|
||||
// For now, use first valid attachment.
|
||||
TSAttachmentStream *_Nullable attachmentStream = nil;
|
||||
for (ConversationMediaGalleryItem *mediaGalleryItem in self.mediaGalleryItems) {
|
||||
if (mediaGalleryItem.attachmentStream && mediaGalleryItem.attachmentStream.isValidVisualMedia) {
|
||||
attachmentStream = mediaGalleryItem.attachmentStream;
|
||||
for (ConversationMediaAlbumItem *mediaAlbumItem in self.mediaAlbumItems) {
|
||||
if (mediaAlbumItem.attachmentStream && mediaAlbumItem.attachmentStream.isValidVisualMedia) {
|
||||
attachmentStream = mediaAlbumItem.attachmentStream;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -570,11 +570,11 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|||
}
|
||||
|
||||
NSArray<TSAttachment *> *attachments = [message attachmentsWithTransaction:transaction];
|
||||
if ([message isMediaGalleryWithTransaction:transaction]) {
|
||||
if ([message isMediaAlbumWithTransaction:transaction]) {
|
||||
OWSAssertDebug(attachments.count > 0);
|
||||
NSArray<ConversationMediaGalleryItem *> *mediaGalleryItems = [self mediaGalleryItemsForAttachments:attachments];
|
||||
self.mediaGalleryItems = mediaGalleryItems;
|
||||
self.messageCellType = OWSMessageCellType_MediaGallery;
|
||||
NSArray<ConversationMediaAlbumItem *> *mediaAlbumItems = [self mediaAlbumItemsForAttachments:attachments];
|
||||
self.mediaAlbumItems = mediaAlbumItems;
|
||||
self.messageCellType = OWSMessageCellType_MediaAlbum;
|
||||
NSString *_Nullable galleryTitle = [message bodyTextWithTransaction:transaction];
|
||||
if (galleryTitle) {
|
||||
self.displayableBodyText = [self displayableBodyTextForText:galleryTitle interactionId:message.uniqueId];
|
||||
|
@ -682,51 +682,51 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|||
}
|
||||
}
|
||||
|
||||
- (NSArray<ConversationMediaGalleryItem *> *)mediaGalleryItemsForAttachments:(NSArray<TSAttachment *> *)attachments
|
||||
- (NSArray<ConversationMediaAlbumItem *> *)mediaAlbumItemsForAttachments:(NSArray<TSAttachment *> *)attachments
|
||||
{
|
||||
OWSAssertIsOnMainThread();
|
||||
OWSAssertDebug(attachments.count > 0);
|
||||
|
||||
NSMutableArray<ConversationMediaGalleryItem *> *mediaGalleryItems = [NSMutableArray new];
|
||||
NSMutableArray<ConversationMediaAlbumItem *> *mediaAlbumItems = [NSMutableArray new];
|
||||
for (TSAttachment *attachment in attachments) {
|
||||
NSString *_Nullable caption = (attachment.caption
|
||||
? [self displayableCaptionForText:attachment.caption attachmentId:attachment.uniqueId].displayText
|
||||
: nil);
|
||||
|
||||
if (![attachment isKindOfClass:[TSAttachmentStream class]]) {
|
||||
[mediaGalleryItems addObject:[[ConversationMediaGalleryItem alloc] initWithAttachment:attachment
|
||||
attachmentStream:nil
|
||||
caption:caption
|
||||
mediaSize:CGSizeZero]];
|
||||
[mediaAlbumItems addObject:[[ConversationMediaAlbumItem alloc] initWithAttachment:attachment
|
||||
attachmentStream:nil
|
||||
caption:caption
|
||||
mediaSize:CGSizeZero]];
|
||||
continue;
|
||||
}
|
||||
TSAttachmentStream *attachmentStream = (TSAttachmentStream *)attachment;
|
||||
if (![attachmentStream isValidVisualMedia]) {
|
||||
OWSLogWarn(@"Filtering invalid media.");
|
||||
[mediaGalleryItems addObject:[[ConversationMediaGalleryItem alloc] initWithAttachment:attachment
|
||||
attachmentStream:nil
|
||||
caption:caption
|
||||
mediaSize:CGSizeZero]];
|
||||
[mediaAlbumItems addObject:[[ConversationMediaAlbumItem alloc] initWithAttachment:attachment
|
||||
attachmentStream:nil
|
||||
caption:caption
|
||||
mediaSize:CGSizeZero]];
|
||||
continue;
|
||||
}
|
||||
CGSize mediaSize = [attachmentStream imageSize];
|
||||
if (mediaSize.width <= 0 || mediaSize.height <= 0) {
|
||||
OWSLogWarn(@"Filtering media with invalid size.");
|
||||
[mediaGalleryItems addObject:[[ConversationMediaGalleryItem alloc] initWithAttachment:attachment
|
||||
attachmentStream:nil
|
||||
caption:caption
|
||||
mediaSize:CGSizeZero]];
|
||||
[mediaAlbumItems addObject:[[ConversationMediaAlbumItem alloc] initWithAttachment:attachment
|
||||
attachmentStream:nil
|
||||
caption:caption
|
||||
mediaSize:CGSizeZero]];
|
||||
continue;
|
||||
}
|
||||
|
||||
ConversationMediaGalleryItem *mediaGalleryItem =
|
||||
[[ConversationMediaGalleryItem alloc] initWithAttachment:attachment
|
||||
attachmentStream:attachmentStream
|
||||
caption:caption
|
||||
mediaSize:mediaSize];
|
||||
[mediaGalleryItems addObject:mediaGalleryItem];
|
||||
ConversationMediaAlbumItem *mediaAlbumItem =
|
||||
[[ConversationMediaAlbumItem alloc] initWithAttachment:attachment
|
||||
attachmentStream:attachmentStream
|
||||
caption:caption
|
||||
mediaSize:mediaSize];
|
||||
[mediaAlbumItems addObject:mediaAlbumItem];
|
||||
}
|
||||
return mediaGalleryItems;
|
||||
return mediaAlbumItems;
|
||||
}
|
||||
|
||||
- (NSString *)systemMessageTextWithTransaction:(YapDatabaseReadTransaction *)transaction
|
||||
|
@ -854,7 +854,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|||
case OWSMessageCellType_AnimatedImage:
|
||||
case OWSMessageCellType_Audio:
|
||||
case OWSMessageCellType_Video:
|
||||
case OWSMessageCellType_MediaGallery:
|
||||
case OWSMessageCellType_MediaAlbum:
|
||||
case OWSMessageCellType_GenericAttachment: {
|
||||
OWSAssertDebug(self.displayableBodyText);
|
||||
[UIPasteboard.generalPasteboard setString:self.displayableBodyText.fullText];
|
||||
|
@ -898,7 +898,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|||
OWSFailDebug(@"Can't copy not-yet-downloaded attachment");
|
||||
break;
|
||||
}
|
||||
case OWSMessageCellType_MediaGallery: {
|
||||
case OWSMessageCellType_MediaAlbum: {
|
||||
OWSFailDebug(@"Can't copy media gallery");
|
||||
break;
|
||||
}
|
||||
|
@ -942,13 +942,13 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|||
OWSFailDebug(@"Can't share not-yet-downloaded attachment");
|
||||
break;
|
||||
}
|
||||
case OWSMessageCellType_MediaGallery: {
|
||||
case OWSMessageCellType_MediaAlbum: {
|
||||
// TODO: We need a "canShareMediaAction" method.
|
||||
OWSAssertDebug(self.mediaGalleryItems);
|
||||
OWSAssertDebug(self.mediaAlbumItems);
|
||||
NSMutableArray<TSAttachmentStream *> *attachmentStreams = [NSMutableArray new];
|
||||
for (ConversationMediaGalleryItem *mediaGalleryItem in self.mediaGalleryItems) {
|
||||
if (mediaGalleryItem.attachmentStream) {
|
||||
[attachmentStreams addObject:mediaGalleryItem.attachmentStream];
|
||||
for (ConversationMediaAlbumItem *mediaAlbumItem in self.mediaAlbumItems) {
|
||||
if (mediaAlbumItem.attachmentStream) {
|
||||
[attachmentStreams addObject:mediaAlbumItem.attachmentStream];
|
||||
}
|
||||
}
|
||||
if (attachmentStreams.count < 1) {
|
||||
|
@ -978,7 +978,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|||
return UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(self.attachmentStream.originalFilePath);
|
||||
case OWSMessageCellType_GenericAttachment:
|
||||
case OWSMessageCellType_DownloadingAttachment:
|
||||
case OWSMessageCellType_MediaGallery:
|
||||
case OWSMessageCellType_MediaAlbum:
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
@ -1001,17 +1001,17 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|||
case OWSMessageCellType_GenericAttachment:
|
||||
case OWSMessageCellType_DownloadingAttachment:
|
||||
return NO;
|
||||
case OWSMessageCellType_MediaGallery: {
|
||||
for (ConversationMediaGalleryItem *mediaGalleryItem in self.mediaGalleryItems) {
|
||||
if (!mediaGalleryItem.attachmentStream) {
|
||||
case OWSMessageCellType_MediaAlbum: {
|
||||
for (ConversationMediaAlbumItem *mediaAlbumItem in self.mediaAlbumItems) {
|
||||
if (!mediaAlbumItem.attachmentStream) {
|
||||
continue;
|
||||
}
|
||||
if (mediaGalleryItem.attachmentStream.isImage || mediaGalleryItem.attachmentStream.isAnimated) {
|
||||
if (mediaAlbumItem.attachmentStream.isImage || mediaAlbumItem.attachmentStream.isAnimated) {
|
||||
return YES;
|
||||
}
|
||||
if (mediaGalleryItem.attachmentStream.isVideo) {
|
||||
if (mediaAlbumItem.attachmentStream.isVideo) {
|
||||
if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(
|
||||
mediaGalleryItem.attachmentStream.originalFilePath)) {
|
||||
mediaAlbumItem.attachmentStream.originalFilePath)) {
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
@ -1064,15 +1064,15 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|||
OWSFailDebug(@"Can't save not-yet-downloaded attachment");
|
||||
break;
|
||||
}
|
||||
case OWSMessageCellType_MediaGallery: {
|
||||
case OWSMessageCellType_MediaAlbum: {
|
||||
// TODO: Use PHPhotoLibrary.
|
||||
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
|
||||
for (ConversationMediaGalleryItem *mediaGalleryItem in self.mediaGalleryItems) {
|
||||
if (!mediaGalleryItem.attachmentStream) {
|
||||
for (ConversationMediaAlbumItem *mediaAlbumItem in self.mediaAlbumItems) {
|
||||
if (!mediaAlbumItem.attachmentStream) {
|
||||
continue;
|
||||
}
|
||||
if (mediaGalleryItem.attachmentStream.isImage || mediaGalleryItem.attachmentStream.isAnimated) {
|
||||
NSData *data = [NSData dataWithContentsOfURL:[mediaGalleryItem.attachmentStream originalMediaURL]];
|
||||
if (mediaAlbumItem.attachmentStream.isImage || mediaAlbumItem.attachmentStream.isAnimated) {
|
||||
NSData *data = [NSData dataWithContentsOfURL:[mediaAlbumItem.attachmentStream originalMediaURL]];
|
||||
if (!data) {
|
||||
OWSFailDebug(@"Could not load image data");
|
||||
continue;
|
||||
|
@ -1085,11 +1085,11 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|||
}
|
||||
}];
|
||||
}
|
||||
if (mediaGalleryItem.attachmentStream.isVideo) {
|
||||
if (mediaAlbumItem.attachmentStream.isVideo) {
|
||||
if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(
|
||||
mediaGalleryItem.attachmentStream.originalFilePath)) {
|
||||
mediaAlbumItem.attachmentStream.originalFilePath)) {
|
||||
UISaveVideoAtPathToSavedPhotosAlbum(
|
||||
mediaGalleryItem.attachmentStream.originalFilePath, self, nil, nil);
|
||||
mediaAlbumItem.attachmentStream.originalFilePath, self, nil, nil);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1124,7 +1124,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|||
case OWSMessageCellType_DownloadingAttachment: {
|
||||
return NO;
|
||||
}
|
||||
case OWSMessageCellType_MediaGallery:
|
||||
case OWSMessageCellType_MediaAlbum:
|
||||
// TODO: I suspect we need separate "can save media", "can share media", etc. methods.
|
||||
return self.firstValidGalleryAttachment != nil;
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
}],
|
||||
[OWSTableItem itemWithTitle:@"Send Media Gallery"
|
||||
actionBlock:^{
|
||||
[DebugUIMessages sendMediaGalleryInThread:thread];
|
||||
[DebugUIMessages sendMediaAlbumInThread:thread];
|
||||
}],
|
||||
[OWSTableItem itemWithTitle:@"Send Exemplary Media Galleries"
|
||||
actionBlock:^{
|
||||
|
@ -4642,7 +4642,7 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
|
|||
}
|
||||
}
|
||||
|
||||
+ (void)sendMediaGalleryInThread:(TSThread *)thread
|
||||
+ (void)sendMediaAlbumInThread:(TSThread *)thread
|
||||
{
|
||||
OWSLogInfo(@"");
|
||||
|
||||
|
@ -4650,32 +4650,32 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
|
|||
const uint32_t kMaxImageCount = 10;
|
||||
uint32_t imageCount = kMinImageCount + arc4random_uniform(kMaxImageCount - kMinImageCount);
|
||||
NSString *_Nullable messageBody = (arc4random_uniform(2) > 0 ? @"This is the media gallery title..." : nil);
|
||||
[self sendMediaGalleryInThread:thread imageCount:imageCount messageBody:messageBody];
|
||||
[self sendMediaAlbumInThread:thread imageCount:imageCount messageBody:messageBody];
|
||||
}
|
||||
|
||||
+ (void)sendExemplaryMediaGalleriesInThread:(TSThread *)thread
|
||||
{
|
||||
OWSLogInfo(@"");
|
||||
|
||||
[self sendMediaGalleryInThread:thread imageCount:2 messageBody:nil];
|
||||
[self sendMediaGalleryInThread:thread imageCount:3 messageBody:nil];
|
||||
[self sendMediaGalleryInThread:thread imageCount:4 messageBody:nil];
|
||||
[self sendMediaGalleryInThread:thread imageCount:5 messageBody:nil];
|
||||
[self sendMediaGalleryInThread:thread imageCount:6 messageBody:nil];
|
||||
[self sendMediaGalleryInThread:thread imageCount:7 messageBody:nil];
|
||||
[self sendMediaAlbumInThread:thread imageCount:2 messageBody:nil];
|
||||
[self sendMediaAlbumInThread:thread imageCount:3 messageBody:nil];
|
||||
[self sendMediaAlbumInThread:thread imageCount:4 messageBody:nil];
|
||||
[self sendMediaAlbumInThread:thread imageCount:5 messageBody:nil];
|
||||
[self sendMediaAlbumInThread:thread imageCount:6 messageBody:nil];
|
||||
[self sendMediaAlbumInThread:thread imageCount:7 messageBody:nil];
|
||||
NSString *messageBody = @"This is the media gallery title...";
|
||||
[self sendMediaGalleryInThread:thread imageCount:2 messageBody:messageBody];
|
||||
[self sendMediaGalleryInThread:thread imageCount:3 messageBody:messageBody];
|
||||
[self sendMediaGalleryInThread:thread imageCount:4 messageBody:messageBody];
|
||||
[self sendMediaGalleryInThread:thread imageCount:5 messageBody:messageBody];
|
||||
[self sendMediaGalleryInThread:thread imageCount:6 messageBody:messageBody];
|
||||
[self sendMediaGalleryInThread:thread imageCount:7 messageBody:messageBody];
|
||||
[self sendMediaAlbumInThread:thread imageCount:2 messageBody:messageBody];
|
||||
[self sendMediaAlbumInThread:thread imageCount:3 messageBody:messageBody];
|
||||
[self sendMediaAlbumInThread:thread imageCount:4 messageBody:messageBody];
|
||||
[self sendMediaAlbumInThread:thread imageCount:5 messageBody:messageBody];
|
||||
[self sendMediaAlbumInThread:thread imageCount:6 messageBody:messageBody];
|
||||
[self sendMediaAlbumInThread:thread imageCount:7 messageBody:messageBody];
|
||||
}
|
||||
|
||||
+ (void)sendMediaGalleryInThread:(TSThread *)thread
|
||||
imageCount:(uint32_t)imageCount
|
||||
messageBody:(nullable NSString *)messageBody
|
||||
fakeAssetLoaders:(NSArray<DebugUIMessagesAssetLoader *> *)fakeAssetLoaders
|
||||
+ (void)sendMediaAlbumInThread:(TSThread *)thread
|
||||
imageCount:(uint32_t)imageCount
|
||||
messageBody:(nullable NSString *)messageBody
|
||||
fakeAssetLoaders:(NSArray<DebugUIMessagesAssetLoader *> *)fakeAssetLoaders
|
||||
{
|
||||
OWSAssertDebug(imageCount > 0);
|
||||
OWSLogInfo(@"");
|
||||
|
@ -4706,9 +4706,9 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
|
|||
}];
|
||||
}
|
||||
|
||||
+ (void)sendMediaGalleryInThread:(TSThread *)thread
|
||||
imageCount:(uint32_t)imageCount
|
||||
messageBody:(nullable NSString *)messageBody
|
||||
+ (void)sendMediaAlbumInThread:(TSThread *)thread
|
||||
imageCount:(uint32_t)imageCount
|
||||
messageBody:(nullable NSString *)messageBody
|
||||
{
|
||||
OWSAssertDebug(thread);
|
||||
|
||||
|
@ -4721,10 +4721,10 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac
|
|||
];
|
||||
[DebugUIMessagesAssetLoader prepareAssetLoaders:fakeAssetLoaders
|
||||
success:^{
|
||||
[self sendMediaGalleryInThread:thread
|
||||
imageCount:imageCount
|
||||
messageBody:messageBody
|
||||
fakeAssetLoaders:fakeAssetLoaders];
|
||||
[self sendMediaAlbumInThread:thread
|
||||
imageCount:imageCount
|
||||
messageBody:messageBody
|
||||
fakeAssetLoaders:fakeAssetLoaders];
|
||||
}
|
||||
failure:^{
|
||||
OWSLogError(@"Could not prepare fake asset loaders.");
|
||||
|
|
|
@ -43,7 +43,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
- (BOOL)hasAttachments;
|
||||
- (NSArray<TSAttachment *> *)attachmentsWithTransaction:(YapDatabaseReadTransaction *)transaction;
|
||||
|
||||
- (BOOL)isMediaGalleryWithTransaction:(YapDatabaseReadTransaction *)transaction;
|
||||
- (BOOL)isMediaAlbumWithTransaction:(YapDatabaseReadTransaction *)transaction;
|
||||
|
||||
- (void)setQuotedMessageThumbnailAttachmentStream:(TSAttachmentStream *)attachmentStream;
|
||||
|
||||
|
|
|
@ -214,7 +214,7 @@ static const NSUInteger OWSMessageSchemaVersion = 4;
|
|||
return [attachments copy];
|
||||
}
|
||||
|
||||
- (BOOL)isMediaGalleryWithTransaction:(YapDatabaseReadTransaction *)transaction
|
||||
- (BOOL)isMediaAlbumWithTransaction:(YapDatabaseReadTransaction *)transaction
|
||||
{
|
||||
NSArray<TSAttachment *> *attachments = [self attachmentsWithTransaction:transaction];
|
||||
if (attachments.count < 2) {
|
||||
|
|
Loading…
Reference in a new issue