Merge commit '58cc60eaa1fcfa4a489ab345ac84a4b6a146c6b9'

This commit is contained in:
Ali 2020-07-11 23:03:20 +04:00
commit 69f662b17f
8 changed files with 37 additions and 54 deletions

View File

@ -29,6 +29,7 @@
@property (nonatomic, copy) void (^tabsChanged)(void);
@property (nonatomic, copy) bool (^isVideoPlaying)();
@property (nonatomic, copy) void (^controlVideoPlayback)(bool);
@property (nonatomic, copy) void (^controlVideoSeek)(NSTimeInterval);
@property (nonatomic, copy) void (^controlVideoEndTime)(NSTimeInterval);

View File

@ -43,6 +43,8 @@ const CGFloat TGPhotoAvatarPreviewLandscapePanelSize = TGPhotoAvatarPreviewPanel
UIView *_landscapeToolControlView;
UILabel *_coverLabel;
bool _wasPlayingBeforeCropping;
bool _scheduledTransitionIn;
}
@ -80,6 +82,10 @@ const CGFloat TGPhotoAvatarPreviewLandscapePanelSize = TGPhotoAvatarPreviewPanel
if (strongSelf == nil)
return;
if (strongSelf.isVideoPlaying != nil) {
strongSelf->_wasPlayingBeforeCropping = strongSelf.isVideoPlaying();
}
strongSelf.controlVideoPlayback(false);
};
void(^interactionEnded)(void) = ^
@ -91,7 +97,9 @@ const CGFloat TGPhotoAvatarPreviewLandscapePanelSize = TGPhotoAvatarPreviewPanel
if ([strongSelf shouldAutorotate])
[TGViewController attemptAutorotation];
strongSelf.controlVideoPlayback(true);
if (strongSelf->_wasPlayingBeforeCropping) {
strongSelf.controlVideoPlayback(true);
}
};
PGPhotoEditor *photoEditor = self.photoEditor;

View File

@ -1274,6 +1274,12 @@
[strongSelf stopVideoPlayback:false];
}
};
cropController.isVideoPlaying = ^bool{
__strong TGPhotoEditorController *strongSelf = weakSelf;
if (strongSelf == nil)
return false;
return strongSelf->_isPlaying;
};
cropController.togglePlayback = ^{
__strong TGPhotoEditorController *strongSelf = weakSelf;
if (strongSelf == nil || !strongSelf->_item.isVideo)
@ -2902,5 +2908,4 @@
return self.item.originalSize;
}
@end

View File

@ -368,7 +368,7 @@ public func createChannelController(context: AccountContext) -> ViewController {
}
if let timestamp = videoStartTimestamp {
videoStartTimestamp = max(0.0, min(timestamp, result.duration))
videoStartTimestamp = max(0.0, min(timestamp, result.duration - 0.05))
}
var value = stat()

View File

@ -626,7 +626,7 @@ public func createGroupControllerImpl(context: AccountContext, peerIds: [PeerId]
}
if let timestamp = videoStartTimestamp {
videoStartTimestamp = max(0.0, min(timestamp, result.duration))
videoStartTimestamp = max(0.0, min(timestamp, result.duration - 0.05))
}
var value = stat()

View File

