mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
Video avatar fixes
This commit is contained in:
@@ -871,7 +871,12 @@ const NSUInteger TGAttachmentDisplayedAssetLimit = 500;
|
|||||||
{
|
{
|
||||||
id<LegacyComponentsOverlayWindowManager> windowManager = [_context makeOverlayWindowManager];
|
id<LegacyComponentsOverlayWindowManager> 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<TGMediaEditableItem> 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.editingContext = _editingContext;
|
||||||
controller.stickersContext = _stickersContext;
|
controller.stickersContext = _stickersContext;
|
||||||
controller.dontHideStatusBar = true;
|
controller.dontHideStatusBar = true;
|
||||||
|
|||||||
@@ -91,7 +91,7 @@
|
|||||||
return [SSignal single:_cachedAVAsset];
|
return [SSignal single:_cachedAVAsset];
|
||||||
} else {
|
} else {
|
||||||
if (_originalAsset.type == TGMediaAssetGifType) {
|
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;
|
NSData *data = assetData.imageData;
|
||||||
|
|
||||||
const char *gif87Header = "GIF87";
|
const char *gif87Header = "GIF87";
|
||||||
@@ -110,7 +110,7 @@
|
|||||||
}
|
}
|
||||||
}] onNext:^(id next) {
|
}] onNext:^(id next) {
|
||||||
_cachedAVAsset = next;
|
_cachedAVAsset = next;
|
||||||
}];
|
}]];
|
||||||
} else {
|
} else {
|
||||||
return [[[TGMediaAssetImageSignals avAssetForVideoAsset:_originalAsset allowNetworkAccess:false] mapToSignal:^SSignal *(AVURLAsset *asset) {
|
return [[[TGMediaAssetImageSignals avAssetForVideoAsset:_originalAsset allowNetworkAccess:false] mapToSignal:^SSignal *(AVURLAsset *asset) {
|
||||||
return [SSignal single:asset];
|
return [SSignal single:asset];
|
||||||
|
|||||||
@@ -396,7 +396,13 @@
|
|||||||
if (_intent == TGMediaAssetsControllerSetSignupProfilePhotoIntent) {
|
if (_intent == TGMediaAssetsControllerSetSignupProfilePhotoIntent) {
|
||||||
intent = TGPhotoEditorControllerSignupAvatarIntent;
|
intent = TGPhotoEditorControllerSignupAvatarIntent;
|
||||||
}
|
}
|
||||||
TGPhotoEditorController *controller = [[TGPhotoEditorController alloc] initWithContext:_context item:asset intent:intent adjustments:nil caption:nil screenImage:thumbnailImage availableTabs:[TGPhotoEditorController defaultTabsForAvatarIntent] selectedTab:TGPhotoEditorCropTab];
|
|
||||||
|
id<TGMediaEditableItem> 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.editingContext = self.editingContext;
|
||||||
controller.didFinishRenderingFullSizeImage = ^(UIImage *resultImage)
|
controller.didFinishRenderingFullSizeImage = ^(UIImage *resultImage)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -422,10 +422,12 @@
|
|||||||
{
|
{
|
||||||
CGFloat progress = 0.0;
|
CGFloat progress = 0.0;
|
||||||
bool progressVisible = false;
|
bool progressVisible = false;
|
||||||
bool doneEnabled = false;
|
bool doneEnabled = true;
|
||||||
if ([next isKindOfClass:[UIImage class]]) {
|
if ([next isKindOfClass:[UIImage class]]) {
|
||||||
[_photoEditor setImage:(UIImage *)next forCropRect:_photoEditor.cropRect cropRotation:_photoEditor.cropRotation cropOrientation:_photoEditor.cropOrientation cropMirrored:_photoEditor.cropMirrored fullSize:false];
|
[_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]]) {
|
} else if ([next isKindOfClass:[AVAsset class]]) {
|
||||||
_playerItem = [AVPlayerItem playerItemWithAsset:(AVAsset *)next];
|
_playerItem = [AVPlayerItem playerItemWithAsset:(AVAsset *)next];
|
||||||
_player = [AVPlayer playerWithPlayerItem:_playerItem];
|
_player = [AVPlayer playerWithPlayerItem:_playerItem];
|
||||||
@@ -453,13 +455,13 @@
|
|||||||
} else if ([next isKindOfClass:[NSNumber class]]) {
|
} else if ([next isKindOfClass:[NSNumber class]]) {
|
||||||
progress = [next floatValue];
|
progress = [next floatValue];
|
||||||
progressVisible = true;
|
progressVisible = true;
|
||||||
|
doneEnabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
TGDispatchOnMainThread(^{
|
TGDispatchOnMainThread(^{
|
||||||
[self setProgressVisible:progressVisible value:progress animated:true];
|
[self setProgressVisible:progressVisible value:progress animated:true];
|
||||||
|
|
||||||
if (doneEnabled)
|
[self updateDoneButtonEnabled:doneEnabled animated:true];
|
||||||
[self updateDoneButtonEnabled:true animated:true];
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if ([next isKindOfClass:[NSNumber class]]) {
|
if ([next isKindOfClass:[NSNumber class]]) {
|
||||||
@@ -2373,7 +2375,7 @@
|
|||||||
if ([self.item isKindOfClass:[TGMediaAsset class]]) {
|
if ([self.item isKindOfClass:[TGMediaAsset class]]) {
|
||||||
thumbnailsSignal = [TGMediaAssetImageSignals videoThumbnailsForAsset:(TGMediaAsset *)self.item size:size timestamps:timestamps];
|
thumbnailsSignal = [TGMediaAssetImageSignals videoThumbnailsForAsset:(TGMediaAsset *)self.item size:size timestamps:timestamps];
|
||||||
} else if ([self.item isKindOfClass:[TGCameraCapturedVideo class]]) {
|
} 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];
|
return [TGMediaAssetImageSignals videoThumbnailsForAVAsset:avAsset size:size timestamps:timestamps];
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user