Remove obsolete fallbacks folder older OS versions (#2110)

* Remove fallback for NSByteCountFormatter

* Remove fallback for NSFont -monospacedDigitSystemFontOfSize:weight:
This commit is contained in:
Eitot authored and GitHub committed 2022-04-21 20:00:33 -07:00
1 parent f250bead4b
commit c0cf32c2b7
2 files changed
+8 -41

No files matched your search

+7 -34
View File
@@ -440,50 +440,23 @@
}
}
- (NSString *)localizedStringFromByteCount:(long long)value
{
if (![SUOperatingSystem isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){10, 8, 0}]) {
if (value < 1000) {
return [NSString stringWithFormat:@"%.0lf %@", value / 1.0,
SULocalizedString(@"B", @"the unit for bytes")];
}
if (value < 1000 * 1000) {
return [NSString stringWithFormat:@"%.0lf %@", value / 1000.0,
SULocalizedString(@"KB", @"the unit for kilobytes")];
}
if (value < 1000 * 1000 * 1000) {
return [NSString stringWithFormat:@"%.1lf %@", value / 1000.0 / 1000.0,
SULocalizedString(@"MB", @"the unit for megabytes")];
}
return [NSString stringWithFormat:@"%.2lf %@", value / 1000.0 / 1000.0 / 1000.0,
SULocalizedString(@"GB", @"the unit for gigabytes")];
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpartial-availability"
NSByteCountFormatter *formatter = [[NSByteCountFormatter alloc] init];
[formatter setZeroPadsFractionDigits:YES];
return [formatter stringFromByteCount:value];
#pragma clang diagnostic pop
}
- (void)showDownloadDidReceiveDataOfLength:(uint64_t)length
{
assert(NSThread.isMainThread);
self.bytesDownloaded += length;
NSByteCountFormatter *formatter = [[NSByteCountFormatter alloc] init];
[formatter setZeroPadsFractionDigits:YES];
if (self.expectedContentLength > 0.0) {
double newProgressValue = (double)self.bytesDownloaded / (double)self.expectedContentLength;
[self.statusController setProgressValue:MIN(newProgressValue, 1.0)];
[self.statusController setStatusText:[NSString stringWithFormat:SULocalizedString(@"%@ of %@", nil), [self localizedStringFromByteCount:(long long)self.bytesDownloaded], [self localizedStringFromByteCount:(long long)MAX(self.bytesDownloaded, self.expectedContentLength)]]];
[self.statusController setStatusText:[NSString stringWithFormat:SULocalizedString(@"%@ of %@", @"The download progress in units of bytes, e.g. 100 KB of 1,0 MB"), [formatter stringFromByteCount:(long long)self.bytesDownloaded], [formatter stringFromByteCount:(long long)MAX(self.bytesDownloaded, self.expectedContentLength)]]];
} else {
[self.statusController setStatusText:[NSString stringWithFormat:SULocalizedString(@"%@ downloaded", nil), [self localizedStringFromByteCount:(long long)self.bytesDownloaded]]];
[self.statusController setStatusText:[NSString stringWithFormat:SULocalizedString(@"%@ downloaded", @"The download progress in a unit of bytes, e.g. 100 KB"), [formatter stringFromByteCount:(long long)self.bytesDownloaded]]];
}
}
+1 -7
View File
@@ -60,13 +60,7 @@ static NSString *const SUStatusControllerTouchBarIndentifier = @"" SPARKLE_BUNDL
self.window.styleMask |= NSWindowStyleMaskMiniaturizable;
}
[self.progressBar setUsesThreadedAnimation:YES];
if ([SUOperatingSystem isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){10, 11, 0}]) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpartial-availability"
[self.statusTextField setFont:[NSFont monospacedDigitSystemFontOfSize:0 weight:NSFontWeightRegular]];
#pragma clang diagnostic pop
}
[self.statusTextField setFont:[NSFont monospacedDigitSystemFontOfSize:0 weight:NSFontWeightRegular]];
}
- (NSString *)windowTitle