mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Don't ignore default browser setting if passcode is set
This commit is contained in:
@@ -16702,101 +16702,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
self.chatDisplayNode.dismissInput()
|
||||
self.present(actionSheet, in: .window(.root))
|
||||
}
|
||||
|
||||
func avatarPreviewingController(from sourceView: UIView) -> (UIViewController, CGRect)? {
|
||||
guard let layout = self.validLayout else {
|
||||
return nil
|
||||
}
|
||||
guard let buttonView = (self.chatInfoNavigationButton?.buttonItem.customDisplayNode as? ChatAvatarNavigationNode)?.avatarNode.view else {
|
||||
return nil
|
||||
}
|
||||
if let peer = self.presentationInterfaceState.renderedPeer?.chatMainPeer, peer.smallProfileImage != nil {
|
||||
let galleryController = AvatarGalleryController(context: self.context, peer: peer, remoteEntries: nil, replaceRootController: { controller, ready in
|
||||
}, synchronousLoad: true)
|
||||
galleryController.setHintWillBePresentedInPreviewingContext(true)
|
||||
galleryController.containerLayoutUpdated(ContainerViewLayout(size: CGSize(width: self.view.bounds.size.width, height: self.view.bounds.size.height), metrics: LayoutMetrics(), deviceMetrics: layout.deviceMetrics, intrinsicInsets: UIEdgeInsets(), safeInsets: UIEdgeInsets(), additionalInsets: UIEdgeInsets(), statusBarHeight: nil, inputHeight: nil, inputHeightIsInteractivellyChanging: false, inVoiceOver: false), transition: .immediate)
|
||||
return (galleryController, buttonView.convert(buttonView.bounds, to: sourceView))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func previewingController(from sourceView: UIView, for location: CGPoint) -> (UIViewController, CGRect)? {
|
||||
guard let layout = self.validLayout, case .phone = layout.deviceMetrics.type, let view = self.chatDisplayNode.view.hitTest(location, with: nil), view.isDescendant(of: self.chatDisplayNode.historyNode.view) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
let historyPoint = sourceView.convert(location, to: self.chatDisplayNode.historyNode.view)
|
||||
var result: (Message, ChatMessagePeekPreviewContent)?
|
||||
self.chatDisplayNode.historyNode.forEachItemNode { itemNode in
|
||||
if let itemNode = itemNode as? ChatMessageItemView {
|
||||
if itemNode.frame.contains(historyPoint) {
|
||||
if let value = itemNode.peekPreviewContent(at: self.chatDisplayNode.historyNode.view.convert(historyPoint, to: itemNode.view)) {
|
||||
result = value
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if let (message, content) = result {
|
||||
switch content {
|
||||
case let .media(media):
|
||||
var selectedTransitionNode: (ASDisplayNode, CGRect, () -> (UIView?, UIView?))?
|
||||
self.chatDisplayNode.historyNode.forEachItemNode { itemNode in
|
||||
if let itemNode = itemNode as? ChatMessageItemView {
|
||||
if let result = itemNode.transitionNode(id: message.id, media: media) {
|
||||
selectedTransitionNode = result
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let selectedTransitionNode = selectedTransitionNode {
|
||||
if let previewData = chatMessagePreviewControllerData(context: self.context, chatLocation: self.chatLocation, chatLocationContextHolder: self.chatLocationContextHolder, message: message, standalone: false, reverseMessageGalleryOrder: false, navigationController: self.effectiveNavigationController) {
|
||||
switch previewData {
|
||||
case let .gallery(gallery):
|
||||
gallery.setHintWillBePresentedInPreviewingContext(true)
|
||||
let rect = selectedTransitionNode.0.view.convert(selectedTransitionNode.0.bounds, to: sourceView)
|
||||
let sourceRect = rect.insetBy(dx: -2.0, dy: -2.0)
|
||||
gallery.containerLayoutUpdated(ContainerViewLayout(size: CGSize(width: self.view.bounds.size.width, height: self.view.bounds.size.height), metrics: LayoutMetrics(), deviceMetrics: layout.deviceMetrics, intrinsicInsets: UIEdgeInsets(), safeInsets: UIEdgeInsets(), additionalInsets: UIEdgeInsets(), statusBarHeight: nil, inputHeight: nil, inputHeightIsInteractivellyChanging: false, inVoiceOver: false), transition: .immediate)
|
||||
return (gallery, sourceRect)
|
||||
case .instantPage:
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
case let .url(node, rect, string, concealed):
|
||||
var parsedUrlValue: URL?
|
||||
if let parsed = URL(string: string) {
|
||||
parsedUrlValue = parsed
|
||||
} else if let encoded = (string as NSString).addingPercentEncoding(withAllowedCharacters: .urlQueryValueAllowed), let parsed = URL(string: encoded) {
|
||||
parsedUrlValue = parsed
|
||||
}
|
||||
|
||||
if let parsedUrlValue = parsedUrlValue {
|
||||
if concealed, (parsedUrlValue.scheme == "http" || parsedUrlValue.scheme == "https"), !isConcealedUrlWhitelisted(parsedUrlValue) {
|
||||
return nil
|
||||
}
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
|
||||
let targetRect = node.view.convert(rect, to: sourceView)
|
||||
let sourceRect = CGRect(origin: CGPoint(x: floor(targetRect.midX), y: floor(targetRect.midY)), size: CGSize(width: 1.0, height: 1.0))
|
||||
if let parsedUrl = parsedUrlValue {
|
||||
if parsedUrl.scheme == "http" || parsedUrl.scheme == "https" {
|
||||
if #available(iOSApplicationExtension 9.0, iOS 9.0, *) {
|
||||
let controller = SFSafariViewController(url: parsedUrl)
|
||||
if #available(iOSApplicationExtension 10.0, iOS 10.0, *) {
|
||||
controller.preferredBarTintColor = self.presentationData.theme.rootController.navigationBar.opaqueBackgroundColor
|
||||
controller.preferredControlTintColor = self.presentationData.theme.rootController.navigationBar.accentTextColor
|
||||
}
|
||||
return (controller, sourceRect)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
private func presentBanMessageOptions(accountPeerId: PeerId, author: Peer, messageIds: Set<MessageId>, options: ChatAvailableMessageActionOptions) {
|
||||
guard let peerId = self.chatLocation.peerId else {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user