From ecb2f4d55175d9e9fdf77da06b1e81c3add5f824 Mon Sep 17 00:00:00 2001 From: khcrysalis <97859147+khcrysalis@users.noreply.github.com> Date: Mon, 10 Feb 2025 03:15:47 -0800 Subject: [PATCH] chore: lock app-updates behind preference --- Shared/Data/UserDefaults/Preferences.swift | 4 ++++ feather.xcodeproj/project.pbxproj | 8 +++---- iOS/Delegates/AppDelegate.swift | 22 ++++++++++--------- .../ServerOptionsViewController.swift | 20 +++++++++++++++-- 4 files changed, 38 insertions(+), 16 deletions(-) diff --git a/Shared/Data/UserDefaults/Preferences.swift b/Shared/Data/UserDefaults/Preferences.swift index 4974687..01f736e 100644 --- a/Shared/Data/UserDefaults/Preferences.swift +++ b/Shared/Data/UserDefaults/Preferences.swift @@ -23,6 +23,10 @@ enum Preferences { // Default repo is from the repository static var defaultRepos: Bool + @Storage(key: "Feather.AppUpdates", defaultValue: false) + // Default repo is from the repository + static var appUpdates: Bool + @Storage(key: "Feather.gotSSLCerts", defaultValue: false) static var gotSSLCerts: Bool diff --git a/feather.xcodeproj/project.pbxproj b/feather.xcodeproj/project.pbxproj index 606df04..7a2756a 100644 --- a/feather.xcodeproj/project.pbxproj +++ b/feather.xcodeproj/project.pbxproj @@ -1298,7 +1298,7 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 4; + CURRENT_PROJECT_VERSION = 5; DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = iOS/Info.plist; @@ -1321,7 +1321,7 @@ "$(PROJECT_DIR)/Shared/Magic", "$(PROJECT_DIR)/Shared/Resources", ); - MARKETING_VERSION = 1.3.0; + MARKETING_VERSION = 1.3.1; "OTHER_CPLUSPLUSFLAGS[arch=*]" = ( "$(OTHER_CFLAGS)", "-w", @@ -1351,7 +1351,7 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 4; + CURRENT_PROJECT_VERSION = 5; DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = iOS/Info.plist; @@ -1374,7 +1374,7 @@ "$(PROJECT_DIR)/Shared/Magic", "$(PROJECT_DIR)/Shared/Resources", ); - MARKETING_VERSION = 1.3.0; + MARKETING_VERSION = 1.3.1; "OTHER_CPLUSPLUSFLAGS[arch=*]" = ( "$(OTHER_CFLAGS)", "-w", diff --git a/iOS/Delegates/AppDelegate.swift b/iOS/Delegates/AppDelegate.swift index 2ade655..ad9aaac 100644 --- a/iOS/Delegates/AppDelegate.swift +++ b/iOS/Delegates/AppDelegate.swift @@ -64,16 +64,18 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UIOnboardingViewControlle Debug.shared.log(message: "Model: \(UIDevice.current.model)") Debug.shared.log(message: "Feather Version: \(logAppVersionInfo())\n") - // Register background task - BGTaskScheduler.shared.register(forTaskWithIdentifier: "kh.crysalis.feather.sourcerefresh", using: nil) { task in - self.handleAppRefresh(task: task as! BGAppRefreshTask) - } - scheduleAppRefresh() - - let backgroundQueue = OperationQueue() - backgroundQueue.qualityOfService = .background - let operation = SourceRefreshOperation() - backgroundQueue.addOperation(operation) + if Preferences.appUpdates { + // Register background task + BGTaskScheduler.shared.register(forTaskWithIdentifier: "kh.crysalis.feather.sourcerefresh", using: nil) { task in + self.handleAppRefresh(task: task as! BGAppRefreshTask) + } + scheduleAppRefresh() + + let backgroundQueue = OperationQueue() + backgroundQueue.qualityOfService = .background + let operation = SourceRefreshOperation() + backgroundQueue.addOperation(operation) + } return true } diff --git a/iOS/Views/Settings/Server Options/ServerOptionsViewController.swift b/iOS/Views/Settings/Server Options/ServerOptionsViewController.swift index 7120e04..410ce17 100644 --- a/iOS/Views/Settings/Server Options/ServerOptionsViewController.swift +++ b/iOS/Views/Settings/Server Options/ServerOptionsViewController.swift @@ -14,6 +14,9 @@ class ServerOptionsViewController: UITableViewController { var isDownloadingCertifcate = false var tableData = [ + [ + "App Updates" + ], [ "Use Server", String.localized("SETTINGS_VIEW_CONTROLLER_CELL_USE_CUSTOM_SERVER") @@ -25,6 +28,7 @@ class ServerOptionsViewController: UITableViewController { var sectionTitles = [ + "", String.localized("SETTINGS_VIEW_CONTROLLER_TITLE_ONLINE"), String.localized("SETTINGS_VIEW_CONTROLLER_TITLE_LOCAL"), ] @@ -54,8 +58,9 @@ extension ServerOptionsViewController { override func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? { switch section { - case 0: return String.localized("SETTINGS_VIEW_CONTROLLER_SECTION_FOOTER_DEFAULT_SERVER", arguments: Preferences.defaultInstallPath) - case 1: return String.localized("SETTINGS_VIEW_CONTROLLER_SECTION_FOOTER_SERVER_LIMITATIONS") + case 0: return "Whether updates should be checked, this is an experimental feature." + case 1: return String.localized("SETTINGS_VIEW_CONTROLLER_SECTION_FOOTER_DEFAULT_SERVER", arguments: Preferences.defaultInstallPath) + case 2: return String.localized("SETTINGS_VIEW_CONTROLLER_SECTION_FOOTER_SERVER_LIMITATIONS") default: return nil } @@ -71,6 +76,13 @@ extension ServerOptionsViewController { cell.textLabel?.text = cellText switch cellText { + case "App Updates": + let useS = SwitchViewCell() + useS.textLabel?.text = "Check For Signed App Updates" + useS.switchControl.addTarget(self, action: #selector(appUpdates(_:)), for: .valueChanged) + useS.switchControl.isOn = Preferences.appUpdates + useS.selectionStyle = .none + return useS case "Use Server": let useS = SwitchViewCell() useS.textLabel?.text = String.localized("SETTINGS_VIEW_CONTROLLER_CELL_ONLINE_INSTALL_METHOD") @@ -134,6 +146,10 @@ extension ServerOptionsViewController { tableView.deselectRow(at: indexPath, animated: true) } + @objc func appUpdates(_ sender: UISwitch) { + Preferences.appUpdates = sender.isOn + } + @objc func onlinePathToggled(_ sender: UISwitch) { Preferences.userSelectedServer = sender.isOn