Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 77ee5c4
Showing
869 changed files
with
54,858 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
fastlane/README.md | ||
fastlane/report.xml | ||
fastlane/test_output/* | ||
*.pbxuser | ||
!default.pbxuser | ||
*.mode1v3 | ||
!default.mode1v3 | ||
*.mode2v3 | ||
!default.mode2v3 | ||
*.perspectivev3 | ||
!default.perspectivev3 | ||
xcuserdata | ||
*.xccheckout | ||
*.xcscmblueprint | ||
*.moved-aside | ||
DerivedData | ||
*.hmap | ||
*.ipa | ||
*.xcuserstate | ||
.DS_Store | ||
*.dSYM | ||
*.dSYM.zip | ||
*.ipa | ||
*/xcuserdata/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
[submodule "submodules/AsyncDisplayKit"] | ||
path = submodules/AsyncDisplayKit | ||
url = git@github.com:peter-iakovlev/AsyncDisplayKit.git | ||
[submodule "submodules/Display"] | ||
path = submodules/Display | ||
url = git@github.com:peter-iakovlev/Display.git | ||
[submodule "submodules/HockeySDK-iOS"] | ||
path = submodules/HockeySDK-iOS | ||
url = git@github.com:peter-iakovlev/HockeySDK-iOS.git | ||
[submodule "submodules/LegacyComponents"] | ||
path = submodules/LegacyComponents | ||
url = git@github.com:peter-iakovlev/LegacyComponents.git | ||
[submodule "submodules/libtgvoip"] | ||
path = submodules/libtgvoip | ||
url=https://github.com/grishka/libtgvoip.git | ||
[submodule "submodules/lottie-ios"] | ||
path = submodules/lottie-ios | ||
url=git@github.com:peter-iakovlev/lottie-ios.git | ||
[submodule "submodules/MtProtoKit"] | ||
path = submodules/MtProtoKit | ||
url=git@github.com:peter-iakovlev/MtProtoKit.git | ||
[submodule "submodules/Postbox"] | ||
path = submodules/Postbox | ||
url = git@github.com:peter-iakovlev/Postbox.git | ||
[submodule "submodules/SSignalKit"] | ||
path = submodules/SSignalKit | ||
url = git@github.com:peter-iakovlev/Signals.git | ||
[submodule "submodules/TelegramCore"] | ||
path = submodules/TelegramCore | ||
url = git@github.com:peter-iakovlev/TelegramCore.git | ||
[submodule "submodules/TelegramUI"] | ||
path = submodules/TelegramUI | ||
url = git@github.com:peter-iakovlev/TelegramUI.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="M4Y-Lb-cyx"> | ||
<device id="retina4_7" orientation="portrait"> | ||
<adaptation id="fullscreen"/> | ||
</device> | ||
<dependencies> | ||
<deployment identifier="iOS"/> | ||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.14"/> | ||
<capability name="Safe area layout guides" minToolsVersion="9.0"/> | ||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> | ||
</dependencies> | ||
<scenes> | ||
<!--Notification View Controller--> | ||
<scene sceneID="cwh-vc-ff4"> | ||
<objects> | ||
<viewController id="M4Y-Lb-cyx" userLabel="Notification View Controller" customClass="NotificationViewController" customModule="NotificationContent" customModuleProvider="target" sceneMemberID="viewController"> | ||
<view key="view" contentMode="scaleToFill" simulatedAppContext="notificationCenter" id="S3S-Oj-5AN"> | ||
<rect key="frame" x="0.0" y="0.0" width="320" height="37"/> | ||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> | ||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> | ||
<viewLayoutGuide key="safeArea" id="2BE-c3-nQJ"/> | ||
</view> | ||
<extendedEdge key="edgesForExtendedLayout"/> | ||
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/> | ||
<size key="freeformSize" width="320" height="37"/> | ||
</viewController> | ||
<placeholder placeholderIdentifier="IBFirstResponder" id="vXp-U4-Rya" userLabel="First Responder" sceneMemberID="firstResponder"/> | ||
</objects> | ||
</scene> | ||
</scenes> | ||
</document> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,260 @@ | ||
import Foundation | ||
import Display | ||
import TelegramCore | ||
import TelegramUI | ||
import Postbox | ||
import SwiftSignalKit | ||
|
||
private let accountCache = Atomic<[AccountRecordId: Account]>(value: [:]) | ||
|
||
private struct ChatHistoryFragmentEntry: Comparable, Identifiable { | ||
let message: Message | ||
let read: Bool | ||
|
||
var stableId: UInt32 { | ||
return self.message.stableId | ||
} | ||
} | ||
|
||
private func==(lhs: ChatHistoryFragmentEntry, rhs: ChatHistoryFragmentEntry) -> Bool { | ||
if MessageIndex(lhs.message) == MessageIndex(rhs.message) && lhs.message.flags == rhs.message.flags { | ||
if lhs.message.media.count != rhs.message.media.count { | ||
return false | ||
} | ||
if lhs.read != rhs.read { | ||
return false | ||
} | ||
for i in 0 ..< lhs.message.media.count { | ||
if !lhs.message.media[i].isEqual(rhs.message.media[i]) { | ||
return false | ||
} | ||
} | ||
return true | ||
} else { | ||
return false | ||
} | ||
} | ||
|
||
private func <(lhs: ChatHistoryFragmentEntry, rhs: ChatHistoryFragmentEntry) -> Bool { | ||
return MessageIndex(lhs.message) < MessageIndex(rhs.message) | ||
} | ||
|
||
private final class ChatHistoryFragmentDisplayItem { | ||
fileprivate let item: ListViewItem | ||
fileprivate var node: ListViewItemNode? | ||
|
||
init(item: ListViewItem) { | ||
self.item = item | ||
} | ||
|
||
init(item: ListViewItem, node: ListViewItemNode?) { | ||
self.item = item | ||
self.node = node | ||
} | ||
} | ||
|
||
final class ChatHistoryFragmentView: UIView { | ||
private let sizeUpdated: (CGSize) -> Void | ||
|
||
private var layoutWidth: CGFloat? | ||
private var displayItems: [ChatHistoryFragmentDisplayItem] = [] | ||
|
||
private let disposable = MetaDisposable() | ||
|
||
let account = Promise<Account>() | ||
|
||
init(peerId: PeerId, width: CGFloat, sizeUpdated: @escaping (CGSize) -> Void) { | ||
self.sizeUpdated = sizeUpdated | ||
self.layoutWidth = width | ||
|
||
super.init(frame: CGRect()) | ||
|
||
/*let appBundleIdentifier = Bundle.main.bundleIdentifier! | ||
guard let lastDotRange = appBundleIdentifier.range(of: ".", options: [.backwards]) else { | ||
return | ||
} | ||
let appGroupName = "group.\(appBundleIdentifier.substring(to: lastDotRange.lowerBound))" | ||
let maybeAppGroupUrl = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: appGroupName) | ||
guard let appGroupUrl = maybeAppGroupUrl else { | ||
return | ||
} | ||
let accountPromise = self.account | ||
let accountId = currentAccountId(appGroupPath: appGroupUrl.path, testingEnvironment: false) | ||
let authorizedAccount: Signal<Account, NoError> | ||
let cachedAccount = accountCache.with { dict -> Account? in | ||
if let account = dict[accountId] { | ||
return account | ||
} else { | ||
return nil | ||
} | ||
} | ||
if let cachedAccount = cachedAccount { | ||
authorizedAccount = .single(cachedAccount) | ||
} else { | ||
authorizedAccount = accountWithId(accountId, appGroupPath: appGroupUrl.path, logger: .named("notification-content"), testingEnvironment: false) |> mapToSignal { account -> Signal<Account, NoError> in | ||
switch account { | ||
case .left: | ||
return .complete() | ||
case let .right(authorizedAccount): | ||
setupAccount(authorizedAccount) | ||
let _ = accountCache.modify { dict in | ||
var dict = dict | ||
dict[accountId] = authorizedAccount | ||
return dict | ||
} | ||
return .single(authorizedAccount) | ||
} | ||
} | ||
} | ||
let view = authorizedAccount | ||
|> take(1) | ||
|> mapToSignal { account -> Signal<(Account, MessageHistoryView, ViewUpdateType), NoError> in | ||
accountPromise.set(.single(account)) | ||
account.stateManager.reset() | ||
account.shouldBeServiceTaskMaster.set(.single(.now)) | ||
let view = account.viewTracker.aroundMessageHistoryViewForPeerId(peerId, index: MessageIndex.upperBound(peerId: peerId), count: 20, anchorIndex: MessageIndex.upperBound(peerId: peerId), fixedCombinedReadStates: nil, tagMask: nil) | ||
|> map { view, updateType, _ -> (Account, MessageHistoryView, ViewUpdateType) in | ||
return (account, view, updateType) | ||
} | ||
return view | ||
} | ||
let previousEntries = Atomic<[ChatHistoryFragmentEntry]>(value: []) | ||
let controllerInteraction = ChatControllerInteraction(openMessage: { _ in }, openSecretMessagePreview: { _ in }, closeSecretMessagePreview: { }, openPeer: { _ in }, openPeerMention: { _ in }, openMessageContextMenu: { _ in }, navigateToMessage: { _ in }, clickThroughMessage: { }, toggleMessagesSelection: { _ in }, sendMessage: { _ in }, sendSticker: { _ in }, requestMessageActionCallback: { _ in }, openUrl: { _ in }, shareCurrentLocation: {}, shareAccountContact: {}, sendBotCommand: { _, _ in }, openInstantPage: { _ in }, openHashtag: { _ in }, updateInputState: { _ in }) | ||
let messages = view | ||
|> map { (account, view, viewUpdateType) -> (Account, [ChatHistoryFragmentEntry], [Int: Int]) in | ||
var entries: [ChatHistoryFragmentEntry] = [] | ||
for entry in view.entries.reversed() { | ||
switch entry { | ||
case let .MessageEntry(message, read, _): | ||
entries.append(ChatHistoryFragmentEntry(message: message, read: read)) | ||
default: | ||
break | ||
} | ||
} | ||
var previousIndices: [Int: Int] = [:] | ||
let _ = previousEntries.modify { previousEntries in | ||
var index = 0 | ||
for entry in entries { | ||
var previousIndex = 0 | ||
for previousEntry in previousEntries { | ||
if previousEntry.stableId == entry.stableId { | ||
previousIndices[index] = previousIndex | ||
break | ||
} | ||
previousIndex += 1 | ||
} | ||
index += 1 | ||
} | ||
return entries | ||
} | ||
return (account, entries, previousIndices) | ||
} | ||
let displayItems = messages | ||
|> map { (account, messages, previousIndices) -> ([ChatHistoryFragmentDisplayItem], [Int: Int]) in | ||
var result: [ChatHistoryFragmentDisplayItem] = [] | ||
for entry in messages { | ||
result.append(ChatHistoryFragmentDisplayItem(item: ChatMessageItem(account: account, peerId: peerId, controllerInteraction: controllerInteraction, message: entry.message, read: entry.read))) | ||
} | ||
return (result, previousIndices) | ||
} | ||
let semaphore = DispatchSemaphore(value: 0) | ||
var resultItems: [ChatHistoryFragmentDisplayItem]? | ||
disposable.set(displayItems.start(next: { [weak self] (displayItems, previousIndices) in | ||
if resultItems == nil { | ||
resultItems = displayItems | ||
semaphore.signal() | ||
} else { | ||
Queue.mainQueue().async { | ||
if let strongSelf = self { | ||
var updatedDisplayItems: [ChatHistoryFragmentDisplayItem] = [] | ||
for i in 0 ..< displayItems.count { | ||
if let previousIndex = previousIndices[i] { | ||
updatedDisplayItems.append(ChatHistoryFragmentDisplayItem(item: displayItems[i].item, node: strongSelf.displayItems[previousIndex].node)) | ||
} else { | ||
updatedDisplayItems.append(displayItems[i]) | ||
} | ||
} | ||
let previousIndexSet = Set(previousIndices.values) | ||
for i in 0 ..< strongSelf.displayItems.count { | ||
if !previousIndexSet.contains(i) { | ||
strongSelf.displayItems[i].node?.removeFromSupernode() | ||
} | ||
} | ||
strongSelf.displayItems = updatedDisplayItems | ||
if let layoutWidth = strongSelf.layoutWidth { | ||
strongSelf.updateDisplayItems(width: layoutWidth) | ||
} | ||
} | ||
} | ||
} | ||
})) | ||
semaphore.wait() | ||
if let resultItems = resultItems { | ||
self.displayItems = resultItems | ||
} | ||
if let layoutWidth = self.layoutWidth { | ||
self.updateDisplayItems(width: layoutWidth) | ||
}*/ | ||
} | ||
|
||
required init?(coder aDecoder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
deinit { | ||
self.disposable.dispose() | ||
} | ||
|
||
private func updateDisplayItems(width: CGFloat) { | ||
for i in 0 ..< self.displayItems.count { | ||
if let node = self.displayItems[i].node { | ||
self.displayItems[i].item.updateNode(async: { $0() }, node: node, width: width, previousItem: i == 0 ? nil : self.displayItems[i - 1].item, nextItem: i == self.displayItems.count - 1 ? nil : self.displayItems[i + 1].item, animation: .None, completion: { layout, apply in | ||
node.insets = layout.insets | ||
node.contentSize = layout.contentSize | ||
apply() | ||
}) | ||
node.layoutForWidth(width, item: self.displayItems[i].item, previousItem: i == 0 ? nil : self.displayItems[i - 1].item, nextItem: i == self.displayItems.count - 1 ? nil : self.displayItems[i + 1].item) | ||
} else { | ||
self.displayItems[i].item.nodeConfiguredForWidth(async: { $0() }, width: width, previousItem: i == 0 ? nil : self.displayItems[i - 1].item, nextItem: i == self.displayItems.count - 1 ? nil : self.displayItems[i + 1].item, completion: { node, apply in | ||
apply() | ||
self.displayItems[i].node = node | ||
self.addSubnode(node) | ||
}) | ||
} | ||
} | ||
|
||
var verticalOffset: CGFloat = 4.0 | ||
for displayItem in self.displayItems { | ||
if let node = displayItem.node { | ||
node.frame = CGRect(origin: CGPoint(x: 0.0, y: verticalOffset), size: node.layout.size) | ||
verticalOffset += node.layout.size.height | ||
} | ||
} | ||
|
||
let displaySize = CGSize(width: width, height: verticalOffset + 4.0) | ||
self.sizeUpdated(displaySize) | ||
} | ||
|
||
override func layoutSubviews() { | ||
super.layoutSubviews() | ||
|
||
if self.layoutWidth != self.bounds.size.width { | ||
self.layoutWidth = self.bounds.size.width | ||
self.updateDisplayItems(width: self.bounds.size.width) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>$(DEVELOPMENT_LANGUAGE)</string> | ||
<key>CFBundleDisplayName</key> | ||
<string>NotificationContent</string> | ||
<key>CFBundleExecutable</key> | ||
<string>$(EXECUTABLE_NAME)</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>$(PRODUCT_NAME)</string> | ||
<key>CFBundlePackageType</key> | ||
<string>XPC!</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>5.0.17</string> | ||
<key>CFBundleVersion</key> | ||
<string>624</string> | ||
<key>NSExtension</key> | ||
<dict> | ||
<key>NSExtensionAttributes</key> | ||
<dict> | ||
<key>UNNotificationExtensionCategory</key> | ||
<array> | ||
<string>withReplyMedia</string> | ||
<string>withMuteMedia</string> | ||
</array> | ||
<key>UNNotificationExtensionInitialContentSizeRatio</key> | ||
<real>0.0001</real> | ||
</dict> | ||
<key>NSExtensionMainStoryboard</key> | ||
<string>MainInterface</string> | ||
<key>NSExtensionPointIdentifier</key> | ||
<string>com.apple.usernotifications.content-extension</string> | ||
</dict> | ||
</dict> | ||
</plist> |
Oops, something went wrong.
77ee5c4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MathingDeviceContact => MatchingDeviceContact