Varius UI fixes

This commit is contained in:
Ilya Laktyushin 2019-09-23 18:05:19 +03:00
parent b28f49417a
commit 107972b3e9
8 changed files with 35 additions and 18 deletions

View File

@ -1136,6 +1136,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
} }
var online = false var online = false
var animateOnline = false
let peerRevealOptions: [ItemListRevealOption] let peerRevealOptions: [ItemListRevealOption]
let peerLeftRevealOptions: [ItemListRevealOption] let peerLeftRevealOptions: [ItemListRevealOption]
@ -1146,6 +1147,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
if case .online = relativeStatus { if case .online = relativeStatus {
online = true online = true
} }
animateOnline = true
} }
let isPinned = item.index.pinningIndex != nil let isPinned = item.index.pinningIndex != nil
@ -1335,14 +1337,14 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
onlineIcon = PresentationResourcesChatList.recentStatusOnlineIcon(item.presentationData.theme, state: .regular) onlineIcon = PresentationResourcesChatList.recentStatusOnlineIcon(item.presentationData.theme, state: .regular)
} }
strongSelf.onlineNode.setImage(onlineIcon) strongSelf.onlineNode.setImage(onlineIcon)
let _ = dateApply() let _ = dateApply()
let _ = textApply() let _ = textApply()
let _ = authorApply() let _ = authorApply()
let _ = titleApply() let _ = titleApply()
let _ = badgeApply(animateBadges, !isMuted) let _ = badgeApply(animateBadges, !isMuted)
let _ = mentionBadgeApply(animateBadges, true) let _ = mentionBadgeApply(animateBadges, true)
let _ = onlineApply(animateContent) let _ = onlineApply(animateContent && animateOnline)
let contentRect = rawContentRect.offsetBy(dx: editingOffset + leftInset + revealOffset, dy: 0.0) let contentRect = rawContentRect.offsetBy(dx: editingOffset + leftInset + revealOffset, dy: 0.0)

View File

