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