diff --git a/Gemini-iOS/Info.plist b/Gemini-iOS/Info.plist index 8945ee1..1084fca 100644 --- a/Gemini-iOS/Info.plist +++ b/Gemini-iOS/Info.plist @@ -2,6 +2,17 @@ + UIApplicationShortcutItems + + + UIApplicationShortcutItemIconType + UIApplicationShortcutIconTypeHome + UIApplicationShortcutItemType + home + UIApplicationShortcutItemTitle + Homepage + + CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleDisplayName diff --git a/Gemini-iOS/SceneDelegate.swift b/Gemini-iOS/SceneDelegate.swift index 4cca168..c7e3fa1 100644 --- a/Gemini-iOS/SceneDelegate.swift +++ b/Gemini-iOS/SceneDelegate.swift @@ -56,10 +56,21 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { } func scene(_ scene: UIScene, continue userActivity: NSUserActivity) { - if let url = userActivity.geminiURL { + if userActivity.isHomepage { + navigationManager.changeURL(Preferences.shared.homepage) + } else if let url = userActivity.geminiURL { navigationManager.changeURL(url) } } + + func windowScene(_ windowScene: UIWindowScene, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) { + if shortcutItem.type == "home" { + navigationManager.changeURL(Preferences.shared.homepage) + completionHandler(true) + } else { + completionHandler(false) + } + } func sceneDidDisconnect(_ scene: UIScene) { // Called as the scene is being released by the system. @@ -100,6 +111,8 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { // navigate the existing manager to that URL if let newURL = connectionOptions.userActivities.first?.geminiURL { manager.changeURL(newURL) + } else if connectionOptions.shortcutItem?.type == "home" { + manager.changeURL(Preferences.shared.homepage) } return manager } @@ -120,14 +133,16 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { initialURL = connectionOptions.urlContexts.first?.url } - if initialURL == nil { - if ProcessInfo.processInfo.environment.keys.contains("DEFAULT_URL") { - initialURL = URL(string: ProcessInfo.processInfo.environment["DEFAULT_URL"]!)! - } else { - initialURL = Preferences.shared.homepage - } + if initialURL == nil || connectionOptions.shortcutItem?.type == "home" { + initialURL = Preferences.shared.homepage } + #if DEBUG + if ProcessInfo.processInfo.environment.keys.contains("DEFAULT_URL") { + initialURL = URL(string: ProcessInfo.processInfo.environment["DEFAULT_URL"]!)! + } + #endif + return NavigationManager(url: initialURL!) }