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

View File

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

View File

@ -309,13 +309,16 @@ public func galleryItemForEntry(
} else { } else {
if let fileName = file.fileName, (fileName as NSString).pathExtension.lowercased() == "json" { if let fileName = file.fileName, (fileName as NSString).pathExtension.lowercased() == "json" {
return ChatAnimationGalleryItem(context: context, presentationData: presentationData, message: message, location: location) 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 var pixelsCount: Int = 0
if let dimensions = file.dimensions { if let dimensions = file.dimensions {
pixelsCount = Int(dimensions.width) * Int(dimensions.height) 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( return ChatImageGalleryItem(
context: context, context: context,
presentationData: presentationData, presentationData: presentationData,

View File

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

View File

@ -628,10 +628,20 @@ public final class MediaEditor {
case let .asset(asset): case let .asset(asset):
textureSource = Signal { subscriber in textureSource = Signal { subscriber in
let isVideo = asset.mediaType == .video let isVideo = asset.mediaType == .video
let targetSize = isVideo ? CGSize(width: 128.0, height: 128.0) : CGSize(width: 1920.0, height: 1920.0) let targetSize = isVideo ? CGSize(width: 128.0, height: 128.0) : CGSize(width: 1920.0, height: 1920.0)
let options = PHImageRequestOptions() 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 options.isNetworkAccessAllowed = true
let requestId = PHImageManager.default().requestImage( let requestId = PHImageManager.default().requestImage(