Add Homepage home screen shortcut item

This commit is contained in:
Shadowfacts 2021-10-02 11:45:27 -04:00
parent e470d7b58e
commit 29e2589d5c
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
2 changed files with 33 additions and 7 deletions

View File

@ -2,6 +2,17 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UIApplicationShortcutItems</key>
<array>
<dict>
<key>UIApplicationShortcutItemIconType</key>
<string>UIApplicationShortcutIconTypeHome</string>
<key>UIApplicationShortcutItemType</key>
<string>home</string>
<key>UIApplicationShortcutItemTitle</key>
<string>Homepage</string>
</dict>
</array>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>

View File

@ -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!)
}