diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index 3216aeb9bb..c39e84136e 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -253,6 +253,9 @@ "PUSH_CHAT_REACT_INVOICE" = "%2$@|%1$@ %3$@ to your invoice"; "PUSH_CHAT_REACT_GIF" = "%2$@|%1$@ %3$@ to your GIF"; +"PUSH_MESSAGE_SUGGEST_USERPIC" = "%1$@ suggested you new profile photo"; + + "PUSH_REMINDER_TITLE" = "🗓 Reminder"; "PUSH_SENDER_YOU" = "📅 You"; diff --git a/submodules/DrawingUI/Sources/DrawingMetalView.swift b/submodules/DrawingUI/Sources/DrawingMetalView.swift index 835af639d7..cbbe56ea13 100644 --- a/submodules/DrawingUI/Sources/DrawingMetalView.swift +++ b/submodules/DrawingUI/Sources/DrawingMetalView.swift @@ -7,7 +7,7 @@ import SwiftSignalKit import AppBundle final class DrawingMetalView: MTKView { - private let size: CGSize + let size: CGSize private let commandQueue: MTLCommandQueue fileprivate let library: MTLLibrary @@ -21,11 +21,6 @@ final class DrawingMetalView: MTKView { private var markerBrush: Brush? init?(size: CGSize) { - var size = size - if Int(size.width) % 16 != 0 { - size.width = ceil(size.width / 16.0) * 16.0 - } - let mainBundle = Bundle(for: DrawingView.self) guard let path = mainBundle.path(forResource: "DrawingUIBundle", ofType: "bundle") else { return nil @@ -55,6 +50,8 @@ final class DrawingMetalView: MTKView { self.isOpaque = false self.contentScaleFactor = 1.0 self.isPaused = true + self.preferredFramesPerSecond = 60 + self.presentsWithTransaction = true self.setup() } @@ -179,10 +176,12 @@ final class DrawingMetalView: MTKView { commandEncoder?.drawPrimitives(type: .triangleStrip, vertexStart: 0, vertexCount: 4) commandEncoder?.endEncoding() - if let drawable = self.currentDrawable { - commandBuffer?.present(drawable) - } commandBuffer?.commit() + commandBuffer?.waitUntilScheduled() + self.currentDrawable?.present() +// if let drawable = self.currentDrawable { +// commandBuffer?.present(drawable) +// } } func clear() { diff --git a/submodules/DrawingUI/Sources/DrawingView.swift b/submodules/DrawingUI/Sources/DrawingView.swift index 60190e9ef5..203b90aebb 100644 --- a/submodules/DrawingUI/Sources/DrawingView.swift +++ b/submodules/DrawingUI/Sources/DrawingView.swift @@ -798,9 +798,19 @@ public final class DrawingView: UIView, UIGestureRecognizerDelegate, TGPhotoDraw self.toolColor = brushState.color self.toolBrushSize = brushState.size - if self.metalView == nil, let metalView = DrawingMetalView(size: self.imageSize) { + var size = self.imageSize + if Int(size.width) % 16 != 0 { + size.width = ceil(size.width / 16.0) * 16.0 + } + + if self.metalView == nil, let metalView = DrawingMetalView(size: size) { metalView.transform = self.currentDrawingViewContainer.transform - metalView.frame = self.currentDrawingViewContainer.frame + if size.width != self.imageSize.width { + let scaledSize = size.preciseAspectFilled(self.currentDrawingViewContainer.frame.size) + metalView.frame = CGRect(origin: .zero, size: scaledSize) + } else { + metalView.frame = self.currentDrawingViewContainer.frame + } self.insertSubview(metalView, aboveSubview: self.currentDrawingViewContainer) self.metalView = metalView } @@ -958,8 +968,17 @@ public final class DrawingView: UIView, UIGestureRecognizerDelegate, TGPhotoDraw self.drawingGesturePipeline?.transform = CGAffineTransformMakeScale(1.0 / scale, 1.0 / scale) if let metalView = self.metalView { + var size = self.imageSize + if Int(size.width) % 16 != 0 { + size.width = ceil(size.width / 16.0) * 16.0 + } metalView.transform = transform - metalView.frame = self.bounds + if size.width != self.imageSize.width { + let scaledSize = size.preciseAspectFilled(self.currentDrawingViewContainer.frame.size) + metalView.frame = CGRect(origin: .zero, size: scaledSize) + } else { + metalView.frame = self.currentDrawingViewContainer.frame + } } self.brushSizePreviewLayer.position = CGPoint(x: self.bounds.width / 2.0, y: self.bounds.height / 2.0) @@ -978,6 +997,13 @@ public final class DrawingView: UIView, UIGestureRecognizerDelegate, TGPhotoDraw } } +private extension CGSize { + func preciseAspectFilled(_ size: CGSize) -> CGSize { + let scale = max(size.width / max(1.0, self.width), size.height / max(1.0, self.height)) + return CGSize(width: self.width * scale, height: self.height * scale) + } +} + private class DrawingSlice { private static let queue = Queue() diff --git a/submodules/MediaPickerUI/Sources/MediaPickerGridItem.swift b/submodules/MediaPickerUI/Sources/MediaPickerGridItem.swift index 0d0ae20e0b..f3ada8873a 100644 --- a/submodules/MediaPickerUI/Sources/MediaPickerGridItem.swift +++ b/submodules/MediaPickerUI/Sources/MediaPickerGridItem.swift @@ -448,6 +448,7 @@ class SpoilerOverlayNode: ASDisplayNode { override init() { self.blurNode = ASImageNode() self.blurNode.displaysAsynchronously = false + self.blurNode.contentMode = .scaleAspectFill self.dustNode = MediaDustNode() diff --git a/submodules/MediaPickerUI/Sources/MediaPickerScreen.swift b/submodules/MediaPickerUI/Sources/MediaPickerScreen.swift index a466b594b5..d232e7d68f 100644 --- a/submodules/MediaPickerUI/Sources/MediaPickerScreen.swift +++ b/submodules/MediaPickerUI/Sources/MediaPickerScreen.swift @@ -1515,11 +1515,13 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable { let selectionCount = self.selectionCount var hasSpoilers = false + var hasGeneric = false if let selectionContext = self.interaction?.selectionState, let editingContext = self.interaction?.editingState { for case let item as TGMediaEditableItem in selectionContext.selectedItems() { if editingContext.spoiler(for: item) { hasSpoilers = true - break + } else { + hasGeneric = true } } } @@ -1565,7 +1567,7 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable { if !items.isEmpty { items.append(.separator) } - items.append(.action(ContextMenuActionItem(text: hasSpoilers ? strings.Attachment_DisableSpoiler : strings.Attachment_EnableSpoiler, icon: { _ in return nil }, animationName: "anim_spoiler", action: { [weak self] _, f in + items.append(.action(ContextMenuActionItem(text: hasGeneric ? strings.Attachment_EnableSpoiler : strings.Attachment_DisableSpoiler, icon: { _ in return nil }, animationName: "anim_spoiler", action: { [weak self] _, f in f(.default) guard let strongSelf = self else { return @@ -1573,7 +1575,7 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable { if let selectionContext = strongSelf.interaction?.selectionState, let editingContext = strongSelf.interaction?.editingState { for case let item as TGMediaEditableItem in selectionContext.selectedItems() { - editingContext.setSpoiler(!hasSpoilers, for: item) + editingContext.setSpoiler(hasGeneric, for: item) } } }))) diff --git a/submodules/TelegramUI/Sources/ChatMessageInteractiveMediaNode.swift b/submodules/TelegramUI/Sources/ChatMessageInteractiveMediaNode.swift index 4de4199ce4..a23297d89e 100644 --- a/submodules/TelegramUI/Sources/ChatMessageInteractiveMediaNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageInteractiveMediaNode.swift @@ -709,6 +709,7 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio } } + let hasSpoiler = message.attributes.contains(where: { $0 is MediaSpoilerMessageAttribute }) var isExtendedMediaPreview = false var isInlinePlayableVideo = false var isSticker = false @@ -1496,7 +1497,7 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio strongSelf.updateStatus(animated: synchronousLoads) - strongSelf.pinchContainerNode.isPinchGestureEnabled = !isSecretMedia && !isExtendedMediaPreview + strongSelf.pinchContainerNode.isPinchGestureEnabled = !isSecretMedia && !isExtendedMediaPreview && !hasSpoiler } }) })