From 0a35f9d807bd960d9df7f12786c1707bea504262 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sat, 23 Jan 2021 13:53:17 -0800 Subject: [PATCH 1/7] Hide skip and later buttons in appropriate scenarios --- Sparkle/SUUpdateAlert.m | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/Sparkle/SUUpdateAlert.m b/Sparkle/SUUpdateAlert.m index fd8304aa..0e0c7b86 100644 --- a/Sparkle/SUUpdateAlert.m +++ b/Sparkle/SUUpdateAlert.m @@ -391,7 +391,8 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE // When we show release notes, it looks ugly if the install buttons are not closer to the release notes view // However when we don't show release notes, it looks ugly if the install buttons are too close to the description field. Shrugs. - if (showReleaseNotes && ![self allowsAutomaticUpdates]) { + BOOL automaticDownloadsEnabledByDeveloper = [self.host boolForInfoDictionaryKey:SUAutomaticallyUpdateKey]; + if (showReleaseNotes && (!self.allowsAutomaticUpdates || automaticDownloadsEnabledByDeveloper)) { NSLayoutConstraint *skipButtonToReleaseNotesContainerConstraint = [NSLayoutConstraint constraintWithItem:self.skipButton attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.releaseNotesContainerView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:12.0]; [self.window.contentView addConstraint:skipButtonToReleaseNotesContainerConstraint]; @@ -399,22 +400,31 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE [self.automaticallyInstallUpdatesButton removeFromSuperview]; } + if (automaticDownloadsEnabledByDeveloper && !showReleaseNotes) { + // Disable automatic install updates option if the developer wishes for it in Info.plist + // If we are showing release notes, this button will be hidden instead + self.automaticallyInstallUpdatesButton.enabled = NO; + } + BOOL startedInstalling = (self.resumableCompletionBlock != nil); if (startedInstalling) { - // Should we hide the button or disable the button if the update has already started installing? - // Personally I think it looks better when the button is visible on the window... - // Anyway an already downloaded update can't be skipped - self.skipButton.enabled = NO; + // An already downloaded & resumable update can't be skipped + self.skipButton.hidden = YES; // We're going to be relaunching pretty instantaneously self.installButton.title = SULocalizedString(@"Install & Relaunch", nil); // We should be explicit that the update will be installed on quit - self.laterButton.title = SULocalizedString(@"Install on Quit", nil); + self.laterButton.title = SULocalizedString(@"Install Later", @"Alternate title for 'Remind me later' button when downloaded updates can be resumed"); } if ([self.updateItem isCriticalUpdate]) { - self.skipButton.enabled = NO; + self.skipButton.hidden = YES; + self.laterButton.hidden = YES; + } + + if (![self.host boolForKey:SUEnableAutomaticChecksKey]) { + self.laterButton.hidden = YES; } [self.window center]; From c3ce4f624b9c212ab3d50f6ca0fa9ce923e426ee Mon Sep 17 00:00:00 2001 From: Zorg Date: Sat, 23 Jan 2021 18:15:58 -0800 Subject: [PATCH 2/7] Hide skip button when developer enables automatic downloads too --- Sparkle/SUUpdateAlert.m | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Sparkle/SUUpdateAlert.m b/Sparkle/SUUpdateAlert.m index 0e0c7b86..bffd26d0 100644 --- a/Sparkle/SUUpdateAlert.m +++ b/Sparkle/SUUpdateAlert.m @@ -400,10 +400,14 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE [self.automaticallyInstallUpdatesButton removeFromSuperview]; } - if (automaticDownloadsEnabledByDeveloper && !showReleaseNotes) { - // Disable automatic install updates option if the developer wishes for it in Info.plist - // If we are showing release notes, this button will be hidden instead - self.automaticallyInstallUpdatesButton.enabled = NO; + if (automaticDownloadsEnabledByDeveloper) { + if (!showReleaseNotes) { + // Disable automatic install updates option if the developer wishes for it in Info.plist + // If we are showing release notes, this button will be hidden instead + self.automaticallyInstallUpdatesButton.enabled = NO; + } + + self.skipButton.hidden = YES; } BOOL startedInstalling = (self.resumableCompletionBlock != nil); From c1381d48d18f84278c6b302a57310d42f431b624 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sat, 23 Jan 2021 19:29:50 -0800 Subject: [PATCH 3/7] Add comments and rename some title alert strings to match 1.x --- Sparkle/SUUpdateAlert.m | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Sparkle/SUUpdateAlert.m b/Sparkle/SUUpdateAlert.m index bffd26d0..d9a0990b 100644 --- a/Sparkle/SUUpdateAlert.m +++ b/Sparkle/SUUpdateAlert.m @@ -389,10 +389,15 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE [self.releaseNotesContainerView removeFromSuperview]; } + // NOTE: The code below for deciding what buttons to hide is complex! Due to array of feature configurations :) + // When we show release notes, it looks ugly if the install buttons are not closer to the release notes view // However when we don't show release notes, it looks ugly if the install buttons are too close to the description field. Shrugs. + // Automatic downloads is enabled by developer if they set SUAutomaticallyUpdateKey in Info.plist, + // rather than the user toggling the setting BOOL automaticDownloadsEnabledByDeveloper = [self.host boolForInfoDictionaryKey:SUAutomaticallyUpdateKey]; if (showReleaseNotes && (!self.allowsAutomaticUpdates || automaticDownloadsEnabledByDeveloper)) { + // Fix constraints so that buttons aren't far away from web view when we hide the automatic updates check box NSLayoutConstraint *skipButtonToReleaseNotesContainerConstraint = [NSLayoutConstraint constraintWithItem:self.skipButton attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.releaseNotesContainerView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:12.0]; [self.window.contentView addConstraint:skipButtonToReleaseNotesContainerConstraint]; @@ -407,6 +412,7 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE self.automaticallyInstallUpdatesButton.enabled = NO; } + // A developer wishing for automatic updates shouldn't want users to skip updates self.skipButton.hidden = YES; } @@ -416,10 +422,10 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE self.skipButton.hidden = YES; // We're going to be relaunching pretty instantaneously - self.installButton.title = SULocalizedString(@"Install & Relaunch", nil); + self.installButton.title = SULocalizedString(@"Install and Relaunch", nil); // We should be explicit that the update will be installed on quit - self.laterButton.title = SULocalizedString(@"Install Later", @"Alternate title for 'Remind me later' button when downloaded updates can be resumed"); + self.laterButton.title = SULocalizedString(@"Install Later", @"Alternate title for 'Remind Me Later' button when downloaded updates can be resumed"); } if ([self.updateItem isCriticalUpdate]) { From 507255224aed2f292064fe2d8a58c13bca6aad41 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sat, 23 Jan 2021 20:50:07 -0800 Subject: [PATCH 4/7] Fix hidden state for automatic install button and add comments --- Sparkle/Base.lproj/SUUpdateAlert.xib | 5 ----- Sparkle/SUUpdateAlert.m | 25 +++++++++++++------------ 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/Sparkle/Base.lproj/SUUpdateAlert.xib b/Sparkle/Base.lproj/SUUpdateAlert.xib index f9d5d104..94fbcc59 100644 --- a/Sparkle/Base.lproj/SUUpdateAlert.xib +++ b/Sparkle/Base.lproj/SUUpdateAlert.xib @@ -174,11 +174,6 @@ DQ - - - NSNegateBoolean - - diff --git a/Sparkle/SUUpdateAlert.m b/Sparkle/SUUpdateAlert.m index d9a0990b..6d202f14 100644 --- a/Sparkle/SUUpdateAlert.m +++ b/Sparkle/SUUpdateAlert.m @@ -396,22 +396,22 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE // Automatic downloads is enabled by developer if they set SUAutomaticallyUpdateKey in Info.plist, // rather than the user toggling the setting BOOL automaticDownloadsEnabledByDeveloper = [self.host boolForInfoDictionaryKey:SUAutomaticallyUpdateKey]; - if (showReleaseNotes && (!self.allowsAutomaticUpdates || automaticDownloadsEnabledByDeveloper)) { - // Fix constraints so that buttons aren't far away from web view when we hide the automatic updates check box - NSLayoutConstraint *skipButtonToReleaseNotesContainerConstraint = [NSLayoutConstraint constraintWithItem:self.skipButton attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.releaseNotesContainerView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:12.0]; - - [self.window.contentView addConstraint:skipButtonToReleaseNotesContainerConstraint]; - - [self.automaticallyInstallUpdatesButton removeFromSuperview]; - } - - if (automaticDownloadsEnabledByDeveloper) { - if (!showReleaseNotes) { + if (!self.allowsAutomaticUpdates || automaticDownloadsEnabledByDeveloper) { + if (showReleaseNotes) { + // Fix constraints so that buttons aren't far away from web view when we hide the automatic updates check box + NSLayoutConstraint *skipButtonToReleaseNotesContainerConstraint = [NSLayoutConstraint constraintWithItem:self.skipButton attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.releaseNotesContainerView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:12.0]; + + [self.window.contentView addConstraint:skipButtonToReleaseNotesContainerConstraint]; + + [self.automaticallyInstallUpdatesButton removeFromSuperview]; + } else { // Disable automatic install updates option if the developer wishes for it in Info.plist // If we are showing release notes, this button will be hidden instead self.automaticallyInstallUpdatesButton.enabled = NO; } - + } + + if (automaticDownloadsEnabledByDeveloper) { // A developer wishing for automatic updates shouldn't want users to skip updates self.skipButton.hidden = YES; } @@ -433,6 +433,7 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE self.laterButton.hidden = YES; } + // Reminding user later doesn't make sense when automatic update checks are off if (![self.host boolForKey:SUEnableAutomaticChecksKey]) { self.laterButton.hidden = YES; } From 3e544c7d26dea0d3288bf750281961068d370d18 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sat, 23 Jan 2021 21:30:47 -0800 Subject: [PATCH 5/7] Use "Install On Quit" localization again --- Sparkle/SUUpdateAlert.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sparkle/SUUpdateAlert.m b/Sparkle/SUUpdateAlert.m index 6d202f14..be4c6975 100644 --- a/Sparkle/SUUpdateAlert.m +++ b/Sparkle/SUUpdateAlert.m @@ -425,7 +425,7 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE self.installButton.title = SULocalizedString(@"Install and Relaunch", nil); // We should be explicit that the update will be installed on quit - self.laterButton.title = SULocalizedString(@"Install Later", @"Alternate title for 'Remind Me Later' button when downloaded updates can be resumed"); + self.laterButton.title = SULocalizedString(@"Install On Quit", @"Alternate title for 'Remind Me Later' button when downloaded updates can be resumed"); } if ([self.updateItem isCriticalUpdate]) { From 27f31a291371e20100cdaf4a2043707d992dbf68 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sat, 23 Jan 2021 21:32:51 -0800 Subject: [PATCH 6/7] Change capitalization --- Sparkle/SUUpdateAlert.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sparkle/SUUpdateAlert.m b/Sparkle/SUUpdateAlert.m index be4c6975..88885a4b 100644 --- a/Sparkle/SUUpdateAlert.m +++ b/Sparkle/SUUpdateAlert.m @@ -425,7 +425,7 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE self.installButton.title = SULocalizedString(@"Install and Relaunch", nil); // We should be explicit that the update will be installed on quit - self.laterButton.title = SULocalizedString(@"Install On Quit", @"Alternate title for 'Remind Me Later' button when downloaded updates can be resumed"); + self.laterButton.title = SULocalizedString(@"Install on Quit", @"Alternate title for 'Remind Me Later' button when downloaded updates can be resumed"); } if ([self.updateItem isCriticalUpdate]) { From e197f3093aa65110030aa5e789b8d469f9a9c3ec Mon Sep 17 00:00:00 2001 From: Zorg Date: Sun, 24 Jan 2021 10:25:45 -0800 Subject: [PATCH 7/7] Update hiding skip button case with checking minimumAutoupdateVersion --- Sparkle/SUUpdateAlert.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sparkle/SUUpdateAlert.m b/Sparkle/SUUpdateAlert.m index 88885a4b..9a3aaf05 100644 --- a/Sparkle/SUUpdateAlert.m +++ b/Sparkle/SUUpdateAlert.m @@ -411,8 +411,9 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE } } - if (automaticDownloadsEnabledByDeveloper) { - // A developer wishing for automatic updates shouldn't want users to skip updates + // A developer wishing for automatic updates shouldn't want users to skip updates + // Except maybe when there's a minimum auto update version for auto-downloading specified + if (automaticDownloadsEnabledByDeveloper && self.updateItem.minimumAutoupdateVersion.length == 0) { self.skipButton.hidden = YES; }