mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Video Stickers Fixes
This commit is contained in:
parent
8f74c6be76
commit
a506cbf7cf
@ -117,7 +117,7 @@ func _internal_searchStickers(account: Account, query: String, scope: SearchStic
|
|||||||
matchingRecentItemsIds.insert(file.fileId)
|
matchingRecentItemsIds.insert(file.fileId)
|
||||||
}
|
}
|
||||||
recentItemsIds.insert(file.fileId)
|
recentItemsIds.insert(file.fileId)
|
||||||
if file.isAnimatedSticker {
|
if file.isAnimatedSticker || file.isVideoSticker {
|
||||||
recentAnimatedItems.append(file)
|
recentAnimatedItems.append(file)
|
||||||
} else {
|
} else {
|
||||||
recentItems.append(file)
|
recentItems.append(file)
|
||||||
@ -147,7 +147,7 @@ func _internal_searchStickers(account: Account, query: String, scope: SearchStic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !recentItemsIds.contains(item.file.fileId) {
|
if !recentItemsIds.contains(item.file.fileId) {
|
||||||
if item.file.isAnimatedSticker {
|
if item.file.isAnimatedSticker || item.file.isVideoSticker {
|
||||||
installedAnimatedItems.append(FoundStickerItem(file: item.file, stringRepresentations: stringRepresentations))
|
installedAnimatedItems.append(FoundStickerItem(file: item.file, stringRepresentations: stringRepresentations))
|
||||||
} else {
|
} else {
|
||||||
installedItems.append(FoundStickerItem(file: item.file, stringRepresentations: stringRepresentations))
|
installedItems.append(FoundStickerItem(file: item.file, stringRepresentations: stringRepresentations))
|
||||||
@ -199,7 +199,7 @@ func _internal_searchStickers(account: Account, query: String, scope: SearchStic
|
|||||||
|
|
||||||
for file in cached.items {
|
for file in cached.items {
|
||||||
if !currentItemIds.contains(file.fileId) {
|
if !currentItemIds.contains(file.fileId) {
|
||||||
if file.isAnimatedSticker {
|
if file.isAnimatedSticker || file.isVideoSticker {
|
||||||
cachedAnimatedItems.append(FoundStickerItem(file: file, stringRepresentations: []))
|
cachedAnimatedItems.append(FoundStickerItem(file: file, stringRepresentations: []))
|
||||||
} else {
|
} else {
|
||||||
cachedItems.append(FoundStickerItem(file: file, stringRepresentations: []))
|
cachedItems.append(FoundStickerItem(file: file, stringRepresentations: []))
|
||||||
@ -230,7 +230,7 @@ func _internal_searchStickers(account: Account, query: String, scope: SearchStic
|
|||||||
if let file = telegramMediaFileFromApiDocument(sticker), let id = file.id {
|
if let file = telegramMediaFileFromApiDocument(sticker), let id = file.id {
|
||||||
files.append(file)
|
files.append(file)
|
||||||
if !currentItemIds.contains(id) {
|
if !currentItemIds.contains(id) {
|
||||||
if file.isAnimatedSticker {
|
if file.isAnimatedSticker || file.isVideoSticker {
|
||||||
animatedItems.append(FoundStickerItem(file: file, stringRepresentations: []))
|
animatedItems.append(FoundStickerItem(file: file, stringRepresentations: []))
|
||||||
} else {
|
} else {
|
||||||
items.append(FoundStickerItem(file: file, stringRepresentations: []))
|
items.append(FoundStickerItem(file: file, stringRepresentations: []))
|
||||||
|
@ -440,7 +440,10 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
unboundSize = CGSize(width: floor(dimensions.cgSize.width * 0.5), height: floor(dimensions.cgSize.height * 0.5))
|
unboundSize = CGSize(width: floor(dimensions.cgSize.width * 0.5), height: floor(dimensions.cgSize.height * 0.5))
|
||||||
if file.isAnimated {
|
if file.isSticker || file.isAnimatedSticker || file.isVideoSticker {
|
||||||
|
unboundSize = unboundSize.aspectFilled(CGSize(width: 162.0, height: 162.0))
|
||||||
|
isSticker = true
|
||||||
|
} else if file.isAnimated {
|
||||||
unboundSize = unboundSize.aspectFilled(CGSize(width: 480.0, height: 480.0))
|
unboundSize = unboundSize.aspectFilled(CGSize(width: 480.0, height: 480.0))
|
||||||
} else if file.isVideo && !file.isAnimated, case let .constrained(constrainedSize) = sizeCalculation {
|
} else if file.isVideo && !file.isAnimated, case let .constrained(constrainedSize) = sizeCalculation {
|
||||||
if unboundSize.width > unboundSize.height {
|
if unboundSize.width > unboundSize.height {
|
||||||
@ -449,9 +452,6 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
|
|||||||
maxDimensions = CGSize(width: constrainedSize.width, height: layoutConstants.video.maxVerticalHeight)
|
maxDimensions = CGSize(width: constrainedSize.width, height: layoutConstants.video.maxVerticalHeight)
|
||||||
}
|
}
|
||||||
maxHeight = maxDimensions.height
|
maxHeight = maxDimensions.height
|
||||||
} else if file.isSticker || file.isAnimatedSticker {
|
|
||||||
unboundSize = unboundSize.aspectFilled(CGSize(width: 162.0, height: 162.0))
|
|
||||||
isSticker = true
|
|
||||||
}
|
}
|
||||||
isInlinePlayableVideo = file.isVideo && !isSecretMedia
|
isInlinePlayableVideo = file.isVideo && !isSecretMedia
|
||||||
} else if let image = media as? TelegramMediaWebFile, let dimensions = image.dimensions {
|
} else if let image = media as? TelegramMediaWebFile, let dimensions = image.dimensions {
|
||||||
@ -712,7 +712,7 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
|
|||||||
updateImageSignal = { synchronousLoad, _ in
|
updateImageSignal = { synchronousLoad, _ in
|
||||||
return chatMessageAnimatedSticker(postbox: context.account.postbox, file: file, small: false, size: dimensions.cgSize.aspectFitted(CGSize(width: 400.0, height: 400.0)))
|
return chatMessageAnimatedSticker(postbox: context.account.postbox, file: file, small: false, size: dimensions.cgSize.aspectFitted(CGSize(width: 400.0, height: 400.0)))
|
||||||
}
|
}
|
||||||
} else if file.isSticker {
|
} else if file.isSticker || file.isVideoSticker {
|
||||||
updateImageSignal = { synchronousLoad, _ in
|
updateImageSignal = { synchronousLoad, _ in
|
||||||
return chatMessageSticker(account: context.account, file: file, small: false)
|
return chatMessageSticker(account: context.account, file: file, small: false)
|
||||||
}
|
}
|
||||||
@ -729,7 +729,7 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
|
|||||||
uploading = true
|
uploading = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if file.isVideo && !isSecretMedia && automaticPlayback && !uploading {
|
if file.isVideo && !file.isVideoSticker && !isSecretMedia && automaticPlayback && !uploading {
|
||||||
updateVideoFile = file
|
updateVideoFile = file
|
||||||
if hasCurrentVideoNode {
|
if hasCurrentVideoNode {
|
||||||
if let currentFile = currentMedia as? TelegramMediaFile {
|
if let currentFile = currentMedia as? TelegramMediaFile {
|
||||||
@ -751,7 +751,7 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
|
|||||||
replaceVideoNode = false
|
replaceVideoNode = false
|
||||||
}
|
}
|
||||||
|
|
||||||
if file.isAnimatedSticker {
|
if file.isAnimatedSticker || file.isVideoSticker {
|
||||||
updateAnimatedStickerFile = file
|
updateAnimatedStickerFile = file
|
||||||
if hasCurrentAnimatedStickerNode {
|
if hasCurrentAnimatedStickerNode {
|
||||||
if let currentMedia = currentMedia {
|
if let currentMedia = currentMedia {
|
||||||
@ -871,6 +871,8 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let arguments = TransformImageArguments(corners: corners, imageSize: drawingSize, boundingSize: boundingSize, intrinsicInsets: UIEdgeInsets(), resizeMode: isInlinePlayableVideo ? .fill(.black) : .blurBackground, emptyColor: emptyColor, custom: patternArguments)
|
let arguments = TransformImageArguments(corners: corners, imageSize: drawingSize, boundingSize: boundingSize, intrinsicInsets: UIEdgeInsets(), resizeMode: isInlinePlayableVideo ? .fill(.black) : .blurBackground, emptyColor: emptyColor, custom: patternArguments)
|
||||||
|
|
||||||
let imageFrame = CGRect(origin: CGPoint(x: -arguments.insets.left, y: -arguments.insets.top), size: arguments.drawingSize).ensuredValid
|
let imageFrame = CGRect(origin: CGPoint(x: -arguments.insets.left, y: -arguments.insets.top), size: arguments.drawingSize).ensuredValid
|
||||||
@ -1200,14 +1202,14 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
|
|||||||
} else if let fetchStatus = self.fetchStatus {
|
} else if let fetchStatus = self.fetchStatus {
|
||||||
switch fetchStatus {
|
switch fetchStatus {
|
||||||
case .Local:
|
case .Local:
|
||||||
if let file = media as? TelegramMediaFile, file.isVideo {
|
if let file = media as? TelegramMediaFile, file.isVideo && !file.isVideoSticker {
|
||||||
progressRequired = true
|
progressRequired = true
|
||||||
} else if isSecretMedia {
|
} else if isSecretMedia {
|
||||||
progressRequired = true
|
progressRequired = true
|
||||||
} else if let webpage = webpage, case let .Loaded(content) = webpage.content {
|
} else if let webpage = webpage, case let .Loaded(content) = webpage.content {
|
||||||
if content.embedUrl != nil {
|
if content.embedUrl != nil {
|
||||||
progressRequired = true
|
progressRequired = true
|
||||||
} else if let file = content.file, file.isVideo, !file.isAnimated {
|
} else if let file = content.file, file.isVideo, !file.isAnimated && !file.isVideoSticker {
|
||||||
progressRequired = true
|
progressRequired = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1335,7 +1337,10 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let file = self.media as? TelegramMediaFile {
|
if let file = self.media as? TelegramMediaFile {
|
||||||
if wideLayout {
|
if file.isVideoSticker {
|
||||||
|
state = .none
|
||||||
|
badgeContent = nil
|
||||||
|
} else if wideLayout {
|
||||||
if let size = file.size {
|
if let size = file.size {
|
||||||
let sizeString = "\(dataSizeString(Int(Float(size) * progress), forceDecimal: true, formatting: formatting)) / \(dataSizeString(size, forceDecimal: true, formatting: formatting))"
|
let sizeString = "\(dataSizeString(Int(Float(size) * progress), forceDecimal: true, formatting: formatting)) / \(dataSizeString(size, forceDecimal: true, formatting: formatting))"
|
||||||
if let duration = file.duration, !message.flags.contains(.Unsent) {
|
if let duration = file.duration, !message.flags.contains(.Unsent) {
|
||||||
@ -1425,7 +1430,7 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
|
|||||||
state = .secretTimeout(color: messageTheme.mediaOverlayControlColors.foregroundColor, icon: secretProgressIcon, beginTime: beginTime, timeout: timeout, sparks: true)
|
state = .secretTimeout(color: messageTheme.mediaOverlayControlColors.foregroundColor, icon: secretProgressIcon, beginTime: beginTime, timeout: timeout, sparks: true)
|
||||||
} else if isSecretMedia, let secretProgressIcon = secretProgressIcon {
|
} else if isSecretMedia, let secretProgressIcon = secretProgressIcon {
|
||||||
state = .customIcon(secretProgressIcon)
|
state = .customIcon(secretProgressIcon)
|
||||||
} else if let file = media as? TelegramMediaFile {
|
} else if let file = media as? TelegramMediaFile, !file.isVideoSticker {
|
||||||
let isInlinePlayableVideo = file.isVideo && !isSecretMedia && (self.automaticPlayback ?? false)
|
let isInlinePlayableVideo = file.isVideo && !isSecretMedia && (self.automaticPlayback ?? false)
|
||||||
if !isInlinePlayableVideo && file.isVideo {
|
if !isInlinePlayableVideo && file.isVideo {
|
||||||
state = .play(messageTheme.mediaOverlayControlColors.foregroundColor)
|
state = .play(messageTheme.mediaOverlayControlColors.foregroundColor)
|
||||||
@ -1439,13 +1444,13 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
|
|||||||
state = .play(messageTheme.mediaOverlayControlColors.foregroundColor)
|
state = .play(messageTheme.mediaOverlayControlColors.foregroundColor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let file = media as? TelegramMediaFile, let duration = file.duration {
|
if let file = media as? TelegramMediaFile, let duration = file.duration, !file.isVideoSticker {
|
||||||
let durationString = file.isAnimated ? gifTitle : stringForDuration(playerDuration > 0 ? playerDuration : duration, position: playerPosition)
|
let durationString = file.isAnimated ? gifTitle : stringForDuration(playerDuration > 0 ? playerDuration : duration, position: playerPosition)
|
||||||
badgeContent = .mediaDownload(backgroundColor: messageTheme.mediaDateAndStatusFillColor, foregroundColor: messageTheme.mediaDateAndStatusTextColor, duration: durationString, size: nil, muted: muted, active: false)
|
badgeContent = .mediaDownload(backgroundColor: messageTheme.mediaDateAndStatusFillColor, foregroundColor: messageTheme.mediaDateAndStatusTextColor, duration: durationString, size: nil, muted: muted, active: false)
|
||||||
}
|
}
|
||||||
case .Remote:
|
case .Remote:
|
||||||
state = .download(messageTheme.mediaOverlayControlColors.foregroundColor)
|
state = .download(messageTheme.mediaOverlayControlColors.foregroundColor)
|
||||||
if let file = self.media as? TelegramMediaFile {
|
if let file = self.media as? TelegramMediaFile, !file.isVideoSticker {
|
||||||
do {
|
do {
|
||||||
let durationString = file.isAnimated ? gifTitle : stringForDuration(playerDuration > 0 ? playerDuration : (file.duration ?? 0), position: playerPosition)
|
let durationString = file.isAnimated ? gifTitle : stringForDuration(playerDuration > 0 ? playerDuration : (file.duration ?? 0), position: playerPosition)
|
||||||
if wideLayout {
|
if wideLayout {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user