From 8c209b78bdf46e55c14080a5bd3d51497eb0bb46 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Wed, 12 Feb 2020 02:47:38 +0400 Subject: [PATCH] Various fixes --- Telegram-iOS/en.lproj/Localizable.strings | 2 +- .../ChatItemGalleryFooterContentNode.swift | 7 +++++- .../GalleryUI/Sources/GalleryItemNode.swift | 2 ++ .../GalleryUI/Sources/GalleryPagerNode.swift | 12 ++++++++++ .../Items/UniversalVideoGalleryItem.swift | 20 ++++++++++++---- .../ZoomableContentGalleryItemNode.swift | 4 ++-- .../Sources/PeerReportController.swift | 24 +++++++------------ 7 files changed, 47 insertions(+), 24 deletions(-) diff --git a/Telegram-iOS/en.lproj/Localizable.strings b/Telegram-iOS/en.lproj/Localizable.strings index 363e615909..5cfd6af771 100644 --- a/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram-iOS/en.lproj/Localizable.strings @@ -5317,7 +5317,7 @@ Any member of this group will be able to see messages in the channel."; "PeopleNearby.VisibleUntil" = "visible until %@"; "PeopleNearby.MakeVisibleTitle" = "Make Myself Visible"; -"PeopleNearby.MakeVisibleDescription" = "Users nearby will be able to view your profile and send you messages. This may help you find new friends, but could also attract excessive attention. You can stop sharing your profile and location at any time.\n\nYour phone number will remain hidden."; +"PeopleNearby.MakeVisibleDescription" = "Users nearby will be able to view your profile and send you messages. This may help you find new friends, but could also attract excessive attention. You can stop sharing your profile at any time.\n\nYour phone number will remain hidden."; "PeopleNearby.DiscoverDescription" = "Exchange contact info with people nearby\nand find new friends."; diff --git a/submodules/GalleryUI/Sources/ChatItemGalleryFooterContentNode.swift b/submodules/GalleryUI/Sources/ChatItemGalleryFooterContentNode.swift index df429f52d5..2a31c310a1 100644 --- a/submodules/GalleryUI/Sources/ChatItemGalleryFooterContentNode.swift +++ b/submodules/GalleryUI/Sources/ChatItemGalleryFooterContentNode.swift @@ -168,7 +168,12 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScroll self.dateNode.isHidden = true self.backwardButton.isHidden = true self.forwardButton.isHidden = true - self.playbackControlButton.isHidden = true + if status == .Local { + self.playbackControlButton.isHidden = false + self.playbackControlButton.setImage(playImage, for: []) + } else { + self.playbackControlButton.isHidden = true + } self.statusButtonNode.isHidden = false self.statusNode.isHidden = false diff --git a/submodules/GalleryUI/Sources/GalleryItemNode.swift b/submodules/GalleryUI/Sources/GalleryItemNode.swift index 615bdde364..b2c513654f 100644 --- a/submodules/GalleryUI/Sources/GalleryItemNode.swift +++ b/submodules/GalleryUI/Sources/GalleryItemNode.swift @@ -23,6 +23,8 @@ open class GalleryItemNode: ASDisplayNode { public var toggleControlsVisibility: () -> Void = { } public var goToPreviousItem: () -> Void = { } public var goToNextItem: () -> Void = { } + public var canGoToPreviousItem: () -> Bool = { return false } + public var canGoToNextItem: () -> Bool = { return false } public var dismiss: () -> Void = { } public var beginCustomDismiss: () -> Void = { } public var completeCustomDismiss: () -> Void = { } diff --git a/submodules/GalleryUI/Sources/GalleryPagerNode.swift b/submodules/GalleryUI/Sources/GalleryPagerNode.swift index 125b432cdc..1b2f7e5649 100644 --- a/submodules/GalleryUI/Sources/GalleryPagerNode.swift +++ b/submodules/GalleryUI/Sources/GalleryPagerNode.swift @@ -255,6 +255,18 @@ public final class GalleryPagerNode: ASDisplayNode, UIScrollViewDelegate { } } } + node.canGoToPreviousItem = { [weak self] in + if let strongSelf = self, let index = strongSelf.centralItemIndex, index > 0 { + return true + } + return false + } + node.canGoToNextItem = { [weak self] in + if let strongSelf = self, let index = strongSelf.centralItemIndex, index < strongSelf.items.count - 1 { + return true + } + return false + } node.dismiss = self.dismiss node.beginCustomDismiss = self.beginCustomDismiss node.completeCustomDismiss = self.completeCustomDismiss diff --git a/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift b/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift index dc01efd988..48431dbfea 100644 --- a/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift +++ b/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift @@ -255,6 +255,7 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode { private var _isVisible: Bool? private var initiallyActivated = false private var hideStatusNodeUntilCentrality = false + private var playOnContentOwnership = false private var validLayout: (ContainerViewLayout, CGFloat)? private var didPause = false private var isPaused = true @@ -475,6 +476,12 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode { videoNode.ownsContentNodeUpdated = { [weak self] value in if let strongSelf = self { strongSelf.updateDisplayPlaceholder(!value) + + if strongSelf.playOnContentOwnership { + strongSelf.playOnContentOwnership = false + strongSelf.initiallyActivated = true + strongSelf.videoNode?.playOnceWithSound(playAndRecord: false, actionAtEnd: .stop) + } } } self.videoNode = videoNode @@ -710,7 +717,8 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode { } private func shouldAutoplayOnCentrality() -> Bool { - if let item = self.item, let content = item.content as? NativeVideoContent, !self.initiallyActivated { +// !self.initiallyActivated + if let item = self.item, let content = item.content as? NativeVideoContent { var isLocal = false if let fetchStatus = self.fetchStatus, case .Local = fetchStatus { isLocal = true @@ -743,15 +751,19 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode { self.hideStatusNodeUntilCentrality = false self.statusButtonNode.isHidden = self.hideStatusNodeUntilCentrality || self.statusNodeShouldBeHidden + if videoNode.ownsContentNode { if isAnimated { videoNode.seek(0.0) videoNode.play() - } - else if self.shouldAutoplayOnCentrality() { + } else if self.shouldAutoplayOnCentrality() { self.initiallyActivated = true videoNode.playOnceWithSound(playAndRecord: false, actionAtEnd: .stop) } + } else { + if self.shouldAutoplayOnCentrality() { + self.playOnContentOwnership = true + } } } else { self.dismissOnOrientationChange = false @@ -1283,6 +1295,6 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode { } override func footerContent() -> Signal<(GalleryFooterContentNode?, GalleryOverlayContentNode?), NoError> { - return .single((self.footerContentNode, self.overlayContentNode)) + return .single((self.footerContentNode, nil)) } } diff --git a/submodules/GalleryUI/Sources/ZoomableContentGalleryItemNode.swift b/submodules/GalleryUI/Sources/ZoomableContentGalleryItemNode.swift index a420bcbf20..58550dd126 100644 --- a/submodules/GalleryUI/Sources/ZoomableContentGalleryItemNode.swift +++ b/submodules/GalleryUI/Sources/ZoomableContentGalleryItemNode.swift @@ -91,12 +91,12 @@ open class ZoomableContentGalleryItemNode: GalleryItemNode, UIScrollViewDelegate tapRecognizer.highlight = { [weak self] location in if let strongSelf = self { let transition: ContainedViewLayoutTransition = .animated(duration: 0.07, curve: .easeInOut) - if let location = location, location.x < 44.0 { + if let location = location, location.x < 44.0 && strongSelf.canGoToPreviousItem() { transition.updateAlpha(node: strongSelf.leftFadeNode, alpha: 1.0) } else { transition.updateAlpha(node: strongSelf.leftFadeNode, alpha: 0.0) } - if let location = location, location.x > strongSelf.frame.width - 44.0 { + if let location = location, location.x > strongSelf.frame.width - 44.0 && strongSelf.canGoToNextItem() { transition.updateAlpha(node: strongSelf.rightFadeNode, alpha: 1.0) } else { transition.updateAlpha(node: strongSelf.rightFadeNode, alpha: 0.0) diff --git a/submodules/PeerInfoUI/Sources/PeerReportController.swift b/submodules/PeerInfoUI/Sources/PeerReportController.swift index 5e057cf581..21fb66aeb3 100644 --- a/submodules/PeerInfoUI/Sources/PeerReportController.swift +++ b/submodules/PeerInfoUI/Sources/PeerReportController.swift @@ -18,26 +18,18 @@ public enum PeerReportSubject { case messages([MessageId]) } -private enum PeerReportOption { +public enum PeerReportOption { case spam case violence case copyright - case pornoghraphy + case pornography case childAbuse case other } -public func presentPeerReportOptions(context: AccountContext, parent: ViewController, contextController: ContextController?, subject: PeerReportSubject, completion: @escaping (Bool) -> Void) { +public func presentPeerReportOptions(context: AccountContext, parent: ViewController, contextController: ContextController?, subject: PeerReportSubject, options: [PeerReportOption] = [.spam, .violence, .pornography, .childAbuse, .copyright, .other], completion: @escaping (Bool) -> Void) { if let contextController = contextController { let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let options: [PeerReportOption] = [ - .spam, - .violence, - .pornoghraphy, - .childAbuse, - .copyright, - .other - ] var items: [ContextMenuItem] = [] for option in options { let title: String @@ -47,7 +39,7 @@ public func presentPeerReportOptions(context: AccountContext, parent: ViewContro title = presentationData.strings.ReportPeer_ReasonSpam case .violence: title = presentationData.strings.ReportPeer_ReasonViolence - case .pornoghraphy: + case .pornography: title = presentationData.strings.ReportPeer_ReasonPornography case .childAbuse: title = presentationData.strings.ReportPeer_ReasonChildAbuse @@ -67,7 +59,7 @@ public func presentPeerReportOptions(context: AccountContext, parent: ViewContro reportReason = .spam case .violence: reportReason = .violence - case .pornoghraphy: + case .pornography: reportReason = .porno case .childAbuse: reportReason = .childAbuse @@ -116,7 +108,7 @@ public func peerReportOptionsController(context: AccountContext, subject: PeerRe let options: [PeerReportOption] = [ .spam, .violence, - .pornoghraphy, + .pornography, .childAbuse, .copyright, .other @@ -131,7 +123,7 @@ public func peerReportOptionsController(context: AccountContext, subject: PeerRe title = presentationData.strings.ReportPeer_ReasonSpam case .violence: title = presentationData.strings.ReportPeer_ReasonViolence - case .pornoghraphy: + case .pornography: title = presentationData.strings.ReportPeer_ReasonPornography case .childAbuse: title = presentationData.strings.ReportPeer_ReasonChildAbuse @@ -147,7 +139,7 @@ public func peerReportOptionsController(context: AccountContext, subject: PeerRe reportReason = .spam case .violence: reportReason = .violence - case .pornoghraphy: + case .pornography: reportReason = .porno case .childAbuse: reportReason = .childAbuse