From f9a3cbe090404a051f39fd55cb5f523c77704ed3 Mon Sep 17 00:00:00 2001 From: Denis Shilovich Date: Wed, 30 Oct 2024 15:06:04 +0000 Subject: [PATCH] 1.8.7 (358) --- .../Sources/PresentationCallManager.swift | 1 + .../Sources/CallControllerNodeV2.swift | 29 +------------ .../Sources/PresentationCallManager.swift | 42 +++++++++++++++---- 3 files changed, 38 insertions(+), 34 deletions(-) diff --git a/submodules/AccountContext/Sources/PresentationCallManager.swift b/submodules/AccountContext/Sources/PresentationCallManager.swift index 0c374e1f4e..268f4f89e7 100644 --- a/submodules/AccountContext/Sources/PresentationCallManager.swift +++ b/submodules/AccountContext/Sources/PresentationCallManager.swift @@ -480,5 +480,6 @@ public protocol PresentationCallManager: AnyObject { func startRecordCall(with completion: @escaping () -> Void) func stopRecordCall() func setupPeer(peer: EnginePeer) + func showRecordSaveToast() // } diff --git a/submodules/TelegramCallsUI/Sources/CallControllerNodeV2.swift b/submodules/TelegramCallsUI/Sources/CallControllerNodeV2.swift index 3061360a80..701a5c7ff0 100644 --- a/submodules/TelegramCallsUI/Sources/CallControllerNodeV2.swift +++ b/submodules/TelegramCallsUI/Sources/CallControllerNodeV2.swift @@ -168,7 +168,7 @@ final class CallControllerNodeV2: ViewControllerTracingNode, CallControllerNodeP let isCallRecord = !callScreenState.isCallRecord if isCallRecord { self.sharedContext.callManager?.startRecordCall { [weak self] in - self?.showRecordSaveToast() + self?.sharedContext.callManager?.showRecordSaveToast() } self.updateCallRecordButton(with: isCallRecord) } else { @@ -179,7 +179,7 @@ final class CallControllerNodeV2: ViewControllerTracingNode, CallControllerNodeP } self.sharedContext.callManager?.callCompletion = { [weak self] in - self?.showRecordSaveToast() + self?.sharedContext.callManager?.showRecordSaveToast() } // MARK: Nicegram NCG-5828 call recording, isCallRecord self.callScreenState = PrivateCallScreen.State( @@ -784,31 +784,6 @@ final class CallControllerNodeV2: ViewControllerTracingNode, CallControllerNodeP self.callScreenState = callScreenState self.update(transition: .animated(duration: 0.3, curve: .spring)) } - - private func showRecordSaveToast() { - guard let image = UIImage(bundleImageName: "RecordSave") else { return } - - let content: UndoOverlayContent = .image( - image: image, - title: nil, - text: l("NicegramCallRecord.SavedMessage"), - round: true, - undoText: nil - ) - - DispatchQueue.main.async { - let controller = UndoOverlayController( - presentationData: self.presentationData, - content: content, - elevatedLayout: false, - position: .top, - animateInAsReplacement: false, - action: { _ in return false } - ) - - self.sharedContext.mainWindow?.present(controller, on: .root) - } - } // } diff --git a/submodules/TelegramCallsUI/Sources/PresentationCallManager.swift b/submodules/TelegramCallsUI/Sources/PresentationCallManager.swift index 9e1c2874da..c8f54e8ebb 100644 --- a/submodules/TelegramCallsUI/Sources/PresentationCallManager.swift +++ b/submodules/TelegramCallsUI/Sources/PresentationCallManager.swift @@ -15,6 +15,7 @@ import PhoneNumberFormat // MARK: Nicegram NCG-5828 call recording import NGLogging import NGData +import NGStrings import UndoUI // private func callKitIntegrationIfEnabled(_ integration: CallKitIntegration?, settings: VoiceCallSettings?) -> CallKitIntegration? { @@ -321,7 +322,7 @@ public final class PresentationCallManagerImpl: PresentationCallManager { let autodownloadSettings = sharedData.entries[SharedDataKeys.autodownloadSettings]?.get(AutodownloadSettings.self) ?? .defaultSettings let experimentalSettings = sharedData.entries[ApplicationSpecificSharedDataKeys.experimentalUISettings]?.get(ExperimentalUISettings.self) ?? .defaultSettings let appConfiguration = preferences.values[PreferencesKeys.appConfiguration]?.get(AppConfiguration.self) ?? AppConfiguration.defaultValue - + let call = PresentationCallImpl( context: firstState.0, audioSession: strongSelf.audioSession, @@ -349,7 +350,7 @@ public final class PresentationCallManagerImpl: PresentationCallManager { call.callActiveState = { [strongSelf] audioDevice in strongSelf.callActiveState( with: audioDevice, - account: firstState.0.account + accountContext: firstState.0 ) } // @@ -604,7 +605,7 @@ public final class PresentationCallManagerImpl: PresentationCallManager { call.callActiveState = { [strongSelf] audioDevice in strongSelf.callActiveState( with: audioDevice, - account: context.account + accountContext: context ) } // @@ -974,7 +975,7 @@ public final class PresentationCallManagerImpl: PresentationCallManager { public var callCompletion: (() -> Void)? private weak var audioDevice: OngoingCallContext.AudioDevice? - private var account: Account? + private var accountContext: AccountContext? private var enginePeer: EnginePeer? private var userDisplayName: String { guard let enginePeer else { return "" } @@ -1067,13 +1068,14 @@ public final class PresentationCallManagerImpl: PresentationCallManager { ) DispatchQueue.main.async { - if let account = self.account { + if let account = self.accountContext?.account { let _ = enqueueMessages( account: account, peerId: account.peerId, messages: [message] ).start(completed: { [weak self] in self?.deleteFile(from: path) + self?.showRecordSaveToast() completion?() }) } @@ -1082,11 +1084,11 @@ public final class PresentationCallManagerImpl: PresentationCallManager { private func callActiveState( with audioDevice: OngoingCallContext.AudioDevice?, - account: Account + accountContext: AccountContext ) { if let audioDevice { self.audioDevice = audioDevice - self.account = account + self.accountContext = accountContext } if NGSettings.recordAllCalls { @@ -1116,5 +1118,31 @@ public final class PresentationCallManagerImpl: PresentationCallManager { public func setupPeer(peer: EnginePeer) { self.enginePeer = peer } + + public func showRecordSaveToast() { + let (presentationData, _, _) = getDeviceAccessData() + guard let image = UIImage(bundleImageName: "RecordSave") else { return } + + let content: UndoOverlayContent = .image( + image: image, + title: nil, + text: l("NicegramCallRecord.SavedMessage"), + round: true, + undoText: nil + ) + + DispatchQueue.main.async { + let controller = UndoOverlayController( + presentationData: presentationData, + content: content, + elevatedLayout: false, + position: .top, + animateInAsReplacement: false, + action: { _ in return false } + ) + + self.accountContext?.sharedContext.mainWindow?.present(controller, on: .root) + } + } // }