@ -162,6 +162,8 @@ private func collectExternalShareItems(strings: PresentationStrings, postbox: Po
text.append("\n\(strings.MessagePoll_VotedCount(totalVoters))") text.append("\n\(strings.MessagePoll_VotedCount(totalVoters))")
} }
signals.append(.single(.done(.text(text)))) signals.append(.single(.done(.text(text))))
} else if let mediaReference = item.mediaReference, let contact = mediaReference.media as? TelegramMediaContact {
} }
if let url = item.url, let parsedUrl = URL(string: url) { if let url = item.url, let parsedUrl = URL(string: url) {
if signals.isEmpty { if signals.isEmpty {

View File

@ -1671,15 +1671,18 @@ final class SharedApplicationContext {
self.registerForNotifications(replyString: presentationData.strings.Notification_Reply, messagePlaceholderString: presentationData.strings.Conversation_InputTextPlaceholder, hiddenContentString: presentationData.strings.Watch_MessageView_Title, includeNames: displayNames, authorize: authorize, completion: completion) self.registerForNotifications(replyString: presentationData.strings.Notification_Reply, messagePlaceholderString: presentationData.strings.Conversation_InputTextPlaceholder, hiddenContentString: presentationData.strings.Watch_MessageView_Title, includeNames: displayNames, authorize: authorize, completion: completion)
}) })
} }
private func registerForNotifications(replyString: String, messagePlaceholderString: String, hiddenContentString: String, includeNames: Bool, authorize: Bool = true, completion: @escaping (Bool) -> Void = { _ in }) { private func registerForNotifications(replyString: String, messagePlaceholderString: String, hiddenContentString: String, includeNames: Bool, authorize: Bool = true, completion: @escaping (Bool) -> Void = { _ in }) {
if #available(iOS 10.0, *) { if #available(iOS 10.0, *) {
let notificationCenter = UNUserNotificationCenter.current() let notificationCenter = UNUserNotificationCenter.current()
notificationCenter.getNotificationSettings(completionHandler: { settings in notificationCenter.getNotificationSettings(completionHandler: { settings in
switch (settings.authorizationStatus, authorize) { switch (settings.authorizationStatus, authorize) {
case (.authorized, _), (.notDetermined, true): case (.authorized, _), (.notDetermined, true):
notificationCenter.requestAuthorization(options: [.badge, .sound, .alert, .carPlay], completionHandler: { result, _ in var authorizationOptions: UNAuthorizationOptions = [.badge, .sound, .alert, .carPlay]
if #available(iOS 12.0, *) {
authorizationOptions.insert(.providesAppNotificationSettings)
}
notificationCenter.requestAuthorization(options: authorizationOptions, completionHandler: { result, _ in
completion(result) completion(result)
if result { if result {
Queue.mainQueue().async { Queue.mainQueue().async {
@ -1795,6 +1798,11 @@ final class SharedApplicationContext {
}) })
} }
@available(iOS 12.0, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, openSettingsFor notification: UNNotification?) {
}
func application(_ application: UIApplication, handleEventsForBackgroundURLSession identifier: String, completionHandler: @escaping () -> Void) { func application(_ application: UIApplication, handleEventsForBackgroundURLSession identifier: String, completionHandler: @escaping () -> Void) {
Logger.shared.log("App \(self.episodeId)", "handleEventsForBackgroundURLSession \(identifier)") Logger.shared.log("App \(self.episodeId)", "handleEventsForBackgroundURLSession \(identifier)")
completionHandler() completionHandler()

View File

@ -2776,8 +2776,8 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
self?.displayPasteMenu(images) self?.displayPasteMenu(images)
case let .gif(data): case let .gif(data):
self?.enqueueGifData(data) self?.enqueueGifData(data)
case let .sticker(image): case let .sticker(image, isMemoji):
self?.enqueueStickerImage(image) self?.enqueueStickerImage(image, isMemoji: isMemoji)
} }
} }
self.chatDisplayNode.updateTypingActivity = { [weak self] value in self.chatDisplayNode.updateTypingActivity = { [weak self] value in
@ -5666,9 +5666,9 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
})) }))
} }
private func enqueueStickerImage(_ image: UIImage) { private func enqueueStickerImage(_ image: UIImage, isMemoji: Bool) {
let size = image.size.aspectFitted(CGSize(width: 512.0, height: 512.0)) let size = image.size.aspectFitted(CGSize(width: 512.0, height: 512.0))
self.enqueueMediaMessageDisposable.set((convertToWebP(image: image, targetSize: size, quality: 0.85) |> deliverOnMainQueue).start(next: { [weak self] data in self.enqueueMediaMessageDisposable.set((convertToWebP(image: image, targetSize: size, quality: 0.9) |> deliverOnMainQueue).start(next: { [weak self] data in
if let strongSelf = self, !data.isEmpty { if let strongSelf = self, !data.isEmpty {
let resource = LocalFileMediaResource(fileId: arc4random64()) let resource = LocalFileMediaResource(fileId: arc4random64())
strongSelf.context.account.postbox.mediaBox.storeResourceData(resource.id, data: data) strongSelf.context.account.postbox.mediaBox.storeResourceData(resource.id, data: data)

View File

@ -388,7 +388,7 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
} }
} }
} }
}), content: NativeVideoContent(id: .message(item.message.stableId, telegramFile.fileId), fileReference: .message(message: MessageReference(item.message), media: telegramFile), streamVideo: streamVideo ? .earlierStart : .none, enableSound: false, fetchAutomatically: false), priority: .embedded, autoplay: true) }), content: NativeVideoContent(id: .message(item.message.stableId, telegramFile.fileId), fileReference: .message(message: MessageReference(item.message), media: telegramFile), streamVideo: streamVideo ? .conservative : .none, enableSound: false, fetchAutomatically: false), priority: .embedded, autoplay: true)
let previousVideoNode = strongSelf.videoNode let previousVideoNode = strongSelf.videoNode
strongSelf.videoNode = videoNode strongSelf.videoNode = videoNode
strongSelf.insertSubnode(videoNode, belowSubnode: previousVideoNode ?? strongSelf.dateAndStatusNode) strongSelf.insertSubnode(videoNode, belowSubnode: previousVideoNode ?? strongSelf.dateAndStatusNode)

View File

