diff --git a/submodules/LegacyComponents/Sources/TGAttachmentCarouselItemView.m b/submodules/LegacyComponents/Sources/TGAttachmentCarouselItemView.m index c416a4cb3d..b8d5a85d2c 100644 --- a/submodules/LegacyComponents/Sources/TGAttachmentCarouselItemView.m +++ b/submodules/LegacyComponents/Sources/TGAttachmentCarouselItemView.m @@ -871,7 +871,12 @@ const NSUInteger TGAttachmentDisplayedAssetLimit = 500; { id windowManager = [_context makeOverlayWindowManager]; - TGPhotoEditorController *controller = [[TGPhotoEditorController alloc] initWithContext:[windowManager context] item:asset intent:_disableStickers ? TGPhotoEditorControllerSignupAvatarIntent : TGPhotoEditorControllerAvatarIntent adjustments:nil caption:nil screenImage:thumbnailImage availableTabs:[TGPhotoEditorController defaultTabsForAvatarIntent] selectedTab:TGPhotoEditorCropTab]; + id editableItem = asset; + if (asset.type == TGMediaAssetGifType) { + editableItem = [[TGCameraCapturedVideo alloc] initWithAsset:asset livePhoto:false]; + } + + TGPhotoEditorController *controller = [[TGPhotoEditorController alloc] initWithContext:[windowManager context] item:editableItem intent:_disableStickers ? TGPhotoEditorControllerSignupAvatarIntent : TGPhotoEditorControllerAvatarIntent adjustments:nil caption:nil screenImage:thumbnailImage availableTabs:[TGPhotoEditorController defaultTabsForAvatarIntent] selectedTab:TGPhotoEditorCropTab]; controller.editingContext = _editingContext; controller.stickersContext = _stickersContext; controller.dontHideStatusBar = true; diff --git a/submodules/LegacyComponents/Sources/TGCameraCapturedVideo.m b/submodules/LegacyComponents/Sources/TGCameraCapturedVideo.m index 45284ba873..91ab52dd70 100644 --- a/submodules/LegacyComponents/Sources/TGCameraCapturedVideo.m +++ b/submodules/LegacyComponents/Sources/TGCameraCapturedVideo.m @@ -91,7 +91,7 @@ return [SSignal single:_cachedAVAsset]; } else { if (_originalAsset.type == TGMediaAssetGifType) { - return [[[TGMediaAssetImageSignals imageDataForAsset:_originalAsset allowNetworkAccess:false] mapToSignal:^SSignal *(TGMediaAssetImageData *assetData) { + return [[SSignal single:@0.0] then:[[[TGMediaAssetImageSignals imageDataForAsset:_originalAsset allowNetworkAccess:false] mapToSignal:^SSignal *(TGMediaAssetImageData *assetData) { NSData *data = assetData.imageData; const char *gif87Header = "GIF87"; @@ -110,7 +110,7 @@ } }] onNext:^(id next) { _cachedAVAsset = next; - }]; + }]]; } else { return [[[TGMediaAssetImageSignals avAssetForVideoAsset:_originalAsset allowNetworkAccess:false] mapToSignal:^SSignal *(AVURLAsset *asset) { return [SSignal single:asset]; diff --git a/submodules/LegacyComponents/Sources/TGMediaAssetsPickerController.m b/submodules/LegacyComponents/Sources/TGMediaAssetsPickerController.m index 085737d580..13cac6e6c8 100644 --- a/submodules/LegacyComponents/Sources/TGMediaAssetsPickerController.m +++ b/submodules/LegacyComponents/Sources/TGMediaAssetsPickerController.m @@ -396,7 +396,13 @@ if (_intent == TGMediaAssetsControllerSetSignupProfilePhotoIntent) { intent = TGPhotoEditorControllerSignupAvatarIntent; } - TGPhotoEditorController *controller = [[TGPhotoEditorController alloc] initWithContext:_context item:asset intent:intent adjustments:nil caption:nil screenImage:thumbnailImage availableTabs:[TGPhotoEditorController defaultTabsForAvatarIntent] selectedTab:TGPhotoEditorCropTab]; + + id editableItem = asset; + if (asset.type == TGMediaAssetGifType) { + editableItem = [[TGCameraCapturedVideo alloc] initWithAsset:asset livePhoto:false]; + } + + TGPhotoEditorController *controller = [[TGPhotoEditorController alloc] initWithContext:_context item:editableItem intent:intent adjustments:nil caption:nil screenImage:thumbnailImage availableTabs:[TGPhotoEditorController defaultTabsForAvatarIntent] selectedTab:TGPhotoEditorCropTab]; controller.editingContext = self.editingContext; controller.didFinishRenderingFullSizeImage = ^(UIImage *resultImage) { diff --git a/submodules/LegacyComponents/Sources/TGPhotoEditorController.m b/submodules/LegacyComponents/Sources/TGPhotoEditorController.m index f61ba32618..5662bc9b25 100644 --- a/submodules/LegacyComponents/Sources/TGPhotoEditorController.m +++ b/submodules/LegacyComponents/Sources/TGPhotoEditorController.m @@ -422,10 +422,12 @@ { CGFloat progress = 0.0; bool progressVisible = false; - bool doneEnabled = false; + bool doneEnabled = true; if ([next isKindOfClass:[UIImage class]]) { [_photoEditor setImage:(UIImage *)next forCropRect:_photoEditor.cropRect cropRotation:_photoEditor.cropRotation cropOrientation:_photoEditor.cropOrientation cropMirrored:_photoEditor.cropMirrored fullSize:false]; - progress = 1.0f; + if (!((UIImage *)next).degraded) { + progress = 1.0f; + } } else if ([next isKindOfClass:[AVAsset class]]) { _playerItem = [AVPlayerItem playerItemWithAsset:(AVAsset *)next]; _player = [AVPlayer playerWithPlayerItem:_playerItem]; @@ -453,13 +455,13 @@ } else if ([next isKindOfClass:[NSNumber class]]) { progress = [next floatValue]; progressVisible = true; + doneEnabled = false; } TGDispatchOnMainThread(^{ - [self setProgressVisible:progressVisible value:progress animated:true]; + [self setProgressVisible:progressVisible value:progress animated:true]; - if (doneEnabled) - [self updateDoneButtonEnabled:true animated:true]; + [self updateDoneButtonEnabled:doneEnabled animated:true]; }); if ([next isKindOfClass:[NSNumber class]]) { @@ -2373,7 +2375,7 @@ if ([self.item isKindOfClass:[TGMediaAsset class]]) { thumbnailsSignal = [TGMediaAssetImageSignals videoThumbnailsForAsset:(TGMediaAsset *)self.item size:size timestamps:timestamps]; } else if ([self.item isKindOfClass:[TGCameraCapturedVideo class]]) { - thumbnailsSignal = [((TGCameraCapturedVideo *)self.item).avAsset mapToSignal:^SSignal *(AVAsset *avAsset) { + thumbnailsSignal = [[((TGCameraCapturedVideo *)self.item).avAsset takeLast] mapToSignal:^SSignal *(AVAsset *avAsset) { return [TGMediaAssetImageSignals videoThumbnailsForAVAsset:avAsset size:size timestamps:timestamps]; }]; }