diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index d6d88d55..2175a81e 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -342,6 +342,7 @@ C23E885B1BE7B24F0050BB73 /* SparkleTestCodeSignApp.enc.dmg in Resources */ = {isa = PBXBuildFile; fileRef = C23E88591BE7AF890050BB73 /* SparkleTestCodeSignApp.enc.dmg */; }; E1545EC51E1D7E0200FAECE8 /* SUTouchBarButtonGroup.h in Headers */ = {isa = PBXBuildFile; fileRef = E1545EC31E1D7E0200FAECE8 /* SUTouchBarButtonGroup.h */; }; E1545EC61E1D7E0200FAECE8 /* SUTouchBarButtonGroup.m in Sources */ = {isa = PBXBuildFile; fileRef = E1545EC41E1D7E0200FAECE8 /* SUTouchBarButtonGroup.m */; }; + E1D4DDF921C1C5F8003D32E7 /* DarkAqua.css in Resources */ = {isa = PBXBuildFile; fileRef = E1D4DDF821C1C5F8003D32E7 /* DarkAqua.css */; }; E1EC2A301E21667000245715 /* SUTouchBarButtonGroup.m in Sources */ = {isa = PBXBuildFile; fileRef = E1545EC41E1D7E0200FAECE8 /* SUTouchBarButtonGroup.m */; }; F8761EB11ADC5068000C9034 /* SUCodeSigningVerifierTest.m in Sources */ = {isa = PBXBuildFile; fileRef = F8761EB01ADC5068000C9034 /* SUCodeSigningVerifierTest.m */; }; F8761EB31ADC50EB000C9034 /* SparkleTestCodeSignApp.zip in Resources */ = {isa = PBXBuildFile; fileRef = F8761EB21ADC50EB000C9034 /* SparkleTestCodeSignApp.zip */; }; @@ -950,6 +951,7 @@ E1545EC31E1D7E0200FAECE8 /* SUTouchBarButtonGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUTouchBarButtonGroup.h; sourceTree = ""; }; E1545EC41E1D7E0200FAECE8 /* SUTouchBarButtonGroup.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUTouchBarButtonGroup.m; sourceTree = ""; }; E19CA4901E2E7E4D009D4D18 /* SUTouchBarForwardDeclarations.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SUTouchBarForwardDeclarations.h; sourceTree = ""; }; + E1D4DDF821C1C5F8003D32E7 /* DarkAqua.css */ = {isa = PBXFileReference; lastKnownFileType = text.css; path = DarkAqua.css; sourceTree = ""; }; F8761EB01ADC5068000C9034 /* SUCodeSigningVerifierTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUCodeSigningVerifierTest.m; sourceTree = ""; }; F8761EB21ADC50EB000C9034 /* SparkleTestCodeSignApp.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = SparkleTestCodeSignApp.zip; sourceTree = ""; }; FA1941CA0D94A70100DD942E /* ConfigFrameworkDebug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = ConfigFrameworkDebug.xcconfig; sourceTree = ""; }; @@ -1145,6 +1147,7 @@ 55C14BD8136EF00C00649790 /* SUStatus.xib */, 55C14BF0136EF26100649790 /* SUUpdateAlert.xib */, 55C14C05136EF2C700649790 /* SUUpdatePermissionPrompt.xib */, + E1D4DDF821C1C5F8003D32E7 /* DarkAqua.css */, ); name = "Framework Resources"; sourceTree = ""; @@ -2073,6 +2076,7 @@ 55C14BEF136EF21700649790 /* SUStatus.xib in Resources */, 55C14C04136EF26100649790 /* SUUpdateAlert.xib in Resources */, 55C14C19136EF2C700649790 /* SUUpdatePermissionPrompt.xib in Resources */, + E1D4DDF921C1C5F8003D32E7 /* DarkAqua.css in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Sparkle/DarkAqua.css b/Sparkle/DarkAqua.css new file mode 100644 index 00000000..a41e0f28 --- /dev/null +++ b/Sparkle/DarkAqua.css @@ -0,0 +1,9 @@ +html { + color: #FFFFFFD8; +} +:link { + color: #419CFF; +} +:link:active { + color: #FF1919; +} diff --git a/Sparkle/SUUpdateAlert.m b/Sparkle/SUUpdateAlert.m index f6e4eec5..9ca0ec32 100644 --- a/Sparkle/SUUpdateAlert.m +++ b/Sparkle/SUUpdateAlert.m @@ -91,6 +91,21 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE return self; } +- (void)dealloc { +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 + if (@available(macOS 10.14, *)) + { + [self.window removeObserver:self forKeyPath:@"effectiveAppearance"]; + } +#endif +} + +- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(__attribute__((unused)) NSDictionary *)change context:(__attribute__((unused)) void *)context { + if (object == self.window && [keyPath isEqualToString:@"effectiveAppearance"]) { + [self adaptReleaseNotesAppearance]; + } +} + - (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], [self.host bundlePath]]; } - (void)disableKeyboardShortcutForInstallButton { @@ -143,6 +158,22 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE prefs.standardFontFamily = @"-apple-system-font"; prefs.defaultFontSize = (int)[NSFont systemFontSize]; +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 + if (@available(macOS 10.14, *)) + { + NSBox *darkBackgroundView = [[NSBox alloc] initWithFrame:self.releaseNotesView.frame]; + darkBackgroundView.boxType = NSBoxCustom; + darkBackgroundView.fillColor = [NSColor textBackgroundColor]; + darkBackgroundView.borderColor = [NSColor clearColor]; + // Using auto-resizing mask instead of contraints works well enough + darkBackgroundView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable; + [self.releaseNotesView.superview addSubview:darkBackgroundView positioned:NSWindowBelow relativeTo:self.releaseNotesView]; + self.releaseNotesView.drawsBackground = NO; + + prefs.userStyleSheetLocation = [[NSBundle bundleForClass:[self class]] URLForResource:@"DarkAqua" withExtension:@"css"]; + [self.window addObserver:self forKeyPath:@"effectiveAppearance" options:NSKeyValueObservingOptionInitial context:nil]; + } +#endif // Stick a nice big spinner in the middle of the web view until the page is loaded. NSRect frame = [[self.releaseNotesView superview] frame]; self.releaseNotesSpinner = [[NSProgressIndicator alloc] initWithFrame:NSMakeRect(NSMidX(frame) - 16, NSMidY(frame) - 16, 32, 32)]; @@ -263,6 +294,18 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE return finalString; } +- (void)adaptReleaseNotesAppearance +{ +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 + if (@available(macOS 10.14, *)) + { + NSAppearanceName bestAppearance = [self.window.effectiveAppearance bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua, NSAppearanceNameDarkAqua]]; + BOOL isDarkAqua = ([bestAppearance isEqualToString:NSAppearanceNameDarkAqua]); + self.releaseNotesView.preferences.userStyleSheetEnabled = isDarkAqua; + } +#endif +} + - (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame { if ([frame parentFrame] == nil) {