mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +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/PeerTable:PeerTable",
|
||||
"//submodules/sqlcipher:sqlcipher",
|
||||
"//submodules/AppLockState:AppLockState",
|
||||
"//submodules/NotificationsPresentationData:NotificationsPresentationData",
|
||||
],
|
||||
frameworks = [
|
||||
"$SDKROOT/System/Library/Frameworks/Foundation.framework",
|
||||
|
@ -195,6 +195,7 @@ framework(
|
||||
"//submodules/OpenSSLEncryptionProvider:OpenSSLEncryptionProvider",
|
||||
"//submodules/PhoneNumberFormat:PhoneNumberFormat",
|
||||
"//submodules/AppLock:AppLock",
|
||||
"//submodules/NotificationsPresentationData:NotificationsPresentationData",
|
||||
],
|
||||
frameworks = [
|
||||
"$SDKROOT/System/Library/Frameworks/Foundation.framework",
|
||||
|
@ -234,7 +234,20 @@ final class SharedApplicationContext {
|
||||
let statusBarHost = ApplicationStatusBarHost()
|
||||
let (window, hostView) = nativeWindowHostView()
|
||||
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.nativeWindow = window
|
||||
|
||||
@ -715,7 +728,13 @@ final class SharedApplicationContext {
|
||||
|> deliverOnMainQueue
|
||||
|> take(1)
|
||||
|> 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
|
||||
return (accountManager, initialPresentationDataAndSettings)
|
||||
}
|
||||
@ -1630,34 +1649,38 @@ final class SharedApplicationContext {
|
||||
|
||||
@available(iOS 9.0, *)
|
||||
func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
|
||||
let _ = (self.context.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()
|
||||
}
|
||||
}
|
||||
let _ = (self.sharedContextPromise.get()
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { context in
|
||||
if let context = context {
|
||||
if let type = ApplicationShortcutItemType(rawValue: shortcutItem.type) {
|
||||
switch type {
|
||||
case .search:
|
||||
context.openRootSearch()
|
||||
case .compose:
|
||||
context.openRootCompose()
|
||||
case .camera:
|
||||
context.openRootCamera()
|
||||
case .savedMessages:
|
||||
self.openChatWhenReady(accountId: nil, peerId: context.context.account.peerId)
|
||||
|> deliverOnMainQueue).start(next: { sharedContext in
|
||||
let proceed: () -> Void = {
|
||||
let _ = (self.context.get()
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { context in
|
||||
if let context = context {
|
||||
if let type = ApplicationShortcutItemType(rawValue: shortcutItem.type) {
|
||||
switch type {
|
||||
case .search:
|
||||
context.openRootSearch()
|
||||
case .compose:
|
||||
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.previewThemeDarkBlur = presentationData.theme.rootController.keyboardColor == .dark
|
||||
self.mainWindow.setupVolumeControlStatusBarGraphics(presentationData.volumeControlStatusBarIcons.images)
|
||||
|
||||
self.rootController = TelegramRootController(context: context)
|
||||
|
||||
|
@ -8163,6 +8163,8 @@ private final class ContextControllerContentSourceImpl: ContextControllerContent
|
||||
let controller: ViewController
|
||||
weak var sourceNode: ASDisplayNode?
|
||||
|
||||
let navigationController: NavigationController? = nil
|
||||
|
||||
init(controller: ViewController, sourceNode: ASDisplayNode?) {
|
||||
self.controller = controller
|
||||
self.sourceNode = sourceNode
|
||||
|
@ -132,6 +132,8 @@ public func fetchCachedResourceRepresentation(account: Account, resource: MediaR
|
||||
}
|
||||
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()
|
||||
}
|
||||
|
@ -921,6 +921,8 @@ private final class ContextControllerContentSourceImpl: ContextControllerContent
|
||||
let controller: ViewController
|
||||
weak var sourceNode: ASDisplayNode?
|
||||
|
||||
let navigationController: NavigationController? = nil
|
||||
|
||||
init(controller: ViewController, sourceNode: ASDisplayNode?) {
|
||||
self.controller = controller
|
||||
self.sourceNode = sourceNode
|
||||
|
@ -618,7 +618,7 @@ public final class SharedAccountContextImpl: SharedAccountContext {
|
||||
self.widgetDataContext = WidgetDataContext(basePath: self.basePath, activeAccount: self.activeAccounts
|
||||
|> map { primary, _, _ in
|
||||
return primary
|
||||
})
|
||||
}, presentationData: self.presentationData)
|
||||
}
|
||||
|
||||
deinit {
|
||||
|
@ -26,7 +26,7 @@ public let telegramAccountAuxiliaryMethods = AccountAuxiliaryMethods(updatePeerC
|
||||
} else if let photoLibraryResource = resource as? PhotoLibraryMediaResource {
|
||||
return fetchPhotoLibraryResource(localIdentifier: photoLibraryResource.localIdentifier)
|
||||
} else if let mapSnapshotResource = resource as? MapSnapshotMediaResource {
|
||||
return fetchMapSnapshotResource(resource: mapSnapshotResource)
|
||||
return .never()
|
||||
} else if let resource = resource as? ExternalMusicAlbumArtResource {
|
||||
return fetchExternalMusicAlbumArtResource(account: account, resource: resource)
|
||||
} else if let resource = resource as? ICloudFileResource {
|
||||
|
@ -10,18 +10,6 @@ public func doesUrlMatchText(url: String, text: String, fullText: String) -> Boo
|
||||
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 {
|
||||
static let urlQueryValueAllowed: CharacterSet = {
|
||||
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 {
|
||||
private enum CodingKeys: CodingKey {
|
||||
case discriminator
|
||||
|
Loading…
x
Reference in New Issue
Block a user