mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Chat Import: experimental features
This commit is contained in:
parent
cef863ec37
commit
a5a9980161
@ -23,6 +23,7 @@ swift_library(
|
||||
"//submodules/ChatHistoryImportTasks:ChatHistoryImportTasks",
|
||||
"//submodules/MimeTypes:MimeTypes",
|
||||
"//submodules/ConfettiEffect:ConfettiEffect",
|
||||
"//submodules/TelegramUniversalVideoContent:TelegramUniversalVideoContent",
|
||||
],
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
|
@ -14,6 +14,7 @@ import AppBundle
|
||||
import ZIPFoundation
|
||||
import MimeTypes
|
||||
import ConfettiEffect
|
||||
import TelegramUniversalVideoContent
|
||||
|
||||
public final class ChatImportActivityScreen: ViewController {
|
||||
private final class Node: ViewControllerTracingNode {
|
||||
@ -40,6 +41,7 @@ public final class ChatImportActivityScreen: ViewController {
|
||||
private let totalBytes: Int
|
||||
private var isDone: Bool = false
|
||||
|
||||
private var videoNode: UniversalVideoNode?
|
||||
private var feedback: HapticFeedback?
|
||||
|
||||
init(controller: ChatImportActivityScreen, context: AccountContext, totalBytes: Int) {
|
||||
@ -138,6 +140,23 @@ public final class ChatImportActivityScreen: ViewController {
|
||||
strongSelf.doneAnimationNode.visibility = true
|
||||
strongSelf.doneAnimationNode.isHidden = false
|
||||
}
|
||||
|
||||
if let path = getAppBundle().path(forResource: "BlankVideo", ofType: "m4v"), let size = fileSize(path) {
|
||||
let decoration = ChatBubbleVideoDecoration(corners: ImageCorners(), nativeSize: CGSize(width: 100.0, height: 100.0), contentMode: .aspectFit, backgroundColor: .black)
|
||||
|
||||
let dummyFile = TelegramMediaFile(fileId: MediaId(namespace: 0, id: 1), partialReference: nil, resource: LocalFileReferenceMediaResource(localFilePath: path, randomId: 12345), previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "video/mp4", size: size, attributes: [.Video(duration: 1, size: PixelDimensions(width: 100, height: 100), flags: [])])
|
||||
|
||||
let videoContent = NativeVideoContent(id: .message(1, MediaId(namespace: 0, id: 1)), fileReference: .standalone(media: dummyFile), streamVideo: .none, loopVideo: true, enableSound: false, fetchAutomatically: true, onlyFullSizeThumbnail: false, continuePlayingWithoutSoundOnLostAudioSession: false, placeholderColor: .black)
|
||||
|
||||
let videoNode = UniversalVideoNode(postbox: context.account.postbox, audioSession: context.sharedContext.mediaManager.audioSession, manager: context.sharedContext.mediaManager.universalVideoManager, decoration: decoration, content: videoContent, priority: .embedded)
|
||||
videoNode.frame = CGRect(origin: CGPoint(), size: CGSize(width: 2.0, height: 2.0))
|
||||
videoNode.alpha = 0.01
|
||||
self.videoNode = videoNode
|
||||
|
||||
self.addSubnode(videoNode)
|
||||
videoNode.canAttachContent = true
|
||||
videoNode.play()
|
||||
}
|
||||
}
|
||||
|
||||
@objc private func statusButtonPressed() {
|
||||
|
BIN
submodules/TelegramUI/Resources/BlankVideo.m4v
Normal file
BIN
submodules/TelegramUI/Resources/BlankVideo.m4v
Normal file
Binary file not shown.
@ -415,12 +415,31 @@ public class ShareRootControllerImpl {
|
||||
beginShare()
|
||||
return
|
||||
}
|
||||
guard let _ = archive["_chat.txt"] else {
|
||||
|
||||
let mainFileNames: [NSRegularExpression] = [
|
||||
try! NSRegularExpression(pattern: "_chat\\.txt"),
|
||||
try! NSRegularExpression(pattern: "KakaoTalkChats\\.txt"),
|
||||
try! NSRegularExpression(pattern: "Talk_.*?\\.txt"),
|
||||
]
|
||||
|
||||
var maybeMainFileName: String?
|
||||
mainFileLoop: for entry in archive {
|
||||
let entryFileName = entry.path(using: .utf8).replacingOccurrences(of: "/", with: "_").replacingOccurrences(of: "..", with: "_")
|
||||
let fullRange = NSRange(entryFileName.startIndex ..< entryFileName.endIndex, in: entryFileName)
|
||||
for expression in mainFileNames {
|
||||
if expression.firstMatch(in: entryFileName, options: [], range: fullRange) != nil {
|
||||
maybeMainFileName = entryFileName
|
||||
break mainFileLoop
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
guard let mainFileName = maybeMainFileName else {
|
||||
beginShare()
|
||||
return
|
||||
}
|
||||
|
||||
let photoRegex = try! NSRegularExpression(pattern: "[\\d]+-PHOTO-.*?\\.jpg")
|
||||
let photoRegex = try! NSRegularExpression(pattern: ".*?\\.jpg")
|
||||
let videoRegex = try! NSRegularExpression(pattern: "[\\d]+-VIDEO-.*?\\.mp4")
|
||||
let stickerRegex = try! NSRegularExpression(pattern: "[\\d]+-STICKER-.*?\\.webp")
|
||||
let voiceRegex = try! NSRegularExpression(pattern: "[\\d]+-AUDIO-.*?\\.opus")
|
||||
@ -435,7 +454,7 @@ public class ShareRootControllerImpl {
|
||||
continue
|
||||
}
|
||||
let tempFile = TempBox.shared.tempFile(fileName: entryPath)
|
||||
if entryPath == "_chat.txt" {
|
||||
if entryPath == mainFileName {
|
||||
let _ = try archive.extract(entry, to: URL(fileURLWithPath: tempFile.path))
|
||||
mainFile = tempFile
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user