diff --git a/AltStore/Resources/Assets.xcassets/GitHub.imageset/Contents.json b/AltStore/Resources/Assets.xcassets/GitHub.imageset/Contents.json new file mode 100644 index 00000000..1cdaf5ac --- /dev/null +++ b/AltStore/Resources/Assets.xcassets/GitHub.imageset/Contents.json @@ -0,0 +1,15 @@ +{ + "images" : [ + { + "filename" : "github.png", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" + } +} diff --git a/AltStore/Resources/Assets.xcassets/GitHub.imageset/github.png b/AltStore/Resources/Assets.xcassets/GitHub.imageset/github.png new file mode 100644 index 00000000..1d32044b Binary files /dev/null and b/AltStore/Resources/Assets.xcassets/GitHub.imageset/github.png differ diff --git a/AltStore/Resources/Assets.xcassets/Threads.imageset/Contents.json b/AltStore/Resources/Assets.xcassets/Threads.imageset/Contents.json new file mode 100644 index 00000000..221a14ea --- /dev/null +++ b/AltStore/Resources/Assets.xcassets/Threads.imageset/Contents.json @@ -0,0 +1,15 @@ +{ + "images" : [ + { + "filename" : "threads_icon.png", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" + } +} diff --git a/AltStore/Resources/Assets.xcassets/Threads.imageset/threads_icon.png b/AltStore/Resources/Assets.xcassets/Threads.imageset/threads_icon.png new file mode 100644 index 00000000..af1e915a Binary files /dev/null and b/AltStore/Resources/Assets.xcassets/Threads.imageset/threads_icon.png differ diff --git a/AltStore/Resources/Assets.xcassets/mastodon.imageset/Contents.json b/AltStore/Resources/Assets.xcassets/mastodon.imageset/Contents.json new file mode 100644 index 00000000..92dee4b0 --- /dev/null +++ b/AltStore/Resources/Assets.xcassets/mastodon.imageset/Contents.json @@ -0,0 +1,15 @@ +{ + "images" : [ + { + "filename" : "mastodon.png", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" + } +} diff --git a/AltStore/Resources/Assets.xcassets/mastodon.imageset/mastodon.png b/AltStore/Resources/Assets.xcassets/mastodon.imageset/mastodon.png new file mode 100644 index 00000000..69301254 Binary files /dev/null and b/AltStore/Resources/Assets.xcassets/mastodon.imageset/mastodon.png differ diff --git a/AltStore/Resources/Assets.xcassets/twitter.imageset/Contents.json b/AltStore/Resources/Assets.xcassets/twitter.imageset/Contents.json new file mode 100644 index 00000000..6a56a80a --- /dev/null +++ b/AltStore/Resources/Assets.xcassets/twitter.imageset/Contents.json @@ -0,0 +1,15 @@ +{ + "images" : [ + { + "filename" : "twitter.png", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" + } +} diff --git a/AltStore/Resources/Assets.xcassets/twitter.imageset/twitter.png b/AltStore/Resources/Assets.xcassets/twitter.imageset/twitter.png new file mode 100644 index 00000000..ef647d08 Binary files /dev/null and b/AltStore/Resources/Assets.xcassets/twitter.imageset/twitter.png differ diff --git a/AltStore/Settings/Settings.storyboard b/AltStore/Settings/Settings.storyboard index a093cb9e..40974b28 100644 --- a/AltStore/Settings/Settings.storyboard +++ b/AltStore/Settings/Settings.storyboard @@ -15,18 +15,90 @@ - + - + + + + + + + + + + + + + + @@ -918,6 +990,7 @@ + @@ -927,7 +1000,11 @@ - + + + + + @@ -1283,7 +1360,7 @@ Settings by i cons from the Noun Project - + @@ -1403,6 +1480,8 @@ Settings by i cons from the Noun Project + + diff --git a/AltStore/Settings/SettingsViewController.swift b/AltStore/Settings/SettingsViewController.swift index e85fa870..31f7a3a8 100644 --- a/AltStore/Settings/SettingsViewController.swift +++ b/AltStore/Settings/SettingsViewController.swift @@ -99,6 +99,11 @@ final class SettingsViewController: UITableViewController @IBOutlet private var enforceThreeAppLimitSwitch: UISwitch! @IBOutlet private var disableResponseCachingSwitch: UISwitch! + @IBOutlet private var mastodonButton: UIButton! + @IBOutlet private var threadsButton: UIButton! + @IBOutlet private var twitterButton: UIButton! + @IBOutlet private var githubButton: UIButton! + @IBOutlet private var versionLabel: UILabel! override var preferredStatusBarStyle: UIStatusBarStyle { @@ -142,7 +147,7 @@ final class SettingsViewController: UITableViewController let localizedVersion = installedApp.version #endif - self.versionLabel.text = NSLocalizedString(String(format: "AltStore %@", localizedVersion), comment: "AltStore Version") + self.versionLabel.text = NSLocalizedString(String(format: "Version %@", localizedVersion), comment: "AltStore Version") } else if let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String { @@ -159,9 +164,11 @@ final class SettingsViewController: UITableViewController versionString += " - \(!pair_test)" } } + self.versionLabel.text = NSLocalizedString(String(format: "Version %@", version), comment: "AltStore Version") } else { + self.versionLabel.text = nil versionString += "SideStore\t" } versionString += "\n\(Bundle.Info.appbundleIdentifier)" @@ -176,10 +183,26 @@ final class SettingsViewController: UITableViewController self.update() - if #available(iOS 15, *), let appearance = self.tabBarController?.tabBar.standardAppearance + if #available(iOS 15, *) { - appearance.stackedLayoutAppearance.normal.badgeBackgroundColor = .altPrimary - self.navigationController?.tabBarItem.scrollEdgeAppearance = appearance + if let appearance = self.tabBarController?.tabBar.standardAppearance + { + appearance.stackedLayoutAppearance.normal.badgeBackgroundColor = .altPrimary + self.navigationController?.tabBarItem.scrollEdgeAppearance = appearance + } + + // We can only configure the contentMode for a button's background image from Interface Builder. + // This works, but it means buttons don't visually highlight because there's no foreground image. + // As a workaround, we manually set the foreground image + contentMode here. + for button in [self.mastodonButton!, self.threadsButton!, self.twitterButton!, self.githubButton!] + { + // Get the assigned image from Interface Builder. + let image = button.configuration?.background.image + + button.configuration = nil + button.setImage(image, for: .normal) + button.imageView?.contentMode = .scaleAspectFit + } } } @@ -497,6 +520,51 @@ private extension SettingsViewController } } } + + func openMastodon(username: String) + { + // Rely on universal links to open app. + + let components = username.split(separator: "@") + guard components.count == 2 else { return } + + let server = String(components[1]) + let username = "@" + String(components[0]) + + guard let serverURL = URL(string: "https://" + server) else { return } + + let mastodonURL = serverURL.appendingPathComponent(username) + UIApplication.shared.open(mastodonURL, options: [:]) + } + + func openThreads(username: String) + { + // Rely on universal links to open app. + + let safariURL = URL(string: "https://www.threads.net/@" + username)! + UIApplication.shared.open(safariURL, options: [:]) + } + + @IBAction func followAltStoreMastodon() + { + self.openMastodon(username: "@altstore@fosstodon.org") + } + + @IBAction func followAltStoreThreads() + { + self.openThreads(username: "altstoreio") + } + + @IBAction func followAltStoreTwitter() + { + self.openTwitter(username: "altstoreio") + } + + @IBAction func followAltStoreGitHub() + { + let safariURL = URL(string: "https://github.com/altstoreio")! + UIApplication.shared.open(safariURL, options: [:]) + } } private extension SettingsViewController