inital progress indicator work

This commit is contained in:
dante ruiz 2019-07-01 19:01:13 -07:00
parent ec4bd95950
commit fb8027bdf5
9 changed files with 72 additions and 8 deletions

View file

@ -22,12 +22,12 @@
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="Abr-HV-cKq"/>
</imageView>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Nrc-t3-PSh">
<rect key="frame" x="192" y="190" width="131" height="112"/>
<rect key="frame" x="192" y="235" width="131" height="112"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="LNv-HQ-3gb"/>
</imageView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="EMF-E4-qLL">
<rect key="frame" x="30" y="109" width="454" height="41"/>
<rect key="frame" x="30" y="161" width="454" height="41"/>
<autoresizingMask key="autoresizingMask"/>
<textFieldCell key="cell" lineBreakMode="clipping" alignment="center" title="Setup will take a moment" id="y9y-tH-HjJ">
<font key="font" metaFont="systemBold" size="28"/>
@ -36,7 +36,7 @@
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="BSg-lp-njL">
<rect key="frame" x="33" y="84" width="448" height="17"/>
<rect key="frame" x="33" y="136" width="448" height="17"/>
<autoresizingMask key="autoresizingMask"/>
<textFieldCell key="cell" lineBreakMode="clipping" alignment="center" title="We're getting your headquaters ready" id="HeV-5p-9FI">
<font key="font" metaFont="system"/>
@ -49,6 +49,10 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="6NP-7q-Mhj"/>
</imageView>
<progressIndicator wantsLayer="YES" fixedFrame="YES" maxValue="100" doubleValue="50" style="bar" translatesAutoresizingMaskIntoConstraints="NO" id="aEr-fi-fkV">
<rect key="frame" x="68" y="78" width="394" height="20"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
</progressIndicator>
</subviews>
<point key="canvasLocation" x="138.5" y="154"/>
</customView>
@ -56,6 +60,7 @@
<connections>
<outlet property="background" destination="kuY-e2-Hqb" id="CBc-bD-ux7"/>
<outlet property="boldStatus" destination="EMF-E4-qLL" id="udm-8B-7lt"/>
<outlet property="progressView" destination="aEr-fi-fkV" id="YzB-3s-Ass"/>
<outlet property="smallLogo" destination="uh2-4K-n56" id="pYg-hP-nr5"/>
<outlet property="smallStatus" destination="BSg-lp-njL" id="ziz-ek-Lq4"/>
<outlet property="voxelImage" destination="Nrc-t3-PSh" id="J81-ex-qbE"/>

View file

@ -2,7 +2,9 @@
@interface DownloadDomainContent : NSObject<NSURLSessionDataDelegate, NSURLSessionDelegate, NSURLSessionTaskDelegate, NSURLDownloadDelegate> {
}
@property (nonatomic, assign) double progressPercentage;
- (void) downloadDomainContent:(NSString*) domainContentUrl;
- (double) getProgressPercentage;
@end

View file

