Skip to content

Commit

Permalink
chore: lock app-updates behind preference
Browse files Browse the repository at this point in the history
  • Loading branch information
khcrysalis committed Feb 10, 2025
1 parent 71cb7ea commit ecb2f4d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 16 deletions.
4 changes: 4 additions & 0 deletions Shared/Data/UserDefaults/Preferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions feather.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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",
Expand Down Expand Up @@ -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;
Expand All @@ -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",
Expand Down
22 changes: 12 additions & 10 deletions iOS/Delegates/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -25,6 +28,7 @@ class ServerOptionsViewController: UITableViewController {

var sectionTitles =
[
"",
String.localized("SETTINGS_VIEW_CONTROLLER_TITLE_ONLINE"),
String.localized("SETTINGS_VIEW_CONTROLLER_TITLE_LOCAL"),
]
Expand Down Expand Up @@ -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
}
Expand All @@ -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")
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit ecb2f4d

Please sign in to comment.