diff --git a/AltStore/Managing Apps/AppManager.swift b/AltStore/Managing Apps/AppManager.swift index d11aa773..4df3fd8c 100644 --- a/AltStore/Managing Apps/AppManager.swift +++ b/AltStore/Managing Apps/AppManager.swift @@ -958,7 +958,13 @@ private extension AppManager } else { + DispatchQueue.main.schedule { + UIApplication.shared.isIdleTimerDisabled = UserDefaults.standard.isIdleTimeoutDisableEnabled + } performAppOperations() + DispatchQueue.main.schedule { + UIApplication.shared.isIdleTimerDisabled = false + } } return group diff --git a/AltStore/Operations/InstallAppOperation.swift b/AltStore/Operations/InstallAppOperation.swift index d7bb0414..e7a44c1b 100644 --- a/AltStore/Operations/InstallAppOperation.swift +++ b/AltStore/Operations/InstallAppOperation.swift @@ -48,6 +48,7 @@ final class InstallAppOperation: ResultOperation let backgroundContext = DatabaseManager.shared.persistentContainer.newBackgroundContext() backgroundContext.perform { + /* App */ let installedApp: InstalledApp diff --git a/AltStore/Settings/Settings.storyboard b/AltStore/Settings/Settings.storyboard index 199d839c..33fc1873 100644 --- a/AltStore/Settings/Settings.storyboard +++ b/AltStore/Settings/Settings.storyboard @@ -236,9 +236,45 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -269,7 +305,7 @@ - + @@ -309,7 +345,7 @@ - + @@ -353,28 +389,28 @@ - + - - + @@ -441,7 +477,7 @@ - + @@ -481,7 +517,7 @@ - + @@ -514,7 +550,7 @@ - + @@ -550,7 +586,7 @@ - + @@ -722,7 +758,6 @@ - @@ -731,6 +766,7 @@ + diff --git a/AltStore/Settings/SettingsViewController.swift b/AltStore/Settings/SettingsViewController.swift index efd40c4a..31ad924c 100644 --- a/AltStore/Settings/SettingsViewController.swift +++ b/AltStore/Settings/SettingsViewController.swift @@ -30,13 +30,14 @@ extension SettingsViewController fileprivate enum AppRefreshRow: Int, CaseIterable { case backgroundRefresh + case noIdleTimeout @available(iOS 14, *) case addToSiri static var allCases: [AppRefreshRow] { - guard #available(iOS 14, *) else { return [.backgroundRefresh] } - return [.backgroundRefresh, .addToSiri] + guard #available(iOS 14, *) else { return [.backgroundRefresh, .noIdleTimeout] } + return [.backgroundRefresh, .noIdleTimeout, .addToSiri] } } @@ -75,6 +76,7 @@ final class SettingsViewController: UITableViewController @IBOutlet private var accountTypeLabel: UILabel! @IBOutlet private var backgroundRefreshSwitch: UISwitch! + @IBOutlet private var noIdleTimeoutSwitch: UISwitch! @IBOutlet private var versionLabel: UILabel! @@ -282,6 +284,11 @@ private extension SettingsViewController UserDefaults.standard.isBackgroundRefreshEnabled = sender.isOn } + @IBAction func toggleNoIdleTimeoutEnabled(_ sender: UISwitch) + { + UserDefaults.standard.isIdleTimeoutDisableEnabled = sender.isOn + } + @available(iOS 14, *) @IBAction func addRefreshAppsShortcut() { @@ -412,15 +419,26 @@ extension SettingsViewController { let cell = super.tableView(tableView, cellForRowAt: indexPath) - if #available(iOS 14, *) {} - else if let cell = cell as? InsetGroupTableViewCell, - indexPath.section == Section.appRefresh.rawValue, - indexPath.row == AppRefreshRow.backgroundRefresh.rawValue +// if #available(iOS 14, *) {} +// else if let cell = cell as? InsetGroupTableViewCell, +// indexPath.section == Section.appRefresh.rawValue, +// indexPath.row == AppRefreshRow.backgroundRefresh.rawValue +// { +// // Only one row is visible pre-iOS 14. +// cell.style = .single +// } + + if AppRefreshRow.AllCases().count == 1 { - // Only one row is visible pre-iOS 14. - cell.style = .single + if let cell = cell as? InsetGroupTableViewCell, + indexPath.section == Section.appRefresh.rawValue, + indexPath.row == AppRefreshRow.backgroundRefresh.rawValue + { + cell.style = .single + } } + return cell } @@ -500,6 +518,7 @@ extension SettingsViewController switch row { case .backgroundRefresh: break + case .noIdleTimeout: break case .addToSiri: guard #available(iOS 14, *) else { return } self.addRefreshAppsShortcut() diff --git a/AltStoreCore/Extensions/UserDefaults+AltStore.swift b/AltStoreCore/Extensions/UserDefaults+AltStore.swift index e72d48dc..84fe5b67 100644 --- a/AltStoreCore/Extensions/UserDefaults+AltStore.swift +++ b/AltStoreCore/Extensions/UserDefaults+AltStore.swift @@ -27,6 +27,7 @@ public extension UserDefaults @NSManaged var preferredServerID: String? @NSManaged var isBackgroundRefreshEnabled: Bool + @NSManaged var isIdleTimeoutDisableEnabled: Bool @NSManaged var isDebugModeEnabled: Bool @NSManaged var presentedLaunchReminderNotification: Bool @@ -72,6 +73,7 @@ public extension UserDefaults let defaults = [ #keyPath(UserDefaults.isBackgroundRefreshEnabled): true, + #keyPath(UserDefaults.isIdleTimeoutDisableEnabled): true, #keyPath(UserDefaults.isLegacyDeactivationSupported): isLegacyDeactivationSupported, #keyPath(UserDefaults.activeAppLimitIncludesExtensions): activeAppLimitIncludesExtensions, #keyPath(UserDefaults.localServerSupportsRefreshing): localServerSupportsRefreshing,