Skip to content

Commit 7364be9

Browse files
author
Isaac
committed
Merge commit '02181ead9e59984f4d348003a96e6dee63126c50'
2 parents 0570dbb + 02181ea commit 7364be9

File tree

5 files changed

+93
-68
lines changed

5 files changed

+93
-68
lines changed

submodules/Camera/Sources/CameraUtils.swift

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -188,16 +188,26 @@ extension CameraPreviewView.Rotation {
188188
}
189189
}
190190

191-
func exifOrientationForDeviceOrientation(_ deviceOrientation: UIDeviceOrientation) -> CGImagePropertyOrientation {
192-
switch deviceOrientation {
193-
case .portraitUpsideDown:
194-
return .rightMirrored
195-
case .landscapeLeft:
196-
return .downMirrored
197-
case .landscapeRight:
198-
return .upMirrored
199-
default:
200-
return .leftMirrored
191+
func exifOrientation(for orientation: AVCaptureVideoOrientation, mirror: Bool) -> Int32 {
192+
switch (orientation, mirror) {
193+
case (.portrait, false):
194+
return 6
195+
case (.portrait, true):
196+
return 5
197+
case (.portraitUpsideDown, false):
198+
return 8
199+
case (.portraitUpsideDown, true):
200+
return 7
201+
case (.landscapeLeft, false):
202+
return 3
203+
case (.landscapeLeft, true):
204+
return 2
205+
case (.landscapeRight, false):
206+
return 1
207+
case (.landscapeRight, true):
208+
return 4
209+
@unknown default:
210+
return 6
201211
}
202212
}
203213

submodules/Camera/Sources/PhotoCaptureContext.swift

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -58,36 +58,16 @@ final class PhotoCaptureContext: NSObject, AVCapturePhotoCaptureDelegate {
5858
print("Error occurred while capturing photo: Missing pixel buffer (\(String(describing: error)))")
5959
return
6060
}
61-
62-
var photoFormatDescription: CMFormatDescription?
63-
CMVideoFormatDescriptionCreateForImageBuffer(allocator: kCFAllocatorDefault, imageBuffer: photoPixelBuffer, formatDescriptionOut: &photoFormatDescription)
64-
65-
var orientation: UIImage.Orientation = .right
66-
if self.orientation == .landscapeLeft {
67-
orientation = .down
68-
} else if self.orientation == .landscapeRight {
69-
orientation = .up
70-
} else if self.orientation == .portraitUpsideDown {
71-
orientation = .left
72-
}
73-
74-
let finalPixelBuffer = photoPixelBuffer
75-
let renderedCIImage = CIImage(cvImageBuffer: finalPixelBuffer)
76-
if let cgImage = self.ciContext.createCGImage(renderedCIImage, from: renderedCIImage.extent) {
77-
var image = UIImage(cgImage: cgImage, scale: 1.0, orientation: orientation)
78-
if image.imageOrientation != .up {
79-
UIGraphicsBeginImageContextWithOptions(image.size, true, image.scale)
80-
if self.mirror, let context = UIGraphicsGetCurrentContext() {
81-
context.translateBy(x: image.size.width / 2.0, y: image.size.height / 2.0)
82-
context.scaleBy(x: -1.0, y: 1.0)
83-
context.translateBy(x: -image.size.width / 2.0, y: -image.size.height / 2.0)
84-
}
85-
image.draw(in: CGRect(origin: .zero, size: image.size))
86-
if let currentImage = UIGraphicsGetImageFromCurrentImageContext() {
87-
image = currentImage
88-
}
89-
UIGraphicsEndImageContext()
90-
}
61+
62+
//if let value = photo.metadata[kCGImagePropertyOrientation as String] as? NSNumber {
63+
// orientation = value.int32Value
64+
//} else {
65+
let orientation = exifOrientation(for: self.orientation, mirror: self.mirror)
66+
//}
67+
68+
let ci = CIImage(cvImageBuffer: photoPixelBuffer).oriented(forExifOrientation: orientation)
69+
if let cgImage = self.ciContext.createCGImage(ci, from: ci.extent) {
70+
let image = UIImage(cgImage: cgImage, scale: 1.0, orientation: .up)
9171
self.pipe.putNext(.finished(image, nil, CACurrentMediaTime()))
9272
} else {
9373
self.pipe.putNext(.failed)

submodules/TelegramCallsUI/Sources/CallStatusBarNode.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,8 @@ public class CallStatusBarNodeImpl: CallStatusBarNode {
268268
self.update()
269269
}
270270

271-
private let textFont = Font.with(size: 13.0, design: .regular, weight: .regular, traits: [.monospacedNumbers])
271+
private let callTextFont = Font.with(size: 13.0, design: .regular, weight: .regular, traits: [.monospacedNumbers])
272+
private let groupCallTextFont = Font.with(size: 13.0, design: .regular, weight: .regular, traits: [])
272273

273274
private func update() {
274275
guard let size = self.currentSize, let content = self.currentContent else {
@@ -277,12 +278,15 @@ public class CallStatusBarNodeImpl: CallStatusBarNode {
277278

278279
let wasEmpty = (self.titleNode.attributedText?.string ?? "").isEmpty
279280

281+
let textFont: UIFont
280282
let setupDataForCall: AnyObject?
281283
switch content {
282284
case let .call(_, _, call):
283285
setupDataForCall = call
286+
textFont = callTextFont
284287
case let .groupCall(_, _, call):
285288
setupDataForCall = call
289+
textFont = groupCallTextFont
286290
}
287291

288292
if self.didSetupDataForCall !== setupDataForCall {
@@ -540,7 +544,11 @@ public class CallStatusBarNodeImpl: CallStatusBarNode {
540544
let subtitleSize = self.subtitleNode.updateLayout(size: CGSize(width: 150.0, height: size.height), animated: true)
541545
let speakerSize = self.speakerNode.updateLayout(CGSize(width: 150.0, height: size.height))
542546

543-
let totalWidth = titleSize.width + spacing + subtitleSize.width
547+
var totalWidth = titleSize.width
548+
if totalWidth > 0.0 {
549+
totalWidth += spacing
550+
}
551+
totalWidth += subtitleSize.width
544552
let horizontalOrigin: CGFloat = floor((size.width - totalWidth) / 2.0)
545553

546554
let contentHeight: CGFloat = 24.0
@@ -553,7 +561,8 @@ public class CallStatusBarNodeImpl: CallStatusBarNode {
553561
transition.updateFrame(node: self.subtitleNode, frame: CGRect(origin: CGPoint(x: horizontalOrigin + titleSize.width + spacing, y: verticalOrigin + floor((contentHeight - subtitleSize.height) / 2.0)), size: subtitleSize))
554562

555563
if displaySpeakerSubtitle {
556-
self.speakerNode.frame = CGRect(origin: CGPoint(x: horizontalOrigin + titleSize.width + spacing, y: verticalOrigin + floor((contentHeight - speakerSize.height) / 2.0)), size: speakerSize)
564+
let speakerOriginX: CGFloat = title.isEmpty ? floor((size.width - speakerSize.width) / 2.0) : horizontalOrigin + titleSize.width + spacing
565+
self.speakerNode.frame = CGRect(origin: CGPoint(x: speakerOriginX, y: verticalOrigin + floor((contentHeight - speakerSize.height) / 2.0)), size: speakerSize)
557566
}
558567

559568
let state: CallStatusBarBackgroundNode.State

submodules/TelegramCallsUI/Sources/Components/MessageItemComponent.swift

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ final class MessageItemComponent: Component {
9191
self.background = GlassBackgroundView()
9292

9393
self.avatarNode = AvatarNode(font: avatarPlaceholderFont(size: 12.0))
94+
self.avatarNode.hitTestSlop = UIEdgeInsets(top: -5.0, left: -5.0, bottom: -5.0, right: -8.0)
9495

9596
self.icon = ComponentView()
9697
self.text = ComponentView()
@@ -156,19 +157,7 @@ final class MessageItemComponent: Component {
156157
transition.animateAlpha(view: self.avatarNode.view, from: 0.0, to: 1.0)
157158
transition.animateScale(view: self.avatarNode.view, from: 0.01, to: 1.0)
158159
}
159-
160-
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
161-
if !self.avatarNode.isHidden, self.avatarNode.frame.contains(point) {
162-
return true
163-
}
164-
if let textView = self.text.view as? MultilineTextWithEntitiesComponent.View, let (_, attributes) = textView.attributes(at: self.convert(point, to: textView)) {
165-
if let _ = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.Spoiler)], textView.isSpoilerConcealed {
166-
return true
167-
}
168-
}
169-
return false
170-
}
171-
160+
172161
func update(component: MessageItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
173162
let isFirstTime = self.component == nil
174163
var transition = transition
@@ -207,6 +196,7 @@ final class MessageItemComponent: Component {
207196

208197
let text = component.text
209198
var entities = component.entities
199+
210200
if let cachedEntities = self.cachedEntities {
211201
entities = cachedEntities
212202
} else if let availableReactions = component.availableReactions, text.count == 1 {
@@ -223,6 +213,21 @@ final class MessageItemComponent: Component {
223213
entities.insert(MessageTextEntity(range: 0 ..< (text as NSString).length, type: .CustomEmoji(stickerPack: nil, fileId: item.file.fileId.id)), at: 0)
224214
self.cachedEntities = entities
225215
}
216+
} else {
217+
entities = entities.filter { entity in
218+
switch entity.type {
219+
case .Bold, .Italic, .Strikethrough, .Underline, .Spoiler:
220+
return true
221+
case .CustomEmoji:
222+
if case let .peer(peer) = component.icon, peer.isPremium {
223+
return true
224+
}
225+
return false
226+
default:
227+
return false
228+
}
229+
}
230+
self.cachedEntities = entities
226231
}
227232

228233
let attributedText: NSAttributedString
@@ -263,7 +268,7 @@ final class MessageItemComponent: Component {
263268
placeholderColor: UIColor(rgb: 0xffffff, alpha: 0.3),
264269
text: .plain(attributedText),
265270
maximumNumberOfLines: 0,
266-
lineSpacing: 0.0,
271+
lineSpacing: 0.1,
267272
spoilerColor: .white,
268273
handleSpoilers: true
269274
)),

submodules/TelegramCallsUI/Sources/VideoChatScreen.swift

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,19 @@ final class VideoChatScreenComponent: Component {
482482
return result
483483
}
484484

485+
override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
486+
if let gestureRecognizer = gestureRecognizer as? UIPanGestureRecognizer {
487+
let location = gestureRecognizer.location(in: self)
488+
if let inputPanelView = self.inputPanel.view {
489+
let mappedLocation = self.convert(location, to: inputPanelView)
490+
if inputPanelView.bounds.contains(mappedLocation) {
491+
return false
492+
}
493+
}
494+
}
495+
return true
496+
}
497+
485498
@objc func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRequireFailureOf otherGestureRecognizer: UIGestureRecognizer) -> Bool {
486499
if gestureRecognizer is UITapGestureRecognizer {
487500
if otherGestureRecognizer is UIPanGestureRecognizer {
@@ -751,7 +764,7 @@ final class VideoChatScreenComponent: Component {
751764
switch result {
752765
case .linkCopied:
753766
let presentationData = groupCall.accountContext.sharedContext.currentPresentationData.with { $0 }
754-
self.presentToast(icon: .icon("anim_linkcopied"), text: presentationData.strings.CallList_ToastCallLinkCopied_Text, duration: 3)
767+
self.presentToast(icon: .animation("anim_linkcopied"), text: presentationData.strings.CallList_ToastCallLinkCopied_Text, duration: 3)
755768
case .openCall:
756769
break
757770
}
@@ -838,15 +851,15 @@ final class VideoChatScreenComponent: Component {
838851
} else {
839852
text = ""
840853
}
841-
self.presentToast(icon: .icon(isSavedMessages ? "anim_savedmessages" : "anim_forward"), text: text, duration: 3)
854+
self.presentToast(icon: .animation(isSavedMessages ? "anim_savedmessages" : "anim_forward"), text: text, duration: 3)
842855
})
843856
}
844857
shareController.actionCompleted = { [weak self] in
845858
guard let self, let environment = self.environment, case let .group(groupCall) = self.currentCall else {
846859
return
847860
}
848861
let presentationData = groupCall.accountContext.sharedContext.currentPresentationData.with({ $0 }).withUpdated(theme: environment.theme)
849-
self.presentToast(icon: .icon("anim_linkcopied"), text: presentationData.strings.VoiceChat_InviteLinkCopiedText, duration: 3)
862+
self.presentToast(icon: .animation("anim_linkcopied"), text: presentationData.strings.VoiceChat_InviteLinkCopiedText, duration: 3)
850863
}
851864
environment.controller()?.present(shareController, in: .window(.root))
852865
})
@@ -889,15 +902,15 @@ final class VideoChatScreenComponent: Component {
889902
} else {
890903
text = ""
891904
}
892-
self.presentToast(icon: .icon(isSavedMessages ? "anim_savedmessages" : "anim_forward"), text: text, duration: 3)
905+
self.presentToast(icon: .animation(isSavedMessages ? "anim_savedmessages" : "anim_forward"), text: text, duration: 3)
893906
})
894907
}
895908
shareController.actionCompleted = { [weak self] in
896909
guard let self, let environment = self.environment, case let .group(groupCall) = self.currentCall else {
897910
return
898911
}
899912
let presentationData = groupCall.accountContext.sharedContext.currentPresentationData.with({ $0 }).withUpdated(theme: environment.theme)
900-
self.presentToast(icon: .icon("anim_linkcopied"), text: presentationData.strings.VoiceChat_InviteLinkCopiedText, duration: 3)
913+
self.presentToast(icon: .animation("anim_linkcopied"), text: presentationData.strings.VoiceChat_InviteLinkCopiedText, duration: 3)
901914
}
902915
environment.controller()?.present(shareController, in: .window(.root))
903916
}
@@ -2472,10 +2485,17 @@ final class VideoChatScreenComponent: Component {
24722485
areButtonsCollapsed = true
24732486
areButtonsActuallyCollapsed = false
24742487

2475-
mainColumnWidth = min(isLandscape ? 356.0 : 320.0, availableSize.width - leftInset - rightInset - 340.0)
2488+
let landscapeColumnWidth: CGFloat
2489+
if environment.metrics.isTablet {
2490+
landscapeColumnWidth = 356.0
2491+
} else {
2492+
landscapeColumnWidth = 340.0
2493+
}
2494+
2495+
mainColumnWidth = min(isLandscape ? landscapeColumnWidth : 320.0, availableSize.width - leftInset - rightInset - 340.0)
24762496
mainColumnSideInset = 0.0
24772497
} else {
2478-
areButtonsCollapsed = true //self.expandedParticipantsVideoState != nil
2498+
areButtonsCollapsed = true
24792499
areButtonsActuallyCollapsed = self.expandedParticipantsVideoState != nil
24802500

24812501
if availableSize.width > maxSingleColumnWidth {
@@ -2692,7 +2712,7 @@ final class VideoChatScreenComponent: Component {
26922712
if buttonsOnTheSide {
26932713
collapsedParticipantsClippingY = availableSize.height
26942714
} else {
2695-
collapsedParticipantsClippingY = collapsedMicrophoneButtonFrame.minY - 16.0
2715+
collapsedParticipantsClippingY = expandedMicrophoneButtonFrame.minY - 70.0
26962716
}
26972717

26982718
let expandedParticipantsClippingY: CGFloat
@@ -2703,7 +2723,7 @@ final class VideoChatScreenComponent: Component {
27032723
expandedParticipantsClippingY = availableSize.height - max(14.0, environment.safeInsets.bottom)
27042724
}
27052725
} else {
2706-
expandedParticipantsClippingY = expandedMicrophoneButtonFrame.minY - 24.0
2726+
expandedParticipantsClippingY = expandedMicrophoneButtonFrame.minY - 28.0
27072727
}
27082728

27092729

@@ -3429,7 +3449,7 @@ final class VideoChatScreenComponent: Component {
34293449
)
34303450

34313451
let availableInputMediaWidth = availableSize.width
3432-
let heightAndOverflow = inputMediaNode.updateLayout(width: availableInputMediaWidth, leftInset: 0.0, rightInset: 0.0, bottomInset: environment.safeInsets.bottom, standardInputHeight: environment.deviceMetrics.standardInputHeight(inLandscape: false), inputHeight: environment.inputHeight, maximumHeight: availableSize.height, inputPanelHeight: 0.0, transition: .immediate, interfaceState: presentationInterfaceState, layoutMetrics: environment.metrics, deviceMetrics: environment.deviceMetrics, isVisible: true, isExpanded: false)
3452+
let heightAndOverflow = inputMediaNode.updateLayout(width: availableInputMediaWidth, leftInset: environment.safeInsets.left, rightInset: environment.safeInsets.right, bottomInset: environment.safeInsets.bottom, standardInputHeight: environment.deviceMetrics.standardInputHeight(inLandscape: false), inputHeight: environment.inputHeight, maximumHeight: availableSize.height, inputPanelHeight: 0.0, transition: .immediate, interfaceState: presentationInterfaceState, layoutMetrics: environment.metrics, deviceMetrics: environment.deviceMetrics, isVisible: true, isExpanded: false)
34333453
let inputNodeHeight = heightAndOverflow.0
34343454
let inputNodeFrame = CGRect(origin: CGPoint(x: floorToScreenPixels((availableSize.width - availableInputMediaWidth) / 2.0), y: availableSize.height - inputNodeHeight), size: CGSize(width: availableInputMediaWidth, height: inputNodeHeight))
34353455
transition.setFrame(layer: inputMediaNode.layer, frame: inputNodeFrame)
@@ -3499,7 +3519,7 @@ final class VideoChatScreenComponent: Component {
34993519
placeholder: .plain(environment.strings.VoiceChat_MessagePlaceholder),
35003520
sendPaidMessageStars: nil,
35013521
maxLength: characterLimit,
3502-
queryTypes: [.mention, .hashtag],
3522+
queryTypes: [],
35033523
alwaysDarkWhenHasText: false,
35043524
useGrayBackground: false,
35053525
resetInputContents: nil,
@@ -3609,6 +3629,7 @@ final class VideoChatScreenComponent: Component {
36093629
}
36103630
let inputPanelFrame = CGRect(origin: CGPoint(x: inputPanelOriginX, y: availableSize.height - inputPanelBottomInset - inputPanelSize.height - 3.0), size: inputPanelSize)
36113631
if let inputPanelView = self.inputPanel.view {
3632+
inputPanelView.disablesInteractiveKeyboardGestureRecognizer = true
36123633
if inputPanelView.superview == nil {
36133634
self.containerView.addSubview(inputPanelView)
36143635
}

0 commit comments

Comments
 (0)