mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Video avatar fixes
This commit is contained in:
@@ -44,6 +44,7 @@
|
|||||||
- (void)prepareTransitionOutSaving:(bool)saving;
|
- (void)prepareTransitionOutSaving:(bool)saving;
|
||||||
|
|
||||||
- (void)prepareForCustomTransitionOut;
|
- (void)prepareForCustomTransitionOut;
|
||||||
|
- (void)finishCustomTransitionOut;
|
||||||
|
|
||||||
- (void)animateTransitionIn;
|
- (void)animateTransitionIn;
|
||||||
- (CGRect)_targetFrameForTransitionInFromFrame:(CGRect)fromFrame;
|
- (CGRect)_targetFrameForTransitionInFromFrame:(CGRect)fromFrame;
|
||||||
|
|||||||
@@ -484,7 +484,6 @@
|
|||||||
[_finalFilter addTarget:self.previewOutput.imageView];
|
[_finalFilter addTarget:self.previewOutput.imageView];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (_histogramGenerator != nil && !self.standalone) {
|
if (_histogramGenerator != nil && !self.standalone) {
|
||||||
[_finalFilter addTarget:_histogramGenerator];
|
[_finalFilter addTarget:_histogramGenerator];
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ const CGFloat TGPhotoAvatarCropViewCurtainMargin = 200;
|
|||||||
|
|
||||||
CGFloat _currentDiameter;
|
CGFloat _currentDiameter;
|
||||||
|
|
||||||
PGPhotoEditorView *_fullPreviewView;
|
__weak PGPhotoEditorView *_fullPreviewView;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@@ -84,7 +84,6 @@ const CGFloat TGPhotoAvatarCropViewCurtainMargin = 200;
|
|||||||
_fullPreviewView.userInteractionEnabled = false;
|
_fullPreviewView.userInteractionEnabled = false;
|
||||||
[_wrapperView addSubview:_fullPreviewView];
|
[_wrapperView addSubview:_fullPreviewView];
|
||||||
|
|
||||||
|
|
||||||
_flashView = [[UIView alloc] init];
|
_flashView = [[UIView alloc] init];
|
||||||
_flashView.alpha = 0.0;
|
_flashView.alpha = 0.0;
|
||||||
_flashView.backgroundColor = [UIColor whiteColor];
|
_flashView.backgroundColor = [UIColor whiteColor];
|
||||||
@@ -131,6 +130,11 @@ const CGFloat TGPhotoAvatarCropViewCurtainMargin = 200;
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)dealloc
|
||||||
|
{
|
||||||
|
_scrollView.delegate = nil;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)handleTap:(UITapGestureRecognizer *)gestureRecognizer {
|
- (void)handleTap:(UITapGestureRecognizer *)gestureRecognizer {
|
||||||
if (self.tapped != nil)
|
if (self.tapped != nil)
|
||||||
self.tapped();
|
self.tapped();
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ const CGFloat TGPhotoAvatarPreviewLandscapePanelSize = TGPhotoAvatarPreviewPanel
|
|||||||
|
|
||||||
UIView *_wrapperView;
|
UIView *_wrapperView;
|
||||||
|
|
||||||
TGPhotoAvatarCropView *_cropView;
|
__weak TGPhotoAvatarCropView *_cropView;
|
||||||
|
|
||||||
UIView *_portraitToolsWrapperView;
|
UIView *_portraitToolsWrapperView;
|
||||||
UIView *_landscapeToolsWrapperView;
|
UIView *_landscapeToolsWrapperView;
|
||||||
@@ -63,6 +63,10 @@ const CGFloat TGPhotoAvatarPreviewLandscapePanelSize = TGPhotoAvatarPreviewPanel
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)dealloc {
|
||||||
|
NSLog(@"");
|
||||||
|
}
|
||||||
|
|
||||||
- (void)loadView
|
- (void)loadView
|
||||||
{
|
{
|
||||||
[super loadView];
|
[super loadView];
|
||||||
@@ -80,7 +84,7 @@ const CGFloat TGPhotoAvatarPreviewLandscapePanelSize = TGPhotoAvatarPreviewPanel
|
|||||||
if (strongSelf == nil)
|
if (strongSelf == nil)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
self.controlVideoPlayback(false);
|
strongSelf.controlVideoPlayback(false);
|
||||||
};
|
};
|
||||||
void(^interactionEnded)(void) = ^
|
void(^interactionEnded)(void) = ^
|
||||||
{
|
{
|
||||||
@@ -91,11 +95,12 @@ const CGFloat TGPhotoAvatarPreviewLandscapePanelSize = TGPhotoAvatarPreviewPanel
|
|||||||
if ([strongSelf shouldAutorotate])
|
if ([strongSelf shouldAutorotate])
|
||||||
[TGViewController attemptAutorotation];
|
[TGViewController attemptAutorotation];
|
||||||
|
|
||||||
self.controlVideoPlayback(true);
|
strongSelf.controlVideoPlayback(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
PGPhotoEditor *photoEditor = self.photoEditor;
|
PGPhotoEditor *photoEditor = self.photoEditor;
|
||||||
_cropView = [[TGPhotoAvatarCropView alloc] initWithOriginalSize:photoEditor.originalSize screenSize:[self referenceViewSize] fullPreviewView:_fullPreviewView];
|
TGPhotoAvatarCropView *cropView = [[TGPhotoAvatarCropView alloc] initWithOriginalSize:photoEditor.originalSize screenSize:[self referenceViewSize] fullPreviewView:_fullPreviewView];
|
||||||
|
_cropView = cropView;
|
||||||
[_cropView setCropRect:photoEditor.cropRect];
|
[_cropView setCropRect:photoEditor.cropRect];
|
||||||
[_cropView setCropOrientation:photoEditor.cropOrientation];
|
[_cropView setCropOrientation:photoEditor.cropOrientation];
|
||||||
[_cropView setCropMirrored:photoEditor.cropMirrored];
|
[_cropView setCropMirrored:photoEditor.cropMirrored];
|
||||||
@@ -132,7 +137,7 @@ const CGFloat TGPhotoAvatarPreviewLandscapePanelSize = TGPhotoAvatarPreviewPanel
|
|||||||
}
|
}
|
||||||
_cropView.interactionBegan = interactionBegan;
|
_cropView.interactionBegan = interactionBegan;
|
||||||
_cropView.interactionEnded = interactionEnded;
|
_cropView.interactionEnded = interactionEnded;
|
||||||
[_wrapperView addSubview:_cropView];
|
[_wrapperView addSubview:cropView];
|
||||||
|
|
||||||
_portraitToolsWrapperView = [[UIView alloc] initWithFrame:CGRectZero];
|
_portraitToolsWrapperView = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
[_wrapperView addSubview:_portraitToolsWrapperView];
|
[_wrapperView addSubview:_portraitToolsWrapperView];
|
||||||
@@ -371,6 +376,7 @@ const CGFloat TGPhotoAvatarPreviewLandscapePanelSize = TGPhotoAvatarPreviewPanel
|
|||||||
_cropView.transform = CGAffineTransformMakeScale(targetCropViewScale, targetCropViewScale);
|
_cropView.transform = CGAffineTransformMakeScale(targetCropViewScale, targetCropViewScale);
|
||||||
} completion:^(__unused BOOL finished)
|
} completion:^(__unused BOOL finished)
|
||||||
{
|
{
|
||||||
|
[_cropView removeFromSuperview];
|
||||||
_previewView.alpha = 1.0;
|
_previewView.alpha = 1.0;
|
||||||
if (self.finishedTransitionOut != nil)
|
if (self.finishedTransitionOut != nil)
|
||||||
self.finishedTransitionOut();
|
self.finishedTransitionOut();
|
||||||
@@ -378,8 +384,9 @@ const CGFloat TGPhotoAvatarPreviewLandscapePanelSize = TGPhotoAvatarPreviewPanel
|
|||||||
if (completion != nil)
|
if (completion != nil)
|
||||||
completion();
|
completion();
|
||||||
}];
|
}];
|
||||||
} else if (self.fromCamera) {
|
} else {
|
||||||
_previewView.alpha = 0.0f;
|
if (self.fromCamera)
|
||||||
|
_previewView.alpha = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (self.effectiveOrientation)
|
switch (self.effectiveOrientation)
|
||||||
@@ -426,6 +433,7 @@ const CGFloat TGPhotoAvatarPreviewLandscapePanelSize = TGPhotoAvatarPreviewPanel
|
|||||||
} completion:^(__unused BOOL finished)
|
} completion:^(__unused BOOL finished)
|
||||||
{
|
{
|
||||||
if (!switching) {
|
if (!switching) {
|
||||||
|
[_cropView removeFromSuperview];
|
||||||
if (completion != nil)
|
if (completion != nil)
|
||||||
completion();
|
completion();
|
||||||
}
|
}
|
||||||
@@ -533,12 +541,17 @@ const CGFloat TGPhotoAvatarPreviewLandscapePanelSize = TGPhotoAvatarPreviewPanel
|
|||||||
} completion:nil];
|
} completion:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)finishCustomTransitionOut
|
||||||
|
{
|
||||||
|
[_cropView removeFromSuperview];
|
||||||
|
}
|
||||||
|
|
||||||
- (CGRect)transitionOutReferenceFrame
|
- (CGRect)transitionOutReferenceFrame
|
||||||
{
|
{
|
||||||
if (_dismissingToCamera) {
|
if (_dismissingToCamera) {
|
||||||
return _fullPreviewView.frame;
|
return [_fullPreviewView.superview convertRect:_fullPreviewView.frame toView:self.view];
|
||||||
} else {
|
} else {
|
||||||
return _previewView.frame;
|
return [_wrapperView convertRect:_cropView.frame toView:self.view];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -564,6 +564,9 @@
|
|||||||
|
|
||||||
if (strongSelf->_ignoreDefaultPreviewViewTransitionIn)
|
if (strongSelf->_ignoreDefaultPreviewViewTransitionIn)
|
||||||
{
|
{
|
||||||
|
__strong TGPhotoEditorController *strongSelf = weakSelf;
|
||||||
|
if (strongSelf == nil)
|
||||||
|
return;
|
||||||
TGDispatchOnMainThread(^
|
TGDispatchOnMainThread(^
|
||||||
{
|
{
|
||||||
if (strongSelf->_dismissed)
|
if (strongSelf->_dismissed)
|
||||||
@@ -578,6 +581,9 @@
|
|||||||
{
|
{
|
||||||
[photoEditor processAnimated:false completion:^
|
[photoEditor processAnimated:false completion:^
|
||||||
{
|
{
|
||||||
|
__strong TGPhotoEditorController *strongSelf = weakSelf;
|
||||||
|
if (strongSelf == nil)
|
||||||
|
return;
|
||||||
TGDispatchOnMainThread(^
|
TGDispatchOnMainThread(^
|
||||||
{
|
{
|
||||||
if (strongSelf->_dismissed)
|
if (strongSelf->_dismissed)
|
||||||
@@ -1093,7 +1099,13 @@
|
|||||||
rep = imageView;
|
rep = imageView;
|
||||||
}
|
}
|
||||||
[_currentTabController prepareForCustomTransitionOut];
|
[_currentTabController prepareForCustomTransitionOut];
|
||||||
self.beginCustomTransitionOut([_currentTabController transitionOutReferenceFrame], rep, completion);
|
|
||||||
|
TGPhotoEditorTabController *tabController = _currentTabController;
|
||||||
|
self.beginCustomTransitionOut([_currentTabController transitionOutReferenceFrame], rep, ^{
|
||||||
|
[tabController finishCustomTransitionOut];
|
||||||
|
if (completion)
|
||||||
|
completion();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1128,6 +1140,8 @@
|
|||||||
{
|
{
|
||||||
if (![currentController isDismissAllowed])
|
if (![currentController isDismissAllowed])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
[self savePaintingData];
|
||||||
|
|
||||||
currentController.switchingToTab = tab;
|
currentController.switchingToTab = tab;
|
||||||
[currentController transitionOutSwitching:true completion:^
|
[currentController transitionOutSwitching:true completion:^
|
||||||
@@ -1643,6 +1657,7 @@
|
|||||||
self.view.frame = targetFrame;
|
self.view.frame = targetFrame;
|
||||||
} completion:^(__unused BOOL finished)
|
} completion:^(__unused BOOL finished)
|
||||||
{
|
{
|
||||||
|
[_currentTabController finishCustomTransitionOut];
|
||||||
if (self.navigationController != nil) {
|
if (self.navigationController != nil) {
|
||||||
[self.navigationController popViewControllerAnimated:false];
|
[self.navigationController popViewControllerAnimated:false];
|
||||||
} else {
|
} else {
|
||||||
@@ -1653,6 +1668,7 @@
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (self.navigationController != nil) {
|
if (self.navigationController != nil) {
|
||||||
|
[_currentTabController finishCustomTransitionOut];
|
||||||
[self.navigationController popViewControllerAnimated:false];
|
[self.navigationController popViewControllerAnimated:false];
|
||||||
} else {
|
} else {
|
||||||
[self dismiss];
|
[self dismiss];
|
||||||
@@ -1767,6 +1783,18 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)savePaintingData {
|
||||||
|
if (![_currentTabController isKindOfClass:[TGPhotoPaintController class]])
|
||||||
|
return;
|
||||||
|
|
||||||
|
TGPhotoPaintController *paintController = (TGPhotoPaintController *)_currentTabController;
|
||||||
|
TGPaintingData *paintingData = [paintController paintingData];
|
||||||
|
_photoEditor.paintingData = paintingData;
|
||||||
|
|
||||||
|
if (paintingData != nil)
|
||||||
|
[TGPaintingData storePaintingData:paintingData inContext:self.editingContext forItem:_item forVideo:(_intent == TGPhotoEditorControllerVideoIntent)];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)applyEditor
|
- (void)applyEditor
|
||||||
{
|
{
|
||||||
if (![_currentTabController isDismissAllowed])
|
if (![_currentTabController isDismissAllowed])
|
||||||
@@ -1775,8 +1803,6 @@
|
|||||||
self.view.userInteractionEnabled = false;
|
self.view.userInteractionEnabled = false;
|
||||||
[_currentTabController prepareTransitionOutSaving:true];
|
[_currentTabController prepareTransitionOutSaving:true];
|
||||||
|
|
||||||
TGPaintingData *paintingData = _photoEditor.paintingData;
|
|
||||||
|
|
||||||
bool saving = true;
|
bool saving = true;
|
||||||
NSTimeInterval videoStartValue = 0.0;
|
NSTimeInterval videoStartValue = 0.0;
|
||||||
NSTimeInterval trimStartValue = 0.0;
|
NSTimeInterval trimStartValue = 0.0;
|
||||||
@@ -1784,12 +1810,7 @@
|
|||||||
|
|
||||||
if ([_currentTabController isKindOfClass:[TGPhotoPaintController class]])
|
if ([_currentTabController isKindOfClass:[TGPhotoPaintController class]])
|
||||||
{
|
{
|
||||||
TGPhotoPaintController *paintController = (TGPhotoPaintController *)_currentTabController;
|
[self savePaintingData];
|
||||||
paintingData = [paintController paintingData];
|
|
||||||
_photoEditor.paintingData = paintingData;
|
|
||||||
|
|
||||||
if (paintingData != nil)
|
|
||||||
[TGPaintingData storePaintingData:paintingData inContext:self.editingContext forItem:_item forVideo:(_intent == TGPhotoEditorControllerVideoIntent)];
|
|
||||||
}
|
}
|
||||||
else if ([_currentTabController isKindOfClass:[TGPhotoQualityController class]])
|
else if ([_currentTabController isKindOfClass:[TGPhotoQualityController class]])
|
||||||
{
|
{
|
||||||
@@ -1807,6 +1828,7 @@
|
|||||||
|
|
||||||
[self stopVideoPlayback:true];
|
[self stopVideoPlayback:true];
|
||||||
|
|
||||||
|
TGPaintingData *paintingData = _photoEditor.paintingData;
|
||||||
TGVideoEditAdjustments *adjustments = [_photoEditor exportAdjustmentsWithPaintingData:paintingData];
|
TGVideoEditAdjustments *adjustments = [_photoEditor exportAdjustmentsWithPaintingData:paintingData];
|
||||||
if ([self presentedForAvatarCreation] && _item.isVideo) {
|
if ([self presentedForAvatarCreation] && _item.isVideo) {
|
||||||
[[SQueue concurrentDefaultQueue] dispatch:^
|
[[SQueue concurrentDefaultQueue] dispatch:^
|
||||||
|
|||||||
@@ -215,6 +215,11 @@ const CGFloat TGPhotoEditorToolbarSize = 49.0f;
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)finishCustomTransitionOut
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
- (void)transitionOutSwitching:(bool)__unused switching completion:(void (^)(void))__unused completion
|
- (void)transitionOutSwitching:(bool)__unused switching completion:(void (^)(void))__unused completion
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ public final class MediaTrackFrameBuffer {
|
|||||||
if self.endOfStream, let decodedFrame = self.decoder.takeRemainingFrame() {
|
if self.endOfStream, let decodedFrame = self.decoder.takeRemainingFrame() {
|
||||||
return .frame(decodedFrame)
|
return .frame(decodedFrame)
|
||||||
} else {
|
} else {
|
||||||
if let bufferedUntilTime = bufferedUntilTime {
|
if let bufferedUntilTime = self.bufferedUntilTime {
|
||||||
if CMTimeCompare(bufferedUntilTime, self.duration) >= 0 || self.endOfStream {
|
if CMTimeCompare(bufferedUntilTime, self.duration) >= 0 || self.endOfStream {
|
||||||
return .finished
|
return .finished
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user