Merge pull request #1734 from sparkle-project/alert-adjustments-1x

Alert adjustments 1x
This commit is contained in:
Mayur Pawashe authored and GitHub committed 2021-01-24 10:15:41 -08:00
commit 0b682d3349
2 files changed
+34 -40

No files matched your search

-5
View File
@@ -174,11 +174,6 @@ DQ
<font key="font" metaFont="smallSystem"/>
</buttonCell>
<connections>
<binding destination="-2" name="hidden" keyPath="allowsAutomaticUpdates" id="141">
<dictionary key="options">
<string key="NSValueTransformerName">NSNegateBoolean</string>
</dictionary>
</binding>
<binding destination="93" name="value" keyPath="values.SUAutomaticallyUpdate" id="135"/>
</connections>
</button>
+34 -35
View File
@@ -305,57 +305,56 @@ 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.
if (showReleaseNotes && ![self allowsAutomaticUpdates]) {
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];
BOOL allowsAutomaticUpdates = [self allowsAutomaticUpdates];
// 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 (!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 {
self.automaticallyInstallUpdatesButton.enabled = NO;
}
}
// 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;
}
if ([self.updateItem isCriticalUpdate]) {
self.skipButton.enabled = NO;
self.skipButton.hidden = YES;
self.laterButton.enabled = NO;
self.laterButton.hidden = YES;
}
if (![self automaticChecksEnabled]) {
self.laterButton.enabled = NO;
// Reminding user later doesn't make sense when automatic update checks are off
if (![self.host boolForKey:SUEnableAutomaticChecksKey]) {
self.laterButton.hidden = YES;
}
if([self automaticallyUpdateEnabled]) {
self.skipButton.hidden = YES;
self.automaticallyInstallUpdatesButton.hidden = YES;
[self.laterButton setTitle:SULocalizedString(@"Install later", @"Alternate title for 'Remind me later' button when automatic updates are enabled")];
// If the developer makes use of minimumAutoupdateVersion, just stick to Remind Me Later on the safe side
// (Install Later would be harmfully incorrect if this update cannot be automatically installed)
// And this is really not the place to do comparison/version checks.
// Also make sure to check that the system and developer allows us to automatically update.
// This logic is not very sound and gets worse in 2.x where apps can be sandboxed. We may need to revisit this
// and also decide if we really need this button in the first place.
if ([self.host boolForKey:SUAutomaticallyUpdateKey] && allowsAutomaticUpdates && self.updateItem.minimumAutoupdateVersion.length == 0) {
[self.laterButton setTitle:SULocalizedString(@"Install Later", @"Alternate title for 'Remind Me Later' button when automatic updates are enabled")];
}
[self.window center];
}
- (BOOL)automaticChecksEnabled {
NSNumber *automaticChecksEnabled = [self.host objectForKey:SUEnableAutomaticChecksKey];
if (automaticChecksEnabled == nil)
{
return false;
}
return [automaticChecksEnabled boolValue];
}
- (BOOL)automaticallyUpdateEnabled {
NSNumber *automaticChecksEnabled = [self.host objectForKey:SUAutomaticallyUpdateKey];
if (automaticChecksEnabled == nil)
{
return false;
}
return [automaticChecksEnabled boolValue];
}
- (BOOL)windowShouldClose:(NSNotification *) __unused note
{
[self endWithSelection:SURemindMeLaterChoice];