mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
Video avatar fixes
This commit is contained in:
@@ -1766,6 +1766,28 @@ static CGPoint TGCameraControllerClampPointToScreenSize(__unused id self, __unus
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
controller.didFinishEditingVideo = ^(NSURL *url, id<TGMediaEditAdjustments> adjustments, UIImage *resultImage, UIImage *thumbnailImage, bool hasChanges) {
|
||||||
|
if (!hasChanges)
|
||||||
|
return;
|
||||||
|
|
||||||
|
__strong TGCameraController *strongSelf = weakSelf;
|
||||||
|
if (strongSelf == nil)
|
||||||
|
return;
|
||||||
|
|
||||||
|
TGDispatchOnMainThread(^
|
||||||
|
{
|
||||||
|
if (strongSelf.finishedWithVideo != nil)
|
||||||
|
strongSelf.finishedWithVideo(nil, url, resultImage, 0, CGSizeZero, adjustments, nil, nil, nil, nil);
|
||||||
|
|
||||||
|
__strong TGPhotoEditorController *strongController = weakController;
|
||||||
|
if (strongController != nil)
|
||||||
|
{
|
||||||
|
[strongController updateStatusBarAppearanceForDismiss];
|
||||||
|
[strongSelf _dismissTransitionForResultController:(TGOverlayController *)strongController];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
controller.requestThumbnailImage = ^(id<TGMediaEditableItem> editableItem)
|
controller.requestThumbnailImage = ^(id<TGMediaEditableItem> editableItem)
|
||||||
{
|
{
|
||||||
return [editableItem thumbnailImageSignal];
|
return [editableItem thumbnailImageSignal];
|
||||||
|
|||||||
@@ -361,6 +361,17 @@
|
|||||||
|
|
||||||
[menuController dismissAnimated:false];
|
[menuController dismissAnimated:false];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
controller.finishedWithVideo = ^(__unused TGOverlayController *controller, NSURL *videoURL, UIImage *previewImage, __unused NSTimeInterval duration, __unused CGSize dimensions, TGVideoEditAdjustments *adjustments, __unused NSString *caption, __unused NSArray *entities, __unused NSArray *stickers, __unused NSNumber *timer){
|
||||||
|
__strong TGMediaAvatarMenuMixin *strongSelf = weakSelf;
|
||||||
|
if (strongSelf == nil)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (strongSelf.didFinishWithVideo != nil)
|
||||||
|
strongSelf.didFinishWithVideo(previewImage, videoURL, adjustments);
|
||||||
|
|
||||||
|
[menuController dismissAnimated:false];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)_displayLegacyCamera
|
- (void)_displayLegacyCamera
|
||||||
|
|||||||
@@ -307,7 +307,7 @@
|
|||||||
[_photoEditor setPreviewOutput:_previewView];
|
[_photoEditor setPreviewOutput:_previewView];
|
||||||
[self updatePreviewView];
|
[self updatePreviewView];
|
||||||
|
|
||||||
if (_intent == TGPhotoEditorControllerAvatarIntent && _item.isVideo) {
|
if ([self presentedForAvatarCreation] && _item.isVideo) {
|
||||||
_scrubberView = [[TGMediaPickerGalleryVideoScrubber alloc] initWithFrame:CGRectMake(0.0f, 0.0, _portraitToolbarView.frame.size.width, 68.0f)];
|
_scrubberView = [[TGMediaPickerGalleryVideoScrubber alloc] initWithFrame:CGRectMake(0.0f, 0.0, _portraitToolbarView.frame.size.width, 68.0f)];
|
||||||
_scrubberView.dataSource = self;
|
_scrubberView.dataSource = self;
|
||||||
_scrubberView.delegate = self;
|
_scrubberView.delegate = self;
|
||||||
@@ -380,16 +380,18 @@
|
|||||||
if ([_currentTabController isKindOfClass:[TGPhotoCropController class]])
|
if ([_currentTabController isKindOfClass:[TGPhotoCropController class]])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_scrubberView.allowsTrimming = self.item.originalDuration >= TGVideoEditMinimumTrimmableDuration;
|
if (self.item.isVideo) {
|
||||||
_scrubberView.hasDotPicker = true;
|
_scrubberView.allowsTrimming = self.item.originalDuration >= TGVideoEditMinimumTrimmableDuration;
|
||||||
_scrubberView.disableZoom = true;
|
_scrubberView.hasDotPicker = true;
|
||||||
_scrubberView.disableTimeDisplay = true;
|
_scrubberView.disableZoom = true;
|
||||||
_scrubberView.trimStartValue = 0.0;
|
_scrubberView.disableTimeDisplay = true;
|
||||||
_scrubberView.trimEndValue = MIN(9.9, self.item.originalDuration);
|
_scrubberView.trimStartValue = 0.0;
|
||||||
[_scrubberView setTrimApplied:self.item.originalDuration > 9.9];
|
_scrubberView.trimEndValue = MIN(9.9, self.item.originalDuration);
|
||||||
_scrubberView.maximumLength = 9.9;
|
[_scrubberView setTrimApplied:self.item.originalDuration > 9.9];
|
||||||
|
_scrubberView.maximumLength = 9.9;
|
||||||
|
|
||||||
[self setVideoEndTime:_scrubberView.trimEndValue];
|
[self setVideoEndTime:_scrubberView.trimEndValue];
|
||||||
|
}
|
||||||
|
|
||||||
NSTimeInterval position = 0;
|
NSTimeInterval position = 0;
|
||||||
TGMediaVideoEditAdjustments *adjustments = [_photoEditor exportAdjustments];
|
TGMediaVideoEditAdjustments *adjustments = [_photoEditor exportAdjustments];
|
||||||
@@ -1385,7 +1387,7 @@
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_intent == TGPhotoEditorControllerAvatarIntent && !isInitialAppearance && tab != TGPhotoEditorPreviewTab) {
|
if ([self presentedForAvatarCreation] && !isInitialAppearance && tab != TGPhotoEditorPreviewTab) {
|
||||||
backButtonType = TGPhotoEditorBackButtonBack;
|
backButtonType = TGPhotoEditorBackButtonBack;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1504,7 +1506,7 @@
|
|||||||
|
|
||||||
- (void)dismissEditor
|
- (void)dismissEditor
|
||||||
{
|
{
|
||||||
if ((![_currentTabController isKindOfClass:[TGPhotoAvatarPreviewController class]] && ![_currentTabController isKindOfClass:[TGPhotoAvatarCropController class]]) && _intent == TGPhotoEditorControllerAvatarIntent) {
|
if ((![_currentTabController isKindOfClass:[TGPhotoAvatarPreviewController class]] && ![_currentTabController isKindOfClass:[TGPhotoAvatarCropController class]]) && [self presentedForAvatarCreation]) {
|
||||||
[self presentEditorTab:TGPhotoEditorPreviewTab];
|
[self presentEditorTab:TGPhotoEditorPreviewTab];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1597,7 +1599,7 @@
|
|||||||
|
|
||||||
- (void)doneButtonPressed
|
- (void)doneButtonPressed
|
||||||
{
|
{
|
||||||
if (_intent == TGPhotoEditorControllerAvatarIntent && ![_currentTabController isKindOfClass:[TGPhotoAvatarPreviewController class]]) {
|
if ([self presentedForAvatarCreation] && ![_currentTabController isKindOfClass:[TGPhotoAvatarPreviewController class]]) {
|
||||||
[self presentEditorTab:TGPhotoEditorPreviewTab];
|
[self presentEditorTab:TGPhotoEditorPreviewTab];
|
||||||
} else {
|
} else {
|
||||||
[self applyEditor];
|
[self applyEditor];
|
||||||
@@ -1643,7 +1645,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
TGVideoEditAdjustments *adjustments = [_photoEditor exportAdjustmentsWithPaintingData:paintingData];
|
TGVideoEditAdjustments *adjustments = [_photoEditor exportAdjustmentsWithPaintingData:paintingData];
|
||||||
if (_intent == TGPhotoEditorControllerAvatarIntent && _item.isVideo) {
|
if ([self presentedForAvatarCreation] && _item.isVideo) {
|
||||||
[[SQueue concurrentDefaultQueue] dispatch:^
|
[[SQueue concurrentDefaultQueue] dispatch:^
|
||||||
{
|
{
|
||||||
id<TGMediaEditableItem> item = _item;
|
id<TGMediaEditableItem> item = _item;
|
||||||
|
|||||||
Reference in New Issue
Block a user