From d63f5c2d6cb33906c2717b4fff2525458021cd05 Mon Sep 17 00:00:00 2001 From: Ali <> Date: Thu, 10 Jun 2021 16:35:57 +0400 Subject: [PATCH 1/2] Fix share button in channels with comments --- submodules/TelegramUI/Sources/AppDelegate.swift | 2 +- .../Sources/ChatMessageAnimatedStickerItemNode.swift | 10 ++++++---- .../TelegramUI/Sources/ChatMessageBubbleItemNode.swift | 6 +++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/submodules/TelegramUI/Sources/AppDelegate.swift b/submodules/TelegramUI/Sources/AppDelegate.swift index 557e54cefe..77e0fd8672 100644 --- a/submodules/TelegramUI/Sources/AppDelegate.swift +++ b/submodules/TelegramUI/Sources/AppDelegate.swift @@ -640,8 +640,8 @@ final class SharedApplicationContext { }, getAvailableAlternateIcons: { if #available(iOS 10.3, *) { var icons = [PresentationAppIcon(name: "Blue", imageName: "BlueIcon", isDefault: buildConfig.isAppStoreBuild), - PresentationAppIcon(name: "New1", imageName: "New1_180x180"), PresentationAppIcon(name: "New2", imageName: "New2_180x180"), + PresentationAppIcon(name: "New1", imageName: "New1_180x180"), PresentationAppIcon(name: "Black", imageName: "BlackIcon"), PresentationAppIcon(name: "BlueClassic", imageName: "BlueClassicIcon"), PresentationAppIcon(name: "BlackClassic", imageName: "BlackClassicIcon"), diff --git a/submodules/TelegramUI/Sources/ChatMessageAnimatedStickerItemNode.swift b/submodules/TelegramUI/Sources/ChatMessageAnimatedStickerItemNode.swift index b46d3957ce..aa3d2b9eeb 100644 --- a/submodules/TelegramUI/Sources/ChatMessageAnimatedStickerItemNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageAnimatedStickerItemNode.swift @@ -73,7 +73,7 @@ class ChatMessageShareButton: HighlightableButtonNode { fatalError("init(coder:) has not been implemented") } - func update(presentationData: ChatPresentationData, chatLocation: ChatLocation, subject: ChatControllerSubject?, message: Message, account: Account) -> CGSize { + func update(presentationData: ChatPresentationData, chatLocation: ChatLocation, subject: ChatControllerSubject?, message: Message, account: Account, disableComments: Bool = false) -> CGSize { var isReplies = false var replyCount = 0 if let channel = message.peers[message.id.peerId] as? TelegramChannel, case .broadcast = channel.info { @@ -89,13 +89,15 @@ class ChatMessageShareButton: HighlightableButtonNode { replyCount = 0 isReplies = false } + if disableComments { + replyCount = 0 + isReplies = false + } if self.theme !== presentationData.theme.theme || self.isReplies != isReplies { self.theme = presentationData.theme.theme self.isReplies = isReplies - - let graphics = PresentationResourcesChat.additionalGraphics(presentationData.theme.theme, wallpaper: presentationData.theme.wallpaper, bubbleCorners: presentationData.chatBubbleCorners) - + var updatedIconImage: UIImage? if case .pinnedMessages = subject { updatedIconImage = PresentationResourcesChat.chatFreeNavigateButtonIcon(presentationData.theme.theme, wallpaper: presentationData.theme.wallpaper) diff --git a/submodules/TelegramUI/Sources/ChatMessageBubbleItemNode.swift b/submodules/TelegramUI/Sources/ChatMessageBubbleItemNode.swift index 65f0138233..8aa40291dd 100644 --- a/submodules/TelegramUI/Sources/ChatMessageBubbleItemNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageBubbleItemNode.swift @@ -2719,7 +2719,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode } if let shareButtonNode = strongSelf.shareButtonNode { let currentBackgroundFrame = strongSelf.backgroundNode.frame - let buttonSize = shareButtonNode.update(presentationData: item.presentationData, chatLocation: item.chatLocation, subject: item.associatedData.subject, message: item.message, account: item.context.account) + let buttonSize = shareButtonNode.update(presentationData: item.presentationData, chatLocation: item.chatLocation, subject: item.associatedData.subject, message: item.message, account: item.context.account, disableComments: true) shareButtonNode.frame = CGRect(origin: CGPoint(x: currentBackgroundFrame.maxX + 8.0, y: currentBackgroundFrame.maxY - buttonSize.width - 1.0), size: buttonSize) } } else { @@ -2729,7 +2729,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode } strongSelf.messageAccessibilityArea.frame = backgroundFrame if let shareButtonNode = strongSelf.shareButtonNode { - let buttonSize = shareButtonNode.update(presentationData: item.presentationData, chatLocation: item.chatLocation, subject: item.associatedData.subject, message: item.message, account: item.context.account) + let buttonSize = shareButtonNode.update(presentationData: item.presentationData, chatLocation: item.chatLocation, subject: item.associatedData.subject, message: item.message, account: item.context.account, disableComments: true) shareButtonNode.frame = CGRect(origin: CGPoint(x: backgroundFrame.maxX + 8.0, y: backgroundFrame.maxY - buttonSize.width - 1.0), size: buttonSize) } @@ -2924,7 +2924,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode self.messageAccessibilityArea.frame = backgroundFrame if let item = self.item, let shareButtonNode = self.shareButtonNode { - let buttonSize = shareButtonNode.update(presentationData: item.presentationData, chatLocation: item.chatLocation, subject: item.associatedData.subject, message: item.message, account: item.context.account) + let buttonSize = shareButtonNode.update(presentationData: item.presentationData, chatLocation: item.chatLocation, subject: item.associatedData.subject, message: item.message, account: item.context.account, disableComments: true) shareButtonNode.frame = CGRect(origin: CGPoint(x: backgroundFrame.maxX + 8.0, y: backgroundFrame.maxY - buttonSize.width - 1.0), size: buttonSize) } From 13564f7d62775b8852a30c3d469aeed8f776eb35 Mon Sep 17 00:00:00 2001 From: overtake Date: Thu, 10 Jun 2021 17:29:11 +0300 Subject: [PATCH 2/2] set on pause for presentation + better updateVideoState --- .../TelegramCore/Sources/GroupCalls.swift | 29 ++++++++++++------- .../OngoingCallThreadLocalContext.h | 1 + .../Sources/OngoingCallThreadLocalContext.mm | 11 ++++++- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/submodules/TelegramCore/Sources/GroupCalls.swift b/submodules/TelegramCore/Sources/GroupCalls.swift index 5fcaeeb942..9aecd7cea3 100644 --- a/submodules/TelegramCore/Sources/GroupCalls.swift +++ b/submodules/TelegramCore/Sources/GroupCalls.swift @@ -1277,9 +1277,9 @@ public final class GroupCallParticipantsContext { private let resetInviteLinksDisposable = MetaDisposable() private let updateShouldBeRecordingDisposable = MetaDisposable() - private var localVideoIsMuted: Bool = true - private var localIsVideoPaused: Bool = true - + private var localVideoIsMuted: Bool? = nil + private var localIsVideoPaused: Bool? = nil + private var localIsPresentationPaused: Bool? = nil public struct ServiceState { fileprivate var nextActivityRank: Int = 0 } @@ -1877,13 +1877,14 @@ public final class GroupCallParticipantsContext { })) } - public func updateVideoState(peerId: PeerId, isVideoMuted: Bool, isVideoPaused: Bool) { - if self.localVideoIsMuted == isVideoMuted && self.localIsVideoPaused == isVideoPaused { + public func updateVideoState(peerId: PeerId, isVideoMuted: Bool?, isVideoPaused: Bool?, isPresentationPaused: Bool?) { + if self.localVideoIsMuted == isVideoMuted && self.localIsVideoPaused == isVideoPaused && self.localIsPresentationPaused == isPresentationPaused { return } self.localVideoIsMuted = isVideoMuted self.localIsVideoPaused = isVideoPaused - + self.localIsPresentationPaused = isPresentationPaused + let disposable = MetaDisposable() let account = self.account @@ -1900,16 +1901,24 @@ public final class GroupCallParticipantsContext { var flags: Int32 = 0 var videoMuted: Api.Bool? - videoMuted = isVideoMuted ? .boolTrue : .boolFalse - flags |= 1 << 3 + if let isVideoMuted = isVideoMuted { + videoMuted = isVideoMuted ? .boolTrue : .boolFalse + flags |= 1 << 3 + } var videoPaused: Api.Bool? - if !isVideoMuted { + if isVideoMuted != nil, let isVideoPaused = isVideoPaused { videoPaused = isVideoPaused ? .boolTrue : .boolFalse flags |= 1 << 4 } + var presentationPaused: Api.Bool? - return account.network.request(Api.functions.phone.editGroupCallParticipant(flags: flags, call: .inputGroupCall(id: id, accessHash: accessHash), participant: inputPeer, muted: nil, volume: nil, raiseHand: nil, videoStopped: videoMuted, videoPaused: videoPaused, presentationPaused: nil)) + if let isPresentationPaused = isPresentationPaused { + presentationPaused = isPresentationPaused ? .boolTrue : .boolFalse + flags |= 1 << 5 + } + + return account.network.request(Api.functions.phone.editGroupCallParticipant(flags: flags, call: .inputGroupCall(id: id, accessHash: accessHash), participant: inputPeer, muted: nil, volume: nil, raiseHand: nil, videoStopped: videoMuted, videoPaused: videoPaused, presentationPaused: presentationPaused)) |> map(Optional.init) |> `catch` { _ -> Signal in return .single(nil) diff --git a/submodules/TgVoipWebrtc/PublicHeaders/TgVoipWebrtc/OngoingCallThreadLocalContext.h b/submodules/TgVoipWebrtc/PublicHeaders/TgVoipWebrtc/OngoingCallThreadLocalContext.h index a847501721..6e8ca83fb0 100644 --- a/submodules/TgVoipWebrtc/PublicHeaders/TgVoipWebrtc/OngoingCallThreadLocalContext.h +++ b/submodules/TgVoipWebrtc/PublicHeaders/TgVoipWebrtc/OngoingCallThreadLocalContext.h @@ -122,6 +122,7 @@ typedef NS_ENUM(int32_t, OngoingCallDataSavingWebrtc) { - (void)makeOutgoingVideoView:(bool)requestClone completion:(void (^_Nonnull)(UIView * _Nullable, UIView * _Nullable))completion; - (void)setOnFatalError:(dispatch_block_t _Nullable)onError; +- (void)setOnPause:(void (^ _Nullable)(bool))onPause; - (void)setOnIsActiveUpdated:(void (^_Nonnull)(bool))onIsActiveUpdated; #if TARGET_OS_IOS diff --git a/submodules/TgVoipWebrtc/Sources/OngoingCallThreadLocalContext.mm b/submodules/TgVoipWebrtc/Sources/OngoingCallThreadLocalContext.mm index e10c71da82..be63b8f5c6 100644 --- a/submodules/TgVoipWebrtc/Sources/OngoingCallThreadLocalContext.mm +++ b/submodules/TgVoipWebrtc/Sources/OngoingCallThreadLocalContext.mm @@ -324,6 +324,13 @@ tgcalls::VideoCaptureInterfaceObject *GetVideoCaptureAssumingSameThread(tgcalls: #endif } +-(void)setOnPause:(void (^)(bool))onPause { +#if TARGET_OS_IOS +#else + _interface->setOnPause(onPause); +#endif +} + - (void)setOnIsActiveUpdated:(void (^)(bool))onIsActiveUpdated { _interface->setOnIsActiveUpdated([onIsActiveUpdated](bool isActive) { if (onIsActiveUpdated) { @@ -354,7 +361,9 @@ tgcalls::VideoCaptureInterfaceObject *GetVideoCaptureAssumingSameThread(tgcalls: if (requestClone) { cloneRenderer = [[VideoSampleBufferView alloc] initWithFrame:CGRectZero]; cloneRenderer.videoContentMode = UIViewContentModeScaleAspectFill; +#ifdef WEBRTC_IOS [remoteRenderer setCloneTarget:cloneRenderer]; +#endif } completion(remoteRenderer, cloneRenderer); @@ -367,10 +376,10 @@ tgcalls::VideoCaptureInterfaceObject *GetVideoCaptureAssumingSameThread(tgcalls: cloneRenderer = [[VideoMetalView alloc] initWithFrame:CGRectZero]; #ifdef WEBRTC_IOS cloneRenderer.videoContentMode = UIViewContentModeScaleToFill; + [remoteRenderer setClone:cloneRenderer]; #else cloneRenderer.videoContentMode = kCAGravityResizeAspectFill; #endif - [remoteRenderer setClone:cloneRenderer]; } std::shared_ptr> sink = [remoteRenderer getSink];