Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios

This commit is contained in:
Ilya Laktyushin 2021-06-10 17:42:40 +03:00
commit 19741bfd47
6 changed files with 40 additions and 19 deletions

View File

@ -1277,9 +1277,9 @@ public final class GroupCallParticipantsContext {
private let resetInviteLinksDisposable = MetaDisposable() private let resetInviteLinksDisposable = MetaDisposable()
private let updateShouldBeRecordingDisposable = MetaDisposable() private let updateShouldBeRecordingDisposable = MetaDisposable()
private var localVideoIsMuted: Bool = true private var localVideoIsMuted: Bool? = nil
private var localIsVideoPaused: Bool = true private var localIsVideoPaused: Bool? = nil
private var localIsPresentationPaused: Bool? = nil
public struct ServiceState { public struct ServiceState {
fileprivate var nextActivityRank: Int = 0 fileprivate var nextActivityRank: Int = 0
} }
@ -1877,12 +1877,13 @@ public final class GroupCallParticipantsContext {
})) }))
} }
public func updateVideoState(peerId: PeerId, isVideoMuted: Bool, isVideoPaused: Bool) { public func updateVideoState(peerId: PeerId, isVideoMuted: Bool?, isVideoPaused: Bool?, isPresentationPaused: Bool?) {
if self.localVideoIsMuted == isVideoMuted && self.localIsVideoPaused == isVideoPaused { if self.localVideoIsMuted == isVideoMuted && self.localIsVideoPaused == isVideoPaused && self.localIsPresentationPaused == isPresentationPaused {
return return
} }
self.localVideoIsMuted = isVideoMuted self.localVideoIsMuted = isVideoMuted
self.localIsVideoPaused = isVideoPaused self.localIsVideoPaused = isVideoPaused
self.localIsPresentationPaused = isPresentationPaused
let disposable = MetaDisposable() let disposable = MetaDisposable()
@ -1900,16 +1901,24 @@ public final class GroupCallParticipantsContext {
var flags: Int32 = 0 var flags: Int32 = 0
var videoMuted: Api.Bool? var videoMuted: Api.Bool?
videoMuted = isVideoMuted ? .boolTrue : .boolFalse if let isVideoMuted = isVideoMuted {
flags |= 1 << 3 videoMuted = isVideoMuted ? .boolTrue : .boolFalse
flags |= 1 << 3
}
var videoPaused: Api.Bool? var videoPaused: Api.Bool?
if !isVideoMuted { if isVideoMuted != nil, let isVideoPaused = isVideoPaused {
videoPaused = isVideoPaused ? .boolTrue : .boolFalse videoPaused = isVideoPaused ? .boolTrue : .boolFalse
flags |= 1 << 4 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) |> map(Optional.init)
|> `catch` { _ -> Signal<Api.Updates?, NoError> in |> `catch` { _ -> Signal<Api.Updates?, NoError> in
return .single(nil) return .single(nil)

View File

@ -640,8 +640,8 @@ final class SharedApplicationContext {
}, getAvailableAlternateIcons: { }, getAvailableAlternateIcons: {
if #available(iOS 10.3, *) { if #available(iOS 10.3, *) {
var icons = [PresentationAppIcon(name: "Blue", imageName: "BlueIcon", isDefault: buildConfig.isAppStoreBuild), var icons = [PresentationAppIcon(name: "Blue", imageName: "BlueIcon", isDefault: buildConfig.isAppStoreBuild),
PresentationAppIcon(name: "New1", imageName: "New1_180x180"),
PresentationAppIcon(name: "New2", imageName: "New2_180x180"), PresentationAppIcon(name: "New2", imageName: "New2_180x180"),
PresentationAppIcon(name: "New1", imageName: "New1_180x180"),
PresentationAppIcon(name: "Black", imageName: "BlackIcon"), PresentationAppIcon(name: "Black", imageName: "BlackIcon"),
PresentationAppIcon(name: "BlueClassic", imageName: "BlueClassicIcon"), PresentationAppIcon(name: "BlueClassic", imageName: "BlueClassicIcon"),
PresentationAppIcon(name: "BlackClassic", imageName: "BlackClassicIcon"), PresentationAppIcon(name: "BlackClassic", imageName: "BlackClassicIcon"),

View File

@ -73,7 +73,7 @@ class ChatMessageShareButton: HighlightableButtonNode {
fatalError("init(coder:) has not been implemented") 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 isReplies = false
var replyCount = 0 var replyCount = 0
if let channel = message.peers[message.id.peerId] as? TelegramChannel, case .broadcast = channel.info { if let channel = message.peers[message.id.peerId] as? TelegramChannel, case .broadcast = channel.info {
@ -89,13 +89,15 @@ class ChatMessageShareButton: HighlightableButtonNode {
replyCount = 0 replyCount = 0
isReplies = false isReplies = false
} }
if disableComments {
replyCount = 0
isReplies = false
}
if self.theme !== presentationData.theme.theme || self.isReplies != isReplies { if self.theme !== presentationData.theme.theme || self.isReplies != isReplies {
self.theme = presentationData.theme.theme self.theme = presentationData.theme.theme
self.isReplies = isReplies self.isReplies = isReplies
let graphics = PresentationResourcesChat.additionalGraphics(presentationData.theme.theme, wallpaper: presentationData.theme.wallpaper, bubbleCorners: presentationData.chatBubbleCorners)
var updatedIconImage: UIImage? var updatedIconImage: UIImage?
if case .pinnedMessages = subject { if case .pinnedMessages = subject {
updatedIconImage = PresentationResourcesChat.chatFreeNavigateButtonIcon(presentationData.theme.theme, wallpaper: presentationData.theme.wallpaper) updatedIconImage = PresentationResourcesChat.chatFreeNavigateButtonIcon(presentationData.theme.theme, wallpaper: presentationData.theme.wallpaper)

View File

@ -2719,7 +2719,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
} }
if let shareButtonNode = strongSelf.shareButtonNode { if let shareButtonNode = strongSelf.shareButtonNode {
let currentBackgroundFrame = strongSelf.backgroundNode.frame 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) shareButtonNode.frame = CGRect(origin: CGPoint(x: currentBackgroundFrame.maxX + 8.0, y: currentBackgroundFrame.maxY - buttonSize.width - 1.0), size: buttonSize)
} }
} else { } else {
@ -2729,7 +2729,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
} }
strongSelf.messageAccessibilityArea.frame = backgroundFrame strongSelf.messageAccessibilityArea.frame = backgroundFrame
if let shareButtonNode = strongSelf.shareButtonNode { 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) 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 self.messageAccessibilityArea.frame = backgroundFrame
if let item = self.item, let shareButtonNode = self.shareButtonNode { 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) shareButtonNode.frame = CGRect(origin: CGPoint(x: backgroundFrame.maxX + 8.0, y: backgroundFrame.maxY - buttonSize.width - 1.0), size: buttonSize)
} }

View File

@ -122,6 +122,7 @@ typedef NS_ENUM(int32_t, OngoingCallDataSavingWebrtc) {
- (void)makeOutgoingVideoView:(bool)requestClone completion:(void (^_Nonnull)(UIView<OngoingCallThreadLocalContextWebrtcVideoView> * _Nullable, UIView<OngoingCallThreadLocalContextWebrtcVideoView> * _Nullable))completion; - (void)makeOutgoingVideoView:(bool)requestClone completion:(void (^_Nonnull)(UIView<OngoingCallThreadLocalContextWebrtcVideoView> * _Nullable, UIView<OngoingCallThreadLocalContextWebrtcVideoView> * _Nullable))completion;
- (void)setOnFatalError:(dispatch_block_t _Nullable)onError; - (void)setOnFatalError:(dispatch_block_t _Nullable)onError;
- (void)setOnPause:(void (^ _Nullable)(bool))onPause;
- (void)setOnIsActiveUpdated:(void (^_Nonnull)(bool))onIsActiveUpdated; - (void)setOnIsActiveUpdated:(void (^_Nonnull)(bool))onIsActiveUpdated;
#if TARGET_OS_IOS #if TARGET_OS_IOS

View File

@ -324,6 +324,13 @@ tgcalls::VideoCaptureInterfaceObject *GetVideoCaptureAssumingSameThread(tgcalls:
#endif #endif
} }
-(void)setOnPause:(void (^)(bool))onPause {
#if TARGET_OS_IOS
#else
_interface->setOnPause(onPause);
#endif
}
- (void)setOnIsActiveUpdated:(void (^)(bool))onIsActiveUpdated { - (void)setOnIsActiveUpdated:(void (^)(bool))onIsActiveUpdated {
_interface->setOnIsActiveUpdated([onIsActiveUpdated](bool isActive) { _interface->setOnIsActiveUpdated([onIsActiveUpdated](bool isActive) {
if (onIsActiveUpdated) { if (onIsActiveUpdated) {
@ -354,7 +361,9 @@ tgcalls::VideoCaptureInterfaceObject *GetVideoCaptureAssumingSameThread(tgcalls:
if (requestClone) { if (requestClone) {
cloneRenderer = [[VideoSampleBufferView alloc] initWithFrame:CGRectZero]; cloneRenderer = [[VideoSampleBufferView alloc] initWithFrame:CGRectZero];
cloneRenderer.videoContentMode = UIViewContentModeScaleAspectFill; cloneRenderer.videoContentMode = UIViewContentModeScaleAspectFill;
#ifdef WEBRTC_IOS
[remoteRenderer setCloneTarget:cloneRenderer]; [remoteRenderer setCloneTarget:cloneRenderer];
#endif
} }
completion(remoteRenderer, cloneRenderer); completion(remoteRenderer, cloneRenderer);
@ -367,10 +376,10 @@ tgcalls::VideoCaptureInterfaceObject *GetVideoCaptureAssumingSameThread(tgcalls:
cloneRenderer = [[VideoMetalView alloc] initWithFrame:CGRectZero]; cloneRenderer = [[VideoMetalView alloc] initWithFrame:CGRectZero];
#ifdef WEBRTC_IOS #ifdef WEBRTC_IOS
cloneRenderer.videoContentMode = UIViewContentModeScaleToFill; cloneRenderer.videoContentMode = UIViewContentModeScaleToFill;
[remoteRenderer setClone:cloneRenderer];
#else #else
cloneRenderer.videoContentMode = kCAGravityResizeAspectFill; cloneRenderer.videoContentMode = kCAGravityResizeAspectFill;
#endif #endif
[remoteRenderer setClone:cloneRenderer];
} }
std::shared_ptr<rtc::VideoSinkInterface<webrtc::VideoFrame>> sink = [remoteRenderer getSink]; std::shared_ptr<rtc::VideoSinkInterface<webrtc::VideoFrame>> sink = [remoteRenderer getSink];