From 8f459a51046f08d3ce8a1da60aa68a6de1a08d5a Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Sun, 27 Nov 2022 23:24:25 +0400 Subject: [PATCH 1/2] Various emoji search fixes --- .../Telegram-iOS/en.lproj/Localizable.strings | 2 ++ ...tionSequencePhoneEntryControllerNode.swift | 2 +- .../Sources/ChatListController.swift | 1 + .../QuickReactionSetupController.swift | 1 + .../Sources/EmojiPagerContentComponent.swift | 14 +++++++--- .../Sources/GifPagerContentComponent.swift | 25 ++++++++++------- .../Sources/ForumCreateTopicScreen.swift | 2 ++ .../TelegramUI/Sources/ChatController.swift | 1 + .../Sources/ChatEntityKeyboardInputNode.swift | 27 ++++++++++++++++--- .../Sources/PeerInfo/PeerInfoScreen.swift | 1 + 10 files changed, 58 insertions(+), 18 deletions(-) diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index acbad4386c..e426459fcb 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -8337,3 +8337,5 @@ Sorry for the inconvenience."; "UserInfo.AnonymousNumberInfo" = "This number is not tied to a SIM card and was acquired on [Fragment]()."; "Login.NewNumber" = "New Number"; + +"EmojiSearch.SearchEmojiPlaceholder" = "Search Emoji"; diff --git a/submodules/AuthorizationUI/Sources/AuthorizationSequencePhoneEntryControllerNode.swift b/submodules/AuthorizationUI/Sources/AuthorizationSequencePhoneEntryControllerNode.swift index 511edeeeb7..baf313b0fc 100644 --- a/submodules/AuthorizationUI/Sources/AuthorizationSequencePhoneEntryControllerNode.swift +++ b/submodules/AuthorizationUI/Sources/AuthorizationSequencePhoneEntryControllerNode.swift @@ -533,7 +533,7 @@ final class AuthorizationSequencePhoneEntryControllerNode: ASDisplayNode { let titleInset: CGFloat = layout.size.width > 320.0 ? 18.0 : 0.0 let additionalBottomInset: CGFloat = layout.size.width > 320.0 ? 80.0 : 10.0 - self.titleNode.attributedText = NSAttributedString(string: strings.Login_PhoneTitle, font: Font.bold(28.0), textColor: self.theme.list.itemPrimaryTextColor) + self.titleNode.attributedText = NSAttributedString(string: self.account == nil ? strings.Login_NewNumber : strings.Login_PhoneTitle, font: Font.bold(28.0), textColor: self.theme.list.itemPrimaryTextColor) let inset: CGFloat = 24.0 let maximumWidth: CGFloat = min(430.0, layout.size.width) diff --git a/submodules/ChatListUI/Sources/ChatListController.swift b/submodules/ChatListUI/Sources/ChatListController.swift index 04c2b38545..ff68aa8dfe 100644 --- a/submodules/ChatListUI/Sources/ChatListController.swift +++ b/submodules/ChatListUI/Sources/ChatListController.swift @@ -792,6 +792,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController isStandalone: false, isStatusSelection: true, isReactionSelection: false, + isEmojiSelection: false, topReactionItems: [], areUnicodeEmojiEnabled: false, areCustomEmojiEnabled: true, diff --git a/submodules/SettingsUI/Sources/Reactions/QuickReactionSetupController.swift b/submodules/SettingsUI/Sources/Reactions/QuickReactionSetupController.swift index ff20f2a03f..364207321b 100644 --- a/submodules/SettingsUI/Sources/Reactions/QuickReactionSetupController.swift +++ b/submodules/SettingsUI/Sources/Reactions/QuickReactionSetupController.swift @@ -347,6 +347,7 @@ public func quickReactionSetupController( isStandalone: false, isStatusSelection: false, isReactionSelection: true, + isEmojiSelection: false, isQuickReactionSelection: true, topReactionItems: [], areUnicodeEmojiEnabled: false, diff --git a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift index a487dd0385..ed12d24ca5 100644 --- a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift +++ b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift @@ -1701,8 +1701,7 @@ public final class EmojiSearchHeaderView: UIView, UITextFieldDelegate { self.clearIconView.isHidden = true self.clearIconTintView.isHidden = true self.clearIconButton.isHidden = true - - + self.deactivated() if let textField = self.textField { @@ -1711,6 +1710,9 @@ public final class EmojiSearchHeaderView: UIView, UITextFieldDelegate { textField.resignFirstResponder() textField.removeFromSuperview() } + + self.tintTextView.view?.isHidden = false + self.textView.view?.isHidden = false } @objc private func clearPressed() { @@ -1720,6 +1722,9 @@ public final class EmojiSearchHeaderView: UIView, UITextFieldDelegate { self.clearIconView.isHidden = true self.clearIconTintView.isHidden = true self.clearIconButton.isHidden = true + + self.tintTextView.view?.isHidden = false + self.textView.view?.isHidden = false } public func textFieldDidBeginEditing(_ textField: UITextField) { @@ -6260,6 +6265,7 @@ public final class EmojiPagerContentComponent: Component { isStandalone: Bool, isStatusSelection: Bool, isReactionSelection: Bool, + isEmojiSelection: Bool, isTopicIconSelection: Bool = false, isQuickReactionSelection: Bool = false, topReactionItems: [EmojiComponentReactionItem], @@ -6977,8 +6983,8 @@ public final class EmojiPagerContentComponent: Component { displaySearchWithPlaceholder = strings.EmojiSearch_SearchStatusesPlaceholder } else if isTopicIconSelection { displaySearchWithPlaceholder = strings.EmojiSearch_SearchTopicIconsPlaceholder - } else { - displaySearchWithPlaceholder = "Search Emoji" + } else if isEmojiSelection { + displaySearchWithPlaceholder = strings.EmojiSearch_SearchEmojiPlaceholder searchInitiallyHidden = false } diff --git a/submodules/TelegramUI/Components/EntityKeyboard/Sources/GifPagerContentComponent.swift b/submodules/TelegramUI/Components/EntityKeyboard/Sources/GifPagerContentComponent.swift index 159a9223e2..734d2290a7 100644 --- a/submodules/TelegramUI/Components/EntityKeyboard/Sources/GifPagerContentComponent.swift +++ b/submodules/TelegramUI/Components/EntityKeyboard/Sources/GifPagerContentComponent.swift @@ -883,15 +883,22 @@ public final class GifPagerContentComponent: Component { guard let theme = self.theme else { return } - if self.vibrancyEffectView == nil { - let style: UIBlurEffect.Style - style = .extraLight - let blurEffect = UIBlurEffect(style: style) - let vibrancyEffect = UIVibrancyEffect(blurEffect: blurEffect) - let vibrancyEffectView = UIVisualEffectView(effect: vibrancyEffect) - self.vibrancyEffectView = vibrancyEffectView - self.backgroundView.addSubview(vibrancyEffectView) - vibrancyEffectView.contentView.addSubview(self.mirrorContentScrollView) + if theme.overallDarkAppearance { + if let vibrancyEffectView = self.vibrancyEffectView { + self.vibrancyEffectView = nil + vibrancyEffectView.removeFromSuperview() + } + } else { + if self.vibrancyEffectView == nil { + let style: UIBlurEffect.Style + style = .extraLight + let blurEffect = UIBlurEffect(style: style) + let vibrancyEffect = UIVibrancyEffect(blurEffect: blurEffect) + let vibrancyEffectView = UIVisualEffectView(effect: vibrancyEffect) + self.vibrancyEffectView = vibrancyEffectView + self.backgroundView.addSubview(vibrancyEffectView) + vibrancyEffectView.contentView.addSubview(self.mirrorContentScrollView) + } } self.backgroundView.updateColor(color: theme.chat.inputMediaPanel.backgroundColor, enableBlur: true, forceKeepBlur: false, transition: transition.containedViewLayoutTransition) transition.setFrame(view: self.backgroundView, frame: backgroundFrame) diff --git a/submodules/TelegramUI/Components/ForumCreateTopicScreen/Sources/ForumCreateTopicScreen.swift b/submodules/TelegramUI/Components/ForumCreateTopicScreen/Sources/ForumCreateTopicScreen.swift index 483c888e64..3a5dc7880c 100644 --- a/submodules/TelegramUI/Components/ForumCreateTopicScreen/Sources/ForumCreateTopicScreen.swift +++ b/submodules/TelegramUI/Components/ForumCreateTopicScreen/Sources/ForumCreateTopicScreen.swift @@ -547,6 +547,7 @@ private final class ForumCreateTopicScreenComponent: CombinedComponent { isStandalone: false, isStatusSelection: false, isReactionSelection: false, + isEmojiSelection: false, isTopicIconSelection: true, topReactionItems: [], areUnicodeEmojiEnabled: false, @@ -614,6 +615,7 @@ private final class ForumCreateTopicScreenComponent: CombinedComponent { isStandalone: false, isStatusSelection: false, isReactionSelection: false, + isEmojiSelection: false, isTopicIconSelection: true, topReactionItems: [], areUnicodeEmojiEnabled: false, diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index e528fe17ef..4ae23d8ff9 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -1134,6 +1134,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G isStandalone: false, isStatusSelection: false, isReactionSelection: true, + isEmojiSelection: false, topReactionItems: reactionItems, areUnicodeEmojiEnabled: false, areCustomEmojiEnabled: true, diff --git a/submodules/TelegramUI/Sources/ChatEntityKeyboardInputNode.swift b/submodules/TelegramUI/Sources/ChatEntityKeyboardInputNode.swift index 86c4129e68..69d0167567 100644 --- a/submodules/TelegramUI/Sources/ChatEntityKeyboardInputNode.swift +++ b/submodules/TelegramUI/Sources/ChatEntityKeyboardInputNode.swift @@ -90,7 +90,7 @@ final class ChatEntityKeyboardInputNode: ChatInputNode { let animationCache = context.animationCache let animationRenderer = context.animationRenderer - let emojiItems = EmojiPagerContentComponent.emojiInputData(context: context, animationCache: animationCache, animationRenderer: animationRenderer, isStandalone: false, isStatusSelection: false, isReactionSelection: false, topReactionItems: [], areUnicodeEmojiEnabled: true, areCustomEmojiEnabled: areCustomEmojiEnabled, chatPeerId: chatPeerId) + let emojiItems = EmojiPagerContentComponent.emojiInputData(context: context, animationCache: animationCache, animationRenderer: animationRenderer, isStandalone: false, isStatusSelection: false, isReactionSelection: false, isEmojiSelection: true, topReactionItems: [], areUnicodeEmojiEnabled: true, areCustomEmojiEnabled: areCustomEmojiEnabled, chatPeerId: chatPeerId) let stickerNamespaces: [ItemCollectionId.Namespace] = [Namespaces.ItemCollection.CloudStickerPacks] let stickerOrderedItemListCollectionIds: [Int32] = [Namespaces.OrderedItemList.CloudSavedStickers, Namespaces.OrderedItemList.CloudRecentStickers, Namespaces.OrderedItemList.CloudAllPremiumStickers] @@ -1210,10 +1210,17 @@ final class ChatEntityKeyboardInputNode: ChatInputNode { |> map { view, availableReactions, hasPremium -> [EmojiPagerContentComponent.ItemGroup] in var result: [(String, TelegramMediaFile?, String)] = [] + var existingEmoticons = Set() + var allEmoticonsList: [String] = [] var allEmoticons: [String: String] = [:] for keyword in keywords { for emoticon in keyword.emoticons { allEmoticons[emoticon] = keyword.keyword + + if !existingEmoticons.contains(emoticon) { + allEmoticonsList.append(emoticon) + existingEmoticons.insert(emoticon) + } } } @@ -1250,7 +1257,8 @@ final class ChatEntityKeyboardInputNode: ChatInputNode { let item = EmojiPagerContentComponent.Item( animationData: animationData, content: .animation(animationData), - itemFile: itemFile, subgroupId: nil, + itemFile: itemFile, + subgroupId: nil, icon: .none, accentTint: false ) @@ -1258,6 +1266,17 @@ final class ChatEntityKeyboardInputNode: ChatInputNode { } } + for emoji in allEmoticonsList { + items.append(EmojiPagerContentComponent.Item( + animationData: nil, + content: .staticEmoji(emoji), + itemFile: nil, + subgroupId: nil, + icon: .none, + accentTint: false) + ) + } + return [EmojiPagerContentComponent.ItemGroup( supergroupId: "search", groupId: "search", @@ -2262,7 +2281,7 @@ final class EntityInputView: UIView, AttachmentTextInputPanelInputView, UIInputV let semaphore = DispatchSemaphore(value: 0) var emojiComponent: EmojiPagerContentComponent? - let _ = EmojiPagerContentComponent.emojiInputData(context: context, animationCache: self.animationCache, animationRenderer: self.animationRenderer, isStandalone: true, isStatusSelection: false, isReactionSelection: false, topReactionItems: [], areUnicodeEmojiEnabled: true, areCustomEmojiEnabled: areCustomEmojiEnabled, chatPeerId: nil).start(next: { value in + let _ = EmojiPagerContentComponent.emojiInputData(context: context, animationCache: self.animationCache, animationRenderer: self.animationRenderer, isStandalone: true, isStatusSelection: false, isReactionSelection: false, isEmojiSelection: false, topReactionItems: [], areUnicodeEmojiEnabled: true, areCustomEmojiEnabled: areCustomEmojiEnabled, chatPeerId: nil).start(next: { value in emojiComponent = value semaphore.signal() }) @@ -2277,7 +2296,7 @@ final class EntityInputView: UIView, AttachmentTextInputPanelInputView, UIInputV gifs: nil, availableGifSearchEmojies: [] ), - updatedInputData: EmojiPagerContentComponent.emojiInputData(context: context, animationCache: self.animationCache, animationRenderer: self.animationRenderer, isStandalone: true, isStatusSelection: false, isReactionSelection: false, topReactionItems: [], areUnicodeEmojiEnabled: true, areCustomEmojiEnabled: areCustomEmojiEnabled, chatPeerId: nil) |> map { emojiComponent -> ChatEntityKeyboardInputNode.InputData in + updatedInputData: EmojiPagerContentComponent.emojiInputData(context: context, animationCache: self.animationCache, animationRenderer: self.animationRenderer, isStandalone: true, isStatusSelection: false, isReactionSelection: false, isEmojiSelection: false, topReactionItems: [], areUnicodeEmojiEnabled: true, areCustomEmojiEnabled: areCustomEmojiEnabled, chatPeerId: nil) |> map { emojiComponent -> ChatEntityKeyboardInputNode.InputData in return ChatEntityKeyboardInputNode.InputData( emoji: emojiComponent, stickers: nil, diff --git a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift index 3757022c62..1a73a20584 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift @@ -3362,6 +3362,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate isStandalone: false, isStatusSelection: true, isReactionSelection: false, + isEmojiSelection: false, topReactionItems: [], areUnicodeEmojiEnabled: false, areCustomEmojiEnabled: true, From 61b298b9e2cc4c5bff12713e21561e1be5582152 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Sun, 27 Nov 2022 23:41:50 +0400 Subject: [PATCH 2/2] Various fixes --- .../Sources/ChatMessageBubbleItemNode.swift | 8 ++++---- .../ChatMessageInstantVideoBubbleContentNode.swift | 8 ++++++-- .../ChatMessageInteractiveInstantVideoNode.swift | 13 ++++++++----- .../Sources/PeerInfo/PeerInfoScreen.swift | 2 ++ 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/submodules/TelegramUI/Sources/ChatMessageBubbleItemNode.swift b/submodules/TelegramUI/Sources/ChatMessageBubbleItemNode.swift index 5c9b491be6..c320e92cc8 100644 --- a/submodules/TelegramUI/Sources/ChatMessageBubbleItemNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageBubbleItemNode.swift @@ -1221,7 +1221,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode } if !isBroadcastChannel { - hasAvatar = item.content.firstMessage.effectivelyIncoming(item.context.account.peerId) + hasAvatar = incoming } else if case .feed = item.chatLocation { hasAvatar = true } @@ -1269,7 +1269,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode } } else if item.message.id.peerId.isReplies { needsShareButton = false - } else if item.message.effectivelyIncoming(item.context.account.peerId) { + } else if incoming { if let _ = sourceReference { needsShareButton = true } @@ -1801,7 +1801,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode let dateText = stringForMessageTimestampStatus(accountPeerId: item.context.account.peerId, message: message, dateTimeFormat: item.presentationData.dateTimeFormat, nameDisplayOrder: item.presentationData.nameDisplayOrder, strings: item.presentationData.strings, format: dateFormat) let statusType: ChatMessageDateAndStatusType - if message.effectivelyIncoming(item.context.account.peerId) { + if incoming { statusType = .ImageIncoming } else { if isFailed { @@ -2080,7 +2080,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode reactions: bubbleReactions, message: item.message, accountPeer: item.associatedData.accountPeer, - isIncoming: item.message.effectivelyIncoming(item.context.account.peerId), + isIncoming: incoming, constrainedWidth: maximumNodeWidth )) maxContentWidth = max(maxContentWidth, minWidth) diff --git a/submodules/TelegramUI/Sources/ChatMessageInstantVideoBubbleContentNode.swift b/submodules/TelegramUI/Sources/ChatMessageInstantVideoBubbleContentNode.swift index 7477732ad9..10c8229697 100644 --- a/submodules/TelegramUI/Sources/ChatMessageInstantVideoBubbleContentNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageInstantVideoBubbleContentNode.swift @@ -165,7 +165,11 @@ class ChatMessageInstantVideoBubbleContentNode: ChatMessageBubbleContentNode { } } - let incoming = item.message.effectivelyIncoming(item.context.account.peerId) + var incoming = item.message.effectivelyIncoming(item.context.account.peerId) + if case .forwardedMessages = item.associatedData.subject { + incoming = false + } + let statusType: ChatMessageDateAndStatusType? switch preparePosition { case .linear(_, .None), .linear(_, .Neighbour(true, _, _)): @@ -198,7 +202,7 @@ class ChatMessageInstantVideoBubbleContentNode: ChatMessageBubbleContentNode { forcedIsEdited: item.isItemEdited, file: selectedFile!, automaticDownload: automaticDownload, - incoming: item.message.effectivelyIncoming(item.context.account.peerId), + incoming: incoming, isRecentActions: item.associatedData.isRecentActions, forcedResourceStatus: item.associatedData.forcedResourceStatus, dateAndStatusType: statusType, diff --git a/submodules/TelegramUI/Sources/ChatMessageInteractiveInstantVideoNode.swift b/submodules/TelegramUI/Sources/ChatMessageInteractiveInstantVideoNode.swift index ce827ebb8a..16ab0f01fc 100644 --- a/submodules/TelegramUI/Sources/ChatMessageInteractiveInstantVideoNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageInteractiveInstantVideoNode.swift @@ -231,6 +231,11 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode { var updatedInfoBackgroundImage: UIImage? var updatedMuteIconImage: UIImage? + var incoming = item.message.effectivelyIncoming(item.context.account.peerId) + if case .forwardedMessages = item.associatedData.subject { + incoming = false + } + var viaBotApply: (TextNodeLayout, () -> TextNode)? var replyInfoApply: (CGSize, (Bool) -> ChatMessageReplyInfoNode)? var updatedReplyBackgroundNode: NavigationBackgroundNode? @@ -430,7 +435,7 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode { let arguments = TransformImageArguments(corners: ImageCorners(radius: videoFrame.size.width / 2.0), imageSize: videoFrame.size, boundingSize: videoFrame.size, intrinsicInsets: UIEdgeInsets()) let statusType: ChatMessageDateAndStatusType - if item.message.effectivelyIncoming(item.context.account.peerId) { + if incoming { switch statusDisplayType { case .free: statusType = .FreeIncoming @@ -622,7 +627,7 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode { durationBlurColor = (selectDateFillStaticColor(theme: theme.theme, wallpaper: theme.wallpaper), dateFillNeedsBlur(theme: theme.theme, wallpaper: theme.wallpaper)) case .bubble: durationBlurColor = nil - if item.message.effectivelyIncoming(item.context.account.peerId) { + if incoming { durationTextColor = theme.theme.chat.message.incoming.secondaryTextColor } else { durationTextColor = theme.theme.chat.message.outgoing.secondaryTextColor @@ -733,9 +738,7 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode { } })) } - - let incoming = item.message.effectivelyIncoming(item.context.account.peerId) - + var displayTranscribe: Bool if item.message.id.peerId.namespace != Namespaces.Peer.SecretChat && statusDisplayType == .free { if item.associatedData.isPremium { diff --git a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift index 1a73a20584..e439d566bd 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift @@ -5523,6 +5523,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate phoneCallAction() } }))) + } else { isAnonymousNumber = true } items.append(.action(ContextMenuActionItem(text: presentationData.strings.Conversation_ContextMenuCopy, icon: { theme in generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Copy"), color: theme.contextMenu.primaryColor) }, action: { c, _ in @@ -5539,6 +5540,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate } })) ) + } else { isAnonymousNumber = true } items.append(