mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-03-01 06:11:18 +00:00
145 lines
5.0 KiB
Swift
145 lines
5.0 KiB
Swift
import UIKit
|
|
import Display
|
|
import TelegramPresentationData
|
|
import WalletUI
|
|
import SwiftSignalKit
|
|
|
|
private func encodeText(_ string: String, _ key: Int) -> String {
|
|
var result = ""
|
|
for c in string.unicodeScalars {
|
|
result.append(Character(UnicodeScalar(UInt32(Int(c.value) + key))!))
|
|
}
|
|
return result
|
|
}
|
|
|
|
private let statusBarRootViewClass: AnyClass = NSClassFromString("UIStatusBar")!
|
|
private let statusBarPlaceholderClass: AnyClass? = NSClassFromString("UIStatusBar_Placeholder")
|
|
private let cutoutStatusBarForegroundClass: AnyClass? = NSClassFromString("_UIStatusBar")
|
|
private let keyboardViewClass: AnyClass? = NSClassFromString(encodeText("VJJoqvuTfuIptuWjfx", -1))!
|
|
private let keyboardViewContainerClass: AnyClass? = NSClassFromString(encodeText("VJJoqvuTfuDpoubjofsWjfx", -1))!
|
|
|
|
private let keyboardWindowClass: AnyClass? = {
|
|
if #available(iOS 9.0, *) {
|
|
return NSClassFromString(encodeText("VJSfnpufLfzcpbseXjoepx", -1))
|
|
} else {
|
|
return NSClassFromString(encodeText("VJUfyuFggfdutXjoepx", -1))
|
|
}
|
|
}()
|
|
|
|
private class ApplicationStatusBarHost: StatusBarHost {
|
|
private let application = UIApplication.shared
|
|
|
|
var isApplicationInForeground: Bool {
|
|
switch self.application.applicationState {
|
|
case .background:
|
|
return false
|
|
default:
|
|
return true
|
|
}
|
|
}
|
|
|
|
var statusBarFrame: CGRect {
|
|
return self.application.statusBarFrame
|
|
}
|
|
var statusBarStyle: UIStatusBarStyle {
|
|
get {
|
|
return self.application.statusBarStyle
|
|
} set(value) {
|
|
self.setStatusBarStyle(value, animated: false)
|
|
}
|
|
}
|
|
|
|
func setStatusBarStyle(_ style: UIStatusBarStyle, animated: Bool) {
|
|
self.application.setStatusBarStyle(style, animated: animated)
|
|
}
|
|
|
|
func setStatusBarHidden(_ value: Bool, animated: Bool) {
|
|
self.application.setStatusBarHidden(value, with: animated ? .fade : .none)
|
|
}
|
|
|
|
var statusBarWindow: UIView? {
|
|
return self.application.value(forKey: "statusBarWindow") as? UIView
|
|
}
|
|
|
|
var statusBarView: UIView? {
|
|
guard let containerView = self.statusBarWindow?.subviews.first else {
|
|
return nil
|
|
}
|
|
|
|
if containerView.isKind(of: statusBarRootViewClass) {
|
|
return containerView
|
|
}
|
|
if let statusBarPlaceholderClass = statusBarPlaceholderClass {
|
|
if containerView.isKind(of: statusBarPlaceholderClass) {
|
|
return containerView
|
|
}
|
|
}
|
|
|
|
|
|
for subview in containerView.subviews {
|
|
if let cutoutStatusBarForegroundClass = cutoutStatusBarForegroundClass, subview.isKind(of: cutoutStatusBarForegroundClass) {
|
|
return subview
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
var keyboardWindow: UIWindow? {
|
|
guard let keyboardWindowClass = keyboardWindowClass else {
|
|
return nil
|
|
}
|
|
|
|
for window in UIApplication.shared.windows {
|
|
if window.isKind(of: keyboardWindowClass) {
|
|
return window
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
var keyboardView: UIView? {
|
|
guard let keyboardWindow = self.keyboardWindow, let keyboardViewContainerClass = keyboardViewContainerClass, let keyboardViewClass = keyboardViewClass else {
|
|
return nil
|
|
}
|
|
|
|
for view in keyboardWindow.subviews {
|
|
if view.isKind(of: keyboardViewContainerClass) {
|
|
for subview in view.subviews {
|
|
if subview.isKind(of: keyboardViewClass) {
|
|
return subview
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
var handleVolumeControl: Signal<Bool, NoError> {
|
|
return .single(false)
|
|
}
|
|
}
|
|
|
|
@objc(AppDelegate)
|
|
final class AppDelegate: NSObject, UIApplicationDelegate {
|
|
var window: UIWindow?
|
|
var mainWindow: Window1?
|
|
|
|
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
|
|
let statusBarHost = ApplicationStatusBarHost()
|
|
let (window, hostView) = nativeWindowHostView()
|
|
self.mainWindow = Window1(hostView: hostView, statusBarHost: statusBarHost)
|
|
hostView.containerView.backgroundColor = UIColor.white
|
|
self.window = window
|
|
|
|
let navigationController = NavigationController(mode: .single, theme: NavigationControllerTheme(presentationTheme: defaultPresentationTheme), backgroundDetailsMode: nil)
|
|
navigationController.setViewControllers([], animated: false)
|
|
self.mainWindow?.viewController = navigationController
|
|
navigationController.presentOverlay(controller: standardTextAlertController(theme: AlertControllerTheme(presentationTheme: defaultPresentationTheme), title: "Test", text: "Text", actions: [TextAlertAction(type: .defaultAction, title: "OK", action: {
|
|
})]), inGlobal: false)
|
|
|
|
self.window?.makeKeyAndVisible()
|
|
|
|
return true
|
|
}
|
|
}
|