mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
This commit is contained in:
commit
37b9b53a9a
@ -800,7 +800,7 @@ public extension ContainedViewLayoutTransition {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateSublayerTransformScale(node: ASDisplayNode, scale: CGPoint, completion: ((Bool) -> Void)? = nil) {
|
func updateSublayerTransformScale(node: ASDisplayNode, scale: CGPoint, beginWithCurrentState: Bool = false, completion: ((Bool) -> Void)? = nil) {
|
||||||
if !node.isNodeLoaded {
|
if !node.isNodeLoaded {
|
||||||
node.subnodeTransform = CATransform3DMakeScale(scale.x, scale.y, 1.0)
|
node.subnodeTransform = CATransform3DMakeScale(scale.x, scale.y, 1.0)
|
||||||
completion?(true)
|
completion?(true)
|
||||||
@ -826,8 +826,15 @@ public extension ContainedViewLayoutTransition {
|
|||||||
completion(true)
|
completion(true)
|
||||||
}
|
}
|
||||||
case let .animated(duration, curve):
|
case let .animated(duration, curve):
|
||||||
|
let initialTransform: CATransform3D
|
||||||
|
if beginWithCurrentState, node.isNodeLoaded {
|
||||||
|
initialTransform = node.layer.presentation()?.sublayerTransform ?? t
|
||||||
|
} else {
|
||||||
|
initialTransform = t
|
||||||
|
}
|
||||||
|
|
||||||
node.layer.sublayerTransform = CATransform3DMakeScale(scale.x, scale.y, 1.0)
|
node.layer.sublayerTransform = CATransform3DMakeScale(scale.x, scale.y, 1.0)
|
||||||
node.layer.animate(from: NSValue(caTransform3D: t), to: NSValue(caTransform3D: node.layer.sublayerTransform), keyPath: "sublayerTransform", timingFunction: curve.timingFunction, duration: duration, delay: 0.0, mediaTimingFunction: curve.mediaTimingFunction, removeOnCompletion: true, additive: false, completion: {
|
node.layer.animate(from: NSValue(caTransform3D: initialTransform), to: NSValue(caTransform3D: node.layer.sublayerTransform), keyPath: "sublayerTransform", timingFunction: curve.timingFunction, duration: duration, delay: 0.0, mediaTimingFunction: curve.mediaTimingFunction, removeOnCompletion: true, additive: false, completion: {
|
||||||
result in
|
result in
|
||||||
if let completion = completion {
|
if let completion = completion {
|
||||||
completion(result)
|
completion(result)
|
||||||
|
@ -852,7 +852,9 @@ public func rebuildControllerStackAfterSupergroupUpgrade(controller: ViewControl
|
|||||||
if controllers[i] === controller {
|
if controllers[i] === controller {
|
||||||
for j in 0 ..< i {
|
for j in 0 ..< i {
|
||||||
if controllers[j] is ChatController {
|
if controllers[j] is ChatController {
|
||||||
|
if j + 1 <= i - 1 {
|
||||||
controllers.removeSubrange(j + 1 ... i - 1)
|
controllers.removeSubrange(j + 1 ... i - 1)
|
||||||
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import AccountContext
|
|||||||
import AppBundle
|
import AppBundle
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
import AnimatedAvatarSetNode
|
import AnimatedAvatarSetNode
|
||||||
|
import AudioBlob
|
||||||
|
|
||||||
private let titleFont = Font.semibold(15.0)
|
private let titleFont = Font.semibold(15.0)
|
||||||
private let subtitleFont = Font.regular(13.0)
|
private let subtitleFont = Font.regular(13.0)
|
||||||
@ -61,9 +62,12 @@ public final class GroupCallNavigationAccessoryPanel: ASDisplayNode {
|
|||||||
private let joinButtonTitleNode: ImmediateTextNode
|
private let joinButtonTitleNode: ImmediateTextNode
|
||||||
private let joinButtonBackgroundNode: ASImageNode
|
private let joinButtonBackgroundNode: ASImageNode
|
||||||
|
|
||||||
|
private var audioLevelView: VoiceBlobView?
|
||||||
|
|
||||||
private let micButton: HighlightTrackingButtonNode
|
private let micButton: HighlightTrackingButtonNode
|
||||||
private let micButtonForegroundNode: VoiceChatMicrophoneNode
|
private let micButtonForegroundNode: VoiceChatMicrophoneNode
|
||||||
private let micButtonBackgroundNode: ASImageNode
|
private let micButtonBackgroundNode: ASImageNode
|
||||||
|
private var micButtonBackgroundNodeIsMuted: Bool?
|
||||||
|
|
||||||
let titleNode: ImmediateTextNode
|
let titleNode: ImmediateTextNode
|
||||||
let textNode: ImmediateTextNode
|
let textNode: ImmediateTextNode
|
||||||
@ -77,6 +81,9 @@ public final class GroupCallNavigationAccessoryPanel: ASDisplayNode {
|
|||||||
|
|
||||||
private let membersDisposable = MetaDisposable()
|
private let membersDisposable = MetaDisposable()
|
||||||
private let isMutedDisposable = MetaDisposable()
|
private let isMutedDisposable = MetaDisposable()
|
||||||
|
private let audioLevelDisposable = MetaDisposable()
|
||||||
|
|
||||||
|
private var callState: PresentationGroupCallState?
|
||||||
|
|
||||||
private var currentData: GroupCallPanelData?
|
private var currentData: GroupCallPanelData?
|
||||||
private var validLayout: (CGSize, CGFloat, CGFloat)?
|
private var validLayout: (CGSize, CGFloat, CGFloat)?
|
||||||
@ -182,16 +189,18 @@ public final class GroupCallNavigationAccessoryPanel: ASDisplayNode {
|
|||||||
private var actionButtonPressGestureStartTime: Double = 0.0
|
private var actionButtonPressGestureStartTime: Double = 0.0
|
||||||
|
|
||||||
@objc private func micButtonPressGesture(_ gestureRecognizer: UILongPressGestureRecognizer) {
|
@objc private func micButtonPressGesture(_ gestureRecognizer: UILongPressGestureRecognizer) {
|
||||||
guard let call = self.currentData?.groupCall else {
|
guard let call = self.currentData?.groupCall, let callState = self.callState else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
switch gestureRecognizer.state {
|
switch gestureRecognizer.state {
|
||||||
case .began:
|
case .began:
|
||||||
self.actionButtonPressGestureStartTime = CACurrentMediaTime()
|
self.actionButtonPressGestureStartTime = CACurrentMediaTime()
|
||||||
|
if callState.muteState != nil {
|
||||||
call.setIsMuted(action: .muted(isPushToTalkActive: true))
|
call.setIsMuted(action: .muted(isPushToTalkActive: true))
|
||||||
|
}
|
||||||
case .ended, .cancelled:
|
case .ended, .cancelled:
|
||||||
let timestamp = CACurrentMediaTime()
|
let timestamp = CACurrentMediaTime()
|
||||||
if timestamp - self.actionButtonPressGestureStartTime < 0.2 {
|
if callState.muteState != nil || timestamp - self.actionButtonPressGestureStartTime < 0.1 {
|
||||||
call.toggleIsMuted()
|
call.toggleIsMuted()
|
||||||
} else {
|
} else {
|
||||||
call.setIsMuted(action: .muted(isPushToTalkActive: false))
|
call.setIsMuted(action: .muted(isPushToTalkActive: false))
|
||||||
@ -214,9 +223,6 @@ public final class GroupCallNavigationAccessoryPanel: ASDisplayNode {
|
|||||||
self.joinButtonTitleNode.attributedText = NSAttributedString(string: presentationData.strings.VoiceChat_PanelJoin.uppercased(), font: Font.semibold(15.0), textColor: presentationData.theme.chat.inputPanel.actionControlForegroundColor)
|
self.joinButtonTitleNode.attributedText = NSAttributedString(string: presentationData.strings.VoiceChat_PanelJoin.uppercased(), font: Font.semibold(15.0), textColor: presentationData.theme.chat.inputPanel.actionControlForegroundColor)
|
||||||
self.joinButtonBackgroundNode.image = generateStretchableFilledCircleImage(diameter: 28.0, color: presentationData.theme.chat.inputPanel.actionControlFillColor)
|
self.joinButtonBackgroundNode.image = generateStretchableFilledCircleImage(diameter: 28.0, color: presentationData.theme.chat.inputPanel.actionControlFillColor)
|
||||||
|
|
||||||
//TODO:localize
|
|
||||||
self.micButtonBackgroundNode.image = generateStretchableFilledCircleImage(diameter: 36.0, color: UIColor(rgb: 0x30b251))
|
|
||||||
|
|
||||||
self.titleNode.attributedText = NSAttributedString(string: presentationData.strings.VoiceChat_Title, font: Font.semibold(15.0), textColor: presentationData.theme.chat.inputPanel.primaryTextColor)
|
self.titleNode.attributedText = NSAttributedString(string: presentationData.strings.VoiceChat_Title, font: Font.semibold(15.0), textColor: presentationData.theme.chat.inputPanel.primaryTextColor)
|
||||||
self.textNode.attributedText = NSAttributedString(string: self.textNode.attributedText?.string ?? "", font: Font.regular(13.0), textColor: presentationData.theme.chat.inputPanel.secondaryTextColor)
|
self.textNode.attributedText = NSAttributedString(string: self.textNode.attributedText?.string ?? "", font: Font.regular(13.0), textColor: presentationData.theme.chat.inputPanel.secondaryTextColor)
|
||||||
|
|
||||||
@ -239,6 +245,8 @@ public final class GroupCallNavigationAccessoryPanel: ASDisplayNode {
|
|||||||
|
|
||||||
self.textNode.attributedText = NSAttributedString(string: membersText, font: Font.regular(13.0), textColor: self.theme.chat.inputPanel.secondaryTextColor)
|
self.textNode.attributedText = NSAttributedString(string: membersText, font: Font.regular(13.0), textColor: self.theme.chat.inputPanel.secondaryTextColor)
|
||||||
|
|
||||||
|
self.callState = nil
|
||||||
|
|
||||||
self.membersDisposable.set(nil)
|
self.membersDisposable.set(nil)
|
||||||
self.isMutedDisposable.set(nil)
|
self.isMutedDisposable.set(nil)
|
||||||
|
|
||||||
@ -272,15 +280,80 @@ public final class GroupCallNavigationAccessoryPanel: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
self.isMutedDisposable.set((groupCall.isMuted
|
self.isMutedDisposable.set((groupCall.state
|
||||||
|> deliverOnMainQueue).start(next: { [weak self] isMuted in
|
|> deliverOnMainQueue).start(next: { [weak self] callState in
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
strongSelf.micButtonForegroundNode.update(state: VoiceChatMicrophoneNode.State(muted: isMuted, color: UIColor.white), animated: true)
|
|
||||||
|
var transition: ContainedViewLayoutTransition = .immediate
|
||||||
|
if strongSelf.callState != nil {
|
||||||
|
transition = .animated(duration: 0.3, curve: .spring)
|
||||||
|
}
|
||||||
|
|
||||||
|
strongSelf.callState = callState
|
||||||
|
|
||||||
|
if let (size, leftInset, rightInset) = strongSelf.validLayout {
|
||||||
|
strongSelf.updateLayout(size: size, leftInset: leftInset, rightInset: rightInset, transition: transition)
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
|
||||||
|
self.audioLevelDisposable.set((groupCall.myAudioLevel
|
||||||
|
|> deliverOnMainQueue).start(next: { [weak self] value in
|
||||||
|
guard let strongSelf = self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if strongSelf.audioLevelView == nil {
|
||||||
|
let blobFrame = CGRect(origin: CGPoint(), size: CGSize(width: 36.0, height: 36.0)).insetBy(dx: -12.0, dy: -12.0)
|
||||||
|
|
||||||
|
let audioLevelView = VoiceBlobView(
|
||||||
|
frame: blobFrame,
|
||||||
|
maxLevel: 0.3,
|
||||||
|
smallBlobRange: (0, 0),
|
||||||
|
mediumBlobRange: (0.7, 0.8),
|
||||||
|
bigBlobRange: (0.8, 0.9)
|
||||||
|
)
|
||||||
|
|
||||||
|
let maskRect = CGRect(origin: .zero, size: blobFrame.size)
|
||||||
|
let playbackMaskLayer = CAShapeLayer()
|
||||||
|
playbackMaskLayer.frame = maskRect
|
||||||
|
playbackMaskLayer.fillRule = .evenOdd
|
||||||
|
let maskPath = UIBezierPath()
|
||||||
|
maskPath.append(UIBezierPath(roundedRect: maskRect.insetBy(dx: 12, dy: 12), cornerRadius: 22))
|
||||||
|
maskPath.append(UIBezierPath(rect: maskRect))
|
||||||
|
playbackMaskLayer.path = maskPath.cgPath
|
||||||
|
audioLevelView.layer.mask = playbackMaskLayer
|
||||||
|
|
||||||
|
audioLevelView.setColor(UIColor(rgb: 0x30B251))
|
||||||
|
strongSelf.audioLevelView = audioLevelView
|
||||||
|
|
||||||
|
strongSelf.micButton.view.insertSubview(audioLevelView, at: 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
var value = value
|
||||||
|
if value <= 0.15 {
|
||||||
|
value = 0.0
|
||||||
|
}
|
||||||
|
let level = min(1.0, max(0.0, CGFloat(value)))
|
||||||
|
let avatarScale: CGFloat
|
||||||
|
|
||||||
|
strongSelf.audioLevelView?.updateLevel(CGFloat(value) * 2.0)
|
||||||
|
if value > 0.0 {
|
||||||
|
strongSelf.audioLevelView?.startAnimating()
|
||||||
|
avatarScale = 1.03 + level * 0.1
|
||||||
|
} else {
|
||||||
|
strongSelf.audioLevelView?.stopAnimating(duration: 0.5)
|
||||||
|
avatarScale = 1.0
|
||||||
|
}
|
||||||
|
|
||||||
|
//let transition: ContainedViewLayoutTransition = .animated(duration: 0.15, curve: .spring)
|
||||||
|
//transition.updateSublayerTransformScale(node: strongSelf.avatarNode, scale: avatarScale, beginWithCurrentState: true)
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
} else if data.groupCall == nil {
|
} else if data.groupCall == nil {
|
||||||
|
self.audioLevelDisposable.set(nil)
|
||||||
|
|
||||||
let membersText: String
|
let membersText: String
|
||||||
let membersTextIsActive: Bool
|
let membersTextIsActive: Bool
|
||||||
if data.numberOfActiveSpeakers != 0 {
|
if data.numberOfActiveSpeakers != 0 {
|
||||||
@ -334,6 +407,26 @@ public final class GroupCallNavigationAccessoryPanel: ASDisplayNode {
|
|||||||
let animationSize = CGSize(width: 36.0, height: 36.0)
|
let animationSize = CGSize(width: 36.0, height: 36.0)
|
||||||
transition.updateFrame(node: self.micButtonForegroundNode, frame: CGRect(origin: CGPoint(x: floor((micButtonFrame.width - animationSize.width) / 2.0), y: floor((micButtonFrame.height - animationSize.height) / 2.0)), size: animationSize))
|
transition.updateFrame(node: self.micButtonForegroundNode, frame: CGRect(origin: CGPoint(x: floor((micButtonFrame.width - animationSize.width) / 2.0), y: floor((micButtonFrame.height - animationSize.height) / 2.0)), size: animationSize))
|
||||||
|
|
||||||
|
var isMuted = true
|
||||||
|
if let _ = self.callState?.muteState {
|
||||||
|
isMuted = true
|
||||||
|
} else {
|
||||||
|
isMuted = false
|
||||||
|
}
|
||||||
|
self.micButtonForegroundNode.update(state: VoiceChatMicrophoneNode.State(muted: isMuted, color: UIColor.white), animated: transition.isAnimated)
|
||||||
|
|
||||||
|
if isMuted != self.micButtonBackgroundNodeIsMuted {
|
||||||
|
self.micButtonBackgroundNodeIsMuted = isMuted
|
||||||
|
let updatedImage = generateStretchableFilledCircleImage(diameter: 36.0, color: isMuted ? UIColor(rgb: 0xb6b6bb) : UIColor(rgb: 0x30b251))
|
||||||
|
|
||||||
|
if let updatedImage = updatedImage, let previousImage = self.micButtonBackgroundNode.image?.cgImage, transition.isAnimated {
|
||||||
|
self.micButtonBackgroundNode.image = updatedImage
|
||||||
|
self.micButtonBackgroundNode.layer.animate(from: previousImage, to: updatedImage.cgImage!, keyPath: "contents", timingFunction: CAMediaTimingFunctionName.easeOut.rawValue, duration: 0.25, delay: 0.0)
|
||||||
|
} else {
|
||||||
|
self.micButtonBackgroundNode.image = updatedImage
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let titleSize = self.titleNode.updateLayout(CGSize(width: size.width, height: .greatestFiniteMagnitude))
|
let titleSize = self.titleNode.updateLayout(CGSize(width: size.width, height: .greatestFiniteMagnitude))
|
||||||
let textSize = self.textNode.updateLayout(CGSize(width: size.width, height: .greatestFiniteMagnitude))
|
let textSize = self.textNode.updateLayout(CGSize(width: size.width, height: .greatestFiniteMagnitude))
|
||||||
|
|
||||||
|
@ -60,6 +60,7 @@ public final class PresentationCallManagerImpl: PresentationCallManager {
|
|||||||
}
|
}
|
||||||
private var currentCallDisposable = MetaDisposable()
|
private var currentCallDisposable = MetaDisposable()
|
||||||
private let removeCurrentCallDisposable = MetaDisposable()
|
private let removeCurrentCallDisposable = MetaDisposable()
|
||||||
|
private let removeCurrentGroupCallDisposable = MetaDisposable()
|
||||||
|
|
||||||
private var currentGroupCallValue: PresentationGroupCallImpl?
|
private var currentGroupCallValue: PresentationGroupCallImpl?
|
||||||
private var currentGroupCall: PresentationGroupCallImpl? {
|
private var currentGroupCall: PresentationGroupCallImpl? {
|
||||||
@ -68,9 +69,17 @@ public final class PresentationCallManagerImpl: PresentationCallManager {
|
|||||||
|
|
||||||
private var ringingStatesDisposable: Disposable?
|
private var ringingStatesDisposable: Disposable?
|
||||||
|
|
||||||
private let hasActiveCallsPromise = ValuePromise<Bool>(false, ignoreRepeated: true)
|
private let hasActivePersonalCallsPromise = ValuePromise<Bool>(false, ignoreRepeated: true)
|
||||||
|
private let hasActiveGroupCallsPromise = ValuePromise<Bool>(false, ignoreRepeated: true)
|
||||||
public var hasActiveCalls: Signal<Bool, NoError> {
|
public var hasActiveCalls: Signal<Bool, NoError> {
|
||||||
return self.hasActiveCallsPromise.get()
|
return combineLatest(queue: .mainQueue(),
|
||||||
|
self.hasActivePersonalCallsPromise.get(),
|
||||||
|
self.hasActiveGroupCallsPromise.get()
|
||||||
|
)
|
||||||
|
|> map { value1, value2 -> Bool in
|
||||||
|
return value1 || value2
|
||||||
|
}
|
||||||
|
|> distinctUntilChanged
|
||||||
}
|
}
|
||||||
|
|
||||||
private let currentCallPromise = Promise<PresentationCall?>(nil)
|
private let currentCallPromise = Promise<PresentationCall?>(nil)
|
||||||
@ -254,6 +263,7 @@ public final class PresentationCallManagerImpl: PresentationCallManager {
|
|||||||
self.currentCallDisposable.dispose()
|
self.currentCallDisposable.dispose()
|
||||||
self.ringingStatesDisposable?.dispose()
|
self.ringingStatesDisposable?.dispose()
|
||||||
self.removeCurrentCallDisposable.dispose()
|
self.removeCurrentCallDisposable.dispose()
|
||||||
|
self.removeCurrentGroupCallDisposable.dispose()
|
||||||
self.startCallDisposable.dispose()
|
self.startCallDisposable.dispose()
|
||||||
self.proxyServerDisposable?.dispose()
|
self.proxyServerDisposable?.dispose()
|
||||||
self.callSettingsDisposable?.dispose()
|
self.callSettingsDisposable?.dispose()
|
||||||
@ -300,14 +310,14 @@ public final class PresentationCallManagerImpl: PresentationCallManager {
|
|||||||
)
|
)
|
||||||
strongSelf.updateCurrentCall(call)
|
strongSelf.updateCurrentCall(call)
|
||||||
strongSelf.currentCallPromise.set(.single(call))
|
strongSelf.currentCallPromise.set(.single(call))
|
||||||
strongSelf.hasActiveCallsPromise.set(true)
|
strongSelf.hasActivePersonalCallsPromise.set(true)
|
||||||
strongSelf.removeCurrentCallDisposable.set((call.canBeRemoved
|
strongSelf.removeCurrentCallDisposable.set((call.canBeRemoved
|
||||||
|> deliverOnMainQueue).start(next: { [weak self, weak call] value in
|
|> deliverOnMainQueue).start(next: { [weak self, weak call] value in
|
||||||
if value, let strongSelf = self, let call = call {
|
if value, let strongSelf = self, let call = call {
|
||||||
if strongSelf.currentCall === call {
|
if strongSelf.currentCall === call {
|
||||||
strongSelf.updateCurrentCall(nil)
|
strongSelf.updateCurrentCall(nil)
|
||||||
strongSelf.currentCallPromise.set(.single(nil))
|
strongSelf.currentCallPromise.set(.single(nil))
|
||||||
strongSelf.hasActiveCallsPromise.set(false)
|
strongSelf.hasActivePersonalCallsPromise.set(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
@ -331,6 +341,9 @@ public final class PresentationCallManagerImpl: PresentationCallManager {
|
|||||||
if let call = self.currentCall {
|
if let call = self.currentCall {
|
||||||
alreadyInCall = true
|
alreadyInCall = true
|
||||||
alreadyInCallWithPeerId = call.peerId
|
alreadyInCallWithPeerId = call.peerId
|
||||||
|
} else if let currentGroupCall = self.currentGroupCallValue {
|
||||||
|
alreadyInCall = true
|
||||||
|
alreadyInCallWithPeerId = currentGroupCall.peerId
|
||||||
} else {
|
} else {
|
||||||
if #available(iOS 10.0, *) {
|
if #available(iOS 10.0, *) {
|
||||||
if CXCallObserver().calls.contains(where: { $0.hasEnded == false }) {
|
if CXCallObserver().calls.contains(where: { $0.hasEnded == false }) {
|
||||||
@ -395,6 +408,13 @@ public final class PresentationCallManagerImpl: PresentationCallManager {
|
|||||||
|> deliverOnMainQueue).start(next: { _ in
|
|> deliverOnMainQueue).start(next: { _ in
|
||||||
begin()
|
begin()
|
||||||
}))
|
}))
|
||||||
|
} else if let currentGroupCall = self.currentGroupCallValue {
|
||||||
|
self.startCallDisposable.set((currentGroupCall.leave(terminateIfPossible: false)
|
||||||
|
|> filter { $0 }
|
||||||
|
|> take(1)
|
||||||
|
|> deliverOnMainQueue).start(next: { _ in
|
||||||
|
begin()
|
||||||
|
}))
|
||||||
} else {
|
} else {
|
||||||
begin()
|
begin()
|
||||||
}
|
}
|
||||||
@ -410,6 +430,13 @@ public final class PresentationCallManagerImpl: PresentationCallManager {
|
|||||||
|> deliverOnMainQueue).start(next: { _ in
|
|> deliverOnMainQueue).start(next: { _ in
|
||||||
begin()
|
begin()
|
||||||
}))
|
}))
|
||||||
|
} else if let currentGroupCall = self.currentGroupCallValue {
|
||||||
|
self.startCallDisposable.set((currentGroupCall.leave(terminateIfPossible: false)
|
||||||
|
|> filter { $0 }
|
||||||
|
|> take(1)
|
||||||
|
|> deliverOnMainQueue).start(next: { _ in
|
||||||
|
begin()
|
||||||
|
}))
|
||||||
} else {
|
} else {
|
||||||
begin()
|
begin()
|
||||||
}
|
}
|
||||||
@ -544,14 +571,14 @@ public final class PresentationCallManagerImpl: PresentationCallManager {
|
|||||||
)
|
)
|
||||||
strongSelf.updateCurrentCall(call)
|
strongSelf.updateCurrentCall(call)
|
||||||
strongSelf.currentCallPromise.set(.single(call))
|
strongSelf.currentCallPromise.set(.single(call))
|
||||||
strongSelf.hasActiveCallsPromise.set(true)
|
strongSelf.hasActivePersonalCallsPromise.set(true)
|
||||||
strongSelf.removeCurrentCallDisposable.set((call.canBeRemoved
|
strongSelf.removeCurrentCallDisposable.set((call.canBeRemoved
|
||||||
|> deliverOnMainQueue).start(next: { [weak call] value in
|
|> deliverOnMainQueue).start(next: { [weak call] value in
|
||||||
if value, let strongSelf = self, let call = call {
|
if value, let strongSelf = self, let call = call {
|
||||||
if strongSelf.currentCall === call {
|
if strongSelf.currentCall === call {
|
||||||
strongSelf.updateCurrentCall(nil)
|
strongSelf.updateCurrentCall(nil)
|
||||||
strongSelf.currentCallPromise.set(.single(nil))
|
strongSelf.currentCallPromise.set(.single(nil))
|
||||||
strongSelf.hasActiveCallsPromise.set(false)
|
strongSelf.hasActivePersonalCallsPromise.set(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
@ -597,6 +624,7 @@ public final class PresentationCallManagerImpl: PresentationCallManager {
|
|||||||
let begin: () -> Void = { [weak self] in
|
let begin: () -> Void = { [weak self] in
|
||||||
let _ = self?.startGroupCall(accountContext: context, peerId: peerId, initialCall: initialCall, sourcePanel: sourcePanel).start()
|
let _ = self?.startGroupCall(accountContext: context, peerId: peerId, initialCall: initialCall, sourcePanel: sourcePanel).start()
|
||||||
}
|
}
|
||||||
|
|
||||||
if let currentGroupCall = self.currentGroupCallValue {
|
if let currentGroupCall = self.currentGroupCallValue {
|
||||||
if endCurrentIfAny {
|
if endCurrentIfAny {
|
||||||
let endSignal = currentGroupCall.leave(terminateIfPossible: false)
|
let endSignal = currentGroupCall.leave(terminateIfPossible: false)
|
||||||
@ -609,6 +637,16 @@ public final class PresentationCallManagerImpl: PresentationCallManager {
|
|||||||
} else {
|
} else {
|
||||||
return .alreadyInProgress(currentGroupCall.peerId)
|
return .alreadyInProgress(currentGroupCall.peerId)
|
||||||
}
|
}
|
||||||
|
} else if let currentCall = self.currentCall {
|
||||||
|
if endCurrentIfAny {
|
||||||
|
self.callKitIntegration?.dropCall(uuid: currentCall.internalId)
|
||||||
|
self.startCallDisposable.set((currentCall.hangUp()
|
||||||
|
|> deliverOnMainQueue).start(next: { _ in
|
||||||
|
begin()
|
||||||
|
}))
|
||||||
|
} else {
|
||||||
|
return .alreadyInProgress(currentCall.peerId)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
begin()
|
begin()
|
||||||
}
|
}
|
||||||
@ -674,14 +712,19 @@ public final class PresentationCallManagerImpl: PresentationCallManager {
|
|||||||
call.sourcePanel = sourcePanel
|
call.sourcePanel = sourcePanel
|
||||||
strongSelf.updateCurrentGroupCall(call)
|
strongSelf.updateCurrentGroupCall(call)
|
||||||
strongSelf.currentGroupCallPromise.set(.single(call))
|
strongSelf.currentGroupCallPromise.set(.single(call))
|
||||||
strongSelf.hasActiveCallsPromise.set(true)
|
strongSelf.hasActiveGroupCallsPromise.set(true)
|
||||||
strongSelf.removeCurrentCallDisposable.set((call.canBeRemoved
|
strongSelf.removeCurrentGroupCallDisposable.set((call.canBeRemoved
|
||||||
|
|> filter { $0 }
|
||||||
|
|> take(1)
|
||||||
|> deliverOnMainQueue).start(next: { [weak call] value in
|
|> deliverOnMainQueue).start(next: { [weak call] value in
|
||||||
if value, let strongSelf = self, let call = call {
|
guard let strongSelf = self, let call = call else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if value {
|
||||||
if strongSelf.currentGroupCall === call {
|
if strongSelf.currentGroupCall === call {
|
||||||
strongSelf.updateCurrentGroupCall(nil)
|
strongSelf.updateCurrentGroupCall(nil)
|
||||||
strongSelf.currentGroupCallPromise.set(.single(nil))
|
strongSelf.currentGroupCallPromise.set(.single(nil))
|
||||||
strongSelf.hasActiveCallsPromise.set(false)
|
strongSelf.hasActiveGroupCallsPromise.set(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
@ -497,6 +497,11 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
|||||||
if let clientParams = joinCallResult.callInfo.clientParams {
|
if let clientParams = joinCallResult.callInfo.clientParams {
|
||||||
strongSelf.updateSessionState(internalState: .estabilished(info: joinCallResult.callInfo, clientParams: clientParams, localSsrc: ssrc, initialState: joinCallResult.state), audioSessionControl: strongSelf.audioSessionControl)
|
strongSelf.updateSessionState(internalState: .estabilished(info: joinCallResult.callInfo, clientParams: clientParams, localSsrc: ssrc, initialState: joinCallResult.state), audioSessionControl: strongSelf.audioSessionControl)
|
||||||
}
|
}
|
||||||
|
}, error: { _ in
|
||||||
|
guard let strongSelf = self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
strongSelf._canBeRemoved.set(.single(true))
|
||||||
}))
|
}))
|
||||||
}))
|
}))
|
||||||
|
|
||||||
@ -690,11 +695,13 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
|||||||
}))
|
}))
|
||||||
} else {
|
} else {
|
||||||
self.leaveDisposable.set((leaveGroupCall(account: self.account, callId: callInfo.id, accessHash: callInfo.accessHash, source: localSsrc)
|
self.leaveDisposable.set((leaveGroupCall(account: self.account, callId: callInfo.id, accessHash: callInfo.accessHash, source: localSsrc)
|
||||||
|> deliverOnMainQueue).start(completed: { [weak self] in
|
|> deliverOnMainQueue).start(error: { [weak self] _ in
|
||||||
|
self?._canBeRemoved.set(.single(true))
|
||||||
|
}, completed: { [weak self] in
|
||||||
self?._canBeRemoved.set(.single(true))
|
self?._canBeRemoved.set(.single(true))
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
} else if case .requesting = self.internalState {
|
} else {
|
||||||
self.callContext?.stop()
|
self.callContext?.stop()
|
||||||
self.callContext = nil
|
self.callContext = nil
|
||||||
self.requestDisposable.set(nil)
|
self.requestDisposable.set(nil)
|
||||||
|
@ -3032,6 +3032,29 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if let group = peer as? TelegramGroup {
|
} else if let group = peer as? TelegramGroup {
|
||||||
|
if case .creator = group.role {
|
||||||
|
items.append(ActionSheetButtonItem(title: presentationData.strings.ChannelInfo_CreateVoiceChat, color: .accent, action: { [weak self] in
|
||||||
|
dismissAction()
|
||||||
|
|
||||||
|
guard let strongSelf = self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
strongSelf.activeActionDisposable.set((convertGroupToSupergroup(account: strongSelf.context.account, peerId: group.id)
|
||||||
|
|> deliverOnMainQueue).start(next: { peerId in
|
||||||
|
guard let strongSelf = self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if let controller = strongSelf.controller, let navigationController = controller.navigationController as? NavigationController {
|
||||||
|
rebuildControllerStackAfterSupergroupUpgrade(controller: controller, navigationController: navigationController)
|
||||||
|
|
||||||
|
strongSelf.createAndJoinGroupCall(peerId: peerId)
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
if case .Member = group.membership {
|
if case .Member = group.membership {
|
||||||
items.append(ActionSheetButtonItem(title: presentationData.strings.Group_LeaveGroup, color: .destructive, action: { [weak self] in
|
items.append(ActionSheetButtonItem(title: presentationData.strings.Group_LeaveGroup, color: .destructive, action: { [weak self] in
|
||||||
dismissAction()
|
dismissAction()
|
||||||
@ -3181,72 +3204,8 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
|
|||||||
|
|
||||||
if let activeCall = cachedChannelData.activeCall {
|
if let activeCall = cachedChannelData.activeCall {
|
||||||
let _ = self.context.sharedContext.callManager?.joinGroupCall(context: self.context, peerId: peer.id, initialCall: activeCall, endCurrentIfAny: false, sourcePanel: nil)
|
let _ = self.context.sharedContext.callManager?.joinGroupCall(context: self.context, peerId: peer.id, initialCall: activeCall, endCurrentIfAny: false, sourcePanel: nil)
|
||||||
} else if let callManager = self.context.sharedContext.callManager {
|
|
||||||
let startCall: (Bool) -> Void = { [weak self] endCurrentIfAny in
|
|
||||||
guard let strongSelf = self else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var dismissStatus: (() -> Void)?
|
|
||||||
let statusController = OverlayStatusController(theme: strongSelf.presentationData.theme, type: .loading(cancelled: {
|
|
||||||
dismissStatus?()
|
|
||||||
}))
|
|
||||||
dismissStatus = { [weak self, weak statusController] in
|
|
||||||
self?.activeActionDisposable.set(nil)
|
|
||||||
statusController?.dismiss()
|
|
||||||
}
|
|
||||||
strongSelf.controller?.present(statusController, in: .window(.root))
|
|
||||||
strongSelf.activeActionDisposable.set((createGroupCall(account: strongSelf.context.account, peerId: peer.id)
|
|
||||||
|> deliverOnMainQueue).start(next: { [weak self] info in
|
|
||||||
guard let strongSelf = self else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
let _ = strongSelf.context.sharedContext.callManager?.joinGroupCall(context: strongSelf.context, peerId: peer.id, initialCall: CachedChannelData.ActiveCall(id: info.id, accessHash: info.accessHash), endCurrentIfAny: endCurrentIfAny, sourcePanel: nil)
|
|
||||||
}, error: { [weak self] _ in
|
|
||||||
dismissStatus?()
|
|
||||||
|
|
||||||
guard let strongSelf = self else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
strongSelf.headerNode.navigationButtonContainer.performAction?(.cancel)
|
|
||||||
}, completed: { [weak self] in
|
|
||||||
dismissStatus?()
|
|
||||||
|
|
||||||
guard let strongSelf = self else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
strongSelf.headerNode.navigationButtonContainer.performAction?(.cancel)
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
let _ = (callManager.currentGroupCallSignal
|
|
||||||
|> take(1)
|
|
||||||
|> deliverOnMainQueue).start(next: { [weak self] activeCall in
|
|
||||||
guard let strongSelf = self else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if let activeCall = activeCall {
|
|
||||||
let currentPeerId = activeCall.peerId
|
|
||||||
let presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 }
|
|
||||||
let _ = (strongSelf.context.account.postbox.transaction { transaction -> (Peer?, Peer?) in
|
|
||||||
return (transaction.getPeer(peer.id), transaction.getPeer(currentPeerId))
|
|
||||||
} |> deliverOnMainQueue).start(next: { [weak self] peer, current in
|
|
||||||
if let peer = peer {
|
|
||||||
if let strongSelf = self, let current = current {
|
|
||||||
strongSelf.controller?.present(textAlertController(context: strongSelf.context, title: presentationData.strings.Call_CallInProgressTitle, text: presentationData.strings.Call_CallInProgressMessage(current.compactDisplayTitle, peer.compactDisplayTitle).0, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_Cancel, action: {}), TextAlertAction(type: .genericAction, title: presentationData.strings.Common_OK, action: {
|
|
||||||
startCall(true)
|
|
||||||
})]), in: .window(.root))
|
|
||||||
} else {
|
} else {
|
||||||
strongSelf.controller?.present(textAlertController(context: strongSelf.context, title: presentationData.strings.Call_CallInProgressTitle, text: presentationData.strings.Call_ExternalCallInProgressMessage, actions: [TextAlertAction(type: .genericAction, title: presentationData.strings.Common_OK, action: {
|
self.createAndJoinGroupCall(peerId: peer.id)
|
||||||
})]), in: .window(.root))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
startCall(false)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -3302,6 +3261,76 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func createAndJoinGroupCall(peerId: PeerId) {
|
||||||
|
if let callManager = self.context.sharedContext.callManager {
|
||||||
|
let startCall: (Bool) -> Void = { [weak self] endCurrentIfAny in
|
||||||
|
guard let strongSelf = self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var dismissStatus: (() -> Void)?
|
||||||
|
let statusController = OverlayStatusController(theme: strongSelf.presentationData.theme, type: .loading(cancelled: {
|
||||||
|
dismissStatus?()
|
||||||
|
}))
|
||||||
|
dismissStatus = { [weak self, weak statusController] in
|
||||||
|
self?.activeActionDisposable.set(nil)
|
||||||
|
statusController?.dismiss()
|
||||||
|
}
|
||||||
|
strongSelf.controller?.present(statusController, in: .window(.root))
|
||||||
|
strongSelf.activeActionDisposable.set((createGroupCall(account: strongSelf.context.account, peerId: peerId)
|
||||||
|
|> deliverOnMainQueue).start(next: { [weak self] info in
|
||||||
|
guard let strongSelf = self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let _ = strongSelf.context.sharedContext.callManager?.joinGroupCall(context: strongSelf.context, peerId: peerId, initialCall: CachedChannelData.ActiveCall(id: info.id, accessHash: info.accessHash), endCurrentIfAny: endCurrentIfAny, sourcePanel: nil)
|
||||||
|
}, error: { [weak self] _ in
|
||||||
|
dismissStatus?()
|
||||||
|
|
||||||
|
guard let strongSelf = self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
strongSelf.headerNode.navigationButtonContainer.performAction?(.cancel)
|
||||||
|
}, completed: { [weak self] in
|
||||||
|
dismissStatus?()
|
||||||
|
|
||||||
|
guard let strongSelf = self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
strongSelf.headerNode.navigationButtonContainer.performAction?(.cancel)
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
let _ = (callManager.currentGroupCallSignal
|
||||||
|
|> take(1)
|
||||||
|
|> deliverOnMainQueue).start(next: { [weak self] activeCall in
|
||||||
|
guard let strongSelf = self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if let activeCall = activeCall {
|
||||||
|
let currentPeerId = activeCall.peerId
|
||||||
|
let presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 }
|
||||||
|
let _ = (strongSelf.context.account.postbox.transaction { transaction -> (Peer?, Peer?) in
|
||||||
|
return (transaction.getPeer(peerId), transaction.getPeer(currentPeerId))
|
||||||
|
} |> deliverOnMainQueue).start(next: { [weak self] peer, current in
|
||||||
|
if let peer = peer {
|
||||||
|
if let strongSelf = self, let current = current {
|
||||||
|
strongSelf.controller?.present(textAlertController(context: strongSelf.context, title: presentationData.strings.Call_CallInProgressTitle, text: presentationData.strings.Call_CallInProgressMessage(current.compactDisplayTitle, peer.compactDisplayTitle).0, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_Cancel, action: {}), TextAlertAction(type: .genericAction, title: presentationData.strings.Common_OK, action: {
|
||||||
|
startCall(true)
|
||||||
|
})]), in: .window(.root))
|
||||||
|
} else {
|
||||||
|
strongSelf.controller?.present(textAlertController(context: strongSelf.context, title: presentationData.strings.Call_CallInProgressTitle, text: presentationData.strings.Call_ExternalCallInProgressMessage, actions: [TextAlertAction(type: .genericAction, title: presentationData.strings.Common_OK, action: {
|
||||||
|
})]), in: .window(.root))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
startCall(false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private func openPhone(value: String) {
|
private func openPhone(value: String) {
|
||||||
let _ = (getUserPeer(postbox: self.context.account.postbox, peerId: peerId)
|
let _ = (getUserPeer(postbox: self.context.account.postbox, peerId: peerId)
|
||||||
|> deliverOnMainQueue).start(next: { [weak self] peer, _ in
|
|> deliverOnMainQueue).start(next: { [weak self] peer, _ in
|
||||||
|
Loading…
x
Reference in New Issue
Block a user