From d0fef93d375adca9f91d4037a082c6b5ed012346 Mon Sep 17 00:00:00 2001 From: Ali <> Date: Fri, 2 Apr 2021 21:38:17 +0400 Subject: [PATCH] Hide compatibility in debug options --- .../Sources/DebugController.swift | 16 +++++++++++++++- .../TelegramUI/Sources/AccountContext.swift | 2 +- .../Sources/ExperimentalUISettings.swift | 10 ++++++++-- .../Sources/OngoingCallThreadLocalContext.mm | 10 ++++++++-- 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/submodules/DebugSettingsUI/Sources/DebugController.swift b/submodules/DebugSettingsUI/Sources/DebugController.swift index 9c4b1a535c..891c535c8c 100644 --- a/submodules/DebugSettingsUI/Sources/DebugController.swift +++ b/submodules/DebugSettingsUI/Sources/DebugController.swift @@ -73,6 +73,7 @@ private enum DebugControllerEntry: ItemListNodeEntry { case photoPreview(PresentationTheme, Bool) case knockoutWallpaper(PresentationTheme, Bool) case demoVideoChats(Bool) + case experimentalCompatibility(Bool) case playerEmbedding(Bool) case playlistPlayback(Bool) case voiceConference @@ -92,7 +93,7 @@ private enum DebugControllerEntry: ItemListNodeEntry { return DebugControllerSection.logging.rawValue case .enableRaiseToSpeak, .keepChatNavigationStack, .skipReadHistory, .crashOnSlowQueries: return DebugControllerSection.experiments.rawValue - case .clearTips, .reimport, .resetData, .resetDatabase, .resetDatabaseAndCache, .resetHoles, .reindexUnread, .resetBiometricsData, .optimizeDatabase, .photoPreview, .knockoutWallpaper, .demoVideoChats, .playerEmbedding, .playlistPlayback, .voiceConference: + case .clearTips, .reimport, .resetData, .resetDatabase, .resetDatabaseAndCache, .resetHoles, .reindexUnread, .resetBiometricsData, .optimizeDatabase, .photoPreview, .knockoutWallpaper, .demoVideoChats, .experimentalCompatibility, .playerEmbedding, .playlistPlayback, .voiceConference: return DebugControllerSection.experiments.rawValue case .preferredVideoCodec: return DebugControllerSection.videoExperiments.rawValue @@ -155,6 +156,8 @@ private enum DebugControllerEntry: ItemListNodeEntry { return 23 case .demoVideoChats: return 24 + case .experimentalCompatibility: + return 25 case .playerEmbedding: return 26 case .playlistPlayback: @@ -712,6 +715,16 @@ private enum DebugControllerEntry: ItemListNodeEntry { }) }).start() }) + case let .experimentalCompatibility(value): + return ItemListSwitchItem(presentationData: presentationData, title: "Experimental Compatibility", value: value, sectionId: self.section, style: .blocks, updated: { value in + let _ = arguments.sharedContext.accountManager.transaction ({ transaction in + transaction.updateSharedData(ApplicationSpecificSharedDataKeys.experimentalUISettings, { settings in + var settings = settings as? ExperimentalUISettings ?? ExperimentalUISettings.defaultSettings + settings.experimentalCompatibility = value + return settings + }) + }).start() + }) case let .playerEmbedding(value): return ItemListSwitchItem(presentationData: presentationData, title: "Player Embedding", value: value, sectionId: self.section, style: .blocks, updated: { value in let _ = arguments.sharedContext.accountManager.transaction ({ transaction in @@ -820,6 +833,7 @@ private func debugControllerEntries(sharedContext: SharedAccountContext, present if isMainApp { entries.append(.knockoutWallpaper(presentationData.theme, experimentalSettings.knockoutWallpaper)) entries.append(.demoVideoChats(experimentalSettings.demoVideoChats)) + entries.append(.experimentalCompatibility(experimentalSettings.experimentalCompatibility)) entries.append(.playerEmbedding(experimentalSettings.playerEmbedding)) entries.append(.playlistPlayback(experimentalSettings.playlistPlayback)) } diff --git a/submodules/TelegramUI/Sources/AccountContext.swift b/submodules/TelegramUI/Sources/AccountContext.swift index 4621ae114e..26c6641465 100644 --- a/submodules/TelegramUI/Sources/AccountContext.swift +++ b/submodules/TelegramUI/Sources/AccountContext.swift @@ -238,7 +238,7 @@ public final class AccountContextImpl: AccountContext { }) } - account.callSessionManager.updateVersions(versions: PresentationCallManagerImpl.voipVersions(includeExperimental: true, includeReference: false).map { version, supportsVideo -> CallSessionManagerImplementationVersion in + account.callSessionManager.updateVersions(versions: PresentationCallManagerImpl.voipVersions(includeExperimental: true, includeReference: sharedContext.immediateExperimentalUISettings.experimentalCompatibility).map { version, supportsVideo -> CallSessionManagerImplementationVersion in CallSessionManagerImplementationVersion(version: version, supportsVideo: supportsVideo) }) } diff --git a/submodules/TelegramUIPreferences/Sources/ExperimentalUISettings.swift b/submodules/TelegramUIPreferences/Sources/ExperimentalUISettings.swift index f5e71e32b4..d79184a23d 100644 --- a/submodules/TelegramUIPreferences/Sources/ExperimentalUISettings.swift +++ b/submodules/TelegramUIPreferences/Sources/ExperimentalUISettings.swift @@ -15,6 +15,7 @@ public struct ExperimentalUISettings: Equatable, PreferencesEntry { public var disableVideoAspectScaling: Bool public var enableVoipTcp: Bool public var demoVideoChats: Bool + public var experimentalCompatibility: Bool public static var defaultSettings: ExperimentalUISettings { return ExperimentalUISettings( @@ -29,7 +30,8 @@ public struct ExperimentalUISettings: Equatable, PreferencesEntry { preferredVideoCodec: nil, disableVideoAspectScaling: false, enableVoipTcp: false, - demoVideoChats: false + demoVideoChats: false, + experimentalCompatibility: false ) } @@ -45,7 +47,8 @@ public struct ExperimentalUISettings: Equatable, PreferencesEntry { preferredVideoCodec: String?, disableVideoAspectScaling: Bool, enableVoipTcp: Bool, - demoVideoChats: Bool + demoVideoChats: Bool, + experimentalCompatibility: Bool ) { self.keepChatNavigationStack = keepChatNavigationStack self.skipReadHistory = skipReadHistory @@ -59,6 +62,7 @@ public struct ExperimentalUISettings: Equatable, PreferencesEntry { self.disableVideoAspectScaling = disableVideoAspectScaling self.enableVoipTcp = enableVoipTcp self.demoVideoChats = demoVideoChats + self.experimentalCompatibility = experimentalCompatibility } public init(decoder: PostboxDecoder) { @@ -74,6 +78,7 @@ public struct ExperimentalUISettings: Equatable, PreferencesEntry { self.disableVideoAspectScaling = decoder.decodeInt32ForKey("disableVideoAspectScaling", orElse: 0) != 0 self.enableVoipTcp = decoder.decodeInt32ForKey("enableVoipTcp", orElse: 0) != 0 self.demoVideoChats = decoder.decodeInt32ForKey("demoVideoChats", orElse: 0) != 0 + self.experimentalCompatibility = decoder.decodeInt32ForKey("experimentalCompatibility", orElse: 0) != 0 } public func encode(_ encoder: PostboxEncoder) { @@ -91,6 +96,7 @@ public struct ExperimentalUISettings: Equatable, PreferencesEntry { encoder.encodeInt32(self.disableVideoAspectScaling ? 1 : 0, forKey: "disableVideoAspectScaling") encoder.encodeInt32(self.enableVoipTcp ? 1 : 0, forKey: "enableVoipTcp") encoder.encodeInt32(self.demoVideoChats ? 1 : 0, forKey: "demoVideoChats") + encoder.encodeInt32(self.experimentalCompatibility ? 1 : 0, forKey: "experimentalCompatibility") } public func isEqual(to: PreferencesEntry) -> Bool { diff --git a/submodules/TgVoipWebrtc/Sources/OngoingCallThreadLocalContext.mm b/submodules/TgVoipWebrtc/Sources/OngoingCallThreadLocalContext.mm index 391fda4bb3..0496174e33 100644 --- a/submodules/TgVoipWebrtc/Sources/OngoingCallThreadLocalContext.mm +++ b/submodules/TgVoipWebrtc/Sources/OngoingCallThreadLocalContext.mm @@ -332,8 +332,14 @@ static void (*InternalVoipLoggingFunction)(NSString *) = NULL; return 92; } -+ (NSArray * _Nonnull)versionsWithIncludeReference:(bool)__unused includeReference { - return @[@"2.7.7", @"3.0.0", @"4.0.0"]; ++ (NSArray * _Nonnull)versionsWithIncludeReference:(bool)includeReference { + NSMutableArray *list = [[NSMutableArray alloc] init]; + [list addObject:@"2.7.7"]; + [list addObject:@"3.0.0"]; + if (includeReference) { + [list addObject:@"4.0.0"]; + } + return list; } + (tgcalls::ProtocolVersion)protocolVersionFromLibraryVersion:(NSString *)version {