Skip to content

Commit 3591be3

Browse files
committed
Migrate to Sparkle 2.8.1 from Sparkle 1 and format source
1 parent ce56515 commit 3591be3

File tree

4 files changed

+46
-58
lines changed

4 files changed

+46
-58
lines changed

GitUp/Application/AppDelegate.m

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@
4242
#define kToolName @"gitup"
4343
#define kToolInstallPath @"/usr/local/bin/" kToolName
4444

45-
@interface AppDelegate () <UNUserNotificationCenterDelegate, SUUpdaterDelegate, NSMenuItemValidation>
45+
@interface AppDelegate () <UNUserNotificationCenterDelegate, SPUUpdaterDelegate, NSMenuItemValidation>
4646
@property(nonatomic, strong) AboutWindowController* aboutWindowController;
4747
@property(nonatomic, strong) CloneWindowController* cloneWindowController;
4848
@property(nonatomic, strong) PreferencesWindowController* preferencesWindowController;
4949
@property(nonatomic, strong) WelcomeWindowController* welcomeWindowController;
5050
@end
5151

5252
@implementation AppDelegate {
53-
SUUpdater* _updater;
53+
SPUStandardUpdaterController* _updaterController;
5454
BOOL _manualCheck;
5555

5656
CFMessagePortRef _messagePort;
@@ -74,7 +74,7 @@ - (CloneWindowController*)cloneWindowController {
7474

7575
- (void)didChangeReleaseChannel:(BOOL)didChange {
7676
if (didChange) {
77-
[_updater checkForUpdatesInBackground];
77+
[_updaterController.updater checkForUpdatesInBackground];
7878
}
7979
}
8080

@@ -205,13 +205,14 @@ - (void)applicationDidFinishLaunching:(NSNotification*)notification {
205205
#if !DEBUG
206206
// Initialize Sparkle and check for update immediately
207207
if (![[NSUserDefaults standardUserDefaults] boolForKey:kUserDefaultsKey_DisableSparkle]) {
208-
_updater = [SUUpdater sharedUpdater];
209-
_updater.delegate = self;
210-
_updater.automaticallyChecksForUpdates = YES;
211-
_updater.sendsSystemProfile = NO;
208+
_updaterController = [[SPUStandardUpdaterController alloc] initWithStartingUpdater:YES
209+
updaterDelegate:self
210+
userDriverDelegate:nil];
211+
_updaterController.updater.automaticallyChecksForUpdates = YES;
212+
_updaterController.updater.sendsSystemProfile = NO;
212213

213214
_manualCheck = NO;
214-
[_updater checkForUpdatesInBackground];
215+
[_updaterController.updater checkForUpdatesInBackground];
215216
}
216217
#endif
217218

@@ -369,7 +370,7 @@ - (NSDictionary*)_processToolCommand:(NSDictionary*)input {
369370

370371
- (BOOL)validateMenuItem:(NSMenuItem*)menuItem {
371372
if (menuItem.action == @selector(checkForUpdates:)) {
372-
return [_updater validateMenuItem:menuItem];
373+
return _updaterController.updater.canCheckForUpdates;
373374
}
374375
return YES;
375376
}
@@ -480,7 +481,7 @@ - (IBAction)dimissModal:(id)sender {
480481

481482
- (IBAction)checkForUpdates:(id)sender {
482483
_manualCheck = YES;
483-
[_updater checkForUpdatesInBackground];
484+
[_updaterController checkForUpdates:sender];
484485
}
485486

486487
- (IBAction)installTool:(id)sender {
@@ -529,20 +530,20 @@ - (IBAction)installTool:(id)sender {
529530
}
530531
}
531532

532-
#pragma mark - SUUpdaterDelegate
533+
#pragma mark - SPUUpdaterDelegate
533534

534-
- (NSString*)feedURLStringForUpdater:(SUUpdater*)updater {
535+
- (NSString*)feedURLStringForUpdater:(SPUUpdater*)updater {
535536
NSString* channel = [[NSUserDefaults standardUserDefaults] stringForKey:kUserDefaultsKey_ReleaseChannel];
536537
return [NSString stringWithFormat:kURL_AppCast, channel];
537538
}
538539

539-
- (void)updater:(SUUpdater*)updater didFindValidUpdate:(SUAppcastItem*)item {
540+
- (void)updater:(SPUUpdater*)updater didFindValidUpdate:(SUAppcastItem*)item {
540541
_manualCheck = NO;
541542
NSString* channel = [[NSUserDefaults standardUserDefaults] stringForKey:kUserDefaultsKey_ReleaseChannel];
542543
XLOG_INFO(@"Did find app update on channel '%@' for version %@", channel, item.versionString);
543544
}
544545

545-
- (void)updaterDidNotFindUpdate:(SUUpdater*)updater {
546+
- (void)updaterDidNotFindUpdate:(SPUUpdater*)updater error:(NSError*)error {
546547
NSString* channel = [[NSUserDefaults standardUserDefaults] stringForKey:kUserDefaultsKey_ReleaseChannel];
547548
XLOG_VERBOSE(@"App is up-to-date at version %@ on channel '%@'", [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"], channel);
548549
if (_manualCheck) {
@@ -555,22 +556,23 @@ - (void)updaterDidNotFindUpdate:(SUUpdater*)updater {
555556
}
556557
}
557558

558-
- (void)updater:(SUUpdater*)updater didAbortWithError:(NSError*)error {
559+
- (void)updater:(SPUUpdater*)updater didAbortWithError:(NSError*)error {
559560
NSString* channel = [[NSUserDefaults standardUserDefaults] stringForKey:kUserDefaultsKey_ReleaseChannel];
560561
if (![error.domain isEqualToString:SUSparkleErrorDomain] || (error.code != SUNoUpdateError)) {
561562
XLOG_ERROR(@"App update on channel '%@' aborted: %@", channel, error);
562563
}
563564
}
564565

565-
- (void)updater:(SUUpdater*)updater willInstallUpdate:(SUAppcastItem*)item {
566+
- (void)updater:(SPUUpdater*)updater willInstallUpdate:(SUAppcastItem*)item {
566567
XLOG_INFO(@"Installing app update for version %@", item.versionString);
567568
}
568569

569-
- (void)updater:(SUUpdater*)updater willInstallUpdateOnQuit:(SUAppcastItem*)item immediateInstallationInvocation:(NSInvocation*)invocation {
570+
- (BOOL)updater:(SPUUpdater*)updater willInstallUpdateOnQuit:(SUAppcastItem*)item immediateInstallationBlock:(void (^)(void))installationBlock {
570571
XLOG_INFO(@"Will install app update for version %@ on quit", item.versionString);
571572
[self _showNotificationWithTitle:NSLocalizedString(@"Update Available", nil)
572573
action:NULL
573574
message:NSLocalizedString(@"Relaunch GitUp to update to version %@ (%@).", nil), item.displayVersionString, item.versionString];
575+
return NO;
574576
}
575577

576578
#pragma mark - UNUserNotificationCenterDelegate

GitUp/Application/Document.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -910,11 +910,11 @@ - (void)_showHelpWithIdentifier:(NSString*)identifier {
910910
XLOG_DEBUG_UNREACHABLE();
911911
}
912912
if (showHelp) {
913-
NSWindow *window = _mainTabView.window;
913+
NSWindow* window = _mainTabView.window;
914914
CGRect frame = window.frame;
915915
CGRect layoutRect = window.contentLayoutRect;
916916
CGFloat toolbarHeight = frame.size.height - layoutRect.size.height;
917-
917+
918918
NSRect contentBounds = _contentView.bounds;
919919
_helpView.hidden = NO;
920920
_mainTabView.frame = NSMakeRect(contentBounds.origin.x, contentBounds.origin.y, contentBounds.size.width, contentBounds.size.height - _helpView.frame.size.height - toolbarHeight);

GitUp/GitUp.xcodeproj/project.pbxproj

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,6 @@
335335
E2C338A919F8562F00063D95 /* Resources */,
336336
E2653D271A5B3298006A9871 /* Copy Frameworks */,
337337
E21DCAF21B2538FB006424E8 /* Copy Tool */,
338-
1D7D03E724528390002C1736 /* ShellScript */,
339338
1DE5583E2B9D89BF006BA332 /* Xcode 15 Framework Patching */,
340339
);
341340
buildRules = (
@@ -444,23 +443,6 @@
444443
/* End PBXResourcesBuildPhase section */
445444

446445
/* Begin PBXShellScriptBuildPhase section */
447-
1D7D03E724528390002C1736 /* ShellScript */ = {
448-
isa = PBXShellScriptBuildPhase;
449-
buildActionMask = 2147483647;
450-
files = (
451-
);
452-
inputFileListPaths = (
453-
);
454-
inputPaths = (
455-
);
456-
outputFileListPaths = (
457-
);
458-
outputPaths = (
459-
);
460-
runOnlyForDeploymentPostprocessing = 0;
461-
shellPath = /bin/sh;
462-
shellScript = "# Code sign sparkle app\nLOCATION=\"${BUILT_PRODUCTS_DIR}\"/\"${FRAMEWORKS_FOLDER_PATH}\"\n\n# By default, use the configured code signing identity for the project/target\nIDENTITY=\"${EXPANDED_CODE_SIGN_IDENTITY}\"\nif [ \"$IDENTITY\" == \"\" ]\nthen\n # If a code signing identity is not specified, use ad hoc signing\n IDENTITY=\"-\"\nfi\ncodesign --verbose --force --deep -o runtime --sign \"$IDENTITY\" \"$LOCATION/Sparkle.framework/Versions/A/Resources/AutoUpdate.app\"\ncodesign --verbose --force -o runtime --sign \"$IDENTITY\" \"$LOCATION/Sparkle.framework/Versions/A\"\n";
463-
};
464446
1DE5583E2B9D89BF006BA332 /* Xcode 15 Framework Patching */ = {
465447
isa = PBXShellScriptBuildPhase;
466448
buildActionMask = 8;
@@ -724,7 +706,7 @@
724706
repositoryURL = "https://github.com/sparkle-project/Sparkle";
725707
requirement = {
726708
kind = exactVersion;
727-
version = 1.27.3;
709+
version = 2.8.1;
728710
};
729711
};
730712
/* End XCRemoteSwiftPackageReference section */

GitUpKit/Utilities/GIWindowController.m

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -238,38 +238,42 @@ - (void)showOverlayWithStyle:(GIOverlayStyle)style message:(NSString*)message {
238238
[CATransaction flush];
239239

240240
_overlayTextField.stringValue = message;
241-
[NSAnimationContext runAnimationGroup:^(NSAnimationContext * _Nonnull context) {
241+
[NSAnimationContext runAnimationGroup:^(NSAnimationContext* _Nonnull context) {
242242
context.duration = kOverlayAnimationInDuration;
243243
context.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
244244
_overlayView.animator.alphaValue = 1;
245245
}];
246246
} else {
247-
[NSAnimationContext runAnimationGroup:^(NSAnimationContext * _Nonnull context) {
248-
context.duration = kOverlayAnimationInDuration;
249-
context.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
250-
_overlayTextField.animator.alphaValue = 0.0;
251-
} completionHandler:^{
252-
_overlayTextField.stringValue = message;
253-
[NSAnimationContext runAnimationGroup:^(NSAnimationContext * _Nonnull context) {
254-
context.duration = kOverlayAnimationInDuration;
255-
context.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
256-
_overlayTextField.animator.alphaValue = 1.0;
257-
}];
258-
}];
247+
[NSAnimationContext
248+
runAnimationGroup:^(NSAnimationContext* _Nonnull context) {
249+
context.duration = kOverlayAnimationInDuration;
250+
context.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
251+
_overlayTextField.animator.alphaValue = 0.0;
252+
}
253+
completionHandler:^{
254+
_overlayTextField.stringValue = message;
255+
[NSAnimationContext runAnimationGroup:^(NSAnimationContext* _Nonnull context) {
256+
context.duration = kOverlayAnimationInDuration;
257+
context.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
258+
_overlayTextField.animator.alphaValue = 1.0;
259+
}];
260+
}];
259261
}
260262

261263
CFRunLoopTimerSetNextFireDate(_overlayTimer, CFAbsoluteTimeGetCurrent() + _overlayDelay);
262264
}
263265

264266
- (void)hideOverlay {
265267
if (_overlayView.superview) {
266-
[NSAnimationContext runAnimationGroup:^(NSAnimationContext * _Nonnull context) {
267-
context.duration = kOverlayAnimationOutDuration;
268-
context.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
269-
_overlayView.animator.alphaValue = 0;
270-
} completionHandler:^{
271-
[_overlayView removeFromSuperview];
272-
}];
268+
[NSAnimationContext
269+
runAnimationGroup:^(NSAnimationContext* _Nonnull context) {
270+
context.duration = kOverlayAnimationOutDuration;
271+
context.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
272+
_overlayView.animator.alphaValue = 0;
273+
}
274+
completionHandler:^{
275+
[_overlayView removeFromSuperview];
276+
}];
273277

274278
CFRunLoopTimerSetNextFireDate(_overlayTimer, HUGE_VALF);
275279
} else {

0 commit comments

Comments
 (0)