mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 06:43:25 +01:00
[AltBackup+Schemes]: Fixes for URL schemes throughout both AltBackup and SideStore apps
This commit is contained in:
@@ -88,14 +88,25 @@ private extension AppDelegate
|
||||
|
||||
@objc func operationDidFinish(_ notification: Notification)
|
||||
{
|
||||
defer { self.currentBackupReturnURL = nil }
|
||||
defer {
|
||||
self.currentBackupReturnURL = nil
|
||||
}
|
||||
|
||||
// TODO: @mahee96: This doesn't account cases where backup is too long and user switched to other apps
|
||||
// The check for self.currentBackupReturnURL when backup/restore was still in progress but app switched
|
||||
// between FG/BG is improper, since it will ignore(eat up) the response(success/failure) to parent
|
||||
//
|
||||
// This leaves the backup/restore to show dummy animation forever
|
||||
guard
|
||||
let returnURL = self.currentBackupReturnURL,
|
||||
let result = notification.userInfo?[AppDelegate.operationResultKey] as? Result<Void, Error>
|
||||
else { return }
|
||||
else {
|
||||
return // This is bad (Needs fixing - never eat up response like this unless there is no context to post response to!)
|
||||
}
|
||||
|
||||
guard var components = URLComponents(url: returnURL, resolvingAgainstBaseURL: false) else { return }
|
||||
guard var components = URLComponents(url: returnURL, resolvingAgainstBaseURL: false) else {
|
||||
return // This is ASSERTION Failure, ie RETURN URL needs to be valid. So ignoring (eating up) response is not the solution
|
||||
}
|
||||
|
||||
switch result
|
||||
{
|
||||
@@ -112,6 +123,7 @@ private extension AppDelegate
|
||||
guard let responseURL = components.url else { return }
|
||||
|
||||
DispatchQueue.main.async {
|
||||
// Response to the caller/parent app is posted here (url is provided by caller in incoming query params)
|
||||
UIApplication.shared.open(responseURL, options: [:]) { (success) in
|
||||
print("Sent response to app with success:", success)
|
||||
}
|
||||
|
||||
@@ -131,7 +131,9 @@ class BackupController: NSObject
|
||||
guard
|
||||
let altstoreAppGroup = Bundle.main.altstoreAppGroup,
|
||||
let sharedDirectoryURL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: altstoreAppGroup)
|
||||
else { throw BackupError(.appGroupNotFound(nil), description: NSLocalizedString("Unable to create backup directory.", comment: "")) }
|
||||
else {
|
||||
throw BackupError(.appGroupNotFound(nil), description: NSLocalizedString("Unable to create backup directory.", comment: ""))
|
||||
}
|
||||
|
||||
let backupsDirectory = sharedDirectoryURL.appendingPathComponent("Backups")
|
||||
|
||||
|
||||
@@ -28,10 +28,10 @@
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Editor</string>
|
||||
<key>CFBundleURLName</key>
|
||||
<string>AltBackup General</string>
|
||||
<string>SideBackup General</string>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>altbackup</string>
|
||||
<string>sidebackup</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
|
||||
@@ -82,23 +82,25 @@ class ViewController: UIViewController
|
||||
self.activityIndicatorView.color = .altstoreText
|
||||
self.activityIndicatorView.startAnimating()
|
||||
|
||||
#if DEBUG
|
||||
let button1 = UIButton(type: .system)
|
||||
button1.setTitle("Backup", for: .normal)
|
||||
button1.setTitleColor(.white, for: .normal)
|
||||
button1.titleLabel?.font = UIFont.preferredFont(forTextStyle: .body)
|
||||
button1.addTarget(self, action: #selector(ViewController.backup), for: .primaryActionTriggered)
|
||||
|
||||
let button2 = UIButton(type: .system)
|
||||
button2.setTitle("Restore", for: .normal)
|
||||
button2.setTitleColor(.white, for: .normal)
|
||||
button2.titleLabel?.font = UIFont.preferredFont(forTextStyle: .body)
|
||||
button2.addTarget(self, action: #selector(ViewController.restore), for: .primaryActionTriggered)
|
||||
|
||||
let arrangedSubviews = [self.textLabel!, self.detailTextLabel!, self.activityIndicatorView!, button1, button2]
|
||||
#else
|
||||
// TODO: @mahee96: Disabled this buttons which were present for debugging purpose.
|
||||
// Can find something useful for these later, but these are not required by this backup/restore app
|
||||
// #if DEBUG
|
||||
// let button1 = UIButton(type: .system)
|
||||
// button1.setTitle("Backup", for: .normal)
|
||||
// button1.setTitleColor(.white, for: .normal)
|
||||
// button1.titleLabel?.font = UIFont.preferredFont(forTextStyle: .body)
|
||||
// button1.addTarget(self, action: #selector(ViewController.backup), for: .primaryActionTriggered)
|
||||
//
|
||||
// let button2 = UIButton(type: .system)
|
||||
// button2.setTitle("Restore", for: .normal)
|
||||
// button2.setTitleColor(.white, for: .normal)
|
||||
// button2.titleLabel?.font = UIFont.preferredFont(forTextStyle: .body)
|
||||
// button2.addTarget(self, action: #selector(ViewController.restore), for: .primaryActionTriggered)
|
||||
//
|
||||
// let arrangedSubviews = [self.textLabel!, self.detailTextLabel!, self.activityIndicatorView!, button1, button2]
|
||||
// #else
|
||||
let arrangedSubviews = [self.textLabel!, self.detailTextLabel!, self.activityIndicatorView!]
|
||||
#endif
|
||||
// #endif
|
||||
|
||||
let stackView = UIStackView(arrangedSubviews: arrangedSubviews)
|
||||
stackView.translatesAutoresizingMaskIntoConstraints = false
|
||||
@@ -155,7 +157,8 @@ private extension ViewController
|
||||
self.textLabel.text = NSLocalizedString("Restoring app data…", comment: "")
|
||||
self.detailTextLabel.isHidden = true
|
||||
self.activityIndicatorView.startAnimating()
|
||||
|
||||
|
||||
// TODO: @mahee96: This is pointless since, app going in bg/fg should still report its last operation properly
|
||||
case .none:
|
||||
self.textLabel.text = String(format: NSLocalizedString("%@ is inactive.", comment: ""),
|
||||
Bundle.main.appName ?? NSLocalizedString("App", comment: ""))
|
||||
@@ -198,6 +201,9 @@ private extension ViewController
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: @mahee96: This doesn't account cases where backup is too long and user switched to other apps
|
||||
// Now the user has lost his progress since current operation was cancelled due to switch between FG and BG
|
||||
// if this just the reset for enum such that UI stops showing progress circle, then this is fine!
|
||||
@objc func didEnterBackground(_ notification: Notification)
|
||||
{
|
||||
// Reset UI once we've left app (but not before).
|
||||
|
||||
Reference in New Issue
Block a user