From 7a114f229c92f63f7674cb38124291d4ad2b16d2 Mon Sep 17 00:00:00 2001 From: Peter Date: Wed, 5 Sep 2018 19:00:52 +0300 Subject: [PATCH] no message --- TelegramUI.xcodeproj/project.pbxproj | 16 +-- .../AuthorizationSequenceController.swift | 13 +++ TelegramUI/ChatController.swift | 103 ++++++++++-------- .../ChatItemGalleryFooterContentNode.swift | 6 +- TelegramUI/ChatListItem.swift | 18 +-- TelegramUI/ChatTextInputPanelNode.swift | 10 +- TelegramUI/CheckDeviceAccess.swift | 12 +- TelegramUI/ItemListRevealOptionsNode.swift | 4 +- TelegramUI/LegacyLocationController.swift | 2 +- TelegramUI/MediaPlayer.swift | 4 +- TelegramUI/OpenInActionSheetController.swift | 6 +- TelegramUI/OpenInOptions.swift | 40 +++---- TelegramUI/PhotoResources.swift | 4 +- TelegramUI/ShareControllerNode.swift | 6 +- TelegramUI/UniversalVideoCalleryItem.swift | 23 ++-- 15 files changed, 154 insertions(+), 113 deletions(-) diff --git a/TelegramUI.xcodeproj/project.pbxproj b/TelegramUI.xcodeproj/project.pbxproj index 9ba11c024b..da8ab078dd 100644 --- a/TelegramUI.xcodeproj/project.pbxproj +++ b/TelegramUI.xcodeproj/project.pbxproj @@ -8,7 +8,6 @@ /* Begin PBXBuildFile section */ 091EB4EB213F48B4005284DE /* Vision.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 094981C52138D73B00A10660 /* Vision.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; - 091EB4F0213F4C4C005284DE /* Lottie.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 091EB4EF213F4C4C005284DE /* Lottie.framework */; }; 09310D2C213ED5FB0020033A /* anim_read.json in Resources */ = {isa = PBXBuildFile; fileRef = 09310D14213BC5DE0020033A /* anim_read.json */; }; 09310D2D213ED5FB0020033A /* anim_pin.json in Resources */ = {isa = PBXBuildFile; fileRef = 09310D15213BC5DE0020033A /* anim_pin.json */; }; 09310D2E213ED5FB0020033A /* anim_unmute.json in Resources */ = {isa = PBXBuildFile; fileRef = 09310D16213BC5DE0020033A /* anim_unmute.json */; }; @@ -347,6 +346,7 @@ D0C27B3B1F4B453700A4E170 /* InstantPagePlayableVideoItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0C27B3A1F4B453700A4E170 /* InstantPagePlayableVideoItem.swift */; }; D0C27B3D1F4B454800A4E170 /* InstantPagePlayableVideoNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0C27B3C1F4B454800A4E170 /* InstantPagePlayableVideoNode.swift */; }; D0C44B641FC64D0500227BE0 /* SwipeToDismissGestureRecognizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0C44B631FC64D0500227BE0 /* SwipeToDismissGestureRecognizer.swift */; }; + D0C45E9F213FFAFD00988156 /* Lottie.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0C45E9E213FFAFD00988156 /* Lottie.framework */; }; D0CAD8FB20AE1D1B00ACD96E /* ChannelMemberCategoryListContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0CAD8FA20AE1D1B00ACD96E /* ChannelMemberCategoryListContext.swift */; }; D0CAD8FD20AE467D00ACD96E /* PeerChannelMemberCategoriesContextsManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0CAD8FC20AE467D00ACD96E /* PeerChannelMemberCategoriesContextsManager.swift */; }; D0CAD90120AEECAC00ACD96E /* ChatEditInterfaceMessageState.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0CAD90020AEECAC00ACD96E /* ChatEditInterfaceMessageState.swift */; }; @@ -1016,9 +1016,6 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 091EB4E9213F475A005284DE /* Lottie.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Lottie.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 091EB4EC213F48BE005284DE /* Lottie.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Lottie.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 091EB4EF213F4C4C005284DE /* Lottie.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Lottie.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 09310D14213BC5DE0020033A /* anim_read.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = anim_read.json; sourceTree = ""; }; 09310D15213BC5DE0020033A /* anim_pin.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = anim_pin.json; sourceTree = ""; }; 09310D16213BC5DE0020033A /* anim_unmute.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = anim_unmute.json; sourceTree = ""; }; @@ -1424,8 +1421,6 @@ D0575AF61EA0ED4F006F2541 /* ChatMessageInstantVideoItemNode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChatMessageInstantVideoItemNode.swift; sourceTree = ""; }; D0575AF91EA0FDA7006F2541 /* AvatarGalleryController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AvatarGalleryController.swift; sourceTree = ""; }; D0575AFB1EA104A6006F2541 /* PeerAvatarImageGalleryItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PeerAvatarImageGalleryItem.swift; sourceTree = ""; }; - D057C52B2004202900990762 /* libLottie.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libLottie.a; sourceTree = BUILT_PRODUCTS_DIR; }; - D057C5412004215B00990762 /* Lottie.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Lottie.framework; sourceTree = BUILT_PRODUCTS_DIR; }; D05811931DD5F9380057C769 /* TelegramApplicationContext.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TelegramApplicationContext.swift; sourceTree = ""; }; D058E0CE1E8AD57300A442DE /* VideoPlayerProxy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VideoPlayerProxy.swift; sourceTree = ""; }; D05A32DB1E6EFCC2002760B4 /* NumericFormat.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NumericFormat.swift; sourceTree = ""; }; @@ -1686,6 +1681,7 @@ D0C27B3A1F4B453700A4E170 /* InstantPagePlayableVideoItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InstantPagePlayableVideoItem.swift; sourceTree = ""; }; D0C27B3C1F4B454800A4E170 /* InstantPagePlayableVideoNode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InstantPagePlayableVideoNode.swift; sourceTree = ""; }; D0C44B631FC64D0500227BE0 /* SwipeToDismissGestureRecognizer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwipeToDismissGestureRecognizer.swift; sourceTree = ""; }; + D0C45E9E213FFAFD00988156 /* Lottie.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Lottie.framework; sourceTree = BUILT_PRODUCTS_DIR; }; D0C48F431E81D5110075317D /* ChatEmptyItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChatEmptyItem.swift; sourceTree = ""; }; D0C50DE81E93A07900F62E39 /* libtgvoip.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = libtgvoip.framework; path = "../libtgvoip/build/Debug-iphoneos/libtgvoip.framework"; sourceTree = ""; }; D0C50E281E93A33700F62E39 /* VoipDynamic.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = VoipDynamic.framework; path = "../../../../Library/Developer/Xcode/DerivedData/Telegram-iOS-diblohvjozhgaifjcniwdlixlilx/Build/Products/Debug-iphoneos/VoipDynamic.framework"; sourceTree = ""; }; @@ -2119,7 +2115,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 091EB4F0213F4C4C005284DE /* Lottie.framework in Frameworks */, + D0C45E9F213FFAFD00988156 /* Lottie.framework in Frameworks */, 091EB4EB213F48B4005284DE /* Vision.framework in Frameworks */, D00ACA4B20222C280045D427 /* libtgvoip.framework in Frameworks */, D07BCBFE1F2B792300ED97AA /* LegacyComponents.framework in Frameworks */, @@ -3010,13 +3006,9 @@ D08D45281D5E340200A7428A /* Frameworks */ = { isa = PBXGroup; children = ( - 091EB4EF213F4C4C005284DE /* Lottie.framework */, - 091EB4EC213F48BE005284DE /* Lottie.framework */, - 091EB4E9213F475A005284DE /* Lottie.framework */, + D0C45E9E213FFAFD00988156 /* Lottie.framework */, D02DADBE2138D76F00116225 /* Vision.framework */, D00ACA4C20222C280045D427 /* libtgvoip.framework */, - D057C5412004215B00990762 /* Lottie.framework */, - D057C52B2004202900990762 /* libLottie.a */, D07BCBFD1F2B792300ED97AA /* LegacyComponents.framework */, D053B4361F1A9CA000E2D58A /* WebKit.framework */, D09E63B11F11289A003444CD /* PassKit.framework */, diff --git a/TelegramUI/AuthorizationSequenceController.swift b/TelegramUI/AuthorizationSequenceController.swift index fac23a3398..5dbbbb5bfe 100644 --- a/TelegramUI/AuthorizationSequenceController.swift +++ b/TelegramUI/AuthorizationSequenceController.swift @@ -48,6 +48,11 @@ public final class AuthorizationSequenceController: NavigationController { self.actionDisposable.dispose() } + override public func loadView() { + super.loadView() + self.view.backgroundColor = self.theme.backgroundColor + } + private func splashController() -> AuthorizationSequenceSplashController { var currentController: AuthorizationSequenceSplashController? for c in self.viewControllers { @@ -527,4 +532,12 @@ public final class AuthorizationSequenceController: NavigationController { } else if let _ = state as? AuthorizedAccountState { } } + + override public func setViewControllers(_ viewControllers: [UIViewController], animated: Bool) { + let wasEmpty = self.viewControllers.isEmpty + super.setViewControllers(viewControllers, animated: animated) + if wasEmpty { + self.topViewController?.view.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3) + } + } } diff --git a/TelegramUI/ChatController.swift b/TelegramUI/ChatController.swift index 13d08067d4..360e2f8a93 100644 --- a/TelegramUI/ChatController.swift +++ b/TelegramUI/ChatController.swift @@ -170,6 +170,8 @@ public final class ChatController: TelegramController, UIViewControllerPreviewin private var screenCaptureEventsDisposable: Disposable? private let chatAdditionalDataDisposable = MetaDisposable() + private var beginMediaRecordingRequestId: Int = 0 + var purposefulAction: (() -> Void)? public init(account: Account, chatLocation: ChatLocation, messageId: MessageId? = nil, botStart: ChatControllerInitialBotStart? = nil, mode: ChatControllerPresentationMode = .standard(previewing: false)) { @@ -2120,57 +2122,70 @@ public final class ChatController: TelegramController, UIViewControllerPreviewin strongSelf.openPeer(peerId: peerId, navigation: .withBotStartPayload(ChatControllerInitialBotStart(payload: payload, behavior: .automatic(returnToPeerId: currentPeerId))), fromMessage: nil) } }, beginMediaRecording: { [weak self] isVideo in - let begin: () -> Void = { - if let strongSelf = self { - let hasOngoingCall: Signal - if let signal = strongSelf.account.telegramApplicationContext.hasOngoingCall { - hasOngoingCall = signal - } else { - hasOngoingCall = .single(false) - } - let _ = (hasOngoingCall - |> deliverOnMainQueue).start(next: { hasOngoingCall in - if let strongSelf = self { - if hasOngoingCall { - strongSelf.present(standardTextAlertController(theme: AlertControllerTheme(presentationTheme: strongSelf.presentationData.theme), title: strongSelf.presentationData.strings.Call_CallInProgressTitle, text: strongSelf.presentationData.strings.Call_RecordingDisabledMessage, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: { - })]), in: .window(.root)) - } else { - if isVideo { - strongSelf.requestVideoRecorder() - } else { - strongSelf.requestAudioRecorder(beginWithTone: false) - } - } - } - }) - } + guard let strongSelf = self else { + return } - if let strongSelf = self { - DeviceAccess.authorizeAccess(to: .microphone(isVideo ? .video : .audio), presentationData: strongSelf.presentationData, present: { c, a in - self?.present(c, in: .window(.root), with: a) - }, openSettings: { - self?.account.telegramApplicationContext.applicationBindings.openSettings() - }, { granted in - if granted { - if isVideo, let strongSelf = self { - DeviceAccess.authorizeAccess(to: .camera, presentationData: strongSelf.presentationData, present: { c, a in - self?.present(c, in: .window(.root), with: a) - }, openSettings: { - self?.account.telegramApplicationContext.applicationBindings.openSettings() - }, { granted in - if granted { - begin() - } - }) + let requestId = strongSelf.beginMediaRecordingRequestId + let begin: () -> Void = { + guard let strongSelf = self, strongSelf.beginMediaRecordingRequestId == requestId else { + return + } + let hasOngoingCall: Signal + if let signal = strongSelf.account.telegramApplicationContext.hasOngoingCall { + hasOngoingCall = signal + } else { + hasOngoingCall = .single(false) + } + let _ = (hasOngoingCall + |> deliverOnMainQueue).start(next: { hasOngoingCall in + guard let strongSelf = self, strongSelf.beginMediaRecordingRequestId == requestId else { + return + } + if hasOngoingCall { + strongSelf.present(standardTextAlertController(theme: AlertControllerTheme(presentationTheme: strongSelf.presentationData.theme), title: strongSelf.presentationData.strings.Call_CallInProgressTitle, text: strongSelf.presentationData.strings.Call_RecordingDisabledMessage, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: { + })]), in: .window(.root)) + } else { + if isVideo { + strongSelf.requestVideoRecorder() } else { - begin() + strongSelf.requestAudioRecorder(beginWithTone: false) } } }) } + DeviceAccess.authorizeAccess(to: .microphone(isVideo ? .video : .audio), presentationData: strongSelf.presentationData, present: { c, a in + self?.present(c, in: .window(.root), with: a) + }, openSettings: { + self?.account.telegramApplicationContext.applicationBindings.openSettings() + }, { granted in + guard let strongSelf = self, granted else { + return + } + if isVideo { + DeviceAccess.authorizeAccess(to: .camera, presentationData: strongSelf.presentationData, present: { c, a in + self?.present(c, in: .window(.root), with: a) + }, openSettings: { + self?.account.telegramApplicationContext.applicationBindings.openSettings() + }, { granted in + if granted { + begin() + } + }) + } else { + begin() + } + }) }, finishMediaRecording: { [weak self] action in - self?.dismissMediaRecorder(action) + guard let strongSelf = self else { + return + } + strongSelf.beginMediaRecordingRequestId += 1 + strongSelf.dismissMediaRecorder(action) }, stopMediaRecording: { [weak self] in + guard let strongSelf = self else { + return + } + strongSelf.beginMediaRecordingRequestId += 1 self?.stopMediaRecorder() }, lockMediaRecording: { [weak self] in self?.lockMediaRecorder() @@ -4365,7 +4380,7 @@ public final class ChatController: TelegramController, UIViewControllerPreviewin private func openUrlIn(_ url: String) { if let applicationContext = self.account.applicationContext as? TelegramApplicationContext { - let actionSheet = OpenInActionSheetController(postbox: self.account.postbox, applicationContext: applicationContext, theme: self.presentationData.theme, strings: self.presentationData.strings, item: .url(url), openUrl: { [weak self] url in + let actionSheet = OpenInActionSheetController(postbox: self.account.postbox, applicationContext: applicationContext, theme: self.presentationData.theme, strings: self.presentationData.strings, item: .url(url: url), openUrl: { [weak self] url in if let strongSelf = self, let applicationContext = strongSelf.account.applicationContext as? TelegramApplicationContext, let navigationController = strongSelf.navigationController as? NavigationController { openExternalUrl(account: strongSelf.account, url: url, presentationData: strongSelf.presentationData, applicationContext: applicationContext, navigationController: navigationController, dismissInput: { self?.chatDisplayNode.dismissInput() diff --git a/TelegramUI/ChatItemGalleryFooterContentNode.swift b/TelegramUI/ChatItemGalleryFooterContentNode.swift index 9497571774..3f57dd2d55 100644 --- a/TelegramUI/ChatItemGalleryFooterContentNode.swift +++ b/TelegramUI/ChatItemGalleryFooterContentNode.swift @@ -283,13 +283,14 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode { override func updateLayout(width: CGFloat, leftInset: CGFloat, rightInset: CGFloat, bottomInset: CGFloat, contentInset: CGFloat, transition: ContainedViewLayoutTransition) -> CGFloat { var panelHeight: CGFloat = 44.0 + bottomInset panelHeight += contentInset + var textFrame = CGRect() if !self.textNode.isHidden { let sideInset: CGFloat = 8.0 + leftInset let topInset: CGFloat = 8.0 let textBottomInset: CGFloat = 8.0 let textSize = self.textNode.measure(CGSize(width: width - sideInset * 2.0, height: CGFloat.greatestFiniteMagnitude)) panelHeight += textSize.height + topInset + textBottomInset - self.textNode.frame = CGRect(origin: CGPoint(x: sideInset, y: topInset), size: textSize) + textFrame = CGRect(origin: CGPoint(x: sideInset, y: topInset), size: textSize) } if let scrubberView = self.scrubberView { @@ -297,10 +298,13 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode { let topInset: CGFloat = 8.0 let bottomInset: CGFloat = 8.0 panelHeight += 34.0 + topInset + bottomInset + textFrame.origin.y += 34.0 + topInset + bottomInset scrubberView.frame = CGRect(origin: CGPoint(x: sideInset, y: topInset), size: CGSize(width: width - sideInset * 2.0, height: 34.0)) } + self.textNode.frame = textFrame + self.actionButton.frame = CGRect(origin: CGPoint(x: leftInset, y: panelHeight - bottomInset - 44.0), size: CGSize(width: 44.0, height: 44.0)) self.deleteButton.frame = CGRect(origin: CGPoint(x: width - 44.0 - rightInset, y: panelHeight - bottomInset - 44.0), size: CGSize(width: 44.0, height: 44.0)) diff --git a/TelegramUI/ChatListItem.swift b/TelegramUI/ChatListItem.swift index 999da00eba..c3c0b60de5 100644 --- a/TelegramUI/ChatListItem.swift +++ b/TelegramUI/ChatListItem.swift @@ -139,15 +139,15 @@ private let textFont = Font.regular(15.0) private let dateFont = Font.regular(14.0) private let badgeFont = Font.regular(14.0) -private let pinIcon = ItemListRevealOptionIcon.animation("anim_pin", keysToColor: nil) -private let unpinIcon = ItemListRevealOptionIcon.animation("anim_unpin", keysToColor: ["un Outlines.Group 1.Stroke 1"]) -private let muteIcon = ItemListRevealOptionIcon.animation("anim_mute", keysToColor: ["un Outlines.Group 1.Stroke 1"]) -private let unmuteIcon = ItemListRevealOptionIcon.animation("anim_unmute", keysToColor: nil) -private let deleteIcon = ItemListRevealOptionIcon.animation("anim_delete", keysToColor: nil) -private let groupIcon = ItemListRevealOptionIcon.animation("anim_group", keysToColor: nil) -private let ungroupIcon = ItemListRevealOptionIcon.animation("anim_ungroup", keysToColor: ["un Outlines.Group 1.Stroke 1"]) -private let readIcon = ItemListRevealOptionIcon.animation("anim_read", keysToColor: nil) -private let unreadIcon = ItemListRevealOptionIcon.animation("anim_unread", keysToColor: ["Oval.Oval.Stroke 1"]) +private let pinIcon = ItemListRevealOptionIcon.animation(animation: "anim_pin", keysToColor: nil) +private let unpinIcon = ItemListRevealOptionIcon.animation(animation: "anim_unpin", keysToColor: ["un Outlines.Group 1.Stroke 1"]) +private let muteIcon = ItemListRevealOptionIcon.animation(animation: "anim_mute", keysToColor: ["un Outlines.Group 1.Stroke 1"]) +private let unmuteIcon = ItemListRevealOptionIcon.animation(animation: "anim_unmute", keysToColor: nil) +private let deleteIcon = ItemListRevealOptionIcon.animation(animation: "anim_delete", keysToColor: nil) +private let groupIcon = ItemListRevealOptionIcon.animation(animation: "anim_group", keysToColor: nil) +private let ungroupIcon = ItemListRevealOptionIcon.animation(animation: "anim_ungroup", keysToColor: ["un Outlines.Group 1.Stroke 1"]) +private let readIcon = ItemListRevealOptionIcon.animation(animation: "anim_read", keysToColor: nil) +private let unreadIcon = ItemListRevealOptionIcon.animation(animation: "anim_unread", keysToColor: ["Oval.Oval.Stroke 1"]) private enum RevealOptionKey: Int32 { case pin diff --git a/TelegramUI/ChatTextInputPanelNode.swift b/TelegramUI/ChatTextInputPanelNode.swift index 171c85b748..9bf0dbd26f 100644 --- a/TelegramUI/ChatTextInputPanelNode.swift +++ b/TelegramUI/ChatTextInputPanelNode.swift @@ -304,9 +304,13 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate { } } self.actionButtons.micButton.endRecording = { [weak self] sendMedia in - if let strongSelf = self, let interfaceState = strongSelf.presentationInterfaceState, let interfaceInteraction = strongSelf.interfaceInteraction, let _ = interfaceState.inputTextPanelState.mediaRecordingState { - if sendMedia { - interfaceInteraction.finishMediaRecording(.send) + if let strongSelf = self, let interfaceState = strongSelf.presentationInterfaceState, let interfaceInteraction = strongSelf.interfaceInteraction { + if let _ = interfaceState.inputTextPanelState.mediaRecordingState { + if sendMedia { + interfaceInteraction.finishMediaRecording(.send) + } else { + interfaceInteraction.finishMediaRecording(.dismiss) + } } else { interfaceInteraction.finishMediaRecording(.dismiss) } diff --git a/TelegramUI/CheckDeviceAccess.swift b/TelegramUI/CheckDeviceAccess.swift index 965b16adfe..c016ea3046 100644 --- a/TelegramUI/CheckDeviceAccess.swift +++ b/TelegramUI/CheckDeviceAccess.swift @@ -53,7 +53,17 @@ public final class DeviceAccess { case .camera: let status = PGCamera.cameraAuthorizationStatus() if status == PGCameraAuthorizationStatusNotDetermined { - completion(true) + AVCaptureDevice.requestAccess(for: AVMediaType.video) { response in + Queue.mainQueue().async { + completion(response) + if !response { + let text = presentationData.strings.AccessDenied_Camera + present(standardTextAlertController(theme: AlertControllerTheme(presentationTheme: presentationData.theme), title: presentationData.strings.AccessDenied_Title, text: text, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_NotNow, action: {}), TextAlertAction(type: .genericAction, title: presentationData.strings.AccessDenied_Settings, action: { + openSettings() + })]), nil) + } + } + } } else if status == PGCameraAuthorizationStatusRestricted || status == PGCameraAuthorizationStatusDenied { let text: String if status == PGCameraAuthorizationStatusRestricted { diff --git a/TelegramUI/ItemListRevealOptionsNode.swift b/TelegramUI/ItemListRevealOptionsNode.swift index ee99a18519..e093af40a5 100644 --- a/TelegramUI/ItemListRevealOptionsNode.swift +++ b/TelegramUI/ItemListRevealOptionsNode.swift @@ -5,8 +5,8 @@ import Lottie enum ItemListRevealOptionIcon: Equatable { case none - case image(_ image: UIImage) - case animation(_ animation: String, keysToColor: [String]?) + case image(image: UIImage) + case animation(animation: String, keysToColor: [String]?) public static func ==(lhs: ItemListRevealOptionIcon, rhs: ItemListRevealOptionIcon) -> Bool { switch lhs { diff --git a/TelegramUI/LegacyLocationController.swift b/TelegramUI/LegacyLocationController.swift index 15498b9372..a4e285007c 100644 --- a/TelegramUI/LegacyLocationController.swift +++ b/TelegramUI/LegacyLocationController.swift @@ -229,7 +229,7 @@ func legacyLocationController(message: Message, mapMedia: TelegramMediaMap, acco strongLegacyController.present(ShareController(account: account, subject: .mapMedia(map), externalShare: true), in: .window(.root), with: nil) }) - strongLegacyController.present(OpenInActionSheetController(postbox: account.postbox, applicationContext: account.telegramApplicationContext, theme: presentationData.theme, strings: presentationData.strings, item: .location(map, withDirections: directions), additionalAction: !directions ? shareAction : nil, openUrl: openUrl), in: .window(.root), with: nil) + strongLegacyController.present(OpenInActionSheetController(postbox: account.postbox, applicationContext: account.telegramApplicationContext, theme: presentationData.theme, strings: presentationData.strings, item: .location(location: map, withDirections: directions), additionalAction: !directions ? shareAction : nil, openUrl: openUrl), in: .window(.root), with: nil) } } diff --git a/TelegramUI/MediaPlayer.swift b/TelegramUI/MediaPlayer.swift index 138136b769..acb25c90e3 100644 --- a/TelegramUI/MediaPlayer.swift +++ b/TelegramUI/MediaPlayer.swift @@ -727,11 +727,11 @@ private final class MediaPlayerContext { f?() case .stop: self.stoppedAtEnd = true - self.seek(timestamp: 0.0, action: .pause) + //self.seek(timestamp: 0.0, action: .pause) self.pause(lostAudioSession: false) case let .action(f): self.stoppedAtEnd = true - self.seek(timestamp: 0.0, action: .pause) + //self.seek(timestamp: 0.0, action: .pause) self.pause(lostAudioSession: false) f() case let .loopDisablingSound(f): diff --git a/TelegramUI/OpenInActionSheetController.swift b/TelegramUI/OpenInActionSheetController.swift index 48f4de6b50..5ebc7ca345 100644 --- a/TelegramUI/OpenInActionSheetController.swift +++ b/TelegramUI/OpenInActionSheetController.swift @@ -198,14 +198,14 @@ private final class OpenInAppNode : ASDisplayNode { switch option.application { case .safari: if let image = UIImage(bundleImageName: "Open In/Safari") { - self.iconNode.setSignal(openInAppIcon(postbox: postbox, appIcon: .image(image))) + self.iconNode.setSignal(openInAppIcon(postbox: postbox, appIcon: .image(image: image))) } case .maps: if let image = UIImage(bundleImageName: "Open In/Maps") { - self.iconNode.setSignal(openInAppIcon(postbox: postbox, appIcon: .image(image))) + self.iconNode.setSignal(openInAppIcon(postbox: postbox, appIcon: .image(image: image))) } case let .other(_, identifier, _): - self.iconNode.setSignal(openInAppIcon(postbox: postbox, appIcon: .resource(OpenInAppIconResource(appStoreId: identifier)))) + self.iconNode.setSignal(openInAppIcon(postbox: postbox, appIcon: .resource(resource: OpenInAppIconResource(appStoreId: identifier)))) } self.action = { diff --git a/TelegramUI/OpenInOptions.swift b/TelegramUI/OpenInOptions.swift index a9f33e31a8..dabdff62cf 100644 --- a/TelegramUI/OpenInOptions.swift +++ b/TelegramUI/OpenInOptions.swift @@ -4,8 +4,8 @@ import CoreLocation import MapKit enum OpenInItem { - case url(_ url: String) - case location(_ location: TelegramMediaMap, withDirections: Bool) + case url(url: String) + case location(location: TelegramMediaMap, withDirections: Bool) } enum OpenInApplication { @@ -16,7 +16,7 @@ enum OpenInApplication { enum OpenInAction { case none - case openUrl(_ url: String) + case openUrl(url: String) case openLocation(latitude: Double, longitude: Double, withDirections: Bool) } @@ -58,14 +58,14 @@ private func allOpenInOptions(applicationContext: TelegramApplicationContext, it switch item { case let .url(url): options.append(OpenInOption(application: .safari, action: { - return .openUrl(url) + return .openUrl(url: url) })) options.append(OpenInOption(application: .other(title: "Chrome", identifier: 535886823, scheme: "chrome"), action: { if let url = URL(string: url), var components = URLComponents(url: url, resolvingAgainstBaseURL: true) { components.scheme = components.scheme == "https" ? "googlechromes" : "googlechrome" if let url = components.string { - return .openUrl(url) + return .openUrl(url: url) } } return .none @@ -73,7 +73,7 @@ private func allOpenInOptions(applicationContext: TelegramApplicationContext, it options.append(OpenInOption(application: .other(title: "Firefox", identifier: 989804926, scheme: "firefox"), action: { if let escapedUrl = url.addingPercentEncoding(withAllowedCharacters: .urlQueryValueAllowed) { - return .openUrl("firefox://open-url?url=\(escapedUrl)") + return .openUrl(url: "firefox://open-url?url=\(escapedUrl)") } return .none })) @@ -82,7 +82,7 @@ private func allOpenInOptions(applicationContext: TelegramApplicationContext, it if let url = URL(string: url), var components = URLComponents(url: url, resolvingAgainstBaseURL: true) { components.scheme = components.scheme == "https" ? "opera-https" : "opera-http" if let url = components.string { - return .openUrl(url) + return .openUrl(url: url) } } return .none @@ -90,7 +90,7 @@ private func allOpenInOptions(applicationContext: TelegramApplicationContext, it options.append(OpenInOption(application: .other(title: "Yandex", identifier: 483693909, scheme: "yandexbrowser-open-url"), action: { if let escapedUrl = url.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed) { - return .openUrl("yandexbrowser-open-url://\(escapedUrl)") + return .openUrl(url: "yandexbrowser-open-url://\(escapedUrl)") } return .none })) @@ -102,7 +102,7 @@ private func allOpenInOptions(applicationContext: TelegramApplicationContext, it if let venue = location.venue, let venueId = venue.id, let provider = venue.provider, provider == "foursquare" { options.append(OpenInOption(application: .other(title: "Foursquare", identifier: 306934924, scheme: "foursquare"), action: { - return .openUrl("foursquare://venues/\(venueId)") + return .openUrl(url: "foursquare://venues/\(venueId)") })) } @@ -113,17 +113,17 @@ private func allOpenInOptions(applicationContext: TelegramApplicationContext, it options.append(OpenInOption(application: .other(title: "Google Maps", identifier: 585027354, scheme: "comgooglemaps-x-callback"), action: { let coordinates = "\(lat),\(lon)" if withDirections { - return .openUrl("comgooglemaps-x-callback://?daddr=\(coordinates)&directionsmode=driving&x-success=telegram://?resume=true&x-source=Telegram") + return .openUrl(url: "comgooglemaps-x-callback://?daddr=\(coordinates)&directionsmode=driving&x-success=telegram://?resume=true&x-source=Telegram") } else { - return .openUrl("comgooglemaps-x-callback://?center=\(coordinates)&q=\(coordinates)&x-success=telegram://?resume=true&x-source=Telegram") + return .openUrl(url: "comgooglemaps-x-callback://?center=\(coordinates)&q=\(coordinates)&x-success=telegram://?resume=true&x-source=Telegram") } })) options.append(OpenInOption(application: .other(title: "Yandex.Maps", identifier: 313877526, scheme: "yandexmaps"), action: { if withDirections { - return .openUrl("yandexmaps://build_route_on_map?lat_to=\(lat)&lon_to=\(lon)") + return .openUrl(url: "yandexmaps://build_route_on_map?lat_to=\(lat)&lon_to=\(lon)") } else { - return .openUrl("yandexmaps://maps.yandex.ru/?pt=\(lon),\(lat)&z=16") + return .openUrl(url: "yandexmaps://maps.yandex.ru/?pt=\(lon),\(lat)&z=16") } })) @@ -140,11 +140,11 @@ private func allOpenInOptions(applicationContext: TelegramApplicationContext, it } else { dropoffAddress = "" } - return .openUrl("uber://?client_id=&action=setPickup&pickup=my_location&dropoff[latitude]=\(lat)&dropoff[longitude]=\(lon)&dropoff[nickname]=\(dropoffName)&dropoff[formatted_address]=\(dropoffAddress)") + return .openUrl(url: "uber://?client_id=&action=setPickup&pickup=my_location&dropoff[latitude]=\(lat)&dropoff[longitude]=\(lon)&dropoff[nickname]=\(dropoffName)&dropoff[formatted_address]=\(dropoffAddress)") })) options.append(OpenInOption(application: .other(title: "Lyft", identifier: 529379082, scheme: "lyft"), action: { - return .openUrl("lyft://ridetype?id=lyft&destination[latitude]=\(lat)&destination[longitude]=\(lon)") + return .openUrl(url: "lyft://ridetype?id=lyft&destination[latitude]=\(lat)&destination[longitude]=\(lon)") })) options.append(OpenInOption(application: .other(title: "Citymapper", identifier: 469463298, scheme: "citymapper"), action: { @@ -160,25 +160,25 @@ private func allOpenInOptions(applicationContext: TelegramApplicationContext, it } else { endAddress = "" } - return .openUrl("citymapper://directions?endcoord=\(lat),\(lon)&endname=\(endName)&endaddress=\(endAddress)") + return .openUrl(url: "citymapper://directions?endcoord=\(lat),\(lon)&endname=\(endName)&endaddress=\(endAddress)") })) if withDirections { options.append(OpenInOption(application: .other(title: "Yandex.Navi", identifier: 474500851, scheme: "yandexnavi"), action: { - return .openUrl("yandexnavi://build_route_on_map?lat_to=\(lat)&lon_to=\(lon)") + return .openUrl(url: "yandexnavi://build_route_on_map?lat_to=\(lat)&lon_to=\(lon)") })) } options.append(OpenInOption(application: .other(title: "HERE Maps", identifier: 955837609, scheme: "here-location"), action: { - return .openUrl("here-location://\(lat),\(lon)") + return .openUrl(url: "here-location://\(lat),\(lon)") })) options.append(OpenInOption(application: .other(title: "Waze", identifier: 323229106, scheme: "waze"), action: { let url = "waze://?ll=\(lat),\(lon)" if withDirections { - return .openUrl(url.appending("&navigate=yes")) + return .openUrl(url: url.appending("&navigate=yes")) } else { - return .openUrl(url) + return .openUrl(url: url) } })) } diff --git a/TelegramUI/PhotoResources.swift b/TelegramUI/PhotoResources.swift index 7cda707f48..dd04e9e98b 100644 --- a/TelegramUI/PhotoResources.swift +++ b/TelegramUI/PhotoResources.swift @@ -2491,8 +2491,8 @@ private func drawOpenInAppIconBorder(into c: CGContext, arguments: TransformImag } enum OpenInAppIcon { - case resource(_ resource: TelegramMediaResource) - case image(_ image: UIImage) + case resource(resource: TelegramMediaResource) + case image(image: UIImage) } func openInAppIcon(postbox: Postbox, appIcon: OpenInAppIcon) -> Signal<(TransformImageArguments) -> DrawingContext?, NoError> { diff --git a/TelegramUI/ShareControllerNode.swift b/TelegramUI/ShareControllerNode.swift index 8f689a97f8..aee203ac3b 100644 --- a/TelegramUI/ShareControllerNode.swift +++ b/TelegramUI/ShareControllerNode.swift @@ -154,9 +154,9 @@ final class ShareControllerNode: ViewControllerTracingNode, UIScrollViewDelegate } if search && added { - strongSelf.controllerInteraction!.foundPeers.removeAll(where: { otherPeer in - return peer.id == otherPeer.id - }) + strongSelf.controllerInteraction!.foundPeers = strongSelf.controllerInteraction!.foundPeers.filter { otherPeer in + return peer.id != otherPeer.id + } strongSelf.controllerInteraction!.foundPeers.append(peer) strongSelf.peersContentNode?.updateFoundPeers() } diff --git a/TelegramUI/UniversalVideoCalleryItem.swift b/TelegramUI/UniversalVideoCalleryItem.swift index adc70d8de0..d992bab202 100644 --- a/TelegramUI/UniversalVideoCalleryItem.swift +++ b/TelegramUI/UniversalVideoCalleryItem.swift @@ -238,6 +238,15 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode { self.statusButtonNode.isHidden = true } + var isAnimated = false + var isInstagram = false + if let content = item.content as? NativeVideoContent { + isAnimated = content.fileReference.media.isAnimated + } else if let _ = item.content as? SystemVideoContent { + isInstagram = true + self._title.set(.single(item.strings.Message_Video)) + } + if let videoNode = self.videoNode { videoNode.canAttachContent = false videoNode.removeFromSupernode() @@ -328,15 +337,6 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode { self.zoomableContent = (videoSize, videoNode) - var isAnimated = false - var isInstagram = false - if let content = item.content as? NativeVideoContent { - isAnimated = content.fileReference.media.isAnimated - } else if let _ = item.content as? SystemVideoContent { - isInstagram = true - self._title.set(.single(item.strings.Message_Video)) - } - if !isAnimated && !isInstagram { //self._titleView.set(.single(self.scrubberView)) } @@ -346,9 +346,12 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode { self._rightBarButtonItem.set(.single(rightBarButtonItem)) } - videoNode.playbackCompleted = { + videoNode.playbackCompleted = { [weak videoNode] in Queue.mainQueue().async { item.playbackCompleted() + if !isAnimated { + videoNode?.seek(0.0) + } } }