@ -3,8 +3,14 @@
@implementation DownloadDomainContent
- (double) getProgressPercentage
{
return self.progressPercentage;
}
- (void) downloadDomainContent:(NSString *)domainContentUrl
{
self.progressPercentage = 0.0;
NSURLRequest* request = [NSURLRequest requestWithURL:[NSURL URLWithString:domainContentUrl]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
@ -19,6 +25,9 @@
CGFloat prog = (float)totalBytesWritten/totalBytesExpectedToWrite;
NSLog(@"domain content downloaded %d%%", (int)(100.0*prog));
self.progressPercentage = (100.0 * prog);
[[Launcher sharedLauncher] updateProgressIndicator];
}
-(void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didResumeAtOffset:(int64_t)fileOffset expectedTotalBytes:(int64_t)expectedTotalBytes {

View file

@ -3,6 +3,9 @@
@interface DownloadInterface : NSObject<NSURLSessionDataDelegate, NSURLSessionDelegate, NSURLSessionTaskDelegate, NSURLDownloadDelegate> {
}
@property (nonatomic, assign) NSString* finalFilePath;
@property (nonatomic, assign) double progressPercentage;
- (void) downloadInterface:(NSString*) downloadUrl;
- (double) getProgressPercentage;
@end

View file

@ -6,6 +6,7 @@
- (void) downloadInterface:(NSString*) downloadUrl
{
self.progressPercentage = 0.0;
NSURLRequest* request = [NSURLRequest requestWithURL:[NSURL URLWithString:downloadUrl]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
@ -21,6 +22,14 @@
CGFloat prog = (float)totalBytesWritten/totalBytesExpectedToWrite;
NSLog(@"interface downloaded %d%%", (int)(100.0*prog));
self.progressPercentage = (100.0 * prog);
[[Launcher sharedLauncher] updateProgressIndicator];
}
- (double) getProgressPercentage
{
return self.progressPercentage;
}
-(void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didResumeAtOffset:(int64_t)fileOffset expectedTotalBytes:(int64_t)expectedTotalBytes {

View file

@ -46,7 +46,10 @@ typedef enum LoginErrorTypes
@property (nonatomic) BOOL waitingForInterfaceToTerminate;
@property (nonatomic, assign, readwrite) ProcessState processState;
@property (nonatomic, assign, readwrite) LoginError loginError;
@property (nonatomic, assign) NSProgressIndicator* progressIndicator;
- (NSProgressIndicator*) getProgressView;
- (void) setProgressView:(NSProgressIndicator*) aProgressIndicator;
- (void) displayNameEntered:(NSString*)aDisplayName;
- (void) credentialsEntered:(NSString*)aOrginization :(NSString*)aUsername :(NSString*)aPassword;
- (void) credentialsAccepted:(BOOL) aCredentialsAccepted;
@ -78,6 +81,7 @@ typedef enum LoginErrorTypes
- (NSString*) getDownloadFilename;
- (BOOL) isLoadedIn;
- (NSString*) getAppPath;
- (void) updateProgressIndicator;
+ (id) sharedLauncher;
@end

View file

@ -17,6 +17,7 @@
static BOOL const DELETE_ZIP_FILES = TRUE;
@implementation Launcher
+ (id) sharedLauncher {
static Launcher* sharedLauncher = nil;
static dispatch_once_t onceToken;
@ -40,6 +41,7 @@ static BOOL const DELETE_ZIP_FILES = TRUE;
self.waitingForCredentialReponse = FALSE;
self.waitingForInterfaceToTerminate = FALSE;
self.userToken = nil;
self.progressIndicator = nil;
self.processState = DOWNLOADING_INTERFACE;
}
return self;
@ -79,6 +81,18 @@ static BOOL const DELETE_ZIP_FILES = TRUE;
return [[[NSBundle mainBundle] bundlePath] stringByAppendingString:@"/Contents/MacOS/"];
}
- (void) updateProgressIndicator
{
NSProgressIndicator* progressIndicator = [self getProgressView];
//double oldValue = progressIndicator.doubleValue;
double contentPercentage = [self.downloadDomainContent getProgressPercentage];
double interfacePercentage = [self.downloadInterface getProgressPercentage];
//double currentTotalPercentage = (contentPercentage * 0.5) + (interfacePercentage * 0.5);
//[progressIndicator incrementBy: (currentTotalPercentage - oldValue)];
progressIndicator.doubleValue = (contentPercentage * 0.4) + (interfacePercentage * 0.4);
}
- (BOOL) extractZipFileAtDestination:(NSString *)destination :(NSString*)file
{
NSTask* task = [[NSTask alloc] init];
@ -101,6 +115,18 @@ static BOOL const DELETE_ZIP_FILES = TRUE;
return TRUE;
}
-(void) setProgressView:(NSProgressIndicator*) aProgressIndicator
{
NSLog(@"Setting progressIndicator %@", aProgressIndicator);
self.progressIndicator = aProgressIndicator;
}
-(NSProgressIndicator*) getProgressView
{
NSLog(@"Getting progressIndicator %@", self.progressIndicator);
return self.progressIndicator;
}
- (void) displayErrorPage
{
ErrorViewController* errorPage = [[ErrorViewController alloc] initWithNibName:@"ErrorScreen" bundle:nil];

View file

@ -8,6 +8,7 @@
@property (nonatomic, assign) IBOutlet NSImageView* voxelImage;
@property (nonatomic, assign) IBOutlet NSTextField* boldStatus;
@property (nonatomic, assign) IBOutlet NSTextField* smallStatus;
@property (nonatomic, assign) IBOutlet NSProgressIndicator* progressView;
@end
@implementation ProcessScreen
@ -20,6 +21,7 @@
[self.smallStatus setStringValue:@"Set up may take several minutes."];
break;
case RUNNING_INTERFACE_AFTER_DOWNLOAD:
[self.progressView setHidden: YES];
[self.boldStatus setStringValue:@"Your new HQ is all setup"];
[self.smallStatus setStringValue:@"Thanks for being patient."];
break;
@ -28,6 +30,7 @@
[self.smallStatus setStringValue:@"We're getting the latest and greatest for you, one sec."];
break;
case RUNNING_INTERFACE_AFTER_UPDATE:
[self.progressView setHidden: YES];
[self.boldStatus setStringValue:@"You're good to go!"];
[self.smallStatus setStringValue:@"Thanks for being patient."];
break;
@ -37,10 +40,13 @@
[self.background setImage: [NSImage imageNamed:hifiBackgroundFilename]];
[self.smallLogo setImage: [NSImage imageNamed:hifiSmallLogoFilename]];
[self.voxelImage setImage: [NSImage imageNamed:hifiVoxelFilename]];
//[sharedLauncher setProgressIndicator: self.progressView];
//sharedLauncher.progressIndicator = self.progressView;
if (self.progressView != nil) {
NSLog(@"Progress view: %@", self.progressView);
[sharedLauncher setProgressView: self.progressView];
}
self.imageRotation = 0;
//[self.voxelImage setFrameCenterRotation:90];
[NSTimer scheduledTimerWithTimeInterval:0.016
target:self
selector:@selector(rotateView:)

View file

@ -17,7 +17,7 @@ void redirectLogToDocuments()
int main(int argc, const char* argv[]) {
//NSApp.appearance = [NSAppearance appearanceNamed: NSAppearanceNameAqua];
redirectLogToDocuments();
//redirectLogToDocuments();
NSArray* apps = [NSRunningApplication runningApplicationsWithBundleIdentifier:@"com.highfidelity.launcher"];
if ([apps count] > 1) {
NSLog(@"launcher is already running");