Restore full-screen thumbnails.

pull/1/head
Matthew Chen 7 years ago
parent 9eb2a4f5ad
commit 748b243156

@ -837,9 +837,8 @@ NS_ASSUME_NONNULL_BEGIN
stillImageView.backgroundColor = [UIColor whiteColor]; stillImageView.backgroundColor = [UIColor whiteColor];
[self addAttachmentUploadViewIfNecessary]; [self addAttachmentUploadViewIfNecessary];
__weak UIImageView *weakImageView = stillImageView;
__weak OWSMessageBubbleView *weakSelf = self; __weak OWSMessageBubbleView *weakSelf = self;
__weak UIImageView *weakImageView = stillImageView;
self.loadCellContentBlock = ^{ self.loadCellContentBlock = ^{
OWSMessageBubbleView *strongSelf = weakSelf; OWSMessageBubbleView *strongSelf = weakSelf;
if (!strongSelf) { if (!strongSelf) {
@ -980,6 +979,7 @@ NS_ASSUME_NONNULL_BEGIN
}]; }];
__weak OWSMessageBubbleView *weakSelf = self; __weak OWSMessageBubbleView *weakSelf = self;
__weak UIImageView *weakImageView = stillImageView;
self.loadCellContentBlock = ^{ self.loadCellContentBlock = ^{
OWSMessageBubbleView *strongSelf = weakSelf; OWSMessageBubbleView *strongSelf = weakSelf;
if (!strongSelf) { if (!strongSelf) {
@ -990,6 +990,22 @@ NS_ASSUME_NONNULL_BEGIN
return; return;
} }
stillImageView.image = [strongSelf stillImageView.image = [strongSelf
tryToLoadCellMedia:^{
OWSCAssert([strongSelf.attachmentStream isImage]);
return [strongSelf.attachmentStream
thumbnailImageMediumWithSuccess:^(UIImage *image) {
weakImageView.image = image;
}
failure:^{
DDLogError(@"Could not load thumbnail.");
}];
}
mediaView:stillImageView
cacheKey:strongSelf.attachmentStream.uniqueId
shouldSkipCache:shouldSkipCache
canLoadAsync:YES];
tryToLoadCellMedia:^{ tryToLoadCellMedia:^{
OWSCAssert([strongSelf.attachmentStream isVideo]); OWSCAssert([strongSelf.attachmentStream isVideo]);

@ -89,6 +89,7 @@ typedef void (^OWSThumbnailFailure)(void);
failure:(OWSThumbnailFailure)failure; failure:(OWSThumbnailFailure)failure;
- (nullable UIImage *)thumbnailImageSmallWithSuccess:(OWSThumbnailSuccess)success failure:(OWSThumbnailFailure)failure; - (nullable UIImage *)thumbnailImageSmallWithSuccess:(OWSThumbnailSuccess)success failure:(OWSThumbnailFailure)failure;
- (nullable UIImage *)thumbnailImageMediumWithSuccess:(OWSThumbnailSuccess)success failure:(OWSThumbnailFailure)failure; - (nullable UIImage *)thumbnailImageMediumWithSuccess:(OWSThumbnailSuccess)success failure:(OWSThumbnailFailure)failure;
- (nullable UIImage *)thumbnailImageLargeWithSuccess:(OWSThumbnailSuccess)success failure:(OWSThumbnailFailure)failure;
- (nullable UIImage *)thumbnailImageSmallSync; - (nullable UIImage *)thumbnailImageSmallSync;
// This method should only be invoked by OWSThumbnailService. // This method should only be invoked by OWSThumbnailService.

@ -15,6 +15,13 @@ NS_ASSUME_NONNULL_BEGIN
const NSUInteger kThumbnailDimensionPointsSmall = 200; const NSUInteger kThumbnailDimensionPointsSmall = 200;
const NSUInteger kThumbnailDimensionPointsMedium = 450; const NSUInteger kThumbnailDimensionPointsMedium = 450;
// This size is large enough to render full screen.
const NSUInteger ThumbnailDimensionPointsLarge()
{
CGSize screenSizePoints = UIScreen.mainScreen.bounds.size;
const CGFloat kMinZoomFactor = 2.f;
return MAX(screenSizePoints.width * kMinZoomFactor, screenSizePoints.height * kMinZoomFactor);
}
typedef void (^OWSLoadedThumbnailSuccess)(OWSLoadedThumbnail *loadedThumbnail); typedef void (^OWSLoadedThumbnailSuccess)(OWSLoadedThumbnail *loadedThumbnail);
@ -625,8 +632,10 @@ typedef void (^OWSLoadedThumbnailSuccess)(OWSLoadedThumbnail *loadedThumbnail);
NSUInteger thumbnailDimensionPoints; NSUInteger thumbnailDimensionPoints;
if (maxDimensionHint <= kThumbnailDimensionPointsSmall) { if (maxDimensionHint <= kThumbnailDimensionPointsSmall) {
thumbnailDimensionPoints = kThumbnailDimensionPointsSmall; thumbnailDimensionPoints = kThumbnailDimensionPointsSmall;
} else { } else if (maxDimensionHint <= kThumbnailDimensionPointsMedium) {
thumbnailDimensionPoints = kThumbnailDimensionPointsMedium; thumbnailDimensionPoints = kThumbnailDimensionPointsMedium;
} else {
thumbnailDimensionPoints = ThumbnailDimensionPointsLarge();
} }
return [self thumbnailImageWithThumbnailDimensionPoints:thumbnailDimensionPoints success:success failure:failure]; return [self thumbnailImageWithThumbnailDimensionPoints:thumbnailDimensionPoints success:success failure:failure];
@ -646,6 +655,13 @@ typedef void (^OWSLoadedThumbnailSuccess)(OWSLoadedThumbnail *loadedThumbnail);
failure:failure]; failure:failure];
} }
- (nullable UIImage *)thumbnailImageLargeWithSuccess:(OWSThumbnailSuccess)success failure:(OWSThumbnailFailure)failure
{
return [self thumbnailImageWithThumbnailDimensionPoints:ThumbnailDimensionPointsLarge()
success:success
failure:failure];
}
- (nullable UIImage *)thumbnailImageWithThumbnailDimensionPoints:(NSUInteger)thumbnailDimensionPoints - (nullable UIImage *)thumbnailImageWithThumbnailDimensionPoints:(NSUInteger)thumbnailDimensionPoints
success:(OWSThumbnailSuccess)success success:(OWSThumbnailSuccess)success
failure:(OWSThumbnailFailure)failure failure:(OWSThumbnailFailure)failure

Loading…
Cancel
Save