This commit is contained in:
Peter 2019-10-29 23:28:14 +04:00
parent 4fa167d56f
commit 340807b42c
12 changed files with 87 additions and 43 deletions

2
BUCK
View File

@ -351,6 +351,8 @@ apple_binary(
"//submodules/Database/PreferencesTable:PreferencesTable", "//submodules/Database/PreferencesTable:PreferencesTable",
"//submodules/Database/PeerTable:PeerTable", "//submodules/Database/PeerTable:PeerTable",
"//submodules/sqlcipher:sqlcipher", "//submodules/sqlcipher:sqlcipher",
"//submodules/AppLockState:AppLockState",
"//submodules/NotificationsPresentationData:NotificationsPresentationData",
], ],
frameworks = [ frameworks = [
"$SDKROOT/System/Library/Frameworks/Foundation.framework", "$SDKROOT/System/Library/Frameworks/Foundation.framework",

View File

@ -195,6 +195,7 @@ framework(
"//submodules/OpenSSLEncryptionProvider:OpenSSLEncryptionProvider", "//submodules/OpenSSLEncryptionProvider:OpenSSLEncryptionProvider",
"//submodules/PhoneNumberFormat:PhoneNumberFormat", "//submodules/PhoneNumberFormat:PhoneNumberFormat",
"//submodules/AppLock:AppLock", "//submodules/AppLock:AppLock",
"//submodules/NotificationsPresentationData:NotificationsPresentationData",
], ],
frameworks = [ frameworks = [
"$SDKROOT/System/Library/Frameworks/Foundation.framework", "$SDKROOT/System/Library/Frameworks/Foundation.framework",

View File

@ -234,7 +234,20 @@ final class SharedApplicationContext {
let statusBarHost = ApplicationStatusBarHost() let statusBarHost = ApplicationStatusBarHost()
let (window, hostView) = nativeWindowHostView() let (window, hostView) = nativeWindowHostView()
self.mainWindow = Window1(hostView: hostView, statusBarHost: statusBarHost) self.mainWindow = Window1(hostView: hostView, statusBarHost: statusBarHost)
if let traitCollection = window.rootViewController?.traitCollection {
if #available(iOS 13.0, *) {
switch traitCollection.userInterfaceStyle {
case .light, .unspecified:
hostView.containerView.backgroundColor = UIColor.white hostView.containerView.backgroundColor = UIColor.white
default:
hostView.containerView.backgroundColor = UIColor.black
}
} else {
hostView.containerView.backgroundColor = UIColor.white
}
} else {
hostView.containerView.backgroundColor = UIColor.white
}
self.window = window self.window = window
self.nativeWindow = window self.nativeWindow = window
@ -715,7 +728,13 @@ final class SharedApplicationContext {
|> deliverOnMainQueue |> deliverOnMainQueue
|> take(1) |> take(1)
|> mapToSignal { accountManager -> Signal<(AccountManager, InitialPresentationDataAndSettings), NoError> in |> mapToSignal { accountManager -> Signal<(AccountManager, InitialPresentationDataAndSettings), NoError> in
return currentPresentationDataAndSettings(accountManager: accountManager, systemUserInterfaceStyle: .light) var systemUserInterfaceStyle: WindowUserInterfaceStyle = .light
if #available(iOS 13.0, *) {
if let traitCollection = window.rootViewController?.traitCollection {
systemUserInterfaceStyle = WindowUserInterfaceStyle(style: traitCollection.userInterfaceStyle)
}
}
return currentPresentationDataAndSettings(accountManager: accountManager, systemUserInterfaceStyle: systemUserInterfaceStyle)
|> map { initialPresentationDataAndSettings -> (AccountManager, InitialPresentationDataAndSettings) in |> map { initialPresentationDataAndSettings -> (AccountManager, InitialPresentationDataAndSettings) in
return (accountManager, initialPresentationDataAndSettings) return (accountManager, initialPresentationDataAndSettings)
} }
@ -1630,19 +1649,11 @@ final class SharedApplicationContext {
@available(iOS 9.0, *) @available(iOS 9.0, *)
func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) { func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
let _ = (self.context.get() let _ = (self.sharedContextPromise.get()
|> mapToSignal { context -> Signal<AuthorizedApplicationContext?, NoError> in
if let context = context {
return context.unlockedState
|> filter { $0 }
|> take(1) |> take(1)
|> map { _ -> AuthorizedApplicationContext? in |> deliverOnMainQueue).start(next: { sharedContext in
return context let proceed: () -> Void = {
} let _ = (self.context.get()
} else {
return .complete()
}
}
|> take(1) |> take(1)
|> deliverOnMainQueue).start(next: { context in |> deliverOnMainQueue).start(next: { context in
if let context = context { if let context = context {
@ -1661,6 +1672,18 @@ final class SharedApplicationContext {
} }
}) })
} }
if let appLockContext = sharedContext.sharedContext.appLockContext as? AppLockContextImpl {
let _ = (appLockContext.isCurrentlyLocked
|> filter { !$0 }
|> take(1)
|> deliverOnMainQueue).start(next: { _ in
proceed()
})
} else {
proceed()
}
})
}
private func openChatWhenReady(accountId: AccountRecordId?, peerId: PeerId, messageId: MessageId? = nil, activateInput: Bool = false) { private func openChatWhenReady(accountId: AccountRecordId?, peerId: PeerId, messageId: MessageId? = nil, activateInput: Bool = false) {
let signal = self.sharedContextPromise.get() let signal = self.sharedContextPromise.get()

View File

@ -123,7 +123,6 @@ final class AuthorizedApplicationContext {
self.mainWindow.previewThemeAccentColor = presentationData.theme.rootController.navigationBar.accentTextColor self.mainWindow.previewThemeAccentColor = presentationData.theme.rootController.navigationBar.accentTextColor
self.mainWindow.previewThemeDarkBlur = presentationData.theme.rootController.keyboardColor == .dark self.mainWindow.previewThemeDarkBlur = presentationData.theme.rootController.keyboardColor == .dark
self.mainWindow.setupVolumeControlStatusBarGraphics(presentationData.volumeControlStatusBarIcons.images)
self.rootController = TelegramRootController(context: context) self.rootController = TelegramRootController(context: context)

View File

@ -8163,6 +8163,8 @@ private final class ContextControllerContentSourceImpl: ContextControllerContent
let controller: ViewController let controller: ViewController
weak var sourceNode: ASDisplayNode? weak var sourceNode: ASDisplayNode?
let navigationController: NavigationController? = nil
init(controller: ViewController, sourceNode: ASDisplayNode?) { init(controller: ViewController, sourceNode: ASDisplayNode?) {
self.controller = controller self.controller = controller
self.sourceNode = sourceNode self.sourceNode = sourceNode

View File

@ -132,6 +132,8 @@ public func fetchCachedResourceRepresentation(account: Account, resource: MediaR
} }
return fetchAnimatedStickerFirstFrameRepresentation(account: account, resource: resource, resourceData: data, representation: representation) return fetchAnimatedStickerFirstFrameRepresentation(account: account, resource: resource, resourceData: data, representation: representation)
} }
} else if let resource = resource as? MapSnapshotMediaResource, let _ = representation as? MapSnapshotMediaResourceRepresentation {
return fetchMapSnapshotResource(resource: resource)
} }
return .never() return .never()
} }

View File

@ -921,6 +921,8 @@ private final class ContextControllerContentSourceImpl: ContextControllerContent
let controller: ViewController let controller: ViewController
weak var sourceNode: ASDisplayNode? weak var sourceNode: ASDisplayNode?
let navigationController: NavigationController? = nil
init(controller: ViewController, sourceNode: ASDisplayNode?) { init(controller: ViewController, sourceNode: ASDisplayNode?) {
self.controller = controller self.controller = controller
self.sourceNode = sourceNode self.sourceNode = sourceNode

View File

@ -618,7 +618,7 @@ public final class SharedAccountContextImpl: SharedAccountContext {
self.widgetDataContext = WidgetDataContext(basePath: self.basePath, activeAccount: self.activeAccounts self.widgetDataContext = WidgetDataContext(basePath: self.basePath, activeAccount: self.activeAccounts
|> map { primary, _, _ in |> map { primary, _, _ in
return primary return primary
}) }, presentationData: self.presentationData)
} }
deinit { deinit {

View File

@ -26,7 +26,7 @@ public let telegramAccountAuxiliaryMethods = AccountAuxiliaryMethods(updatePeerC
} else if let photoLibraryResource = resource as? PhotoLibraryMediaResource { } else if let photoLibraryResource = resource as? PhotoLibraryMediaResource {
return fetchPhotoLibraryResource(localIdentifier: photoLibraryResource.localIdentifier) return fetchPhotoLibraryResource(localIdentifier: photoLibraryResource.localIdentifier)
} else if let mapSnapshotResource = resource as? MapSnapshotMediaResource { } else if let mapSnapshotResource = resource as? MapSnapshotMediaResource {
return fetchMapSnapshotResource(resource: mapSnapshotResource) return .never()
} else if let resource = resource as? ExternalMusicAlbumArtResource { } else if let resource = resource as? ExternalMusicAlbumArtResource {
return fetchExternalMusicAlbumArtResource(account: account, resource: resource) return fetchExternalMusicAlbumArtResource(account: account, resource: resource)
} else if let resource = resource as? ICloudFileResource { } else if let resource = resource as? ICloudFileResource {

View File

@ -10,18 +10,6 @@ public func doesUrlMatchText(url: String, text: String, fullText: String) -> Boo
return false return false
} }
private let whitelistedHosts: Set<String> = Set([
"t.me",
"telegram.me"
])
public func isConcealedUrlWhitelisted(_ url: URL) -> Bool {
if let host = url.host, whitelistedHosts.contains(host) {
return true
}
return false
}
public extension CharacterSet { public extension CharacterSet {
static let urlQueryValueAllowed: CharacterSet = { static let urlQueryValueAllowed: CharacterSet = {
let generalDelimitersToEncode = ":#[]@" let generalDelimitersToEncode = ":#[]@"

View File

@ -0,0 +1,13 @@
import Foundation
private let whitelistedHosts: Set<String> = Set([
"t.me",
"telegram.me"
])
public func isConcealedUrlWhitelisted(_ url: URL) -> Bool {
if let host = url.host, whitelistedHosts.contains(host) {
return true
}
return false
}

View File

@ -28,6 +28,18 @@ public struct WidgetDataPeers: Codable, Equatable {
} }
} }
public struct WidgetPresentationData: Codable, Equatable {
public var applicationLockedString: String
public init(applicationLockedString: String) {
self.applicationLockedString = applicationLockedString
}
}
public func widgetPresentationDataPath(rootPath: String) -> String {
return rootPath + "/widgetPresentationData.json"
}
public enum WidgetData: Codable, Equatable { public enum WidgetData: Codable, Equatable {
private enum CodingKeys: CodingKey { private enum CodingKeys: CodingKey {
case discriminator case discriminator