From 074886ae46c8ffc564b6fd18c95a21804bf99b65 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Sat, 24 Mar 2018 00:58:22 +0400 Subject: [PATCH] no message --- LegacyComponents/TGCameraCapturedVideo.h | 2 +- LegacyComponents/TGCameraCapturedVideo.m | 5 +++ .../TGMediaPickerPhotoStripCell.m | 40 ++++++++++++++----- LegacyComponents/TGMenuSheetTitleItemView.m | 2 +- LegacyComponents/TGMessage.mm | 21 ++++++++++ 5 files changed, 58 insertions(+), 12 deletions(-) diff --git a/LegacyComponents/TGCameraCapturedVideo.h b/LegacyComponents/TGCameraCapturedVideo.h index 326a183e01..23b96a7c0d 100644 --- a/LegacyComponents/TGCameraCapturedVideo.h +++ b/LegacyComponents/TGCameraCapturedVideo.h @@ -7,7 +7,7 @@ @interface TGCameraCapturedVideo : NSObject @property (nonatomic, readonly) AVURLAsset *avAsset; -@property (nonatomic, readonly) NSTimeInterval duration; +@property (nonatomic, readonly) NSTimeInterval videoDuration; - (instancetype)initWithURL:(NSURL *)url; diff --git a/LegacyComponents/TGCameraCapturedVideo.m b/LegacyComponents/TGCameraCapturedVideo.m index be0bfc6591..05fafa2751 100644 --- a/LegacyComponents/TGCameraCapturedVideo.m +++ b/LegacyComponents/TGCameraCapturedVideo.m @@ -49,6 +49,11 @@ return _cachedSize; } +- (NSTimeInterval)videoDuration +{ + return [self originalDuration]; +} + - (NSTimeInterval)originalDuration { if (_cachedDuration > DBL_EPSILON) diff --git a/LegacyComponents/TGMediaPickerPhotoStripCell.m b/LegacyComponents/TGMediaPickerPhotoStripCell.m index 93bb1f5077..6c97f45ccb 100644 --- a/LegacyComponents/TGMediaPickerPhotoStripCell.m +++ b/LegacyComponents/TGMediaPickerPhotoStripCell.m @@ -15,6 +15,7 @@ #import +#import "TGCameraCapturedVideo.h" #import "TGMediaAsset+TGMediaEditableItem.h" NSString *const TGMediaPickerPhotoStripCellKind = @"PhotoStripCell"; @@ -121,6 +122,8 @@ NSString *const TGMediaPickerPhotoStripCellKind = @"PhotoStripCell"; { _item = item; + [_adjustmentsDisposable setDisposable:nil]; + if (removable) { if (_deleteButton == nil) @@ -166,6 +169,33 @@ NSString *const TGMediaPickerPhotoStripCellKind = @"PhotoStripCell"; [_imageView setSignal:signal]; + if ([item isKindOfClass:[TGCameraCapturedVideo class]]) + { + TGCameraCapturedVideo *video = (TGCameraCapturedVideo *)item; + _gradientView.hidden = false; + _label.text = [NSString stringWithFormat:@"%d:%02d", (int)ceil(video.videoDuration) / 60, (int)ceil(video.videoDuration) % 60]; + _iconView.image = TGComponentsImageNamed(@"ModernMediaItemVideoIcon"); + + if (self.editingContext != nil) + { + SSignal *adjustmentsSignal = [self.editingContext adjustmentsSignalForItem:video]; + + __weak TGMediaPickerPhotoStripCell *weakSelf = self; + [_adjustmentsDisposable setDisposable:[adjustmentsSignal startWithNext:^(TGVideoEditAdjustments *next) + { + __strong TGMediaPickerPhotoStripCell *strongSelf = weakSelf; + if (strongSelf == nil) + return; + + if ([next isKindOfClass:[TGVideoEditAdjustments class]]) + [strongSelf _layoutImageForOriginalSize:next.originalSize cropRect:next.cropRect cropOrientation:next.cropOrientation]; + else + [strongSelf _layoutImageWithoutAdjustments]; + }]]; + } + return; + } + TGMediaAsset *asset = (TGMediaAsset *)item; if (![asset isKindOfClass:[TGMediaAsset class]]) return; @@ -347,16 +377,6 @@ NSString *const TGMediaPickerPhotoStripCellKind = @"PhotoStripCell"; UIImage *icon = TGComponentsImageNamed(@"CameraDeleteIcon.png"); [icon drawAtPoint:CGPointMake((size.width - icon.size.width) / 2.0f, (size.height - icon.size.height) / 2.0f)]; -// CGContextSetShadowWithColor(context, CGSizeZero, 0.0f, [UIColor clearColor].CGColor); -// CGContextSetLineCap(context, kCGLineCapRound); -// CGContextSetLineWidth(context, 1.75f); -// CGContextMoveToPoint(context, insideInset + 8.0f, insideInset + 8.0f); -// CGContextAddLineToPoint(context, size.width - insideInset - 8.0f, size.height - insideInset - 8.0f); -// CGContextStrokePath(context); -// -// CGContextMoveToPoint(context, size.width - insideInset - 8.0f, insideInset + 8.0f); -// CGContextAddLineToPoint(context, insideInset + 8.0f, size.height - insideInset - 8.0f); -// CGContextStrokePath(context); image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); diff --git a/LegacyComponents/TGMenuSheetTitleItemView.m b/LegacyComponents/TGMenuSheetTitleItemView.m index 9417961fae..d1feccdbf3 100644 --- a/LegacyComponents/TGMenuSheetTitleItemView.m +++ b/LegacyComponents/TGMenuSheetTitleItemView.m @@ -58,7 +58,7 @@ _titleLabel.textColor = pallete.textColor; _subtitleLabel.backgroundColor = [UIColor clearColor]; - _subtitleLabel.textColor = pallete.textColor; + _subtitleLabel.textColor = pallete.secondaryTextColor; } - (CGFloat)preferredHeightForWidth:(CGFloat)width screenHeight:(CGFloat)__unused screenHeight diff --git a/LegacyComponents/TGMessage.mm b/LegacyComponents/TGMessage.mm index 8731f19931..d480477a9f 100644 --- a/LegacyComponents/TGMessage.mm +++ b/LegacyComponents/TGMessage.mm @@ -809,6 +809,27 @@ typedef enum { return _textCheckingResults; } + NSString *legacyCaption = nil; + NSArray *legacyTextCheckingResults = nil; + for (id attachment in self.mediaAttachments) { + if ([attachment isKindOfClass:[TGImageMediaAttachment class]]) { + legacyCaption = ((TGImageMediaAttachment *)attachment).caption; + if (legacyCaption.length > 0) + legacyTextCheckingResults = ((TGImageMediaAttachment *)attachment).textCheckingResults; + } else if ([attachment isKindOfClass:[TGVideoMediaAttachment class]]) { + legacyCaption = ((TGVideoMediaAttachment *)attachment).caption; + if (legacyCaption.length > 0) + legacyTextCheckingResults = ((TGVideoMediaAttachment *)attachment).textCheckingResults; + } else if ([attachment isKindOfClass:[TGDocumentMediaAttachment class]]) { + legacyCaption = ((TGDocumentMediaAttachment *)attachment).caption; + if (legacyCaption.length > 0) + legacyTextCheckingResults = ((TGDocumentMediaAttachment *)attachment).textCheckingResults; + } + } + + if (legacyTextCheckingResults.count > 0) + return legacyTextCheckingResults; + if (_mediaAttachments.count != 0) { bool hasPhoneEntities = false;