@ -445,7 +445,7 @@ final class PeerInfoAvatarListContainerNode: ASDisplayNode {
playerPosition = playerStatus.timestamp
}
if let videoStartTimestamp = videoStartTimestamp {
if let videoStartTimestamp = videoStartTimestamp, false {
playerPosition -= videoStartTimestamp
if playerPosition < 0.0 {
playerPosition = playerStatus.duration + playerPosition
@ -1069,22 +1069,7 @@ final class PeerInfoAvatarTransformContainerNode: ASDisplayNode {
self.tapped?()
}
}
func reattachVideoNode() {
if let videoNode = self.videoNode {
let maskPath = UIBezierPath(ovalIn: CGRect(origin: CGPoint(), size: self.avatarNode.frame.size))
let shape = CAShapeLayer()
shape.path = maskPath.cgPath
videoNode.layer.mask = shape
videoNode.transform = CATransform3DIdentity
videoNode.updateLayout(size: self.avatarNode.frame.size, transition: .immediate)
videoNode.frame = self.avatarNode.frame
self.addSubnode(videoNode)
}
}
func updateTransitionFraction(_ fraction: CGFloat, transition: ContainedViewLayoutTransition) {
if let videoNode = self.videoNode {
if case .immediate = transition, fraction == 1.0 {
@ -1212,11 +1197,6 @@ final class PeerInfoAvatarTransformContainerNode: ASDisplayNode {
let update = {
videoNode.canAttachContent = !self.isExpanded && self.canAttachVideo
if videoNode.canAttachContent {
// if let videoStartTimestamp = self.videoStartTimestamp {
// videoNode.seek(videoStartTimestamp)
// } else {
// videoNode.seek(0.0)
// }
videoNode.play()
}
}
@ -2292,6 +2272,7 @@ final class PeerInfoHeaderNode: ASDisplayNode {
private(set) var isAvatarExpanded: Bool
private(set) var twoLineInfo = false
var skipCollapseCompletion = false
var ignoreCollapse = false
let avatarListNode: PeerInfoAvatarListNode
@ -2842,7 +2823,7 @@ final class PeerInfoHeaderNode: ASDisplayNode {
}
self.avatarListNode.listContainerNode.update(size: expandedAvatarListSize, peer: peer, isExpanded: self.isAvatarExpanded, transition: transition)
if self.avatarListNode.listContainerNode.isCollapsing {
if self.avatarListNode.listContainerNode.isCollapsing && !self.ignoreCollapse {
self.avatarListNode.avatarContainerNode.canAttachVideo = false
}

View File

@ -3990,13 +3990,11 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
}
if self.headerNode.isAvatarExpanded {
self.headerNode.ignoreCollapse = true
self.headerNode.updateIsAvatarExpanded(false, transition: .immediate)
self.updateNavigationExpansionPresentation(isExpanded: false, animated: true)
}
if let (layout, navigationHeight) = self.validLayout {
self.scrollNode.view.setContentOffset(CGPoint(), animated: false)
self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: .immediate, additive: false)
}
self.scrollNode.view.setContentOffset(CGPoint(), animated: false)
let resource = LocalFileMediaResource(fileId: arc4random64())
self.context.account.postbox.mediaBox.storeResourceData(resource.id, data: data)
@ -4006,6 +4004,7 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
if let (layout, navigationHeight) = self.validLayout {
self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: .immediate, additive: false)
}
self.headerNode.ignoreCollapse = false
let postbox = self.context.account.postbox
let signal = self.isSettings ? updateAccountPhoto(account: self.context.account, resource: resource, videoResource: nil, videoStartTimestamp: nil, mapResourceToAvatarSizes: { resource, representations in
@ -4036,13 +4035,11 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
}
if self.headerNode.isAvatarExpanded {
self.headerNode.ignoreCollapse = true
self.headerNode.updateIsAvatarExpanded(false, transition: .immediate)
self.updateNavigationExpansionPresentation(isExpanded: false, animated: true)
}
if let (layout, navigationHeight) = self.validLayout {
self.scrollNode.view.setContentOffset(CGPoint(), animated: false)
self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: .immediate, additive: false)
}
self.scrollNode.view.setContentOffset(CGPoint(), animated: false)
let photoResource = LocalFileMediaResource(fileId: arc4random64())
self.context.account.postbox.mediaBox.storeResourceData(photoResource.id, data: data)
@ -4052,6 +4049,7 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
if let (layout, navigationHeight) = self.validLayout {
self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: .immediate, additive: false)
}
self.headerNode.ignoreCollapse = false
var videoStartTimestamp: Double? = nil
if let adjustments = adjustments, adjustments.videoStartValue > 0.0 {
@ -4083,7 +4081,7 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
}
if let timestamp = videoStartTimestamp {
videoStartTimestamp = max(0.0, min(timestamp, result.duration))
videoStartTimestamp = max(0.0, min(timestamp, result.duration - 0.05))
}
var value = stat()
@ -4155,6 +4153,12 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
return
}
var currentIsVideo = false
let item = self.headerNode.avatarListNode.listContainerNode.currentItemNode?.item
if let item = item, case let .image(image) = item {
currentIsVideo = !image.2.isEmpty
}
let peerId = self.peerId
let _ = (self.context.account.postbox.transaction { transaction -> (Peer?, SearchBotsConfiguration) in
return (transaction.getPeer(peerId), currentSearchBotsConfiguration(transaction: transaction))
@ -4184,7 +4188,7 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
hasPhotos = true
}
let mixin = TGMediaAvatarMenuMixin(context: legacyController.context, parentController: emptyController, hasSearchButton: true, hasDeleteButton: hasPhotos && hasRemove, hasViewButton: false, personalPhoto: strongSelf.isSettings, isVideo: false, saveEditedPhotos: false, saveCapturedMedia: false, signup: false)!
let mixin = TGMediaAvatarMenuMixin(context: legacyController.context, parentController: emptyController, hasSearchButton: true, hasDeleteButton: hasPhotos && hasRemove, hasViewButton: false, personalPhoto: strongSelf.isSettings, isVideo: currentIsVideo, saveEditedPhotos: false, saveCapturedMedia: false, signup: false)!
let _ = strongSelf.currentAvatarMixin.swap(mixin)
mixin.requestSearchController = { [weak self] assetsController in
guard let strongSelf = self else {
@ -5803,23 +5807,7 @@ public final class PeerInfoScreen: ViewController {
super.displayNodeDidLoad()
}
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.controllerNode.canAttachVideo = false
}
override public func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
self.controllerNode.canAttachVideo = true
if let (layout, navigationHeight) = self.validLayout {
self.controllerNode.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: .immediate)
}
}
override public func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) {
super.containerLayoutUpdated(layout, transition: transition)

View File

@ -448,7 +448,7 @@ public func resolveUrlImpl(account: Account, url: String) -> Signal<ResolvedUrl,
}
}
}
let baseTelegraPhPaths = ["telegra.ph/", "t.me/iv?"]
let baseTelegraPhPaths = ["telegra.ph/", "te.legra.ph/", "graph.org/", "t.me/iv?"]
for basePath in baseTelegraPhPaths {
for scheme in schemes {
let basePrefix = scheme + basePath