From 5f2e4938929b29ec148b6a2bcdf75835c64debf0 Mon Sep 17 00:00:00 2001 From: marcoschmickler Date: Sun, 14 Jun 2026 00:04:50 +0200 Subject: [PATCH] modernize scene --- kplayer.xcodeproj/project.pbxproj | 4 ++ kplayer/AppDelegate.swift | 53 ++----------------- kplayer/Info.plist | 21 +++++++- .../detail/DetailViewController+Show.swift | 6 ++- 4 files changed, 30 insertions(+), 54 deletions(-) diff --git a/kplayer.xcodeproj/project.pbxproj b/kplayer.xcodeproj/project.pbxproj index c110b4e..ae5e16a 100644 --- a/kplayer.xcodeproj/project.pbxproj +++ b/kplayer.xcodeproj/project.pbxproj @@ -95,6 +95,7 @@ C97FE58E2FDDE6C20089D241 /* SVideoHelpView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C97FE58B2FDDE6C20089D241 /* SVideoHelpView.swift */; }; C97FE58F2FDDE6C20089D241 /* svideohelp.md in Resources */ = {isa = PBXBuildFile; fileRef = C97FE58A2FDDE6C20089D241 /* svideohelp.md */; }; C98AF5D51B124D6A00D196CC /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C98AF5D41B124D6A00D196CC /* AppDelegate.swift */; }; + C95CE0DE2F0000000000DE02 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C95CE0DE2F0000000000DE01 /* SceneDelegate.swift */; }; C98AF5D81B124D6A00D196CC /* kplayer.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = C98AF5D61B124D6A00D196CC /* kplayer.xcdatamodeld */; }; C98AF5DF1B124D6A00D196CC /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C98AF5DD1B124D6A00D196CC /* Main.storyboard */; }; C98AF5E11B124D6A00D196CC /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C98AF5E01B124D6A00D196CC /* Images.xcassets */; }; @@ -203,6 +204,7 @@ C98AF5CF1B124D6A00D196CC /* kplayer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = kplayer.app; sourceTree = BUILT_PRODUCTS_DIR; }; C98AF5D31B124D6A00D196CC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; C98AF5D41B124D6A00D196CC /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + C95CE0DE2F0000000000DE01 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; C98AF5D71B124D6A00D196CC /* kplayer.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = kplayer.xcdatamodel; sourceTree = ""; }; C98AF5DE1B124D6A00D196CC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; C98AF5E01B124D6A00D196CC /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; @@ -418,6 +420,7 @@ isa = PBXGroup; children = ( C98AF5D41B124D6A00D196CC /* AppDelegate.swift */, + C95CE0DE2F0000000000DE01 /* SceneDelegate.swift */, C98AF5DD1B124D6A00D196CC /* Main.storyboard */, C98AF5E01B124D6A00D196CC /* Images.xcassets */, C98AF5E21B124D6A00D196CC /* LaunchScreen.xib */, @@ -621,6 +624,7 @@ files = ( C98AF5D81B124D6A00D196CC /* kplayer.xcdatamodeld in Sources */, C98AF5D51B124D6A00D196CC /* AppDelegate.swift in Sources */, + C95CE0DE2F0000000000DE02 /* SceneDelegate.swift in Sources */, 1C736503B656C999E5E12081 /* NetworkManager.swift in Sources */, 1C736FB92B19FE17E4357C85 /* MediaItem.swift in Sources */, 1C73688D13E5A804880C8768 /* UIImageExtension.swift in Sources */, diff --git a/kplayer/AppDelegate.swift b/kplayer/AppDelegate.swift index a29580f..959fed9 100644 --- a/kplayer/AppDelegate.swift +++ b/kplayer/AppDelegate.swift @@ -10,29 +10,14 @@ import UIKit import CoreData @UIApplicationMain -class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDelegate { - - var window: UIWindow? - +class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { - // URLProtocol.registerClass(KNetworkProtocol.self) - // Override point for customization after application launch. - let splitViewController = self.window!.rootViewController as! UISplitViewController - let navigationController = splitViewController.viewControllers[splitViewController.viewControllers.count-1] as! UINavigationController - navigationController.topViewController!.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem - splitViewController.delegate = self - - let masterNavigationController = splitViewController.viewControllers[0] as! UINavigationController - let controller = masterNavigationController.topViewController as! MasterViewController - controller.delegate = NetworkDelegate() - + // App-level setup. UI/window setup lives in SceneDelegate. LocalManager.sharedInstance.loadSettings() NetworkManager.sharedInstance.wakeLinkstation() - controller.model.items = LocalManager.sharedInstance.model!.items - NetworkManager.sharedInstance.alive() Timer.scheduledTimer(withTimeInterval: 60, repeats: true) { (t) in @@ -42,44 +27,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele return true } - func applicationWillResignActive(_ application: UIApplication) { - // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. - // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. - } - - func applicationDidEnterBackground(_ application: UIApplication) { - // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. - // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. - } - - func applicationWillEnterForeground(_ application: UIApplication) { - // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. - } - - func applicationDidBecomeActive(_ application: UIApplication) { - NetworkManager.sharedInstance.alive() - // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. - } - func applicationWillTerminate(_ application: UIApplication) { - // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. + // Called when the application is about to terminate. Save data if appropriate. // Saves changes in the application's managed object context before the application terminates. self.saveContext() } - // MARK: - Split view - - func splitViewController(_ splitViewController: UISplitViewController, collapseSecondary secondaryViewController:UIViewController, onto primaryViewController:UIViewController) -> Bool { - if let secondaryAsNavController = secondaryViewController as? UINavigationController { - if let topAsDetailController = secondaryAsNavController.topViewController as? DetailViewController { - if topAsDetailController.detailItem == nil { - // Return true to indicate that we have handled the collapse by doing nothing; the secondary controller will be discarded. - return true - } - } - } - return false - } // MARK: - Core Data stack lazy var applicationDocumentsDirectory: URL = { diff --git a/kplayer/Info.plist b/kplayer/Info.plist index 86fa10e..ca51d0c 100644 --- a/kplayer/Info.plist +++ b/kplayer/Info.plist @@ -41,8 +41,25 @@ UILaunchStoryboardName LaunchScreen - UIMainStoryboardFile - Main + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + UISceneStoryboardFile + Main + + + + UIRequiredDeviceCapabilities armv7 diff --git a/kplayer/detail/DetailViewController+Show.swift b/kplayer/detail/DetailViewController+Show.swift index bd861ce..81b76d1 100644 --- a/kplayer/detail/DetailViewController+Show.swift +++ b/kplayer/detail/DetailViewController+Show.swift @@ -172,7 +172,9 @@ extension DetailViewController { } func getWindow() -> UIWindow { - let delegate2 = UIApplication.shared.delegate! - return delegate2.window as! UIWindow + return UIApplication.shared.connectedScenes + .compactMap { $0 as? UIWindowScene } + .flatMap { $0.windows } + .first { $0.isKeyWindow }! } } \ No newline at end of file