mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Merge branch '188layer'
This commit is contained in:
commit
97bbea733c
@ -89,9 +89,8 @@ extension ReplyMarkupButton {
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
self.init(title: text, titleWhenForwarded: nil, action: .requestPeer(peerType: mappedPeerType, buttonId: buttonId, maxQuantity: maxQuantity))
|
self.init(title: text, titleWhenForwarded: nil, action: .requestPeer(peerType: mappedPeerType, buttonId: buttonId, maxQuantity: maxQuantity))
|
||||||
case let .keyboardButtonCopy(text, _):
|
case let .keyboardButtonCopy(text, payload):
|
||||||
//TODO:release
|
self.init(title: text, titleWhenForwarded: nil, action: .copyText(payload: payload))
|
||||||
self.init(title: text, titleWhenForwarded: nil, action: .text)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -232,6 +232,7 @@ public enum ReplyMarkupButtonAction: PostboxCoding, Equatable {
|
|||||||
case openUserProfile(peerId: PeerId)
|
case openUserProfile(peerId: PeerId)
|
||||||
case openWebView(url: String, simple: Bool)
|
case openWebView(url: String, simple: Bool)
|
||||||
case requestPeer(peerType: ReplyMarkupButtonRequestPeerType, buttonId: Int32, maxQuantity: Int32)
|
case requestPeer(peerType: ReplyMarkupButtonRequestPeerType, buttonId: Int32, maxQuantity: Int32)
|
||||||
|
case copyText(payload: String)
|
||||||
|
|
||||||
public init(decoder: PostboxDecoder) {
|
public init(decoder: PostboxDecoder) {
|
||||||
switch decoder.decodeInt32ForKey("v", orElse: 0) {
|
switch decoder.decodeInt32ForKey("v", orElse: 0) {
|
||||||
@ -261,6 +262,8 @@ public enum ReplyMarkupButtonAction: PostboxCoding, Equatable {
|
|||||||
self = .openWebView(url: decoder.decodeStringForKey("u", orElse: ""), simple: decoder.decodeInt32ForKey("s", orElse: 0) != 0)
|
self = .openWebView(url: decoder.decodeStringForKey("u", orElse: ""), simple: decoder.decodeInt32ForKey("s", orElse: 0) != 0)
|
||||||
case 12:
|
case 12:
|
||||||
self = .requestPeer(peerType: decoder.decode(ReplyMarkupButtonRequestPeerType.self, forKey: "pt") ?? ReplyMarkupButtonRequestPeerType.user(ReplyMarkupButtonRequestPeerType.User(isBot: nil, isPremium: nil)), buttonId: decoder.decodeInt32ForKey("b", orElse: 0), maxQuantity: decoder.decodeInt32ForKey("q", orElse: 1))
|
self = .requestPeer(peerType: decoder.decode(ReplyMarkupButtonRequestPeerType.self, forKey: "pt") ?? ReplyMarkupButtonRequestPeerType.user(ReplyMarkupButtonRequestPeerType.User(isBot: nil, isPremium: nil)), buttonId: decoder.decodeInt32ForKey("b", orElse: 0), maxQuantity: decoder.decodeInt32ForKey("q", orElse: 1))
|
||||||
|
case 13:
|
||||||
|
self = .copyText(payload: decoder.decodeStringForKey("p", orElse: ""))
|
||||||
default:
|
default:
|
||||||
self = .text
|
self = .text
|
||||||
}
|
}
|
||||||
@ -313,6 +316,9 @@ public enum ReplyMarkupButtonAction: PostboxCoding, Equatable {
|
|||||||
encoder.encodeInt32(buttonId, forKey: "b")
|
encoder.encodeInt32(buttonId, forKey: "b")
|
||||||
encoder.encode(peerType, forKey: "pt")
|
encoder.encode(peerType, forKey: "pt")
|
||||||
encoder.encodeInt32(maxQuantity, forKey: "q")
|
encoder.encodeInt32(maxQuantity, forKey: "q")
|
||||||
|
case let .copyText(payload):
|
||||||
|
encoder.encodeInt32(13, forKey: "v")
|
||||||
|
encoder.encodeString(payload, forKey: "p")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -531,8 +531,8 @@ private class AdMessagesHistoryContextImpl {
|
|||||||
self.maskAsSeenDisposables.set(signal.start(), forKey: opaqueId)
|
self.maskAsSeenDisposables.set(signal.start(), forKey: opaqueId)
|
||||||
}
|
}
|
||||||
|
|
||||||
func markAction(opaqueId: Data) {
|
func markAction(opaqueId: Data, media: Bool, fullscreen: Bool) {
|
||||||
_internal_markAdAction(account: self.account, peerId: self.peerId, opaqueId: opaqueId)
|
_internal_markAdAction(account: self.account, peerId: self.peerId, opaqueId: opaqueId, media: media, fullscreen: fullscreen)
|
||||||
}
|
}
|
||||||
|
|
||||||
func remove(opaqueId: Data) {
|
func remove(opaqueId: Data) {
|
||||||
@ -593,9 +593,9 @@ public class AdMessagesHistoryContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func markAction(opaqueId: Data) {
|
public func markAction(opaqueId: Data, media: Bool, fullscreen: Bool) {
|
||||||
self.impl.with { impl in
|
self.impl.with { impl in
|
||||||
impl.markAction(opaqueId: opaqueId)
|
impl.markAction(opaqueId: opaqueId, media: media, fullscreen: fullscreen)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -607,7 +607,7 @@ public class AdMessagesHistoryContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func _internal_markAdAction(account: Account, peerId: EnginePeer.Id, opaqueId: Data) {
|
func _internal_markAdAction(account: Account, peerId: EnginePeer.Id, opaqueId: Data, media: Bool, fullscreen: Bool) {
|
||||||
let signal: Signal<Never, NoError> = account.postbox.transaction { transaction -> Api.InputChannel? in
|
let signal: Signal<Never, NoError> = account.postbox.transaction { transaction -> Api.InputChannel? in
|
||||||
return transaction.getPeer(peerId).flatMap(apiInputChannel)
|
return transaction.getPeer(peerId).flatMap(apiInputChannel)
|
||||||
}
|
}
|
||||||
@ -615,7 +615,14 @@ func _internal_markAdAction(account: Account, peerId: EnginePeer.Id, opaqueId: D
|
|||||||
guard let inputChannel = inputChannel else {
|
guard let inputChannel = inputChannel else {
|
||||||
return .complete()
|
return .complete()
|
||||||
}
|
}
|
||||||
return account.network.request(Api.functions.channels.clickSponsoredMessage(flags: 0, channel: inputChannel, randomId: Buffer(data: opaqueId)))
|
var flags: Int32 = 0
|
||||||
|
if media {
|
||||||
|
flags |= (1 << 0)
|
||||||
|
}
|
||||||
|
if fullscreen {
|
||||||
|
flags |= (1 << 1)
|
||||||
|
}
|
||||||
|
return account.network.request(Api.functions.channels.clickSponsoredMessage(flags: flags, channel: inputChannel, randomId: Buffer(data: opaqueId)))
|
||||||
|> `catch` { _ -> Signal<Api.Bool, NoError> in
|
|> `catch` { _ -> Signal<Api.Bool, NoError> in
|
||||||
return .single(.boolFalse)
|
return .single(.boolFalse)
|
||||||
}
|
}
|
||||||
|
@ -1466,8 +1466,9 @@ public extension TelegramEngine {
|
|||||||
public func updateExtendedMedia(messageIds: [EngineMessage.Id]) -> Signal<Never, NoError> {
|
public func updateExtendedMedia(messageIds: [EngineMessage.Id]) -> Signal<Never, NoError> {
|
||||||
return _internal_updateExtendedMedia(account: self.account, messageIds: messageIds)
|
return _internal_updateExtendedMedia(account: self.account, messageIds: messageIds)
|
||||||
}
|
}
|
||||||
public func markAdAction(peerId: EnginePeer.Id, opaqueId: Data) {
|
|
||||||
_internal_markAdAction(account: self.account, peerId: peerId, opaqueId: opaqueId)
|
public func markAdAction(peerId: EnginePeer.Id, opaqueId: Data, media: Bool, fullscreen: Bool) {
|
||||||
|
_internal_markAdAction(account: self.account, peerId: peerId, opaqueId: opaqueId, media: media, fullscreen: fullscreen)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func getAllLocalChannels(count: Int) -> Signal<[EnginePeer.Id], NoError> {
|
public func getAllLocalChannels(count: Int) -> Signal<[EnginePeer.Id], NoError> {
|
||||||
|
@ -543,6 +543,7 @@ public final class PrincipalThemeAdditionalGraphics {
|
|||||||
public let chatBubbleActionButtonIncomingProfileIconImage: UIImage
|
public let chatBubbleActionButtonIncomingProfileIconImage: UIImage
|
||||||
public let chatBubbleActionButtonIncomingAddToChatIconImage: UIImage
|
public let chatBubbleActionButtonIncomingAddToChatIconImage: UIImage
|
||||||
public let chatBubbleActionButtonIncomingWebAppIconImage: UIImage
|
public let chatBubbleActionButtonIncomingWebAppIconImage: UIImage
|
||||||
|
public let chatBubbleActionButtonIncomingCopyIconImage: UIImage
|
||||||
|
|
||||||
public let chatBubbleActionButtonOutgoingMessageIconImage: UIImage
|
public let chatBubbleActionButtonOutgoingMessageIconImage: UIImage
|
||||||
public let chatBubbleActionButtonOutgoingLinkIconImage: UIImage
|
public let chatBubbleActionButtonOutgoingLinkIconImage: UIImage
|
||||||
@ -553,6 +554,7 @@ public final class PrincipalThemeAdditionalGraphics {
|
|||||||
public let chatBubbleActionButtonOutgoingProfileIconImage: UIImage
|
public let chatBubbleActionButtonOutgoingProfileIconImage: UIImage
|
||||||
public let chatBubbleActionButtonOutgoingAddToChatIconImage: UIImage
|
public let chatBubbleActionButtonOutgoingAddToChatIconImage: UIImage
|
||||||
public let chatBubbleActionButtonOutgoingWebAppIconImage: UIImage
|
public let chatBubbleActionButtonOutgoingWebAppIconImage: UIImage
|
||||||
|
public let chatBubbleActionButtonOutgoingCopyIconImage: UIImage
|
||||||
|
|
||||||
public let chatEmptyItemLockIcon: UIImage
|
public let chatEmptyItemLockIcon: UIImage
|
||||||
public let emptyChatListCheckIcon: UIImage
|
public let emptyChatListCheckIcon: UIImage
|
||||||
@ -598,6 +600,8 @@ public final class PrincipalThemeAdditionalGraphics {
|
|||||||
self.chatBubbleActionButtonIncomingProfileIconImage = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/BotProfile"), color: bubbleVariableColor(variableColor: theme.message.incoming.actionButtonsTextColor, wallpaper: wallpaper))!
|
self.chatBubbleActionButtonIncomingProfileIconImage = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/BotProfile"), color: bubbleVariableColor(variableColor: theme.message.incoming.actionButtonsTextColor, wallpaper: wallpaper))!
|
||||||
self.chatBubbleActionButtonIncomingAddToChatIconImage = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/BotAddToChat"), color: bubbleVariableColor(variableColor: theme.message.incoming.actionButtonsTextColor, wallpaper: wallpaper))!
|
self.chatBubbleActionButtonIncomingAddToChatIconImage = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/BotAddToChat"), color: bubbleVariableColor(variableColor: theme.message.incoming.actionButtonsTextColor, wallpaper: wallpaper))!
|
||||||
self.chatBubbleActionButtonIncomingWebAppIconImage = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/BotWebApp"), color: bubbleVariableColor(variableColor: theme.message.incoming.actionButtonsTextColor, wallpaper: wallpaper))!
|
self.chatBubbleActionButtonIncomingWebAppIconImage = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/BotWebApp"), color: bubbleVariableColor(variableColor: theme.message.incoming.actionButtonsTextColor, wallpaper: wallpaper))!
|
||||||
|
self.chatBubbleActionButtonIncomingCopyIconImage = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/BotCopy"), color: bubbleVariableColor(variableColor: theme.message.incoming.actionButtonsTextColor, wallpaper: wallpaper))!
|
||||||
|
|
||||||
self.chatBubbleActionButtonOutgoingMessageIconImage = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/BotMessage"), color: bubbleVariableColor(variableColor: theme.message.outgoing.actionButtonsTextColor, wallpaper: wallpaper))!
|
self.chatBubbleActionButtonOutgoingMessageIconImage = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/BotMessage"), color: bubbleVariableColor(variableColor: theme.message.outgoing.actionButtonsTextColor, wallpaper: wallpaper))!
|
||||||
self.chatBubbleActionButtonOutgoingLinkIconImage = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/BotLink"), color: bubbleVariableColor(variableColor: theme.message.outgoing.actionButtonsTextColor, wallpaper: wallpaper))!
|
self.chatBubbleActionButtonOutgoingLinkIconImage = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/BotLink"), color: bubbleVariableColor(variableColor: theme.message.outgoing.actionButtonsTextColor, wallpaper: wallpaper))!
|
||||||
self.chatBubbleActionButtonOutgoingShareIconImage = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/BotShare"), color: bubbleVariableColor(variableColor: theme.message.outgoing.actionButtonsTextColor, wallpaper: wallpaper))!
|
self.chatBubbleActionButtonOutgoingShareIconImage = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/BotShare"), color: bubbleVariableColor(variableColor: theme.message.outgoing.actionButtonsTextColor, wallpaper: wallpaper))!
|
||||||
@ -607,6 +611,7 @@ public final class PrincipalThemeAdditionalGraphics {
|
|||||||
self.chatBubbleActionButtonOutgoingProfileIconImage = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/BotProfile"), color: bubbleVariableColor(variableColor: theme.message.outgoing.actionButtonsTextColor, wallpaper: wallpaper))!
|
self.chatBubbleActionButtonOutgoingProfileIconImage = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/BotProfile"), color: bubbleVariableColor(variableColor: theme.message.outgoing.actionButtonsTextColor, wallpaper: wallpaper))!
|
||||||
self.chatBubbleActionButtonOutgoingAddToChatIconImage = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/BotAddToChat"), color: bubbleVariableColor(variableColor: theme.message.outgoing.actionButtonsTextColor, wallpaper: wallpaper))!
|
self.chatBubbleActionButtonOutgoingAddToChatIconImage = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/BotAddToChat"), color: bubbleVariableColor(variableColor: theme.message.outgoing.actionButtonsTextColor, wallpaper: wallpaper))!
|
||||||
self.chatBubbleActionButtonOutgoingWebAppIconImage = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/BotWebApp"), color: bubbleVariableColor(variableColor: theme.message.outgoing.actionButtonsTextColor, wallpaper: wallpaper))!
|
self.chatBubbleActionButtonOutgoingWebAppIconImage = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/BotWebApp"), color: bubbleVariableColor(variableColor: theme.message.outgoing.actionButtonsTextColor, wallpaper: wallpaper))!
|
||||||
|
self.chatBubbleActionButtonOutgoingCopyIconImage = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/BotCopy"), color: bubbleVariableColor(variableColor: theme.message.outgoing.actionButtonsTextColor, wallpaper: wallpaper))!
|
||||||
|
|
||||||
self.chatEmptyItemLockIcon = generateImage(CGSize(width: 9.0, height: 13.0), rotatedContext: { size, context in
|
self.chatEmptyItemLockIcon = generateImage(CGSize(width: 9.0, height: 13.0), rotatedContext: { size, context in
|
||||||
context.clear(CGRect(origin: CGPoint(), size: size))
|
context.clear(CGRect(origin: CGPoint(), size: size))
|
||||||
|
@ -438,6 +438,8 @@ public final class ChatButtonKeyboardInputNode: ChatInputNode {
|
|||||||
if let message = self.message {
|
if let message = self.message {
|
||||||
self.controllerInteraction.openRequestedPeerSelection(message.id, peerType, buttonId, maxQuantity)
|
self.controllerInteraction.openRequestedPeerSelection(message.id, peerType, buttonId, maxQuantity)
|
||||||
}
|
}
|
||||||
|
case let .copyText(payload):
|
||||||
|
self.controllerInteraction.copyText(payload)
|
||||||
}
|
}
|
||||||
if dismissIfOnce {
|
if dismissIfOnce {
|
||||||
if let message = self.message {
|
if let message = self.message {
|
||||||
|
@ -215,6 +215,8 @@ private final class ChatMessageActionButtonNode: ASDisplayNode {
|
|||||||
iconImage = incoming ? graphics.chatBubbleActionButtonIncomingProfileIconImage : graphics.chatBubbleActionButtonOutgoingProfileIconImage
|
iconImage = incoming ? graphics.chatBubbleActionButtonIncomingProfileIconImage : graphics.chatBubbleActionButtonOutgoingProfileIconImage
|
||||||
case .openWebView:
|
case .openWebView:
|
||||||
iconImage = incoming ? graphics.chatBubbleActionButtonIncomingWebAppIconImage : graphics.chatBubbleActionButtonOutgoingWebAppIconImage
|
iconImage = incoming ? graphics.chatBubbleActionButtonIncomingWebAppIconImage : graphics.chatBubbleActionButtonOutgoingWebAppIconImage
|
||||||
|
case .copyText:
|
||||||
|
iconImage = incoming ? graphics.chatBubbleActionButtonIncomingCopyIconImage : graphics.chatBubbleActionButtonOutgoingCopyIconImage
|
||||||
default:
|
default:
|
||||||
iconImage = nil
|
iconImage = nil
|
||||||
}
|
}
|
||||||
|
@ -205,6 +205,7 @@ private func contentNodeMessagesAndClassesForItem(_ item: ChatMessageItem) -> ([
|
|||||||
result.append((message, ChatMessageGiftBubbleContentNode.self, itemAttributes, BubbleItemAttributes(isAttachment: false, neighborType: .text, neighborSpacing: .default)))
|
result.append((message, ChatMessageGiftBubbleContentNode.self, itemAttributes, BubbleItemAttributes(isAttachment: false, neighborType: .text, neighborSpacing: .default)))
|
||||||
} else if case .giftStars = action.action {
|
} else if case .giftStars = action.action {
|
||||||
result.append((message, ChatMessageGiftBubbleContentNode.self, itemAttributes, BubbleItemAttributes(isAttachment: false, neighborType: .text, neighborSpacing: .default)))
|
result.append((message, ChatMessageGiftBubbleContentNode.self, itemAttributes, BubbleItemAttributes(isAttachment: false, neighborType: .text, neighborSpacing: .default)))
|
||||||
|
skipText = true
|
||||||
} else if case .suggestedProfilePhoto = action.action {
|
} else if case .suggestedProfilePhoto = action.action {
|
||||||
result.append((message, ChatMessageProfilePhotoSuggestionContentNode.self, itemAttributes, BubbleItemAttributes(isAttachment: false, neighborType: .text, neighborSpacing: .default)))
|
result.append((message, ChatMessageProfilePhotoSuggestionContentNode.self, itemAttributes, BubbleItemAttributes(isAttachment: false, neighborType: .text, neighborSpacing: .default)))
|
||||||
} else if case .setChatWallpaper = action.action {
|
} else if case .setChatWallpaper = action.action {
|
||||||
|
@ -863,6 +863,8 @@ open class ChatMessageItemView: ListViewItemNode, ChatMessageItemNodeProtocol {
|
|||||||
item.controllerInteraction.openWebView(button.title, url, simple, .generic)
|
item.controllerInteraction.openWebView(button.title, url, simple, .generic)
|
||||||
case .requestPeer:
|
case .requestPeer:
|
||||||
break
|
break
|
||||||
|
case let .copyText(payload):
|
||||||
|
item.controllerInteraction.copyText(payload)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2589,7 +2589,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let message, let adAttribute = message.attributes.first(where: { $0 is AdMessageAttribute }) as? AdMessageAttribute {
|
if let message, let adAttribute = message.attributes.first(where: { $0 is AdMessageAttribute }) as? AdMessageAttribute {
|
||||||
strongSelf.chatDisplayNode.historyNode.adMessagesContext?.markAction(opaqueId: adAttribute.opaqueId)
|
strongSelf.chatDisplayNode.historyNode.adMessagesContext?.markAction(opaqueId: adAttribute.opaqueId, media: false, fullscreen: false)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let performOpenURL = strongSelf.performOpenURL {
|
if let performOpenURL = strongSelf.performOpenURL {
|
||||||
@ -3917,7 +3917,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.chatDisplayNode.historyNode.adMessagesContext?.markAction(opaqueId: adAttribute.opaqueId)
|
self.chatDisplayNode.historyNode.adMessagesContext?.markAction(opaqueId: adAttribute.opaqueId, media: false, fullscreen: false)
|
||||||
self.controllerInteraction?.openUrl(ChatControllerInteraction.OpenUrl(url: adAttribute.url, concealed: false, external: true, progress: progress))
|
self.controllerInteraction?.openUrl(ChatControllerInteraction.OpenUrl(url: adAttribute.url, concealed: false, external: true, progress: progress))
|
||||||
}, openRequestedPeerSelection: { [weak self] messageId, peerType, buttonId, maxQuantity in
|
}, openRequestedPeerSelection: { [weak self] messageId, peerType, buttonId, maxQuantity in
|
||||||
guard let self else {
|
guard let self else {
|
||||||
|
@ -971,6 +971,8 @@ final class ChatPinnedMessageTitlePanelNode: ChatTitleAccessoryPanelNode {
|
|||||||
controllerInteraction.openWebView(button.title, url, simple, .generic)
|
controllerInteraction.openWebView(button.title, url, simple, .generic)
|
||||||
case .requestPeer:
|
case .requestPeer:
|
||||||
break
|
break
|
||||||
|
case let .copyText(payload):
|
||||||
|
controllerInteraction.copyText(payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
break
|
break
|
||||||
|
Loading…
x
Reference in New Issue
Block a user