mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
Merge commit '841b50da6b8441d9e317722ae22451aa3fa94e8d' into macos-9.4-1-release
This commit is contained in:
commit
75b575e87d
@ -236,7 +236,7 @@ final class JoinLinkPreviewControllerNode: ViewControllerTracingNode, UIScrollVi
|
||||
|
||||
if let contentNode = self.contentNode {
|
||||
transition.updateFrame(node: contentNode, frame: CGRect(origin: CGPoint(x: floor((contentContainerFrame.size.width - contentFrame.size.width) / 2.0), y: 0.0), size: gridSize))
|
||||
contentNode.updateLayout(size: gridSize, isLandscape: layout.size.width > layout.size.height, bottomInset: 0.0, transition: transition)
|
||||
contentNode.updateLayout(size: gridSize, isLandscape: layout.size.width > layout.size.height && layout.metrics.widthClass == .compact, bottomInset: 0.0, transition: transition)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -839,7 +839,7 @@ public final class PostboxDecoder {
|
||||
memcpy(&valueLength, bytes + offset, 4)
|
||||
offset += 4
|
||||
var i: Int32 = 0
|
||||
while i < length {
|
||||
while i < valueLength {
|
||||
if offset + 4 > length {
|
||||
offset = 0
|
||||
return false
|
||||
|
@ -36,6 +36,11 @@ public final class CallKitIntegration {
|
||||
var audioSessionActive: Signal<Bool, NoError> {
|
||||
return self.audioSessionActivePromise.get()
|
||||
}
|
||||
|
||||
private let hasActiveCallsValue = ValuePromise<Bool>(false, ignoreRepeated: true)
|
||||
public var hasActiveCalls: Signal<Bool, NoError> {
|
||||
return self.hasActiveCallsValue.get()
|
||||
}
|
||||
|
||||
private static let sharedInstance: CallKitIntegration? = CallKitIntegration()
|
||||
public static var shared: CallKitIntegration? {
|
||||
@ -50,7 +55,7 @@ public final class CallKitIntegration {
|
||||
audioSessionActivationChanged: @escaping (Bool) -> Void
|
||||
) {
|
||||
if #available(iOSApplicationExtension 10.0, iOS 10.0, *) {
|
||||
(sharedProviderDelegate as? CallKitProviderDelegate)?.setup(audioSessionActivePromise: self.audioSessionActivePromise, startCall: startCall, answerCall: answerCall, endCall: endCall, setCallMuted: setCallMuted, audioSessionActivationChanged: audioSessionActivationChanged)
|
||||
(sharedProviderDelegate as? CallKitProviderDelegate)?.setup(audioSessionActivePromise: self.audioSessionActivePromise, startCall: startCall, answerCall: answerCall, endCall: endCall, setCallMuted: setCallMuted, audioSessionActivationChanged: audioSessionActivationChanged, hasActiveCallsValue: hasActiveCallsValue)
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,6 +135,7 @@ class CallKitProviderDelegate: NSObject, CXProviderDelegate {
|
||||
private var endCall: ((UUID) -> Signal<Bool, NoError>)?
|
||||
private var setCallMuted: ((UUID, Bool) -> Void)?
|
||||
private var audioSessionActivationChanged: ((Bool) -> Void)?
|
||||
private var hasActiveCallsValue: ValuePromise<Bool>?
|
||||
|
||||
private var isAudioSessionActive: Bool = false
|
||||
private var pendingVoiceChatOutputMode: AudioSessionOutputMode?
|
||||
@ -138,6 +144,12 @@ class CallKitProviderDelegate: NSObject, CXProviderDelegate {
|
||||
|
||||
fileprivate var audioSessionActivePromise: ValuePromise<Bool>?
|
||||
|
||||
private var activeCalls = Set<UUID>() {
|
||||
didSet {
|
||||
self.hasActiveCallsValue?.set(!self.activeCalls.isEmpty)
|
||||
}
|
||||
}
|
||||
|
||||
override init() {
|
||||
self.provider = CXProvider(configuration: CallKitProviderDelegate.providerConfiguration())
|
||||
|
||||
@ -146,13 +158,14 @@ class CallKitProviderDelegate: NSObject, CXProviderDelegate {
|
||||
self.provider.setDelegate(self, queue: nil)
|
||||
}
|
||||
|
||||
func setup(audioSessionActivePromise: ValuePromise<Bool>, startCall: @escaping (AccountContext, UUID, EnginePeer.Id?, String, Bool) -> Signal<Bool, NoError>, answerCall: @escaping (UUID) -> Void, endCall: @escaping (UUID) -> Signal<Bool, NoError>, setCallMuted: @escaping (UUID, Bool) -> Void, audioSessionActivationChanged: @escaping (Bool) -> Void) {
|
||||
func setup(audioSessionActivePromise: ValuePromise<Bool>, startCall: @escaping (AccountContext, UUID, EnginePeer.Id?, String, Bool) -> Signal<Bool, NoError>, answerCall: @escaping (UUID) -> Void, endCall: @escaping (UUID) -> Signal<Bool, NoError>, setCallMuted: @escaping (UUID, Bool) -> Void, audioSessionActivationChanged: @escaping (Bool) -> Void, hasActiveCallsValue: ValuePromise<Bool>) {
|
||||
self.audioSessionActivePromise = audioSessionActivePromise
|
||||
self.startCall = startCall
|
||||
self.answerCall = answerCall
|
||||
self.endCall = endCall
|
||||
self.setCallMuted = setCallMuted
|
||||
self.audioSessionActivationChanged = audioSessionActivationChanged
|
||||
self.hasActiveCallsValue = hasActiveCallsValue
|
||||
}
|
||||
|
||||
private static func providerConfiguration() -> CXProviderConfiguration {
|
||||
@ -185,12 +198,16 @@ class CallKitProviderDelegate: NSObject, CXProviderDelegate {
|
||||
let endCallAction = CXEndCallAction(call: uuid)
|
||||
let transaction = CXTransaction(action: endCallAction)
|
||||
self.requestTransaction(transaction)
|
||||
|
||||
self.activeCalls.remove(uuid)
|
||||
}
|
||||
|
||||
func dropCall(uuid: UUID) {
|
||||
Logger.shared.log("CallKitIntegration", "report call ended \(uuid)")
|
||||
|
||||
self.provider.reportCall(with: uuid, endedAt: nil, reason: CXCallEndedReason.remoteEnded)
|
||||
|
||||
self.activeCalls.remove(uuid)
|
||||
}
|
||||
|
||||
func answerCall(uuid: UUID) {
|
||||
@ -231,6 +248,8 @@ class CallKitProviderDelegate: NSObject, CXProviderDelegate {
|
||||
update.supportsDTMF = false
|
||||
|
||||
self.provider.reportCall(with: uuid, updated: update)
|
||||
|
||||
self.activeCalls.insert(uuid)
|
||||
})
|
||||
}
|
||||
|
||||
@ -261,6 +280,10 @@ class CallKitProviderDelegate: NSObject, CXProviderDelegate {
|
||||
OngoingCallContext.setupAudioSession()
|
||||
|
||||
self.provider.reportNewIncomingCall(with: uuid, update: update, completion: { error in
|
||||
if error == nil {
|
||||
self.activeCalls.insert(uuid)
|
||||
}
|
||||
|
||||
completion?(error as NSError?)
|
||||
})
|
||||
}
|
||||
@ -279,6 +302,8 @@ class CallKitProviderDelegate: NSObject, CXProviderDelegate {
|
||||
|
||||
func providerDidReset(_ provider: CXProvider) {
|
||||
Logger.shared.log("CallKitIntegration", "providerDidReset")
|
||||
|
||||
self.activeCalls.removeAll()
|
||||
}
|
||||
|
||||
func provider(_ provider: CXProvider, perform action: CXStartCallAction) {
|
||||
|
@ -234,10 +234,13 @@ private class AdMessagesHistoryContextImpl {
|
||||
}
|
||||
|
||||
messagePeers[author.id] = author
|
||||
|
||||
let messageHash = (self.text.hashValue &+ 31 &* peerId.hashValue) &* 31 &+ author.id.hashValue
|
||||
let messageStableVersion = UInt32(bitPattern: Int32(truncatingIfNeeded: messageHash))
|
||||
|
||||
return Message(
|
||||
stableId: 0,
|
||||
stableVersion: 0,
|
||||
stableVersion: messageStableVersion,
|
||||
id: MessageId(peerId: peerId, namespace: Namespaces.Message.Local, id: 0),
|
||||
globallyUniqueId: nil,
|
||||
groupingKey: nil,
|
||||
|
@ -571,7 +571,20 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
|
||||
|
||||
self.window?.makeKeyAndVisible()
|
||||
|
||||
self.hasActiveAudioSession.set(MediaManagerImpl.globalAudioSession.isActive())
|
||||
var hasActiveCalls: Signal<Bool, NoError> = .single(false)
|
||||
if CallKitIntegration.isAvailable, let callKitIntegration = CallKitIntegration.shared {
|
||||
hasActiveCalls = callKitIntegration.hasActiveCalls
|
||||
}
|
||||
self.hasActiveAudioSession.set(
|
||||
combineLatest(queue: .mainQueue(),
|
||||
hasActiveCalls,
|
||||
MediaManagerImpl.globalAudioSession.isActive()
|
||||
)
|
||||
|> map { hasActiveCalls, isActive -> Bool in
|
||||
return hasActiveCalls || isActive
|
||||
}
|
||||
|> distinctUntilChanged
|
||||
)
|
||||
|
||||
let applicationBindings = TelegramApplicationBindings(isMainApp: true, appBundleId: baseAppBundleId, appBuildType: buildConfig.isAppStoreBuild ? .public : .internal, containerPath: appGroupUrl.path, appSpecificScheme: buildConfig.appSpecificUrlScheme, openUrl: { url in
|
||||
var parsedUrl = URL(string: url)
|
||||
|
Loading…
x
Reference in New Issue
Block a user