mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-01 04:08:07 +00:00
Cleanup
This commit is contained in:
parent
4fa167d56f
commit
340807b42c
2
BUCK
2
BUCK
@ -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",
|
||||||
|
|||||||
@ -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",
|
||||||
|
|||||||
@ -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)
|
||||||
hostView.containerView.backgroundColor = UIColor.white
|
if let traitCollection = window.rootViewController?.traitCollection {
|
||||||
|
if #available(iOS 13.0, *) {
|
||||||
|
switch traitCollection.userInterfaceStyle {
|
||||||
|
case .light, .unspecified:
|
||||||
|
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,34 +1649,38 @@ 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)
|
|
||||||
|> map { _ -> AuthorizedApplicationContext? in
|
|
||||||
return context
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return .complete()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|> take(1)
|
|> take(1)
|
||||||
|> deliverOnMainQueue).start(next: { context in
|
|> deliverOnMainQueue).start(next: { sharedContext in
|
||||||
if let context = context {
|
let proceed: () -> Void = {
|
||||||
if let type = ApplicationShortcutItemType(rawValue: shortcutItem.type) {
|
let _ = (self.context.get()
|
||||||
switch type {
|
|> take(1)
|
||||||
case .search:
|
|> deliverOnMainQueue).start(next: { context in
|
||||||
context.openRootSearch()
|
if let context = context {
|
||||||
case .compose:
|
if let type = ApplicationShortcutItemType(rawValue: shortcutItem.type) {
|
||||||
context.openRootCompose()
|
switch type {
|
||||||
case .camera:
|
case .search:
|
||||||
context.openRootCamera()
|
context.openRootSearch()
|
||||||
case .savedMessages:
|
case .compose:
|
||||||
self.openChatWhenReady(accountId: nil, peerId: context.context.account.peerId)
|
context.openRootCompose()
|
||||||
|
case .camera:
|
||||||
|
context.openRootCamera()
|
||||||
|
case .savedMessages:
|
||||||
|
self.openChatWhenReady(accountId: nil, peerId: context.context.account.peerId)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
}
|
||||||
|
if let appLockContext = sharedContext.sharedContext.appLockContext as? AppLockContextImpl {
|
||||||
|
let _ = (appLockContext.isCurrentlyLocked
|
||||||
|
|> filter { !$0 }
|
||||||
|
|> take(1)
|
||||||
|
|> deliverOnMainQueue).start(next: { _ in
|
||||||
|
proceed()
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
proceed()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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)
|
||||||
|
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -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()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -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 {
|
||||||
|
|||||||
@ -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 {
|
||||||
|
|||||||
@ -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 = ":#[]@"
|
||||||
|
|||||||
13
submodules/UrlWhitetlist/Sources/UrlWhitelist.swift
Normal file
13
submodules/UrlWhitetlist/Sources/UrlWhitelist.swift
Normal 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
|
||||||
|
}
|
||||||
@ -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
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user