Various fixes

This commit is contained in:
Ilya Laktyushin 2024-10-14 21:38:35 +04:00
parent 25251fc9d4
commit 4f255424e5
5 changed files with 36 additions and 29 deletions

View File

@ -1708,11 +1708,10 @@ let setupFontFunctions = """
"""
private let videoSource = """
document.addEventListener('DOMContentLoaded', () => {
function tgBrowserDisableWebkitEnterFullscreen(videoElement) {
if (videoElement && videoElement.webkitEnterFullscreen) {
Object.defineProperty(videoElement, 'webkitEnterFullscreen', {
value: undefined
});
videoElement.setAttribute('playsinline', '');
}
}
@ -1747,6 +1746,7 @@ _tgbrowser_observer.observe(document.body, {
function tgBrowserDisconnectObserver() {
_tgbrowser_observer.disconnect();
}
});
"""
let setupTouchObservers =

View File

@ -100,7 +100,7 @@ public final class DeviceAccess {
public static func isCameraAccessAuthorized() -> Bool {
return AVCaptureDevice.authorizationStatus(for: .video) == .authorized
}
public static func authorizationStatus(applicationInForeground: Signal<Bool, NoError>? = nil, siriAuthorization: (() -> AccessType)? = nil, subject: DeviceAccessSubject) -> Signal<AccessType, NoError> {
switch subject {
case .notifications:

View File

@ -309,13 +309,16 @@ public func galleryItemForEntry(
} else {
if let fileName = file.fileName, (fileName as NSString).pathExtension.lowercased() == "json" {
return ChatAnimationGalleryItem(context: context, presentationData: presentationData, message: message, location: location)
}
else if file.mimeType.hasPrefix("image/") && file.mimeType != "image/gif" {
} else if file.mimeType.hasPrefix("image/") && file.mimeType != "image/gif" {
var pixelsCount: Int = 0
if let dimensions = file.dimensions {
pixelsCount = Int(dimensions.width) * Int(dimensions.height)
}
if pixelsCount < 10000 * 10000 {
var fileSize: Int64 = 0
if let size = file.size {
fileSize = size
}
if pixelsCount < 10000 * 10000 && fileSize < 16 * 1024 * 1024 {
return ChatImageGalleryItem(
context: context,
presentationData: presentationData,

View File

@ -1283,24 +1283,22 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
}
}
recognizer.highlight = { [weak self] point in
if let strongSelf = self {
if strongSelf.selectionNode == nil {
if let replyInfoNode = strongSelf.replyInfoNode {
var translatedPoint: CGPoint?
let convertedNodeFrame = replyInfoNode.view.convert(replyInfoNode.bounds, to: strongSelf.view)
if let point = point, convertedNodeFrame.insetBy(dx: -4.0, dy: -4.0).contains(point) {
translatedPoint = strongSelf.view.convert(point, to: replyInfoNode.view)
}
replyInfoNode.updateTouchesAtPoint(translatedPoint)
if let strongSelf = self, strongSelf.selectionNode == nil {
if let replyInfoNode = strongSelf.replyInfoNode {
var translatedPoint: CGPoint?
let convertedNodeFrame = replyInfoNode.view.convert(replyInfoNode.bounds, to: strongSelf.view)
if let point = point, convertedNodeFrame.insetBy(dx: -4.0, dy: -4.0).contains(point) {
translatedPoint = strongSelf.view.convert(point, to: replyInfoNode.view)
}
if let forwardInfoNode = strongSelf.forwardInfoNode {
var translatedPoint: CGPoint?
let convertedNodeFrame = forwardInfoNode.view.convert(forwardInfoNode.bounds, to: strongSelf.view)
if let point = point, convertedNodeFrame.insetBy(dx: -4.0, dy: -4.0).contains(point) {
translatedPoint = strongSelf.view.convert(point, to: forwardInfoNode.view)
}
forwardInfoNode.updateTouchesAtPoint(translatedPoint)
replyInfoNode.updateTouchesAtPoint(translatedPoint)
}
if let forwardInfoNode = strongSelf.forwardInfoNode {
var translatedPoint: CGPoint?
let convertedNodeFrame = forwardInfoNode.view.convert(forwardInfoNode.bounds, to: strongSelf.view)
if let point = point, convertedNodeFrame.insetBy(dx: -4.0, dy: -4.0).contains(point) {
translatedPoint = strongSelf.view.convert(point, to: forwardInfoNode.view)
}
forwardInfoNode.updateTouchesAtPoint(translatedPoint)
}
for contentNode in strongSelf.contentNodes {
var translatedPoint: CGPoint?
@ -5254,10 +5252,6 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
}
if let selectionNode = self.selectionNode {
// if let replyInfoNode = self.replyInfoNode, replyInfoNode.frame.contains(point) {
// return replyInfoNode.view.hitTest(self.view.convert(point, to: replyInfoNode.view), with: event)
// }
if let result = self.traceSelectionNodes(parent: self, point: point.offsetBy(dx: -42.0, dy: 0.0)) {
return result.view
}

View File

@ -628,10 +628,20 @@ public final class MediaEditor {
case let .asset(asset):
textureSource = Signal { subscriber in
let isVideo = asset.mediaType == .video
let targetSize = isVideo ? CGSize(width: 128.0, height: 128.0) : CGSize(width: 1920.0, height: 1920.0)
let options = PHImageRequestOptions()
options.deliveryMode = isVideo ? .fastFormat : .highQualityFormat
let deliveryMode: PHImageRequestOptionsDeliveryMode
if isVideo {
if #available(iOS 14.0, *), PHPhotoLibrary.authorizationStatus(for: .readWrite) == .limited {
deliveryMode = .highQualityFormat
} else {
deliveryMode = .fastFormat
}
} else {
deliveryMode = .highQualityFormat
}
options.deliveryMode = deliveryMode
options.isNetworkAccessAllowed = true
let requestId = PHImageManager.default().requestImage(