Enhance UX of revision downloading progress

Revisions are already spread across almost 30 XML files 1000 builds
each. Although it may take a considerable amount of time to download the
list, the progress bar doesn't reflect this process.

Because the downloading isn't deterministic, we try to update the
progress after each received file. 0.02 rate should be OK for user and
enough for around 2 years of Chromium builds before hitting bar's 90% limit.
This commit is contained in:
Artur Petrov 2014-09-29 04:52:27 +04:00
parent 2c27526ab5
commit dee1f483b3

View File

@ -157,7 +157,7 @@ NSString * const MGMUBCancel = @"Cancel";
handler = [MGMURLBasicHandler handlerWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]] delegate:self]; handler = [MGMURLBasicHandler handlerWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]] delegate:self];
[handler setFailWithError:@selector(revisions:didFailWithError:)]; [handler setFailWithError:@selector(revisions:didFailWithError:)];
[handler setFinish:@selector(revisionsFinished:)]; [handler setFinish:@selector(revisionsFinished:)];
[statusField setStringValue:@"Loading Revisions"]; [statusField setStringValue:@"Loading revisions..."];
[connectionManager addHandler:handler]; [connectionManager addHandler:handler];
} }
@ -209,7 +209,7 @@ NSString * const MGMUBCancel = @"Cancel";
[progress setIndeterminate:NO]; [progress setIndeterminate:NO];
[progress startAnimation:self]; [progress startAnimation:self];
[progress setDoubleValue:0.25]; [progress setDoubleValue:0.1];
} }
- (void)revisions:(MGMURLBasicHandler *)theHandler didFailWithError:(NSError *)theError { - (void)revisions:(MGMURLBasicHandler *)theHandler didFailWithError:(NSError *)theError {
NSLog(@"%@", theError); NSLog(@"%@", theError);
@ -235,8 +235,9 @@ NSString * const MGMUBCancel = @"Cancel";
- (void)revisionsFinished:(MGMURLBasicHandler *)theHandler { - (void)revisionsFinished:(MGMURLBasicHandler *)theHandler {
NSError *error = nil; NSError *error = nil;
NSXMLDocument *xml = [[NSXMLDocument alloc] initWithData:[theHandler data] options:NSXMLDocumentTidyXML error:&error]; NSXMLDocument *xml = [[NSXMLDocument alloc] initWithData:[theHandler data] options:NSXMLDocumentTidyXML error:&error];
[progress setDoubleValue:0.50]; if ([progress doubleValue] < 0.9) {
[progress incrementBy:0.02];
}
if (error!=nil) { if (error!=nil) {
NSLog(@"%@", error); NSLog(@"%@", error);
NSAlert *alert = [[NSAlert new] autorelease]; NSAlert *alert = [[NSAlert new] autorelease];
@ -331,7 +332,7 @@ NSString * const MGMUBCancel = @"Cancel";
} }
[buildPopUp selectItemAtIndex:itemIndex]; [buildPopUp selectItemAtIndex:itemIndex];
if (startingUp) if (startingUp)
[progress setDoubleValue:0.75]; [progress setDoubleValue:0.9];
[self buildSelect:self]; [self buildSelect:self];
} }
- (IBAction)buildSelect:(id)sender { - (IBAction)buildSelect:(id)sender {
@ -561,7 +562,7 @@ NSString * const MGMUBCancel = @"Cancel";
[updateButton setEnabled:NO]; [updateButton setEnabled:NO];
[progress setIndeterminate:YES]; [progress setIndeterminate:YES];
[progress startAnimation:self]; [progress startAnimation:self];
[statusField setStringValue:@"Uncompressing and installing update."]; [statusField setStringValue:@"Uncompressing and installing update..."];
unzipTask = [NSTask new]; unzipTask = [NSTask new];
[unzipTask setLaunchPath:@"/usr/bin/ditto"]; [unzipTask setLaunchPath:@"/usr/bin/ditto"];