From 99a67640f9570f8ecb343515fd1d21e35bcad2b7 Mon Sep 17 00:00:00 2001 From: Ali <> Date: Tue, 21 Sep 2021 18:48:48 +0300 Subject: [PATCH 1/4] Bump version --- versions.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versions.json b/versions.json index a3127779d2..7fc9f10c3a 100644 --- a/versions.json +++ b/versions.json @@ -1,5 +1,5 @@ { - "app": "8.1", + "app": "8.1.1", "bazel": "4.0.0", "xcode": "12.5.1" } From b90e16d94eac011055cd2eb969b376c20ffca528 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Sun, 26 Sep 2021 10:14:56 +0300 Subject: [PATCH 2/4] Cherry-pick various fixes --- .../Sources/Node/ChatListItem.swift | 2 +- .../Sources/Node/ChatListItemStrings.swift | 10 ++++++- submodules/Display/Source/TextNode.swift | 17 +++++++++-- .../ChatItemGalleryFooterContentNode.swift | 13 ++++++--- .../Sources/ListMessageFileItemNode.swift | 3 ++ ...hannelDiscussionGroupSetupController.swift | 6 ++-- .../Sources/PhoneInputNode.swift | 3 ++ .../Themes/ThemeAccentColorController.swift | 2 +- .../Sources/ShareController.swift | 2 +- .../Sources/VoiceChatController.swift | 29 +++++++++---------- .../Sources/Utils/CanSendMessagesToPeer.swift | 4 ++- .../DefaultDarkPresentationTheme.swift | 5 ++++ .../Sources/MakePresentationTheme.swift | 4 +++ .../Sources/ServiceMessageStrings.swift | 18 ++++++++---- .../Sources/ChatTextInputPanelNode.swift | 8 ++++- .../Sources/PeerInfo/PeerInfoHeaderNode.swift | 18 ++++++++++-- 16 files changed, 105 insertions(+), 39 deletions(-) diff --git a/submodules/ChatListUI/Sources/Node/ChatListItem.swift b/submodules/ChatListUI/Sources/Node/ChatListItem.swift index 1fb071c560..e6664f5767 100644 --- a/submodules/ChatListUI/Sources/Node/ChatListItem.swift +++ b/submodules/ChatListUI/Sources/Node/ChatListItem.swift @@ -774,7 +774,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode { return } if case let .peer(_, peer, _, _, _, _, _, _, promoInfo, _, _, _) = item.content { - if promoInfo == nil, let mainPeer = peer.chatMainPeer { + if promoInfo == nil, let mainPeer = peer.peer { item.interaction.togglePeerSelected(mainPeer) } } diff --git a/submodules/ChatListUI/Sources/Node/ChatListItemStrings.swift b/submodules/ChatListUI/Sources/Node/ChatListItemStrings.swift index 8cf12f0f1a..975abd65a2 100644 --- a/submodules/ChatListUI/Sources/Node/ChatListItemStrings.swift +++ b/submodules/ChatListUI/Sources/Node/ChatListItemStrings.swift @@ -100,7 +100,15 @@ public func chatListItemStrings(strings: PresentationStrings, nameDisplayOrder: textIsReady = true } case .generic: - break + var messageTypes = Set() + for message in messages { + messageTypes.insert(singleMessageType(message: message)) + } + if messageTypes.count == 2 && messageTypes.contains(.photos) && messageTypes.contains(.videos) { + if !messageText.isEmpty { + textIsReady = true + } + } } } diff --git a/submodules/Display/Source/TextNode.swift b/submodules/Display/Source/TextNode.swift index 3d36be6ece..a27360933f 100644 --- a/submodules/Display/Source/TextNode.swift +++ b/submodules/Display/Source/TextNode.swift @@ -6,9 +6,11 @@ import CoreText private let defaultFont = UIFont.systemFont(ofSize: 15.0) private final class TextNodeStrikethrough { + let range: NSRange let frame: CGRect - init(frame: CGRect) { + init(range: NSRange, frame: CGRect) { + self.range = range self.frame = frame } } @@ -990,7 +992,7 @@ public class TextNode: ASDisplayNode { let lowerX = floor(CTLineGetOffsetForStringIndex(coreTextLine, range.location, nil)) let upperX = ceil(CTLineGetOffsetForStringIndex(coreTextLine, range.location + range.length, nil)) let x = lowerX < upperX ? lowerX : upperX - strikethroughs.append(TextNodeStrikethrough(frame: CGRect(x: x, y: 0.0, width: abs(upperX - lowerX), height: fontLineHeight))) + strikethroughs.append(TextNodeStrikethrough(range: range, frame: CGRect(x: x, y: 0.0, width: abs(upperX - lowerX), height: fontLineHeight))) } else if let paragraphStyle = attributes[NSAttributedString.Key.paragraphStyle] as? NSParagraphStyle { headIndent = paragraphStyle.headIndent @@ -1042,7 +1044,7 @@ public class TextNode: ASDisplayNode { let lowerX = floor(CTLineGetOffsetForStringIndex(coreTextLine, range.location, nil)) let upperX = ceil(CTLineGetOffsetForStringIndex(coreTextLine, range.location + range.length, nil)) let x = lowerX < upperX ? lowerX : upperX - strikethroughs.append(TextNodeStrikethrough(frame: CGRect(x: x, y: 0.0, width: abs(upperX - lowerX), height: fontLineHeight))) + strikethroughs.append(TextNodeStrikethrough(range: range, frame: CGRect(x: x, y: 0.0, width: abs(upperX - lowerX), height: fontLineHeight))) } else if let paragraphStyle = attributes[NSAttributedString.Key.paragraphStyle] as? NSParagraphStyle { headIndent = paragraphStyle.headIndent } @@ -1190,6 +1192,15 @@ public class TextNode: ASDisplayNode { if !line.strikethroughs.isEmpty { for strikethrough in line.strikethroughs { + var textColor: UIColor? + layout.attributedString?.enumerateAttributes(in: NSMakeRange(line.range.location, line.range.length), options: []) { attributes, range, _ in + if range == strikethrough.range, let color = attributes[NSAttributedString.Key.foregroundColor] as? UIColor { + textColor = color + } + } + if let textColor = textColor { + context.setFillColor(textColor.cgColor) + } let frame = strikethrough.frame.offsetBy(dx: lineFrame.minX, dy: lineFrame.minY) context.fill(CGRect(x: frame.minX, y: frame.minY - 5.0, width: frame.width, height: 1.0)) } diff --git a/submodules/GalleryUI/Sources/ChatItemGalleryFooterContentNode.swift b/submodules/GalleryUI/Sources/ChatItemGalleryFooterContentNode.swift index 208f1af5e9..670d8c3af9 100644 --- a/submodules/GalleryUI/Sources/ChatItemGalleryFooterContentNode.swift +++ b/submodules/GalleryUI/Sources/ChatItemGalleryFooterContentNode.swift @@ -587,8 +587,12 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScroll } else if let media = media as? TelegramMediaFile, !media.isAnimated { for attribute in media.attributes { switch attribute { - case .Video: - canFullscreen = true + case let .Video(_, dimensions, _): + if dimensions.height > 0 { + if CGFloat(dimensions.width) / CGFloat(dimensions.height) > 1.33 { + canFullscreen = true + } + } default: break } @@ -1114,7 +1118,7 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScroll } var preferredAction = ShareControllerPreferredAction.default - var actionCompletionText: String = "" + var actionCompletionText: String? if let generalMessageContentKind = generalMessageContentKind { switch generalMessageContentKind { case .image: @@ -1164,6 +1168,7 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScroll } else if let image = content.image { subject = .media(.webPage(webPage: WebpageReference(webpage), media: image)) preferredAction = .saveToCameraRoll + actionCompletionText = strongSelf.presentationData.strings.Gallery_ImageSaved } } } else if let file = m as? TelegramMediaFile { @@ -1185,7 +1190,7 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScroll self?.interacting?(false) } shareController.actionCompleted = { [weak self] in - if let strongSelf = self { + if let strongSelf = self, let actionCompletionText = actionCompletionText { let presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 } strongSelf.controllerInteraction?.presentController(UndoOverlayController(presentationData: presentationData, content: .mediaSaved(text: actionCompletionText), elevatedLayout: false, animateInAsReplacement: false, action: { _ in return false }), nil) } diff --git a/submodules/ListMessageItem/Sources/ListMessageFileItemNode.swift b/submodules/ListMessageItem/Sources/ListMessageFileItemNode.swift index e1cd8a7656..5abb11c1c7 100644 --- a/submodules/ListMessageItem/Sources/ListMessageFileItemNode.swift +++ b/submodules/ListMessageItem/Sources/ListMessageFileItemNode.swift @@ -899,6 +899,8 @@ public final class ListMessageFileItemNode: ListMessageNode { if isVoice { iconStatusBackgroundColor = item.presentationData.theme.theme.list.itemAccentColor iconStatusForegroundColor = item.presentationData.theme.theme.list.itemCheckColors.foregroundColor + } else if isAudio { + iconStatusForegroundColor = item.presentationData.theme.theme.list.itemCheckColors.foregroundColor } if !isAudio && !isInstantVideo { @@ -929,6 +931,7 @@ public final class ListMessageFileItemNode: ListMessageNode { } self.iconStatusNode.backgroundNodeColor = iconStatusBackgroundColor self.iconStatusNode.foregroundNodeColor = iconStatusForegroundColor + self.iconStatusNode.overlayForegroundNodeColor = .white self.iconStatusNode.transitionToState(iconStatusState) } diff --git a/submodules/PeerInfoUI/Sources/ChannelDiscussionGroupSetupController.swift b/submodules/PeerInfoUI/Sources/ChannelDiscussionGroupSetupController.swift index d0c546daef..a0102114e3 100644 --- a/submodules/PeerInfoUI/Sources/ChannelDiscussionGroupSetupController.swift +++ b/submodules/PeerInfoUI/Sources/ChannelDiscussionGroupSetupController.swift @@ -151,10 +151,10 @@ private enum ChannelDiscussionGroupSetupControllerEntry: ItemListNodeEntry { let text: String if let peer = peer as? TelegramChannel, let addressName = peer.addressName, !addressName.isEmpty { text = "@\(addressName)" - } else if let peer = peer as? TelegramChannel, case .group = peer.info { - text = strings.Channel_DiscussionGroup_PrivateGroup - } else { + } else if let peer = peer as? TelegramChannel, case .broadcast = peer.info { text = strings.Channel_DiscussionGroup_PrivateChannel + } else { + text = strings.Channel_DiscussionGroup_PrivateGroup } return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: PresentationDateTimeFormat(), nameDisplayOrder: nameOrder, context: arguments.context, peer: peer, aliasHandling: .standard, nameStyle: .plain, presence: nil, text: .text(text, .secondary), label: .none, editing: ItemListPeerItemEditing(editable: false, editing: false, revealed: false), revealOptions: nil, switchValue: nil, enabled: true, selectable: true, sectionId: self.section, action: { arguments.selectGroup(peer.id) diff --git a/submodules/PhoneInputNode/Sources/PhoneInputNode.swift b/submodules/PhoneInputNode/Sources/PhoneInputNode.swift index 6d9662852b..ed3a8fd7ba 100644 --- a/submodules/PhoneInputNode/Sources/PhoneInputNode.swift +++ b/submodules/PhoneInputNode/Sources/PhoneInputNode.swift @@ -280,6 +280,9 @@ public final class PhoneInputNode: ASDisplayNode, UITextFieldDelegate { if !realRegionPrefix.hasPrefix("+") { realRegionPrefix = "+" + realRegionPrefix } + if !text.hasPrefix("+") { + text = "+" + text + } numberText = cleanPrefix(String(text[realRegionPrefix.endIndex...])) } else { realRegionPrefix = text diff --git a/submodules/SettingsUI/Sources/Themes/ThemeAccentColorController.swift b/submodules/SettingsUI/Sources/Themes/ThemeAccentColorController.swift index d701488a1f..bd212a9528 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeAccentColorController.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeAccentColorController.swift @@ -436,7 +436,7 @@ final class ThemeAccentColorController: ViewController { if case let .colors(initialThemeReference, true) = strongSelf.mode { let themeSpecificAccentColor = settings.themeSpecificAccentColors[themeReference.index] var customAccentColor: UIColor? - if let color = themeSpecificAccentColor?.color { + if let color = themeSpecificAccentColor?.color, color != .clear { accentColor = color customAccentColor = accentColor } else if case let .cloud(cloudTheme) = initialThemeReference, let settings = cloudTheme.theme.settings { diff --git a/submodules/ShareController/Sources/ShareController.swift b/submodules/ShareController/Sources/ShareController.swift index e917287c86..19c3b9effb 100644 --- a/submodules/ShareController/Sources/ShareController.swift +++ b/submodules/ShareController/Sources/ShareController.swift @@ -892,7 +892,7 @@ public final class ShareController: ViewController { } else { context = self.sharedContext.makeTempAccountContext(account: self.currentAccount) } - self.controllerNode.transitionToProgressWithValue(signal: SaveToCameraRoll.saveToCameraRoll(context: context, postbox: context.account.postbox, mediaReference: mediaReference) |> map(Optional.init)) + self.controllerNode.transitionToProgressWithValue(signal: SaveToCameraRoll.saveToCameraRoll(context: context, postbox: context.account.postbox, mediaReference: mediaReference) |> map(Optional.init), dismissImmediately: true) } private func switchToAccount(account: Account, animateIn: Bool) { diff --git a/submodules/TelegramCallsUI/Sources/VoiceChatController.swift b/submodules/TelegramCallsUI/Sources/VoiceChatController.swift index f2a5171029..82adac7ae7 100644 --- a/submodules/TelegramCallsUI/Sources/VoiceChatController.swift +++ b/submodules/TelegramCallsUI/Sources/VoiceChatController.swift @@ -1851,7 +1851,7 @@ public final class VoiceChatController: ViewController { self.listContainer.addSubnode(self.topCornersNode) self.contentContainer.addSubnode(self.bottomGradientNode) self.contentContainer.addSubnode(self.bottomPanelBackgroundNode) - self.contentContainer.addSubnode(self.participantsNode) +// self.contentContainer.addSubnode(self.participantsNode) self.contentContainer.addSubnode(self.tileGridNode) self.contentContainer.addSubnode(self.mainStageContainerNode) self.contentContainer.addSubnode(self.transitionContainerNode) @@ -1975,7 +1975,6 @@ public final class VoiceChatController: ViewController { } }) - let titleAndRecording: Signal<(String?, Bool), NoError> = self.call.state |> map { state -> (String?, Bool) in return (state.title, state.recordingStartTimestamp != nil) @@ -1993,7 +1992,7 @@ public final class VoiceChatController: ViewController { } else { isLivestream = false } - strongSelf.participantsNode.isHidden = !isLivestream + strongSelf.participantsNode.isHidden = !isLivestream || strongSelf.isScheduled strongSelf.peer = peer strongSelf.currentTitleIsCustom = title != nil @@ -5020,12 +5019,12 @@ public final class VoiceChatController: ViewController { displayPanelVideos = self.displayPanelVideos } - let isLivestream: Bool - if let channel = self.peer as? TelegramChannel, case .broadcast = channel.info { - isLivestream = true - } else { - isLivestream = false - } +// let isLivestream: Bool +// if let channel = self.peer as? TelegramChannel, case .broadcast = channel.info { +// isLivestream = true +// } else { +// isLivestream = false +// } let canManageCall = self.callState?.canManageCall ?? false @@ -5042,9 +5041,9 @@ public final class VoiceChatController: ViewController { let memberState: VoiceChatPeerEntry.State var memberMuteState: GroupCallParticipantsContext.Participant.MuteState? if member.hasRaiseHand && !(member.muteState?.canUnmute ?? true) { - if isLivestream && !canManageCall { - continue - } +// if isLivestream && !canManageCall { +// continue +// } memberState = .raisedHand memberMuteState = member.muteState @@ -5081,9 +5080,9 @@ public final class VoiceChatController: ViewController { self.raisedHandDisplayDisposables[member.peer.id] = nil } - if isLivestream && !(memberMuteState?.canUnmute ?? true) { - continue - } +// if isLivestream && !(memberMuteState?.canUnmute ?? true) { +// continue +// } } var memberPeer = member.peer diff --git a/submodules/TelegramCore/Sources/Utils/CanSendMessagesToPeer.swift b/submodules/TelegramCore/Sources/Utils/CanSendMessagesToPeer.swift index ce09be6037..d47364a00b 100644 --- a/submodules/TelegramCore/Sources/Utils/CanSendMessagesToPeer.swift +++ b/submodules/TelegramCore/Sources/Utils/CanSendMessagesToPeer.swift @@ -7,7 +7,9 @@ private final class LinkHelperClass: NSObject { } public func canSendMessagesToPeer(_ peer: Peer) -> Bool { - if peer is TelegramUser || peer is TelegramGroup { + if let peer = peer as? TelegramUser, peer.username == "replies" { + return false + } else if peer is TelegramUser || peer is TelegramGroup { return !peer.isDeleted } else if let peer = peer as? TelegramSecretChat { return peer.embeddedState == .active diff --git a/submodules/TelegramPresentationData/Sources/DefaultDarkPresentationTheme.swift b/submodules/TelegramPresentationData/Sources/DefaultDarkPresentationTheme.swift index ada7119ead..3f546a860d 100644 --- a/submodules/TelegramPresentationData/Sources/DefaultDarkPresentationTheme.swift +++ b/submodules/TelegramPresentationData/Sources/DefaultDarkPresentationTheme.swift @@ -59,6 +59,11 @@ public func customizeDefaultDarkPresentationTheme(theme: PresentationTheme, edit } else { bubbleColors = [accentColor.withMultiplied(hue: 0.966, saturation: 0.61, brightness: 0.98).rgb, accentColor.rgb] } + } else { + let accentColor = accentColor ?? UIColor(rgb: 0xffffff) + if accentColor.rgb == 0xffffff { + monochrome = true + } } var badgeFillColor: UIColor? diff --git a/submodules/TelegramPresentationData/Sources/MakePresentationTheme.swift b/submodules/TelegramPresentationData/Sources/MakePresentationTheme.swift index 6c2104cde2..61cbbd19d9 100644 --- a/submodules/TelegramPresentationData/Sources/MakePresentationTheme.swift +++ b/submodules/TelegramPresentationData/Sources/MakePresentationTheme.swift @@ -47,6 +47,10 @@ public func makePresentationTheme(cloudTheme: TelegramTheme) -> PresentationThem } public func makePresentationTheme(mediaBox: MediaBox, themeReference: PresentationThemeReference, extendingThemeReference: PresentationThemeReference? = nil, accentColor: UIColor? = nil, outgoingAccentColor: UIColor? = nil, backgroundColors: [UInt32] = [], bubbleColors: [UInt32] = [], animateBubbleColors: Bool? = nil, wallpaper: TelegramWallpaper? = nil, baseColor: PresentationThemeBaseColor? = nil, serviceBackgroundColor: UIColor? = nil, preview: Bool = false) -> PresentationTheme? { + var accentColor = accentColor + if accentColor == .clear { + accentColor = nil + } let theme: PresentationTheme switch themeReference { case let .builtin(reference): diff --git a/submodules/TelegramStringFormatting/Sources/ServiceMessageStrings.swift b/submodules/TelegramStringFormatting/Sources/ServiceMessageStrings.swift index 38f10a80b6..a5fe448ce0 100644 --- a/submodules/TelegramStringFormatting/Sources/ServiceMessageStrings.swift +++ b/submodules/TelegramStringFormatting/Sources/ServiceMessageStrings.swift @@ -281,12 +281,20 @@ public func universalServiceMessageString(presentationData: (PresentationTheme, string = strings.Conversation_AutoremoveTimerSetUser(authorString, timeValue).string } } else if let _ = messagePeer as? TelegramGroup { - string = strings.Conversation_AutoremoveTimerSetGroup(timeValue).string - } else if let channel = messagePeer as? TelegramChannel { - if case .group = channel.info { - string = strings.Conversation_AutoremoveTimerSetGroup(timeValue).string + if message.author?.id == accountPeerId { + string = strings.Conversation_AutoremoveTimerSetUserYou(timeValue).string } else { - string = strings.Conversation_AutoremoveTimerSetChannel(timeValue).string + string = strings.Conversation_AutoremoveTimerSetGroup(timeValue).string + } + } else if let channel = messagePeer as? TelegramChannel { + if message.author?.id == accountPeerId { + string = strings.Conversation_AutoremoveTimerSetUserYou(timeValue).string + } else { + if case .group = channel.info { + string = strings.Conversation_AutoremoveTimerSetGroup(timeValue).string + } else { + string = strings.Conversation_AutoremoveTimerSetChannel(timeValue).string + } } } else { if message.author?.id == accountPeerId { diff --git a/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift b/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift index 83a217fa33..0b7bc0e661 100644 --- a/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift +++ b/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift @@ -797,6 +797,10 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate { isMediaEnabled = false } } + var isRecording = false + if let _ = interfaceState.inputTextPanelState.mediaRecordingState { + isRecording = true + } var isScheduledMessages = false if case .scheduledMessages = interfaceState.subject { @@ -811,7 +815,7 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate { } } transition.updateAlpha(layer: self.attachmentButton.layer, alpha: isMediaEnabled ? 1.0 : 0.4) - self.attachmentButton.isEnabled = isMediaEnabled + self.attachmentButton.isEnabled = isMediaEnabled && !isRecording self.attachmentButton.accessibilityTraits = (!isSlowmodeActive || isMediaEnabled) ? [.button] : [.button, .notEnabled] self.attachmentButtonDisabledNode.isHidden = !isSlowmodeActive || isMediaEnabled @@ -840,6 +844,7 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate { if self.theme == nil || !self.theme!.chat.inputPanel.inputTextColor.isEqual(interfaceState.theme.chat.inputPanel.inputTextColor) { let textColor = interfaceState.theme.chat.inputPanel.inputTextColor + let tintColor = interfaceState.theme.list.itemAccentColor let baseFontSize = max(minInputFontSize, interfaceState.fontSize.baseDisplaySize) if let textInputNode = self.textInputNode { @@ -849,6 +854,7 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate { textInputNode.selectedRange = range } textInputNode.typingAttributes = [NSAttributedString.Key.font.rawValue: Font.regular(baseFontSize), NSAttributedString.Key.foregroundColor.rawValue: textColor] + textInputNode.tintColor = tintColor } } diff --git a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift index 758a112568..2816c073f6 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift @@ -2009,13 +2009,25 @@ final class PeerInfoHeaderNode: ASDisplayNode { } if let peer = peer { + var title: String if peer.id == self.context.account.peerId && !self.isSettings { - titleString = NSAttributedString(string: presentationData.strings.Conversation_SavedMessages, font: Font.semibold(24.0), textColor: presentationData.theme.list.itemPrimaryTextColor) + title = presentationData.strings.Conversation_SavedMessages } else if peer.id == self.context.account.peerId && !self.isSettings { - titleString = NSAttributedString(string: presentationData.strings.DialogList_Replies, font: Font.semibold(24.0), textColor: presentationData.theme.list.itemPrimaryTextColor) + title = presentationData.strings.DialogList_Replies } else { - titleString = NSAttributedString(string: peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), font: Font.semibold(24.0), textColor: presentationData.theme.list.itemPrimaryTextColor) + title = peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder) } + title = title.replacingOccurrences(of: "\u{1160}", with: "").replacingOccurrences(of: "\u{3164}", with: "") + if title.isEmpty { + if let peer = peer as? TelegramUser, let phone = peer.phone { + title = formatPhoneNumber(phone) + } else if let addressName = peer.addressName { + title = "@\(addressName)" + } else { + title = " " + } + } + titleString = NSAttributedString(string: title, font: Font.semibold(24.0), textColor: presentationData.theme.list.itemPrimaryTextColor) if self.isSettings, let user = peer as? TelegramUser { let formattedPhone = formatPhoneNumber(user.phone ?? "") From 2a61eee4a6aa9d8fbb02b5bb3814a667b747046a Mon Sep 17 00:00:00 2001 From: Ali <> Date: Tue, 28 Sep 2021 15:06:13 +0400 Subject: [PATCH 3/4] Add animation plist key --- Telegram/BUILD | 2 + submodules/Display/Source/ListView.swift | 19 +++++++- .../Source/ObjCRuntimeUtils/RuntimeUtils.h | 2 + .../Source/ObjCRuntimeUtils/RuntimeUtils.m | 47 +++++++++++-------- .../TelegramEngine/Themes/ChatThemes.swift | 4 +- .../Panes/PeerInfoVisualMediaPaneNode.swift | 4 +- 6 files changed, 54 insertions(+), 24 deletions(-) diff --git a/Telegram/BUILD b/Telegram/BUILD index 1e41387b9b..2db05c62e9 100644 --- a/Telegram/BUILD +++ b/Telegram/BUILD @@ -1793,6 +1793,8 @@ plist_fragment( + CADisableMinimumFrameDurationOnPhone + """.format( telegram_bundle_id = telegram_bundle_id, ) diff --git a/submodules/Display/Source/ListView.swift b/submodules/Display/Source/ListView.swift index 9a4ab417cb..4c998fb9a3 100644 --- a/submodules/Display/Source/ListView.swift +++ b/submodules/Display/Source/ListView.swift @@ -2,6 +2,7 @@ import UIKit import AsyncDisplayKit import SwiftSignalKit import UIKitRuntimeUtils +import ObjCRuntimeUtils private let infiniteScrollSize: CGFloat = 10000.0 private let insertionAnimationDuration: Double = 0.4 @@ -822,11 +823,27 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture } private var generalAccumulatedDeltaY: CGFloat = 0.0 + private var previousDidScrollTimestamp: Double = 0.0 private func updateScrollViewDidScroll(_ scrollView: UIScrollView, synchronous: Bool) { if self.ignoreScrollingEvents || scroller !== self.scroller { return } + + /*let timestamp = CACurrentMediaTime() + if !self.previousDidScrollTimestamp.isZero { + let delta = timestamp - self.previousDidScrollTimestamp + if delta < 0.1 { + print("Scrolling delta: \(delta)") + } + } + self.previousDidScrollTimestamp = timestamp + + if let displayLink = self.scroller.getIvarValue("_scrollHeartbeat") as? CADisplayLink { + if #available(iOS 10.0, *) { + displayLink.preferredFramesPerSecond = 120 + } + }*/ //CATransaction.begin() //CATransaction.setDisableActions(true) @@ -854,7 +871,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture self.trackingOffset += -deltaY } - self.enqueueUpdateVisibleItems(synchronous: synchronous) + self.enqueueUpdateVisibleItems(synchronous: true) var useScrollDynamics = false diff --git a/submodules/ObjCRuntimeUtils/Source/ObjCRuntimeUtils/RuntimeUtils.h b/submodules/ObjCRuntimeUtils/Source/ObjCRuntimeUtils/RuntimeUtils.h index 3a06e3c3bf..43ada23203 100644 --- a/submodules/ObjCRuntimeUtils/Source/ObjCRuntimeUtils/RuntimeUtils.h +++ b/submodules/ObjCRuntimeUtils/Source/ObjCRuntimeUtils/RuntimeUtils.h @@ -22,6 +22,8 @@ typedef enum { - (id _Nullable)associatedObjectForKey:(void const * _Nonnull)key; - (bool)checkObjectIsKindOfClass:(Class _Nonnull)targetClass; - (void)setClass:(Class _Nonnull)newClass; ++ (NSArray * _Nonnull)getIvarList:(Class _Nonnull)classValue; +- (id _Nullable)getIvarValue:(NSString * _Nonnull)name; @end diff --git a/submodules/ObjCRuntimeUtils/Source/ObjCRuntimeUtils/RuntimeUtils.m b/submodules/ObjCRuntimeUtils/Source/ObjCRuntimeUtils/RuntimeUtils.m index 060faf64d0..60bf470fbd 100644 --- a/submodules/ObjCRuntimeUtils/Source/ObjCRuntimeUtils/RuntimeUtils.m +++ b/submodules/ObjCRuntimeUtils/Source/ObjCRuntimeUtils/RuntimeUtils.m @@ -98,27 +98,34 @@ object_setClass(self, newClass); } -static Class freedomMakeClass(Class superclass, Class subclass, SEL *copySelectors, int copySelectorsCount) -{ - if (superclass == Nil || subclass == Nil) - return nil; - - Class decoratedClass = objc_allocateClassPair(superclass, [[NSString alloc] initWithFormat:@"%@_%@", NSStringFromClass(superclass), NSStringFromClass(subclass)].UTF8String, 0); - - unsigned int count = 0; - Method *methodList = class_copyMethodList(subclass, &count); - if (methodList != NULL) { - for (unsigned int i = 0; i < count; i++) { - SEL methodName = method_getName(methodList[i]); - class_addMethod(decoratedClass, methodName, method_getImplementation(methodList[i]), method_getTypeEncoding(methodList[i])); - } - - free(methodList); ++ (NSArray * _Nonnull)getIvarList:(Class _Nonnull)classValue { + NSMutableArray *result = [[NSMutableArray alloc] init]; + + unsigned int varCount; + + Ivar *vars = class_copyIvarList(classValue, &varCount); + + for (int i = 0; i < varCount; i++) { + Ivar var = vars[i]; + + const char* name = ivar_getName(var); + const char* typeEncoding = ivar_getTypeEncoding(var); + + [result addObject:[NSString stringWithFormat:@"%s: %s", name, typeEncoding]]; } - - objc_registerClassPair(decoratedClass); - - return decoratedClass; + + free(vars); + + return result; +} + +- (id _Nullable)getIvarValue:(NSString * _Nonnull)name { + Ivar ivar = class_getInstanceVariable([self class], [name UTF8String]); + if (!ivar){ + return nil; + } + id value = object_getIvar(self, ivar); + return value; } @end diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Themes/ChatThemes.swift b/submodules/TelegramCore/Sources/TelegramEngine/Themes/ChatThemes.swift index 2fa2be703e..8e99297288 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Themes/ChatThemes.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Themes/ChatThemes.swift @@ -20,8 +20,8 @@ public struct ChatTheme: PostboxCoding, Equatable { public init(decoder: PostboxDecoder) { self.emoji = decoder.decodeStringForKey("e", orElse: "") - self.theme = decoder.decodeObjectForKey("t") as! TelegramTheme - self.darkTheme = decoder.decodeObjectForKey("dt") as! TelegramTheme + self.theme = decoder.decodeObjectForKey("t", decoder: { TelegramTheme(decoder: $0) }) as! TelegramTheme + self.darkTheme = decoder.decodeObjectForKey("dt", decoder: { TelegramTheme(decoder: $0) }) as! TelegramTheme } public func encode(_ encoder: PostboxEncoder) { diff --git a/submodules/TelegramUI/Sources/PeerInfo/Panes/PeerInfoVisualMediaPaneNode.swift b/submodules/TelegramUI/Sources/PeerInfo/Panes/PeerInfoVisualMediaPaneNode.swift index 9a5af497b4..a66f2a017f 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/Panes/PeerInfoVisualMediaPaneNode.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/Panes/PeerInfoVisualMediaPaneNode.swift @@ -1066,8 +1066,10 @@ final class PeerInfoVisualMediaPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScro self.updateHeaderFlashing(animated: true) } + + private var previousDidScrollTimestamp: Double = 0.0 - func scrollViewDidScroll(_ scrollView: UIScrollView) { + func scrollViewDidScroll(_ scrollView: UIScrollView) { if let (size, sideInset, bottomInset, visibleHeight, _, _, presentationData) = self.currentParams { self.updateVisibleItems(size: size, sideInset: sideInset, bottomInset: bottomInset, visibleHeight: visibleHeight, theme: presentationData.theme, strings: presentationData.strings, synchronousLoad: false) From d68ef5b11bd42ed909fb5dd798550329e6b5157f Mon Sep 17 00:00:00 2001 From: Ali <> Date: Tue, 28 Sep 2021 15:06:23 +0400 Subject: [PATCH 4/4] Bump version --- versions.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versions.json b/versions.json index 7fc9f10c3a..443b8984a7 100644 --- a/versions.json +++ b/versions.json @@ -1,5 +1,5 @@ { - "app": "8.1.1", + "app": "8.1.2", "bazel": "4.0.0", "xcode": "12.5.1" }