Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios

This commit is contained in:
Ilya Laktyushin 2023-01-02 23:20:01 +04:00
commit 547f844ebc
7 changed files with 87 additions and 142 deletions

View File

@ -31,12 +31,8 @@ public func reactionStaticImage(context: AccountContext, animation: TelegramMedi
} }
var customColor: UIColor? var customColor: UIColor?
for attribute in animation.attributes { if animation.isCustomTemplateEmoji {
if case let .CustomEmoji(_, isSingleColor, _, _) = attribute { customColor = nil
if isSingleColor {
customColor = nil
}
}
} }
let fetchFrame = animationCacheFetchFile(context: context, userLocation: .other, userContentType: .sticker, resource: MediaResourceReference.standalone(resource: animation.resource), type: type, keyframeOnly: true, customColor: customColor) let fetchFrame = animationCacheFetchFile(context: context, userLocation: .other, userContentType: .sticker, resource: MediaResourceReference.standalone(resource: animation.resource), type: type, keyframeOnly: true, customColor: customColor)

View File

@ -651,6 +651,26 @@ public final class TelegramMediaFile: Media, Equatable, Codable {
return hasSticker return hasSticker
} }
public var isCustomTemplateEmoji: Bool {
for attribute in self.attributes {
if case let .CustomEmoji(_, isSingleColor, _, packReference) = attribute, let packReference = packReference {
if isSingleColor {
return true
}
switch packReference {
case let .id(id, _):
if id == 1269403972611866647 {
return true
}
default:
break
}
break
}
}
return false
}
public var isPremiumEmoji: Bool { public var isPremiumEmoji: Bool {
for attribute in self.attributes { for attribute in self.attributes {
if case let .CustomEmoji(isPremium, _, _, _) = attribute { if case let .CustomEmoji(isPremium, _, _, _) = attribute {

View File

@ -442,11 +442,11 @@ public final class EmojiStatusComponent: Component {
var accentTint = false var accentTint = false
if let _ = emojiThemeColor { if let _ = emojiThemeColor {
if emojiFile.isCustomTemplateEmoji {
accentTint = true
}
for attribute in emojiFile.attributes { for attribute in emojiFile.attributes {
if case let .CustomEmoji(_, isSingleColor, _, packReference) = attribute { if case let .CustomEmoji(_, _, _, packReference) = attribute {
if isSingleColor {
accentTint = true
}
switch packReference { switch packReference {
case let .id(id, _): case let .id(id, _):
if id == 773947703670341676 || id == 2964141614563343 { if id == 773947703670341676 || id == 2964141614563343 {

View File

@ -651,11 +651,11 @@ public final class EmojiStatusSelectionController: ViewController {
effectView = view effectView = view
} else if let itemFile = item.itemFile { } else if let itemFile = item.itemFile {
var useCleanEffect = false var useCleanEffect = false
if itemFile.isCustomTemplateEmoji {
useCleanEffect = true
}
for attribute in itemFile.attributes { for attribute in itemFile.attributes {
if case let .CustomEmoji(_, isSingleColor, _, packReference) = attribute { if case let .CustomEmoji(_, _, _, packReference) = attribute {
if isSingleColor {
useCleanEffect = true
}
switch packReference { switch packReference {
case let .id(id, _): case let .id(id, _):
if id == 773947703670341676 || id == 2964141614563343 { if id == 773947703670341676 || id == 2964141614563343 {

View File

@ -253,12 +253,8 @@ public final class InlineStickerItemLayer: MultiAnimationRenderTarget {
if !self.isDisplayingPlaceholder { if !self.isDisplayingPlaceholder {
var customColor = self.contentTintColor var customColor = self.contentTintColor
if let file = self.file { if let file = self.file {
for attribute in file.attributes { if file.isCustomTemplateEmoji {
if case let .CustomEmoji(_, isSingleColor, _, _) = attribute { customColor = self.dynamicColor
if isSingleColor {
customColor = self.dynamicColor
}
}
} }
} }
@ -334,12 +330,7 @@ public final class InlineStickerItemLayer: MultiAnimationRenderTarget {
self.loadAnimation() self.loadAnimation()
} else { } else {
var isTemplate = false let isTemplate = file.isCustomTemplateEmoji
for attribute in file.attributes {
if case let .CustomEmoji(_, isSingleColor, _, _) = attribute {
isTemplate = isSingleColor
}
}
let pointSize = self.pointSize let pointSize = self.pointSize
let placeholderColor = self.placeholderColor let placeholderColor = self.placeholderColor
@ -380,12 +371,7 @@ public final class InlineStickerItemLayer: MultiAnimationRenderTarget {
return return
} }
var isTemplate = false let isTemplate = file.isCustomTemplateEmoji
for attribute in file.attributes {
if case let .CustomEmoji(_, isSingleColor, _, _) = attribute {
isTemplate = isSingleColor
}
}
let context = self.context let context = self.context
if file.isAnimatedSticker || file.isVideoEmoji { if file.isAnimatedSticker || file.isVideoEmoji {

View File

@ -243,12 +243,7 @@ public final class EntityKeyboardAnimationData: Equatable {
} else { } else {
type = .still type = .still
} }
var isTemplate = false let isTemplate = file.isCustomTemplateEmoji
for attribute in file.attributes {
if case let .CustomEmoji(_, isSingleColor, _, _) = attribute {
isTemplate = isSingleColor
}
}
self.init(id: .file(file.fileId), type: type, resource: .standalone(resource: file.resource), dimensions: file.dimensions?.cgSize ?? CGSize(width: 512.0, height: 512.0), immediateThumbnailData: file.immediateThumbnailData, isReaction: isReaction, isTemplate: isTemplate) self.init(id: .file(file.fileId), type: type, resource: .standalone(resource: file.resource), dimensions: file.dimensions?.cgSize ?? CGSize(width: 512.0, height: 512.0), immediateThumbnailData: file.immediateThumbnailData, isReaction: isReaction, isTemplate: isTemplate)
} }
@ -6442,11 +6437,11 @@ public final class EmojiPagerContentComponent: Component {
existingIds.insert(file.fileId) existingIds.insert(file.fileId)
var tintMode: Item.TintMode = .none var tintMode: Item.TintMode = .none
if file.isCustomTemplateEmoji {
tintMode = .accent
}
for attribute in file.attributes { for attribute in file.attributes {
if case let .CustomEmoji(_, isSingleColor, _, packReference) = attribute { if case let .CustomEmoji(_, _, _, packReference) = attribute {
if isSingleColor {
tintMode = .accent
}
switch packReference { switch packReference {
case let .id(id, _): case let .id(id, _):
if id == 773947703670341676 || id == 2964141614563343 { if id == 773947703670341676 || id == 2964141614563343 {
@ -6501,11 +6496,11 @@ public final class EmojiPagerContentComponent: Component {
existingIds.insert(file.fileId) existingIds.insert(file.fileId)
var tintMode: Item.TintMode = .none var tintMode: Item.TintMode = .none
if file.isCustomTemplateEmoji {
tintMode = .accent
}
for attribute in file.attributes { for attribute in file.attributes {
if case let .CustomEmoji(_, isSingleColor, _, packReference) = attribute { if case let .CustomEmoji(_, _, _, packReference) = attribute {
if isSingleColor {
tintMode = .accent
}
switch packReference { switch packReference {
case let .id(id, _): case let .id(id, _):
if id == 773947703670341676 || id == 2964141614563343 { if id == 773947703670341676 || id == 2964141614563343 {
@ -6547,11 +6542,11 @@ public final class EmojiPagerContentComponent: Component {
existingIds.insert(file.fileId) existingIds.insert(file.fileId)
var tintMode: Item.TintMode = .none var tintMode: Item.TintMode = .none
if file.isCustomTemplateEmoji {
tintMode = .accent
}
for attribute in file.attributes { for attribute in file.attributes {
if case let .CustomEmoji(_, isSingleColor, _, packReference) = attribute { if case let .CustomEmoji(_, _, _, packReference) = attribute {
if isSingleColor {
tintMode = .accent
}
switch packReference { switch packReference {
case let .id(id, _): case let .id(id, _):
if id == 773947703670341676 || id == 2964141614563343 { if id == 773947703670341676 || id == 2964141614563343 {
@ -6599,11 +6594,11 @@ public final class EmojiPagerContentComponent: Component {
let resultItem: EmojiPagerContentComponent.Item let resultItem: EmojiPagerContentComponent.Item
var tintMode: Item.TintMode = .none var tintMode: Item.TintMode = .none
if file.isCustomTemplateEmoji {
tintMode = .accent
}
for attribute in file.attributes { for attribute in file.attributes {
if case let .CustomEmoji(_, isSingleColor, _, packReference) = attribute { if case let .CustomEmoji(_, _, _, packReference) = attribute {
if isSingleColor {
tintMode = .accent
}
switch packReference { switch packReference {
case let .id(id, _): case let .id(id, _):
if id == 773947703670341676 || id == 2964141614563343 { if id == 773947703670341676 || id == 2964141614563343 {
@ -6680,12 +6675,8 @@ public final class EmojiPagerContentComponent: Component {
} }
var tintMode: Item.TintMode = .none var tintMode: Item.TintMode = .none
for attribute in reactionItem.file.attributes { if reactionItem.file.isCustomTemplateEmoji {
if case let .CustomEmoji(_, isSingleColor, _, _) = attribute { tintMode = .primary
if isSingleColor {
tintMode = .primary
}
}
} }
let animationFile = reactionItem.file let animationFile = reactionItem.file
@ -6744,12 +6735,8 @@ public final class EmojiPagerContentComponent: Component {
} }
var tintMode: Item.TintMode = .none var tintMode: Item.TintMode = .none
for attribute in reactionItem.selectAnimation.attributes { if reactionItem.selectAnimation.isCustomTemplateEmoji {
if case let .CustomEmoji(_, isSingleColor, _, _) = attribute { tintMode = .primary
if isSingleColor {
tintMode = .primary
}
}
} }
let animationFile = reactionItem.selectAnimation let animationFile = reactionItem.selectAnimation
@ -6829,12 +6816,8 @@ public final class EmojiPagerContentComponent: Component {
} }
var tintMode: Item.TintMode = .none var tintMode: Item.TintMode = .none
for attribute in animationFile.attributes { if animationFile.isCustomTemplateEmoji {
if case let .CustomEmoji(_, isSingleColor, _, _) = attribute { tintMode = .primary
if isSingleColor {
tintMode = .primary
}
}
} }
let animationData = EntityKeyboardAnimationData(file: animationFile, isReaction: true) let animationData = EntityKeyboardAnimationData(file: animationFile, isReaction: true)
@ -6881,12 +6864,8 @@ public final class EmojiPagerContentComponent: Component {
switch item.content { switch item.content {
case let .file(file): case let .file(file):
var tintMode: Item.TintMode = .none var tintMode: Item.TintMode = .none
for attribute in file.attributes { if file.isCustomTemplateEmoji {
if case let .CustomEmoji(_, isSingleColor, _, _) = attribute { tintMode = .primary
if isSingleColor {
tintMode = .primary
}
}
} }
let animationData = EntityKeyboardAnimationData(file: file) let animationData = EntityKeyboardAnimationData(file: file)
@ -6936,15 +6915,11 @@ public final class EmojiPagerContentComponent: Component {
} }
var tintMode: Item.TintMode = .none var tintMode: Item.TintMode = .none
for attribute in item.file.attributes { if item.file.isCustomTemplateEmoji {
if case let .CustomEmoji(_, isSingleColor, _, _) = attribute { if isStatusSelection {
if isSingleColor { tintMode = .accent
if isStatusSelection { } else {
tintMode = .accent tintMode = .primary
} else {
tintMode = .primary
}
}
} }
} }
@ -7011,15 +6986,11 @@ public final class EmojiPagerContentComponent: Component {
for item in featuredEmojiPack.topItems { for item in featuredEmojiPack.topItems {
var tintMode: Item.TintMode = .none var tintMode: Item.TintMode = .none
for attribute in item.file.attributes { if item.file.isCustomTemplateEmoji {
if case let .CustomEmoji(_, isSingleColor, _, _) = attribute { if isStatusSelection {
if isSingleColor { tintMode = .accent
if isStatusSelection { } else {
tintMode = .accent tintMode = .primary
} else {
tintMode = .primary
}
}
} }
} }
@ -7307,12 +7278,8 @@ public final class EmojiPagerContentComponent: Component {
} }
var tintMode: Item.TintMode = .none var tintMode: Item.TintMode = .none
for attribute in item.file.attributes { if item.file.isCustomTemplateEmoji {
if case let .CustomEmoji(_, isSingleColor, _, _) = attribute { tintMode = .primary
if isSingleColor {
tintMode = .primary
}
}
} }
let resultItem = EmojiPagerContentComponent.Item( let resultItem = EmojiPagerContentComponent.Item(
@ -7353,12 +7320,8 @@ public final class EmojiPagerContentComponent: Component {
} }
var tintMode: Item.TintMode = .none var tintMode: Item.TintMode = .none
for attribute in item.file.attributes { if item.file.isCustomTemplateEmoji {
if case let .CustomEmoji(_, isSingleColor, _, _) = attribute { tintMode = .primary
if isSingleColor {
tintMode = .primary
}
}
} }
let animationData = EntityKeyboardAnimationData(file: item.file) let animationData = EntityKeyboardAnimationData(file: item.file)
@ -7391,12 +7354,8 @@ public final class EmojiPagerContentComponent: Component {
} }
var tintMode: Item.TintMode = .none var tintMode: Item.TintMode = .none
for attribute in item.media.attributes { if item.media.isCustomTemplateEmoji {
if case let .CustomEmoji(_, isSingleColor, _, _) = attribute { tintMode = .primary
if isSingleColor {
tintMode = .primary
}
}
} }
let animationData = EntityKeyboardAnimationData(file: item.media) let animationData = EntityKeyboardAnimationData(file: item.media)
@ -7452,12 +7411,8 @@ public final class EmojiPagerContentComponent: Component {
processedIds.insert(item.file.fileId) processedIds.insert(item.file.fileId)
var tintMode: Item.TintMode = .none var tintMode: Item.TintMode = .none
for attribute in item.file.attributes { if item.file.isCustomTemplateEmoji {
if case let .CustomEmoji(_, isSingleColor, _, _) = attribute { tintMode = .primary
if isSingleColor {
tintMode = .primary
}
}
} }
let animationData = EntityKeyboardAnimationData(file: item.file) let animationData = EntityKeyboardAnimationData(file: item.file)
@ -7495,12 +7450,8 @@ public final class EmojiPagerContentComponent: Component {
processedIds.insert(item.file.fileId) processedIds.insert(item.file.fileId)
var tintMode: Item.TintMode = .none var tintMode: Item.TintMode = .none
for attribute in item.file.attributes { if item.file.isCustomTemplateEmoji {
if case let .CustomEmoji(_, isSingleColor, _, _) = attribute { tintMode = .primary
if isSingleColor {
tintMode = .primary
}
}
} }
let animationData = EntityKeyboardAnimationData(file: item.file) let animationData = EntityKeyboardAnimationData(file: item.file)
@ -7529,12 +7480,8 @@ public final class EmojiPagerContentComponent: Component {
} }
var tintMode: Item.TintMode = .none var tintMode: Item.TintMode = .none
for attribute in item.file.attributes { if item.file.isCustomTemplateEmoji {
if case let .CustomEmoji(_, isSingleColor, _, _) = attribute { tintMode = .primary
if isSingleColor {
tintMode = .primary
}
}
} }
let animationData = EntityKeyboardAnimationData(file: item.file) let animationData = EntityKeyboardAnimationData(file: item.file)
@ -7593,12 +7540,8 @@ public final class EmojiPagerContentComponent: Component {
for item in featuredStickerPack.topItems { for item in featuredStickerPack.topItems {
var tintMode: Item.TintMode = .none var tintMode: Item.TintMode = .none
for attribute in item.file.attributes { if item.file.isCustomTemplateEmoji {
if case let .CustomEmoji(_, isSingleColor, _, _) = attribute { tintMode = .primary
if isSingleColor {
tintMode = .primary
}
}
} }
let animationData = EntityKeyboardAnimationData(file: item.file) let animationData = EntityKeyboardAnimationData(file: item.file)

View File

@ -79,11 +79,11 @@ private func callConnectionDescriptionsWebrtc(_ connection: CallSessionConnectio
guard let id = idMapping[reflector.id] else { guard let id = idMapping[reflector.id] else {
return [] return []
} }
#if DEBUG /*#if DEBUG
if id != 1 { if id != 1 {
return [] return []
} }
#endif #endif*/
var result: [OngoingCallConnectionDescriptionWebrtc] = [] var result: [OngoingCallConnectionDescriptionWebrtc] = []
if !reflector.ip.isEmpty { if !reflector.ip.isEmpty {
result.append(OngoingCallConnectionDescriptionWebrtc(reflectorId: id, hasStun: false, hasTurn: true, hasTcp: reflector.isTcp, ip: reflector.ip, port: reflector.port, username: "reflector", password: hexString(reflector.peerTag))) result.append(OngoingCallConnectionDescriptionWebrtc(reflectorId: id, hasStun: false, hasTurn: true, hasTcp: reflector.isTcp, ip: reflector.ip, port: reflector.port, username: "reflector", password: hexString(reflector.peerTag)))
@ -93,11 +93,11 @@ private func callConnectionDescriptionsWebrtc(_ connection: CallSessionConnectio
} }
return result return result
case let .webRtcReflector(reflector): case let .webRtcReflector(reflector):
#if DEBUG /*#if DEBUG
if "".isEmpty { if "".isEmpty {
return [] return []
} }
#endif #endif*/
var result: [OngoingCallConnectionDescriptionWebrtc] = [] var result: [OngoingCallConnectionDescriptionWebrtc] = []
if !reflector.ip.isEmpty { if !reflector.ip.isEmpty {
result.append(OngoingCallConnectionDescriptionWebrtc(reflectorId: 0, hasStun: reflector.hasStun, hasTurn: reflector.hasTurn, hasTcp: false, ip: reflector.ip, port: reflector.port, username: reflector.username, password: reflector.password)) result.append(OngoingCallConnectionDescriptionWebrtc(reflectorId: 0, hasStun: reflector.hasStun, hasTurn: reflector.hasTurn, hasTcp: false, ip: reflector.ip, port: reflector.port, username: reflector.username, password: reflector.password))