diff --git a/submodules/LegacyComponents/Sources/TGCameraController.m b/submodules/LegacyComponents/Sources/TGCameraController.m index cd1da999f4..0cae82eb74 100644 --- a/submodules/LegacyComponents/Sources/TGCameraController.m +++ b/submodules/LegacyComponents/Sources/TGCameraController.m @@ -602,7 +602,6 @@ static CGPoint TGCameraControllerClampPointToScreenSize(__unused id self, __unus TGDispatchOnMainThread(^ { - [strongSelf->_previewView endTransitionAnimated:true]; [strongSelf->_interfaceView setZoomLevel:1.0f displayNeeded:false]; if (!strongSelf->_dismissing) @@ -636,6 +635,8 @@ static CGPoint TGCameraControllerClampPointToScreenSize(__unused id self, __unus }; } } + + [strongSelf->_previewView endTransitionAnimated:true]; }); }; diff --git a/submodules/LegacyComponents/Sources/TGCameraMainPhoneView.m b/submodules/LegacyComponents/Sources/TGCameraMainPhoneView.m index 928c39af20..53f5f94e89 100644 --- a/submodules/LegacyComponents/Sources/TGCameraMainPhoneView.m +++ b/submodules/LegacyComponents/Sources/TGCameraMainPhoneView.m @@ -84,7 +84,7 @@ TGMenuContainerView *_tooltipContainerView; NSTimer *_tooltipTimer; - bool _dismissingWheel; + int _dismissingWheelCounter; } @end @@ -108,6 +108,8 @@ { _actionHandle = [[ASHandle alloc] initWithDelegate:self releaseOnMainThread:true]; + _dismissingWheelCounter = 0; + CGFloat shutterButtonWidth = 66.0f; CGSize screenSize = TGScreenSize(); CGFloat widescreenWidth = MAX(screenSize.width, screenSize.height); @@ -210,17 +212,19 @@ [strongSelf->_zoomModeView setZoomLevel:zoomLevel animated:false]; if (!strongSelf->_zoomWheelView.isHidden) { - strongSelf->_dismissingWheel = true; + NSInteger counter = strongSelf->_dismissingWheelCounter + 1; + strongSelf->_dismissingWheelCounter = counter; - TGDispatchAfter(0.6, dispatch_get_main_queue(), ^{ - if (strongSelf->_dismissingWheel) { + TGDispatchAfter(1.5, dispatch_get_main_queue(), ^{ + if (strongSelf->_dismissingWheelCounter == counter) { [strongSelf->_zoomModeView setHidden:false animated:true]; [strongSelf->_zoomWheelView setHidden:true animated:true]; } }); } } else { - strongSelf->_dismissingWheel = false; + NSInteger counter = strongSelf->_dismissingWheelCounter + 1; + strongSelf->_dismissingWheelCounter = counter; [strongSelf->_zoomWheelView setZoomLevel:zoomLevel panning:true]; [strongSelf->_zoomModeView setHidden:true animated:true]; [strongSelf->_zoomWheelView setHidden:false animated:true]; @@ -489,20 +493,26 @@ UIInterfaceOrientation orientation = _interfaceOrientation; PGCameraMode cameraMode = _modeControl.cameraMode; - [UIView animateWithDuration:0.25f delay:0.0f options:UIViewAnimationOptionCurveLinear animations:^ - { - if (cameraMode == PGCameraModeVideo) + if (previousMode == PGCameraModePhoto && cameraMode == PGCameraModeVideo) { + [UIView animateWithDuration:0.25f delay:0.0f options:UIViewAnimationOptionCurveLinear animations:^ { _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; - } - } 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))) { [UIView animateWithDuration:0.25f delay:0.0f options:UIViewAnimationOptionCurveLinear animations:^ { - _topPanelView.alpha = 0.0f; _videoLandscapePanelView.alpha = 0.0f; } completion:^(__unused BOOL finished) { @@ -530,8 +540,6 @@ { if (cameraMode == PGCameraModeVideo) _videoLandscapePanelView.alpha = 1.0f; - else - _topPanelView.alpha = 1.0f; } completion:nil]; }]; } @@ -602,7 +610,6 @@ _flashControl.hidden = false; _flipButton.hidden = hasDoneButton; _topFlipButton.hidden = !hasDoneButton; - _bottomPanelBackgroundView.hidden = false; } [UIView animateWithDuration:0.2 delay:0.0 options:7 << 16 animations:^{ @@ -618,7 +625,6 @@ _flashControl.alpha = alpha; _flipButton.alpha = alpha; _topFlipButton.alpha = alpha; - _bottomPanelBackgroundView.alpha = alpha; if (hasDoneButton) _doneButton.alpha = alpha; @@ -631,7 +637,6 @@ _flashControl.hidden = hidden; _flipButton.hidden = hidden || hasDoneButton; _topFlipButton.hidden = hidden || !hasDoneButton; - _bottomPanelBackgroundView.hidden = hidden; if (hasDoneButton) _doneButton.hidden = hidden; @@ -653,8 +658,6 @@ _flipButton.alpha = alpha; _topFlipButton.hidden = hidden || !hasDoneButton; _topFlipButton.alpha = alpha; - _bottomPanelBackgroundView.hidden = hidden; - _bottomPanelBackgroundView.alpha = alpha; 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); diff --git a/submodules/LegacyComponents/Sources/TGCameraZoomView.m b/submodules/LegacyComponents/Sources/TGCameraZoomView.m index 0b8a9d279f..33bb1714ce 100644 --- a/submodules/LegacyComponents/Sources/TGCameraZoomView.m +++ b/submodules/LegacyComponents/Sources/TGCameraZoomView.m @@ -238,6 +238,8 @@ bool _hasUltrawideCamera; bool _hasTelephotoCamera; + + bool _beganFromPress; TGCameraZoomModeItemView *_leftItem; TGCameraZoomModeItemView *_centerItem; @@ -299,6 +301,7 @@ - (void)pressGesture:(UILongPressGestureRecognizer *)gestureRecognizer { switch (gestureRecognizer.state) { case UIGestureRecognizerStateBegan: + _beganFromPress = true; self.zoomChanged(_zoomLevel, false, false); break; case UIGestureRecognizerStateEnded: @@ -330,9 +333,10 @@ case UIGestureRecognizerStateEnded: case UIGestureRecognizerStateCancelled: { - if (gestureRecognizer.view != self) { + if (gestureRecognizer.view != self || !_beganFromPress) { self.zoomChanged(_zoomLevel, true, false); } + _beganFromPress = false; } break; default: diff --git a/submodules/TelegramUI/Sources/ChatMessageInstantVideoItemNode.swift b/submodules/TelegramUI/Sources/ChatMessageInstantVideoItemNode.swift index 6cd464e424..a76da960e4 100644 --- a/submodules/TelegramUI/Sources/ChatMessageInstantVideoItemNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageInstantVideoItemNode.swift @@ -393,7 +393,7 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView, UIGestureRecognizerD var replyBackgroundImage: UIImage? 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 ignoreSource = false @@ -511,7 +511,7 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView, UIGestureRecognizerD 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)) if let currentForwardBackgroundNode = currentForwardBackgroundNode { diff --git a/submodules/TelegramUI/Sources/SharedMediaPlayer.swift b/submodules/TelegramUI/Sources/SharedMediaPlayer.swift index 0b96de1a52..2e2c8bdc09 100644 --- a/submodules/TelegramUI/Sources/SharedMediaPlayer.swift +++ b/submodules/TelegramUI/Sources/SharedMediaPlayer.swift @@ -290,7 +290,12 @@ final class SharedMediaPlayer { player.play() } 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: playbackItem.pause()