Various Fixes

This commit is contained in:
Ilya Laktyushin 2021-07-28 01:32:37 +03:00
parent eb7d7ce1be
commit ab5d37068d
5 changed files with 37 additions and 24 deletions

View File

@ -602,7 +602,6 @@ static CGPoint TGCameraControllerClampPointToScreenSize(__unused id self, __unus
TGDispatchOnMainThread(^ TGDispatchOnMainThread(^
{ {
[strongSelf->_previewView endTransitionAnimated:true];
[strongSelf->_interfaceView setZoomLevel:1.0f displayNeeded:false]; [strongSelf->_interfaceView setZoomLevel:1.0f displayNeeded:false];
if (!strongSelf->_dismissing) if (!strongSelf->_dismissing)
@ -636,6 +635,8 @@ static CGPoint TGCameraControllerClampPointToScreenSize(__unused id self, __unus
}; };
} }
} }
[strongSelf->_previewView endTransitionAnimated:true];
}); });
}; };

View File

@ -84,7 +84,7 @@
TGMenuContainerView *_tooltipContainerView; TGMenuContainerView *_tooltipContainerView;
NSTimer *_tooltipTimer; NSTimer *_tooltipTimer;
bool _dismissingWheel; int _dismissingWheelCounter;
} }
@end @end
@ -108,6 +108,8 @@
{ {
_actionHandle = [[ASHandle alloc] initWithDelegate:self releaseOnMainThread:true]; _actionHandle = [[ASHandle alloc] initWithDelegate:self releaseOnMainThread:true];
_dismissingWheelCounter = 0;
CGFloat shutterButtonWidth = 66.0f; CGFloat shutterButtonWidth = 66.0f;
CGSize screenSize = TGScreenSize(); CGSize screenSize = TGScreenSize();
CGFloat widescreenWidth = MAX(screenSize.width, screenSize.height); CGFloat widescreenWidth = MAX(screenSize.width, screenSize.height);
@ -210,17 +212,19 @@
[strongSelf->_zoomModeView setZoomLevel:zoomLevel animated:false]; [strongSelf->_zoomModeView setZoomLevel:zoomLevel animated:false];
if (!strongSelf->_zoomWheelView.isHidden) { if (!strongSelf->_zoomWheelView.isHidden) {
strongSelf->_dismissingWheel = true; NSInteger counter = strongSelf->_dismissingWheelCounter + 1;
strongSelf->_dismissingWheelCounter = counter;
TGDispatchAfter(0.6, dispatch_get_main_queue(), ^{ TGDispatchAfter(1.5, dispatch_get_main_queue(), ^{
if (strongSelf->_dismissingWheel) { if (strongSelf->_dismissingWheelCounter == counter) {
[strongSelf->_zoomModeView setHidden:false animated:true]; [strongSelf->_zoomModeView setHidden:false animated:true];
[strongSelf->_zoomWheelView setHidden:true animated:true]; [strongSelf->_zoomWheelView setHidden:true animated:true];
} }
}); });
} }
} else { } else {
strongSelf->_dismissingWheel = false; NSInteger counter = strongSelf->_dismissingWheelCounter + 1;
strongSelf->_dismissingWheelCounter = counter;
[strongSelf->_zoomWheelView setZoomLevel:zoomLevel panning:true]; [strongSelf->_zoomWheelView setZoomLevel:zoomLevel panning:true];
[strongSelf->_zoomModeView setHidden:true animated:true]; [strongSelf->_zoomModeView setHidden:true animated:true];
[strongSelf->_zoomWheelView setHidden:false animated:true]; [strongSelf->_zoomWheelView setHidden:false animated:true];
@ -489,20 +493,26 @@
UIInterfaceOrientation orientation = _interfaceOrientation; UIInterfaceOrientation orientation = _interfaceOrientation;
PGCameraMode cameraMode = _modeControl.cameraMode; PGCameraMode cameraMode = _modeControl.cameraMode;
[UIView animateWithDuration:0.25f delay:0.0f options:UIViewAnimationOptionCurveLinear animations:^ if (previousMode == PGCameraModePhoto && cameraMode == PGCameraModeVideo) {
{ [UIView animateWithDuration:0.25f delay:0.0f options:UIViewAnimationOptionCurveLinear animations:^
if (cameraMode == PGCameraModeVideo)
{ {
_timecodeView.alpha = 1.0; _timecodeView.alpha = 1.0;
} else { _bottomPanelBackgroundView.alpha = 0.0;
} completion:nil];
} else if (previousMode == PGCameraModeVideo && cameraMode == PGCameraModePhoto) {
[UIView animateWithDuration:0.25f delay:0.0f options:UIViewAnimationOptionCurveLinear animations:^
{
_timecodeView.alpha = 0.0; _timecodeView.alpha = 0.0;
} } completion:nil];
} completion:nil]; [UIView animateWithDuration:0.25f delay:1.5f options:UIViewAnimationOptionCurveLinear animations:^
{
_bottomPanelBackgroundView.alpha = 1.0;
} completion:nil];
}
if (UIInterfaceOrientationIsLandscape(orientation) && !((cameraMode == PGCameraModePhoto && previousMode == PGCameraModeSquarePhoto) || (cameraMode == PGCameraModeSquarePhoto && previousMode == PGCameraModePhoto))) if (UIInterfaceOrientationIsLandscape(orientation) && !((cameraMode == PGCameraModePhoto && previousMode == PGCameraModeSquarePhoto) || (cameraMode == PGCameraModeSquarePhoto && previousMode == PGCameraModePhoto)))
{ {
[UIView animateWithDuration:0.25f delay:0.0f options:UIViewAnimationOptionCurveLinear animations:^ [UIView animateWithDuration:0.25f delay:0.0f options:UIViewAnimationOptionCurveLinear animations:^
{ {
_topPanelView.alpha = 0.0f;
_videoLandscapePanelView.alpha = 0.0f; _videoLandscapePanelView.alpha = 0.0f;
} completion:^(__unused BOOL finished) } completion:^(__unused BOOL finished)
{ {
@ -530,8 +540,6 @@
{ {
if (cameraMode == PGCameraModeVideo) if (cameraMode == PGCameraModeVideo)
_videoLandscapePanelView.alpha = 1.0f; _videoLandscapePanelView.alpha = 1.0f;
else
_topPanelView.alpha = 1.0f;
} completion:nil]; } completion:nil];
}]; }];
} }
@ -602,7 +610,6 @@
_flashControl.hidden = false; _flashControl.hidden = false;
_flipButton.hidden = hasDoneButton; _flipButton.hidden = hasDoneButton;
_topFlipButton.hidden = !hasDoneButton; _topFlipButton.hidden = !hasDoneButton;
_bottomPanelBackgroundView.hidden = false;
} }
[UIView animateWithDuration:0.2 delay:0.0 options:7 << 16 animations:^{ [UIView animateWithDuration:0.2 delay:0.0 options:7 << 16 animations:^{
@ -618,7 +625,6 @@
_flashControl.alpha = alpha; _flashControl.alpha = alpha;
_flipButton.alpha = alpha; _flipButton.alpha = alpha;
_topFlipButton.alpha = alpha; _topFlipButton.alpha = alpha;
_bottomPanelBackgroundView.alpha = alpha;
if (hasDoneButton) if (hasDoneButton)
_doneButton.alpha = alpha; _doneButton.alpha = alpha;
@ -631,7 +637,6 @@
_flashControl.hidden = hidden; _flashControl.hidden = hidden;
_flipButton.hidden = hidden || hasDoneButton; _flipButton.hidden = hidden || hasDoneButton;
_topFlipButton.hidden = hidden || !hasDoneButton; _topFlipButton.hidden = hidden || !hasDoneButton;
_bottomPanelBackgroundView.hidden = hidden;
if (hasDoneButton) if (hasDoneButton)
_doneButton.hidden = hidden; _doneButton.hidden = hidden;
@ -653,8 +658,6 @@
_flipButton.alpha = alpha; _flipButton.alpha = alpha;
_topFlipButton.hidden = hidden || !hasDoneButton; _topFlipButton.hidden = hidden || !hasDoneButton;
_topFlipButton.alpha = alpha; _topFlipButton.alpha = alpha;
_bottomPanelBackgroundView.hidden = hidden;
_bottomPanelBackgroundView.alpha = alpha;
CGFloat offset = hidden ? 19 : 18 + 43; CGFloat offset = hidden ? 19 : 18 + 43;
_zoomModeView.frame = CGRectMake(floor((self.bounds.size.width - 129.0) / 2.0), self.bounds.size.height - _bottomPanelHeight - _bottomPanelOffset - offset, 129, 43); _zoomModeView.frame = CGRectMake(floor((self.bounds.size.width - 129.0) / 2.0), self.bounds.size.height - _bottomPanelHeight - _bottomPanelOffset - offset, 129, 43);

View File

@ -238,6 +238,8 @@
bool _hasUltrawideCamera; bool _hasUltrawideCamera;
bool _hasTelephotoCamera; bool _hasTelephotoCamera;
bool _beganFromPress;
TGCameraZoomModeItemView *_leftItem; TGCameraZoomModeItemView *_leftItem;
TGCameraZoomModeItemView *_centerItem; TGCameraZoomModeItemView *_centerItem;
@ -299,6 +301,7 @@
- (void)pressGesture:(UILongPressGestureRecognizer *)gestureRecognizer { - (void)pressGesture:(UILongPressGestureRecognizer *)gestureRecognizer {
switch (gestureRecognizer.state) { switch (gestureRecognizer.state) {
case UIGestureRecognizerStateBegan: case UIGestureRecognizerStateBegan:
_beganFromPress = true;
self.zoomChanged(_zoomLevel, false, false); self.zoomChanged(_zoomLevel, false, false);
break; break;
case UIGestureRecognizerStateEnded: case UIGestureRecognizerStateEnded:
@ -330,9 +333,10 @@
case UIGestureRecognizerStateEnded: case UIGestureRecognizerStateEnded:
case UIGestureRecognizerStateCancelled: case UIGestureRecognizerStateCancelled:
{ {
if (gestureRecognizer.view != self) { if (gestureRecognizer.view != self || !_beganFromPress) {
self.zoomChanged(_zoomLevel, true, false); self.zoomChanged(_zoomLevel, true, false);
} }
_beganFromPress = false;
} }
break; break;
default: default:

View File

@ -393,7 +393,7 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView, UIGestureRecognizerD
var replyBackgroundImage: UIImage? var replyBackgroundImage: UIImage?
var replyMarkup: ReplyMarkupMessageAttribute? var replyMarkup: ReplyMarkupMessageAttribute?
let availableWidth = max(60.0, params.width - params.leftInset - params.rightInset - videoLayout.contentSize.width - 20.0 - layoutConstants.bubble.edgeInset * 2.0 - avatarInset - layoutConstants.bubble.contentInsets.left) let availableWidth = max(60.0, params.width - params.leftInset - params.rightInset - normalDisplaySize.width - 20.0 - layoutConstants.bubble.edgeInset * 2.0 - avatarInset - layoutConstants.bubble.contentInsets.left)
var ignoreForward = false var ignoreForward = false
var ignoreSource = false var ignoreSource = false
@ -511,7 +511,7 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView, UIGestureRecognizerD
forwardAuthorSignature = forwardInfo.authorSignature forwardAuthorSignature = forwardInfo.authorSignature
} }
} }
let availableWidth = max(60.0, availableContentWidth - videoLayout.contentSize.width + 6.0) let availableWidth = max(60.0, availableContentWidth - normalDisplaySize.width + 6.0)
forwardInfoSizeApply = makeForwardInfoLayout(item.presentationData, item.presentationData.strings, .standalone, forwardSource, forwardAuthorSignature, forwardPsaType, CGSize(width: availableWidth, height: CGFloat.greatestFiniteMagnitude)) forwardInfoSizeApply = makeForwardInfoLayout(item.presentationData, item.presentationData.strings, .standalone, forwardSource, forwardAuthorSignature, forwardPsaType, CGSize(width: availableWidth, height: CGFloat.greatestFiniteMagnitude))
if let currentForwardBackgroundNode = currentForwardBackgroundNode { if let currentForwardBackgroundNode = currentForwardBackgroundNode {

View File

@ -290,7 +290,12 @@ final class SharedMediaPlayer {
player.play() player.play()
} }
case let .instantVideo(node): case let .instantVideo(node):
node.playOnceWithSound(playAndRecord: controlPlaybackWithProximity) if let scheduledStartTime = scheduledStartTime {
node.seek(scheduledStartTime)
node.playOnceWithSound(playAndRecord: controlPlaybackWithProximity)
} else {
node.playOnceWithSound(playAndRecord: controlPlaybackWithProximity)
}
} }
case .pause: case .pause:
playbackItem.pause() playbackItem.pause()