@ -199,7 +199,7 @@ private func textInputBackgroundImage(backgroundColor: UIColor, strokeColor: UIC
enum ChatTextInputPanelPasteData { enum ChatTextInputPanelPasteData {
case images([UIImage]) case images([UIImage])
case gif(Data) case gif(Data)
case sticker(UIImage) case sticker(UIImage, Bool)
} }
class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate { class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
@ -1589,8 +1589,13 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
return false return false
} else { } else {
var isPNG = false var isPNG = false
var isMemoji = false
for item in pasteboard.items { for item in pasteboard.items {
if let image = item[kUTTypePNG as String] as? UIImage { if let image = item["com.apple.png-sticker"] as? UIImage {
images.append(image)
isPNG = true
isMemoji = true
} else eif let image = item[kUTTypePNG as String] as? UIImage {
images.append(image) images.append(image)
isPNG = true isPNG = true
} else if let image = item["com.apple.uikit.image"] as? UIImage { } else if let image = item["com.apple.uikit.image"] as? UIImage {
@ -1609,8 +1614,8 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
return false return false
} }
let aspectRatio = min(image.size.width, image.size.height) / maxSide let aspectRatio = min(image.size.width, image.size.height) / maxSide
if imageHasTransparency(cgImage), aspectRatio > 0.85 { if isMemoji || (imageHasTransparency(cgImage) && aspectRatio > 0.85) {
self.paste(.sticker(image)) self.paste(.sticker(image, isMemoji))
return false return false
} }
} }

View File

@ -8,7 +8,7 @@ import WebPImage
import WebP import WebP
#endif #endif
private func scaleImage(_ image: UIImage, dimensions: CGSize) -> UIImage? { private func scaleImage(_ image: UIImage, size: CGSize, boundiingSize: CGSize) -> UIImage? {
if #available(iOSApplicationExtension 10.0, iOS 10.0, *) { if #available(iOSApplicationExtension 10.0, iOS 10.0, *) {
let format = UIGraphicsImageRendererFormat() let format = UIGraphicsImageRendererFormat()
format.scale = 1.0 format.scale = 1.0
@ -21,7 +21,7 @@ private func scaleImage(_ image: UIImage, dimensions: CGSize) -> UIImage? {
} }
} }
func convertToWebP(image: UIImage, targetSize: CGSize?, quality: CGFloat) -> Signal<Data, NoError> { func convertToWebP(image: UIImage, targetSize: CGSize?, targetBoundingSize: CGSize?, quality: CGFloat) -> Signal<Data, NoError> {
var image = image var image = image
if let targetSize = targetSize, let scaledImage = scaleImage(image, dimensions: targetSize) { if let targetSize = targetSize, let scaledImage = scaleImage(image, dimensions: targetSize) {
image = scaledImage image = scaledImage

View File

@ -613,9 +613,9 @@ final class ListMessageFileItemNode: ListMessageNode {
} }
let statusSize = CGSize(width: 28.0, height: 28.0) let statusSize = CGSize(width: 28.0, height: 28.0)
transition.updateFrame(node: strongSelf.statusNode, frame: CGRect(origin: CGPoint(x: params.width - params.rightInset - rightInset - statusSize.width, y: floor((nodeLayout.contentSize.height - statusSize.height) / 2.0)), size: statusSize)) transition.updateFrame(node: strongSelf.statusNode, frame: CGRect(origin: CGPoint(x: params.width - params.rightInset - rightInset - statusSize.width + leftOffset, y: floor((nodeLayout.contentSize.height - statusSize.height) / 2.0)), size: statusSize))
strongSelf.statusButtonNode.frame = CGRect(origin: CGPoint(x: params.width - params.rightInset - rightInset - 40.0, y: 0.0), size: CGSize(width: 40.0, height: nodeLayout.contentSize.height)) strongSelf.statusButtonNode.frame = CGRect(origin: CGPoint(x: params.width - params.rightInset - rightInset - 40.0 + leftOffset, y: 0.0), size: CGSize(width: 40.0, height: nodeLayout.contentSize.height))
if let updatedStatusSignal = updatedStatusSignal { if let updatedStatusSignal = updatedStatusSignal {
strongSelf.statusDisposable.set((updatedStatusSignal strongSelf.statusDisposable.set((updatedStatusSignal