mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Call confirmation
This commit is contained in:
parent
462e870b2d
commit
7f7cd9c06b
@ -92,6 +92,7 @@ private enum SGBoolSetting: String {
|
||||
case forceEmojiTab
|
||||
case forceBuiltInMic
|
||||
case hideChannelBottomButton
|
||||
case confirmCalls
|
||||
}
|
||||
|
||||
private enum SGOneFromManySetting: String {
|
||||
@ -162,6 +163,8 @@ private func SGControllerEntries(presentationData: PresentationData, callListSet
|
||||
entries.append(.notice(id: id.count, section: .profiles, text: i18n("Settings.ShowRegDate.Notice", lang)))
|
||||
entries.append(.toggle(id: id.count, section: .profiles, settingName: .showCreationDate, value: SGSimpleSettings.shared.showCreationDate, text: i18n("Settings.ShowCreationDate", lang), enabled: true))
|
||||
entries.append(.notice(id: id.count, section: .profiles, text: i18n("Settings.ShowCreationDate.Notice", lang)))
|
||||
entries.append(.toggle(id: id.count, section: .profiles, settingName: .confirmCalls, value: SGSimpleSettings.shared.confirmCalls, text: i18n("Settings.CallConfirmation", lang), enabled: true))
|
||||
entries.append(.notice(id: id.count, section: .profiles, text: i18n("Settings.CallConfirmation.Notice", lang)))
|
||||
|
||||
entries.append(.header(id: id.count, section: .stories, text: presentationData.strings.AutoDownloadSettings_Stories.uppercased(), badge: nil))
|
||||
entries.append(.toggle(id: id.count, section: .stories, settingName: .hideStories, value: SGSettings.hideStories, text: i18n("Settings.Stories.Hide", lang), enabled: true))
|
||||
@ -446,6 +449,8 @@ public func sgSettingsController(context: AccountContext/*, focusOnItemTag: Int?
|
||||
SGSimpleSettings.shared.forceBuiltInMic = value
|
||||
case .hideChannelBottomButton:
|
||||
SGSimpleSettings.shared.hideChannelBottomButton = value
|
||||
case .confirmCalls:
|
||||
SGSimpleSettings.shared.confirmCalls = value
|
||||
}
|
||||
}, updateSliderValue: { setting, value in
|
||||
switch (setting) {
|
||||
|
@ -104,6 +104,7 @@ public class SGSimpleSettings {
|
||||
case forceBuiltInMic
|
||||
case hideChannelBottomButton
|
||||
case forceSystemSharing
|
||||
case confirmCalls
|
||||
}
|
||||
|
||||
public enum DownloadSpeedBoostValues: String, CaseIterable {
|
||||
@ -192,6 +193,7 @@ public class SGSimpleSettings {
|
||||
Keys.forceEmojiTab.rawValue: false,
|
||||
Keys.hideChannelBottomButton.rawValue: false,
|
||||
Keys.forceSystemSharing.rawValue: false,
|
||||
Keys.confirmCalls.rawValue: true,
|
||||
]
|
||||
|
||||
@UserDefault(key: Keys.hidePhoneInSettings.rawValue)
|
||||
@ -360,6 +362,9 @@ public class SGSimpleSettings {
|
||||
|
||||
@UserDefault(key: Keys.forceSystemSharing.rawValue)
|
||||
public var forceSystemSharing: Bool
|
||||
|
||||
@UserDefault(key: Keys.confirmCalls.rawValue)
|
||||
public var confirmCalls: Bool
|
||||
}
|
||||
|
||||
extension SGSimpleSettings {
|
||||
|
@ -134,4 +134,13 @@
|
||||
"Settings.forceBuiltInMic" = "Force Device Microphone";
|
||||
"Settings.forceBuiltInMic.Notice" = "If enabled, app will use only device microphone even if headphones are connected.";
|
||||
|
||||
"Settings.hideChannelBottomButton" = "Hide Channel Bottom Panel";
|
||||
"Settings.hideChannelBottomButton" = "Hide Channel Bottom Panel";
|
||||
|
||||
"Settings.CallConfirmation" = "Call Confirmation";
|
||||
"Settings.CallConfirmation.Notice" = "Swiftgram will ask for your confirmation before making a call.";
|
||||
|
||||
/* Confirmation before making a Call */
|
||||
"CallConfirmation.Audio.Title" = "Make a Call?";
|
||||
|
||||
/* Confirmation before making a Video Call */
|
||||
"CallConfirmation.Video.Title" = "Make a Video Call?";
|
||||
|
@ -1,3 +1,6 @@
|
||||
import SGStrings
|
||||
import SGSimpleSettings
|
||||
|
||||
import Foundation
|
||||
import SwiftSignalKit
|
||||
import UIKit
|
||||
@ -655,6 +658,8 @@ public final class AccountContextImpl: AccountContext {
|
||||
}
|
||||
|
||||
public func requestCall(peerId: PeerId, isVideo: Bool, completion: @escaping () -> Void) {
|
||||
// MARK: Swiftgram
|
||||
let makeCall = {
|
||||
guard let callResult = self.sharedContext.callManager?.requestCall(context: self, peerId: peerId, isVideo: isVideo, endCurrentIfAny: false) else {
|
||||
return
|
||||
}
|
||||
@ -722,6 +727,19 @@ public final class AccountContextImpl: AccountContext {
|
||||
} else {
|
||||
completion()
|
||||
}
|
||||
// MARK: Swiftgram
|
||||
}
|
||||
if SGSimpleSettings.shared.confirmCalls {
|
||||
let presentationData = self.sharedContext.currentPresentationData.with { $0 }
|
||||
self.sharedContext.mainWindow?.present(textAlertController(context: self, title: nil, text: isVideo ? i18n("CallConfirmation.Video.Title", presentationData.strings.baseLanguageCode) : i18n("CallConfirmation.Audio.Title", presentationData.strings.baseLanguageCode), actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_No, action: {}), TextAlertAction(type: .genericAction, title: presentationData.strings.Common_Yes, action: { [weak self] in
|
||||
guard let _ = self else {
|
||||
return
|
||||
}
|
||||
makeCall()
|
||||
})]), on: .root)
|
||||
} else {
|
||||
makeCall()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user