From 5e1330af01a588f0f255c3efe18afab7fb7eba29 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Wed, 15 Jul 2020 15:27:39 +0300 Subject: [PATCH] Video avatar fixes --- submodules/GalleryUI/Sources/GalleryControllerNode.swift | 2 +- .../Sources/Items/UniversalVideoGalleryItem.swift | 2 +- .../Sources/TGAttachmentCarouselItemView.m | 7 ++++++- submodules/LegacyComponents/Sources/TGGifConverter.m | 5 +++-- .../TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift | 1 - 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/submodules/GalleryUI/Sources/GalleryControllerNode.swift b/submodules/GalleryUI/Sources/GalleryControllerNode.swift index 5d0e45f4df..481fbe325f 100644 --- a/submodules/GalleryUI/Sources/GalleryControllerNode.swift +++ b/submodules/GalleryUI/Sources/GalleryControllerNode.swift @@ -253,7 +253,7 @@ open class GalleryControllerNode: ASDisplayNode, UIScrollViewDelegate, UIGesture if displayThumbnailPanel { thumbnailPanelHeight = 52.0 } - let thumbnailsFrame = CGRect(origin: CGPoint(x: 0.0, y: layout.size.height - 40.0 - panelHeight + 4.0 - layout.intrinsicInsets.bottom), size: CGSize(width: layout.size.width, height: panelHeight - 4.0)) + let thumbnailsFrame = CGRect(origin: CGPoint(x: 0.0, y: layout.size.height - 40.0 - panelHeight + 4.0 - layout.intrinsicInsets.bottom + (self.areControlsHidden ? 54.0 : 0.0)), size: CGSize(width: layout.size.width, height: panelHeight - 4.0)) transition.updateFrame(node: currentThumbnailContainerNode, frame: thumbnailsFrame) currentThumbnailContainerNode.updateLayout(size: thumbnailsFrame.size, transition: transition) diff --git a/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift b/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift index c91fabfb92..18229bde15 100644 --- a/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift +++ b/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift @@ -661,7 +661,7 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode { seekable = value.duration >= 30.0 } - if playing && strongSelf.previousPlaying != true { + if playing && strongSelf.previousPlaying != true && !disablePlayerControls { let timer = SwiftSignalKit.Timer(timeout: 3.0, repeat: false, completion: { [weak self] in self?.updateControlsVisibility(false) self?.controlsTimer = nil diff --git a/submodules/LegacyComponents/Sources/TGAttachmentCarouselItemView.m b/submodules/LegacyComponents/Sources/TGAttachmentCarouselItemView.m index 039995c8b6..d4094aa7bd 100644 --- a/submodules/LegacyComponents/Sources/TGAttachmentCarouselItemView.m +++ b/submodules/LegacyComponents/Sources/TGAttachmentCarouselItemView.m @@ -445,7 +445,12 @@ const NSUInteger TGAttachmentDisplayedAssetLimit = 500; TGMediaAssetImageType screenImageType = refresh ? TGMediaAssetImageTypeLargeThumbnail : TGMediaAssetImageTypeFastLargeThumbnail; TGMediaAssetImageType imageType = thumbnail ? TGMediaAssetImageTypeAspectRatioThumbnail : screenImageType; - SSignal *assetSignal = [TGMediaAssetImageSignals imageForAsset:asset imageType:imageType size:imageSize]; + TGMediaAsset *concreteAsset = asset; + if ([concreteAsset isKindOfClass:[TGCameraCapturedVideo class]]) { + concreteAsset = [(TGCameraCapturedVideo *)asset originalAsset]; + } + + SSignal *assetSignal = [TGMediaAssetImageSignals imageForAsset:concreteAsset imageType:imageType size:imageSize]; if (_editingContext == nil) return assetSignal; diff --git a/submodules/LegacyComponents/Sources/TGGifConverter.m b/submodules/LegacyComponents/Sources/TGGifConverter.m index 01df95a41f..ce1560786b 100644 --- a/submodules/LegacyComponents/Sources/TGGifConverter.m +++ b/submodules/LegacyComponents/Sources/TGGifConverter.m @@ -81,6 +81,7 @@ const CGFloat TGGifConverterMaximumSide = 720.0f; CGFloat renderWidth = CGFloor(sourceWidth / blockSize) * blockSize; CGFloat renderHeight = CGFloor(sourceHeight * renderWidth / sourceWidth); + CGSize renderSize = CGSizeMake(renderWidth, renderHeight); CGSize targetSize = TGFitSizeF(CGSizeMake(renderWidth, renderHeight), CGSizeMake(TGGifConverterMaximumSide, TGGifConverterMaximumSide)); NSDictionary *videoCleanApertureSettings = @ @@ -152,11 +153,11 @@ const CGFloat TGGifConverterMaximumSide = 720.0f; if (gifProperties != NULL) { - CVPixelBufferRef pxBuffer = [self newBufferFrom:imgRef size:targetSize withPixelBufferPool:adaptor.pixelBufferPool andAttributes:adaptor.sourcePixelBufferAttributes]; + CVPixelBufferRef pxBuffer = [self newBufferFrom:imgRef size:renderSize withPixelBufferPool:adaptor.pixelBufferPool andAttributes:adaptor.sourcePixelBufferAttributes]; if (pxBuffer != NULL) { if (previewImage == nil) { - previewImage = TGScaleImageToPixelSize([[UIImage alloc] initWithCGImage:imgRef], targetSize); + previewImage = TGScaleImageToPixelSize([[UIImage alloc] initWithCGImage:imgRef], renderSize); } float frameDuration = 0.1f; NSNumber *delayTimeUnclampedProp = CFDictionaryGetValue(gifProperties, kCGImagePropertyGIFUnclampedDelayTime); diff --git a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift index f0d459d3ae..4ff9d63478 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift @@ -1027,7 +1027,6 @@ final class PeerInfoAvatarListContainerNode: ASDisplayNode { let indexOffset = CGFloat(i - self.currentIndex) let itemFrame = CGRect(origin: CGPoint(x: indexOffset * size.width + self.transitionFraction * size.width - size.width / 2.0, y: -size.height / 2.0), size: size) - if wasAdded { itemsAdded = true addedItemNodesForAdditiveTransition.append(itemNode)