Download process string updated to match master

This commit is contained in:
aone committed 2018-05-28 10:09:05 +02:00
1 parent 67320fcb80
commit b3ecc89f11
1 file changed
+27 -2
+27 -2
View File
@@ -17,6 +17,7 @@
#import "SUUpdateAlert.h"
#import "SULocalizations.h"
#import "SUApplicationInfo.h"
#import "SUOperatingSystem.h"
@interface SPUStandardUserDriver ()
@@ -339,8 +340,32 @@
- (NSString *)localizedStringFromByteCount:(long long)value
{
return [NSByteCountFormatter stringFromByteCount:value
countStyle:NSByteCountFormatterCountStyleFile];
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