Skip to content

Commit 6a4b085

Browse files
author
Isaac
committed
Various improvements
1 parent 4c0dc35 commit 6a4b085

File tree

10 files changed

+63
-31
lines changed

10 files changed

+63
-31
lines changed

submodules/DebugSettingsUI/Sources/DebugController.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private enum DebugControllerEntry: ItemListNodeEntry {
100100
case enableReactionOverrides(Bool)
101101
case storiesExperiment(Bool)
102102
case storiesJpegExperiment(Bool)
103-
case playlistPlayback(Bool)
103+
case conferenceDebug(Bool)
104104
case enableQuickReactionSwitch(Bool)
105105
case disableReloginTokens(Bool)
106106
case liveStreamV2(Bool)
@@ -133,7 +133,7 @@ private enum DebugControllerEntry: ItemListNodeEntry {
133133
return DebugControllerSection.web.rawValue
134134
case .keepChatNavigationStack, .skipReadHistory, .dustEffect, .crashOnSlowQueries, .crashOnMemoryPressure:
135135
return DebugControllerSection.experiments.rawValue
136-
case .clearTips, .resetNotifications, .crash, .fillLocalSavedMessageCache, .resetDatabase, .resetDatabaseAndCache, .resetHoles, .resetTagHoles, .reindexUnread, .resetCacheIndex, .reindexCache, .resetBiometricsData, .optimizeDatabase, .photoPreview, .knockoutWallpaper, .storiesExperiment, .storiesJpegExperiment, .playlistPlayback, .enableQuickReactionSwitch, .experimentalCompatibility, .enableDebugDataDisplay, .rippleEffect, .browserExperiment, .localTranscription, .enableReactionOverrides, .restorePurchases, .disableReloginTokens, .liveStreamV2, .experimentalCallMute, .playerV2, .devRequests, .fakeAds, .enableLocalTranslation:
136+
case .clearTips, .resetNotifications, .crash, .fillLocalSavedMessageCache, .resetDatabase, .resetDatabaseAndCache, .resetHoles, .resetTagHoles, .reindexUnread, .resetCacheIndex, .reindexCache, .resetBiometricsData, .optimizeDatabase, .photoPreview, .knockoutWallpaper, .storiesExperiment, .storiesJpegExperiment, .conferenceDebug, .enableQuickReactionSwitch, .experimentalCompatibility, .enableDebugDataDisplay, .rippleEffect, .browserExperiment, .localTranscription, .enableReactionOverrides, .restorePurchases, .disableReloginTokens, .liveStreamV2, .experimentalCallMute, .playerV2, .devRequests, .fakeAds, .enableLocalTranslation:
137137
return DebugControllerSection.experiments.rawValue
138138
case .logTranslationRecognition, .resetTranslationStates:
139139
return DebugControllerSection.translation.rawValue
@@ -242,7 +242,7 @@ private enum DebugControllerEntry: ItemListNodeEntry {
242242
return 47
243243
case .disableReloginTokens:
244244
return 48
245-
case .playlistPlayback:
245+
case .conferenceDebug:
246246
return 49
247247
case .enableQuickReactionSwitch:
248248
return 50
@@ -1308,12 +1308,12 @@ private enum DebugControllerEntry: ItemListNodeEntry {
13081308
})
13091309
}).start()
13101310
})
1311-
case let .playlistPlayback(value):
1312-
return ItemListSwitchItem(presentationData: presentationData, title: "Playlist Playback", value: value, sectionId: self.section, style: .blocks, updated: { value in
1311+
case let .conferenceDebug(value):
1312+
return ItemListSwitchItem(presentationData: presentationData, title: "Conference Debug", value: value, sectionId: self.section, style: .blocks, updated: { value in
13131313
let _ = arguments.sharedContext.accountManager.transaction ({ transaction in
13141314
transaction.updateSharedData(ApplicationSpecificSharedDataKeys.experimentalUISettings, { settings in
13151315
var settings = settings?.get(ExperimentalUISettings.self) ?? ExperimentalUISettings.defaultSettings
1316-
settings.playlistPlayback = value
1316+
settings.conferenceDebug = value
13171317
return PreferencesEntry(settings)
13181318
})
13191319
}).start()
@@ -1540,7 +1540,7 @@ private func debugControllerEntries(sharedContext: SharedAccountContext, present
15401540
entries.append(.storiesJpegExperiment(experimentalSettings.storiesJpegExperiment))
15411541
entries.append(.disableReloginTokens(experimentalSettings.disableReloginTokens))
15421542
}
1543-
entries.append(.playlistPlayback(experimentalSettings.playlistPlayback))
1543+
entries.append(.conferenceDebug(experimentalSettings.conferenceDebug))
15441544
entries.append(.enableQuickReactionSwitch(!experimentalSettings.disableQuickReaction))
15451545
entries.append(.liveStreamV2(experimentalSettings.liveStreamV2))
15461546
entries.append(.experimentalCallMute(experimentalSettings.experimentalCallMute))

submodules/SemanticStatusNode/BUILD

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ swift_library(
1616
"//submodules/GZip:GZip",
1717
"//submodules/rlottie:RLottieBinding",
1818
"//submodules/AppBundle:AppBundle",
19-
"//submodules/ManagedAnimationNode:ManagedAnimationNode"
19+
"//submodules/ManagedAnimationNode:ManagedAnimationNode",
20+
"//submodules/Components/HierarchyTrackingLayer",
2021
],
2122
visibility = [
2223
"//visibility:public",

submodules/SemanticStatusNode/Sources/SemanticStatusNode.swift

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import SwiftSignalKit
66
import RLottieBinding
77
import GZip
88
import AppBundle
9+
import HierarchyTrackingLayer
910

1011
public enum SemanticStatusNodeState: Equatable {
1112
public struct ProgressAppearance: Equatable {
@@ -90,7 +91,7 @@ private func svgPath(_ path: StaticString, scale: CGPoint = CGPoint(x: 1.0, y: 1
9091
}
9192

9293
private extension SemanticStatusNodeState {
93-
func context(current: SemanticStatusNodeStateContext?) -> SemanticStatusNodeStateContext {
94+
func context(current: SemanticStatusNodeStateContext?, animated: Bool) -> SemanticStatusNodeStateContext {
9495
switch self {
9596
case .none, .download, .play, .pause, .customIcon:
9697
let icon: SemanticStatusNodeIcon
@@ -114,7 +115,7 @@ private extension SemanticStatusNodeState {
114115
if current.icon == icon {
115116
return current
116117
} else if (current.icon == .play && icon == .pause) || (current.icon == .pause && icon == .play) {
117-
current.icon = icon
118+
current.setIcon(icon: icon, animated: animated)
118119
return current
119120
} else {
120121
return SemanticStatusNodeIconContext(icon: icon)
@@ -376,6 +377,8 @@ public final class SemanticStatusNode: ASControlNode {
376377
private var stateContext: SemanticStatusNodeStateContext
377378
private var appearanceContext: SemanticStatusNodeAppearanceContext
378379

380+
private let hierarchyTrackingLayer: HierarchyTrackingLayer
381+
379382
private var disposable: Disposable?
380383
private var backgroundNodeImage: UIImage?
381384

@@ -391,13 +394,16 @@ public final class SemanticStatusNode: ASControlNode {
391394

392395
public init(backgroundNodeColor: UIColor, foregroundNodeColor: UIColor, image: Signal<(TransformImageArguments) -> DrawingContext?, NoError>? = nil, overlayForegroundNodeColor: UIColor? = nil, cutout: CGRect? = nil) {
393396
self.state = .none
394-
self.stateContext = self.state.context(current: nil)
397+
self.stateContext = self.state.context(current: nil, animated: false)
395398
self.appearanceContext = SemanticStatusNodeAppearanceContext(background: backgroundNodeColor, foreground: foregroundNodeColor, backgroundImage: nil, overlayForeground: overlayForegroundNodeColor, cutout: cutout)
399+
self.hierarchyTrackingLayer = HierarchyTrackingLayer()
396400

397401
super.init()
398402

403+
self.layer.addSublayer(self.hierarchyTrackingLayer)
404+
399405
self.isOpaque = false
400-
self.displaysAsynchronously = true
406+
self.displaysAsynchronously = false
401407

402408
if let image {
403409
self.setBackgroundImage(image, size: CGSize(width: 44.0, height: 44.0))
@@ -420,7 +426,6 @@ public final class SemanticStatusNode: ASControlNode {
420426
animate = true
421427
}
422428
}
423-
424429
if self.stateContext.isAnimating {
425430
animate = true
426431
}
@@ -449,12 +454,15 @@ public final class SemanticStatusNode: ASControlNode {
449454
self.hasState = true
450455
animated = false
451456
}
457+
if !self.hierarchyTrackingLayer.isInHierarchy {
458+
animated = false
459+
}
452460
if self.state != state || self.appearanceContext.cutout != cutout {
453461
self.state = state
454462
let previousStateContext = self.stateContext
455463
let previousAppearanceContext = updateCutout ? self.appearanceContext : nil
456464

457-
self.stateContext = self.state.context(current: self.stateContext)
465+
self.stateContext = self.state.context(current: self.stateContext, animated: animated)
458466
self.stateContext.requestUpdate = { [weak self] in
459467
self?.setNeedsDisplay()
460468
}

submodules/SemanticStatusNode/Sources/SemanticStatusNodeIconContext.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,7 @@ final class SemanticStatusNodeIconContext: SemanticStatusNodeStateContext {
131131
}
132132
}
133133

134-
var icon: SemanticStatusNodeIcon {
135-
didSet {
136-
self.animationNode?.enqueueState(self.icon == .play ? .play : .pause, animated: self.iconImage != nil)
137-
}
138-
}
134+
private(set) var icon: SemanticStatusNodeIcon
139135

140136
private var animationNode: PlayPauseIconNode?
141137
private var iconImage: UIImage?
@@ -171,6 +167,11 @@ final class SemanticStatusNodeIconContext: SemanticStatusNodeStateContext {
171167

172168
var requestUpdate: () -> Void = {}
173169

170+
func setIcon(icon: SemanticStatusNodeIcon, animated: Bool) {
171+
self.icon = icon
172+
self.animationNode?.enqueueState(self.icon == .play ? .play : .pause, animated: animated)
173+
}
174+
174175
func drawingState(transitionFraction: CGFloat) -> SemanticStatusNodeStateDrawingState {
175176
return DrawingState(transitionFraction: transitionFraction, icon: self.icon, iconImage: self.iconImage, iconOffset: self.iconOffset)
176177
}

submodules/TelegramCallsUI/Sources/CallControllerNodeV2.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,14 @@ final class CallControllerNodeV2: ViewControllerTracingNode, CallControllerNodeP
167167
self.conferenceAddParticipant?()
168168
}
169169

170+
var isConferencePossible = false
171+
if self.call.context.sharedContext.immediateExperimentalUISettings.conferenceDebug {
172+
isConferencePossible = true
173+
}
174+
if let data = self.call.context.currentAppConfiguration.with({ $0 }).data, let value = data["ios_enable_conference"] as? Double {
175+
isConferencePossible = value != 0.0
176+
}
177+
170178
self.callScreenState = PrivateCallScreen.State(
171179
strings: presentationData.strings,
172180
lifecycleState: .connecting,
@@ -180,7 +188,7 @@ final class CallControllerNodeV2: ViewControllerTracingNode, CallControllerNodeP
180188
remoteVideo: nil,
181189
isRemoteBatteryLow: false,
182190
isEnergySavingEnabled: !self.sharedContext.energyUsageSettings.fullTranslucency,
183-
isConferencePossible: true
191+
isConferencePossible: isConferencePossible
184192
)
185193

186194
self.isMicrophoneMutedDisposable = (call.isMuted

submodules/TelegramUI/Components/BatchVideoRendering/Sources/BatchVideoRenderingContext.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ public final class BatchVideoRenderingContext {
153153
for (id, targetContext) in self.targetContexts {
154154
if targetContext.target != nil {
155155
if targetContext.fetchDisposable == nil {
156-
//TODO:release pass resource reference
157156
targetContext.fetchDisposable = fetchedMediaResource(
158157
mediaBox: self.context.account.postbox.mediaBox,
159158
userLocation: targetContext.userLocation,

submodules/TelegramUI/Components/Chat/ChatMessageInteractiveFileNode/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ swift_library(
4343
"//submodules/TelegramUI/Components/Chat/ChatMessageItemCommon",
4444
"//submodules/AnimatedCountLabelNode",
4545
"//submodules/AudioWaveform",
46+
"//submodules/DeviceProximity",
4647
],
4748
visibility = [
4849
"//visibility:public",

submodules/TelegramUI/Components/Chat/ChatMessageInteractiveFileNode/Sources/ChatMessageInteractiveFileNode.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import ChatMessageItemCommon
3434
import TelegramStringFormatting
3535
import AnimatedCountLabelNode
3636
import AudioWaveform
37+
import DeviceProximity
3738

3839
private struct FetchControls {
3940
let fetch: (Bool) -> Void
@@ -1561,6 +1562,12 @@ public final class ChatMessageInteractiveFileNode: ASDisplayNode {
15611562
guard let arguments = self.arguments else {
15621563
return
15631564
}
1565+
1566+
var animated = animated
1567+
if DeviceProximityManager.shared().currentValue() {
1568+
animated = false
1569+
}
1570+
15641571
let incoming = message.effectivelyIncoming(context.account.peerId)
15651572
let messageTheme = incoming ? presentationData.theme.theme.chat.message.incoming : presentationData.theme.theme.chat.message.outgoing
15661573

submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoHeaderNavigationButtonContainerNode.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ final class PeerInfoHeaderNavigationButtonContainerNode: SparseNode {
5454
}
5555

5656
var accumulatedRightButtonOffset: CGFloat = canBeExpanded ? 16.0 : 0.0
57-
for (_, button) in self.rightButtonNodes {
57+
for spec in self.currentRightButtons.reversed() {
58+
guard let button = self.rightButtonNodes[spec.key] else {
59+
continue
60+
}
5861
button.updateContentsColor(backgroundColor: self.backgroundContentColor, contentsColor: self.contentsColor, canBeExpanded: canBeExpanded, transition: transition)
5962
transition.updateSublayerTransformOffset(layer: button.layer, offset: CGPoint(x: accumulatedRightButtonOffset, y: 0.0))
6063
if self.backgroundContentColor.alpha != 0.0 {
@@ -174,6 +177,7 @@ final class PeerInfoHeaderNavigationButtonContainerNode: SparseNode {
174177
}
175178
}
176179

180+
var accumulatedRightButtonOffset: CGFloat = self.canBeExpanded ? 16.0 : 0.0
177181
if self.currentRightButtons != rightButtons || presentationData.strings !== self.presentationData?.strings {
178182
self.currentRightButtons = rightButtons
179183

@@ -225,7 +229,10 @@ final class PeerInfoHeaderNavigationButtonContainerNode: SparseNode {
225229
buttonNode.alpha = 0.0
226230
transition.updateAlpha(node: buttonNode, alpha: alphaFactor * alphaFactor)
227231

228-
transition.updateSublayerTransformOffset(layer: buttonNode.layer, offset: CGPoint(x: canBeExpanded ? 16.0 : 0.0, y: 0.0))
232+
transition.updateSublayerTransformOffset(layer: buttonNode.layer, offset: CGPoint(x: accumulatedRightButtonOffset, y: 0.0))
233+
if self.backgroundContentColor.alpha != 0.0 {
234+
accumulatedRightButtonOffset -= 6.0
235+
}
229236
} else {
230237
transition.updateFrameAdditiveToCenter(node: buttonNode, frame: buttonFrame)
231238
transition.updateAlpha(node: buttonNode, alpha: alphaFactor * alphaFactor)

submodules/TelegramUIPreferences/Sources/ExperimentalUISettings.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ public struct ExperimentalUISettings: Codable, Equatable {
3232
public var knockoutWallpaper: Bool
3333
public var foldersTabAtBottom: Bool
3434
public var playerEmbedding: Bool
35-
public var playlistPlayback: Bool
3635
public var preferredVideoCodec: String?
3736
public var disableVideoAspectScaling: Bool
3837
public var enableVoipTcp: Bool
@@ -65,6 +64,7 @@ public struct ExperimentalUISettings: Codable, Equatable {
6564
public var playerV2: Bool
6665
public var devRequests: Bool
6766
public var fakeAds: Bool
67+
public var conferenceDebug: Bool
6868

6969
public static var defaultSettings: ExperimentalUISettings {
7070
return ExperimentalUISettings(
@@ -75,7 +75,6 @@ public struct ExperimentalUISettings: Codable, Equatable {
7575
knockoutWallpaper: false,
7676
foldersTabAtBottom: false,
7777
playerEmbedding: false,
78-
playlistPlayback: false,
7978
preferredVideoCodec: nil,
8079
disableVideoAspectScaling: false,
8180
enableVoipTcp: false,
@@ -107,7 +106,8 @@ public struct ExperimentalUISettings: Codable, Equatable {
107106
autoBenchmarkReflectors: nil,
108107
playerV2: false,
109108
devRequests: false,
110-
fakeAds: false
109+
fakeAds: false,
110+
conferenceDebug: false
111111
)
112112
}
113113

@@ -119,7 +119,6 @@ public struct ExperimentalUISettings: Codable, Equatable {
119119
knockoutWallpaper: Bool,
120120
foldersTabAtBottom: Bool,
121121
playerEmbedding: Bool,
122-
playlistPlayback: Bool,
123122
preferredVideoCodec: String?,
124123
disableVideoAspectScaling: Bool,
125124
enableVoipTcp: Bool,
@@ -151,7 +150,8 @@ public struct ExperimentalUISettings: Codable, Equatable {
151150
autoBenchmarkReflectors: Bool?,
152151
playerV2: Bool,
153152
devRequests: Bool,
154-
fakeAds: Bool
153+
fakeAds: Bool,
154+
conferenceDebug: Bool
155155
) {
156156
self.keepChatNavigationStack = keepChatNavigationStack
157157
self.skipReadHistory = skipReadHistory
@@ -160,7 +160,6 @@ public struct ExperimentalUISettings: Codable, Equatable {
160160
self.knockoutWallpaper = knockoutWallpaper
161161
self.foldersTabAtBottom = foldersTabAtBottom
162162
self.playerEmbedding = playerEmbedding
163-
self.playlistPlayback = playlistPlayback
164163
self.preferredVideoCodec = preferredVideoCodec
165164
self.disableVideoAspectScaling = disableVideoAspectScaling
166165
self.enableVoipTcp = enableVoipTcp
@@ -193,6 +192,7 @@ public struct ExperimentalUISettings: Codable, Equatable {
193192
self.playerV2 = playerV2
194193
self.devRequests = devRequests
195194
self.fakeAds = fakeAds
195+
self.conferenceDebug = conferenceDebug
196196
}
197197

198198
public init(from decoder: Decoder) throws {
@@ -205,7 +205,6 @@ public struct ExperimentalUISettings: Codable, Equatable {
205205
self.knockoutWallpaper = (try container.decodeIfPresent(Int32.self, forKey: "knockoutWallpaper") ?? 0) != 0
206206
self.foldersTabAtBottom = (try container.decodeIfPresent(Int32.self, forKey: "foldersTabAtBottom") ?? 0) != 0
207207
self.playerEmbedding = (try container.decodeIfPresent(Int32.self, forKey: "playerEmbedding") ?? 0) != 0
208-
self.playlistPlayback = (try container.decodeIfPresent(Int32.self, forKey: "playlistPlayback") ?? 0) != 0
209208
self.preferredVideoCodec = try container.decodeIfPresent(String.self.self, forKey: "preferredVideoCodec")
210209
self.disableVideoAspectScaling = (try container.decodeIfPresent(Int32.self, forKey: "disableVideoAspectScaling") ?? 0) != 0
211210
self.enableVoipTcp = (try container.decodeIfPresent(Int32.self, forKey: "enableVoipTcp") ?? 0) != 0
@@ -238,6 +237,7 @@ public struct ExperimentalUISettings: Codable, Equatable {
238237
self.playerV2 = try container.decodeIfPresent(Bool.self, forKey: "playerV2") ?? false
239238
self.devRequests = try container.decodeIfPresent(Bool.self, forKey: "devRequests") ?? false
240239
self.fakeAds = try container.decodeIfPresent(Bool.self, forKey: "fakeAds") ?? false
240+
self.conferenceDebug = try container.decodeIfPresent(Bool.self, forKey: "conferenceDebug") ?? false
241241
}
242242

243243
public func encode(to encoder: Encoder) throws {
@@ -250,7 +250,6 @@ public struct ExperimentalUISettings: Codable, Equatable {
250250
try container.encode((self.knockoutWallpaper ? 1 : 0) as Int32, forKey: "knockoutWallpaper")
251251
try container.encode((self.foldersTabAtBottom ? 1 : 0) as Int32, forKey: "foldersTabAtBottom")
252252
try container.encode((self.playerEmbedding ? 1 : 0) as Int32, forKey: "playerEmbedding")
253-
try container.encode((self.playlistPlayback ? 1 : 0) as Int32, forKey: "playlistPlayback")
254253
try container.encodeIfPresent(self.preferredVideoCodec, forKey: "preferredVideoCodec")
255254
try container.encode((self.disableVideoAspectScaling ? 1 : 0) as Int32, forKey: "disableVideoAspectScaling")
256255
try container.encode((self.enableVoipTcp ? 1 : 0) as Int32, forKey: "enableVoipTcp")
@@ -283,6 +282,7 @@ public struct ExperimentalUISettings: Codable, Equatable {
283282
try container.encodeIfPresent(self.playerV2, forKey: "playerV2")
284283
try container.encodeIfPresent(self.devRequests, forKey: "devRequests")
285284
try container.encodeIfPresent(self.fakeAds, forKey: "fakeAds")
285+
try container.encodeIfPresent(self.conferenceDebug, forKey: "conferenceDebug")
286286
}
287287
}
288288

0 commit comments

Comments
 (0)