diff --git a/Capture.xcodeproj/project.pbxproj b/Capture.xcodeproj/project.pbxproj index 03216a4..56dec11 100755 --- a/Capture.xcodeproj/project.pbxproj +++ b/Capture.xcodeproj/project.pbxproj @@ -35,6 +35,7 @@ 0B3D7A70223109DD000F8C85 /* Path+Codable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B3D7A67223109DD000F8C85 /* Path+Codable.swift */; }; 0B3D7A71223109DD000F8C85 /* Path+StringConvertibles.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B3D7A68223109DD000F8C85 /* Path+StringConvertibles.swift */; }; 0B3D7A7422310A52000F8C85 /* PMKFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0B3D7A7322310A52000F8C85 /* PMKFoundation.framework */; }; + 0B3D7A7622311676000F8C85 /* Alerts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B3D7A7522311676000F8C85 /* Alerts.swift */; }; 0B4309A7221916C500766DB0 /* VideoPlayerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B4309A6221916C500766DB0 /* VideoPlayerViewController.swift */; }; 0B4309A9221926C500766DB0 /* BundleExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B4309A8221926C500766DB0 /* BundleExtension.swift */; }; 0B4309AF22198FAA00766DB0 /* Preferences.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0B4309AC22198FAA00766DB0 /* Preferences.storyboard */; }; @@ -109,6 +110,7 @@ 0B3D7A67223109DD000F8C85 /* Path+Codable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Path+Codable.swift"; sourceTree = ""; }; 0B3D7A68223109DD000F8C85 /* Path+StringConvertibles.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Path+StringConvertibles.swift"; sourceTree = ""; }; 0B3D7A7322310A52000F8C85 /* PMKFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PMKFoundation.framework; path = Carthage/Build/Mac/PMKFoundation.framework; sourceTree = ""; }; + 0B3D7A7522311676000F8C85 /* Alerts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Alerts.swift; sourceTree = ""; }; 0B4309A6221916C500766DB0 /* VideoPlayerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoPlayerViewController.swift; sourceTree = ""; }; 0B4309A8221926C500766DB0 /* BundleExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BundleExtension.swift; sourceTree = ""; }; 0B4309AC22198FAA00766DB0 /* Preferences.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Preferences.storyboard; sourceTree = ""; }; @@ -306,6 +308,7 @@ 0BC83209221A085200FD8CF4 /* Utilities */ = { isa = PBXGroup; children = ( + 0B3D7A7522311676000F8C85 /* Alerts.swift */, 0B4309A8221926C500766DB0 /* BundleExtension.swift */, 0B64CD922218DA3F004F6321 /* DirectoryHandler.swift */, 0B64CD9B2218DE1B004F6321 /* Result.swift */, @@ -551,6 +554,7 @@ 0BE418BC221AF3B200B8E85D /* ContainerViewController.swift in Sources */, 0B581A2A222199EA006EF012 /* HotKeyService.swift in Sources */, 0B64CD972218DD5A004F6321 /* ConvertGif.swift in Sources */, + 0B3D7A7622311676000F8C85 /* Alerts.swift in Sources */, 0B3276CA2219D9410028F007 /* UserDefaultsExtension.swift in Sources */, 0B3276D02219E6810028F007 /* GeneralPreferencesViewController.swift in Sources */, 0B3D7A5E223109CC000F8C85 /* Version+Comparable.swift in Sources */, diff --git a/Capture/AppUpdater/AppUpdater.swift b/Capture/AppUpdater/AppUpdater.swift index 85338db..7e4f32a 100644 --- a/Capture/AppUpdater/AppUpdater.swift +++ b/Capture/AppUpdater/AppUpdater.swift @@ -4,6 +4,11 @@ import PMKFoundation import Foundation import PromiseKit +enum AppUpdaterError: Error { + case alreadyUpToDate + case failure(String) +} + public class AppUpdater { var active = Promise() #if !DEBUG diff --git a/Capture/Info.plist b/Capture/Info.plist index daec7ea..0a037dc 100755 --- a/Capture/Info.plist +++ b/Capture/Info.plist @@ -17,9 +17,9 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.0 + 0.9.1 CFBundleVersion - 1 + 0.9.1 LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) NSHumanReadableCopyright diff --git a/Capture/Preferences/View/GeneralPreferencesViewController.swift b/Capture/Preferences/View/GeneralPreferencesViewController.swift index ade40fc..5d19d3f 100644 --- a/Capture/Preferences/View/GeneralPreferencesViewController.swift +++ b/Capture/Preferences/View/GeneralPreferencesViewController.swift @@ -17,6 +17,16 @@ class GeneralPreferencesViewController: PreferencesViewController { prepareHotKeys() } + @IBAction func userRequestedAnExplicitUpdateCheck(_ sender: Any) { + let delegate = NSApplication.shared.delegate as? AppDelegate + delegate?.updater.check().catch(policy: .allErrors) { error in + if error.isCancelled { + showAlert(title: "alreadyUpToDateTitle".localized, message: ErrorMessageProvider.string(for: AppUpdaterError.alreadyUpToDate)) + } else { + self.presentError(NSError.create(from: AppUpdaterError.failure(error.localizedDescription))) + } + } + } } // MARK: - Shortcut diff --git a/Capture/Preferences/View/Preferences.storyboard b/Capture/Preferences/View/Preferences.storyboard index 765f3ae..985135a 100755 --- a/Capture/Preferences/View/Preferences.storyboard +++ b/Capture/Preferences/View/Preferences.storyboard @@ -56,11 +56,11 @@ - + - + @@ -77,7 +77,7 @@ - + @@ -85,7 +85,7 @@ - + @@ -93,7 +93,7 @@ - + @@ -101,7 +101,7 @@ - + @@ -109,28 +109,62 @@ - + + + + + + + + + + + + + + + + + + - + + + + + + + + + @@ -140,7 +174,7 @@ - + diff --git a/Capture/Utilities/Alerts.swift b/Capture/Utilities/Alerts.swift new file mode 100644 index 0000000..2e7306f --- /dev/null +++ b/Capture/Utilities/Alerts.swift @@ -0,0 +1,9 @@ +import AppKit + +func showAlert(title: String, message: String) { + let alert = NSAlert.init() + alert.messageText = title + alert.informativeText = message + alert.addButton(withTitle: "OK") + alert.runModal() +} diff --git a/Capture/Utilities/Error/ErrorMessageProvider.swift b/Capture/Utilities/Error/ErrorMessageProvider.swift index 052ca0d..08d3b97 100644 --- a/Capture/Utilities/Error/ErrorMessageProvider.swift +++ b/Capture/Utilities/Error/ErrorMessageProvider.swift @@ -8,6 +8,8 @@ struct ErrorMessageProvider { return string(for: error) } else if let error = error as? VideoPlayerError { return string(for: error) + } else if let error = error as? AppUpdaterError { + return string(for: error) } return error.localizedDescription } @@ -36,4 +38,13 @@ struct ErrorMessageProvider { return "exportFailed".localized } } + + private static func string(for error: AppUpdaterError) -> String { + switch error { + case .alreadyUpToDate: + return "alreadyUpToDate".localized + case .failure(let message): + return String(format: "updateFailed".localized, message) + } + } } diff --git a/Capture/en.lproj/Localizable.strings b/Capture/en.lproj/Localizable.strings index d182f66..37ae6b3 100644 --- a/Capture/en.lproj/Localizable.strings +++ b/Capture/en.lproj/Localizable.strings @@ -18,4 +18,6 @@ "noCurrentItem" = "The video player does not know which video file to export. Therefore the operation failed."; "missingFile" = "The video file could not be found and therefore the export failed. Please try again with a different recording."; "exportFailed" = "The GIF export failed. Please try again with a different recording."; - +"alreadyUpToDate" = "Capture is already up to date. Thank you for using Capture ❤️"; +"updateFailed" = "Checking for an update failed: %@"; +"alreadyUpToDateTitle" = "Already up to date!";