Skip to content

Commit 021aa41

Browse files
extracting ipa after clicking upload or archive
1 parent 212179d commit 021aa41

2 files changed

Lines changed: 58 additions & 26 deletions

File tree

AppBox/ViewController/HomeViewController/HomeViewController.m

Lines changed: 54 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ - (void)viewWillAppear{
4444
if (![[DBSession sharedSession] isLinked]) {
4545
[self performSegueWithIdentifier:@"DropBoxLogin" sender:self];
4646
}else{
47-
[self progressCompletedViewState];
47+
[self viewStateForProgress:YES];
4848
}
4949
}
5050

@@ -98,26 +98,13 @@ - (IBAction)ipaFilePathHandle:(NSPathControl *)sender {
9898
if (![project.fullPath isEqual:sender.URL]){
9999
project.ipaFullPath = sender.URL;
100100
[self updateViewState];
101-
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
102-
[self getIPAInfoFromLocalURL:project.ipaFullPath];
103-
});
104101
}
105102
}
106103

107104
- (IBAction)buttonUniqueLinkTapped:(NSButton *)sender{
108105
//NOT required
109106
}
110107

111-
#pragma mark → Final Action Button (Build/IPA)
112-
//Build Button Action
113-
- (IBAction)actionButtonTapped:(NSButton *)sender {
114-
if (project.fullPath){
115-
[project setIsBuildOnly:NO];
116-
[self runBuildScript];
117-
}else if (project.ipaFullPath){
118-
[self uploadIPAFileWithLocalURL:project.ipaFullPath];
119-
}
120-
}
121108

122109
#pragma mark → Mail Controls Action
123110
//Send mail option
@@ -149,6 +136,21 @@ - (IBAction)textFieldDevMessageValueChanged:(NSTextField *)sender {
149136
[UserData setUserMessage:sender.stringValue];
150137
}
151138

139+
#pragma mark → Final Action Button (Build/IPA)
140+
//Build Button Action
141+
- (IBAction)actionButtonTapped:(NSButton *)sender {
142+
if (![sender.title.lowercaseString isEqualToString:@"stop"]){
143+
if (project.fullPath){
144+
[project setIsBuildOnly:NO];
145+
[self runBuildScript];
146+
}else if (project.ipaFullPath){
147+
[self uploadIPAFileWithLocalURL:project.ipaFullPath];
148+
}
149+
[self viewStateForProgress:NO];
150+
}else{
151+
[Common showAlertWithTitle:@"AppBox" andMessage:@"Comming Soon... You can quit and start again :D !!"];
152+
}
153+
}
152154

153155
#pragma mark - NSTask (Scheme, TeamId and Archive) -
154156
#pragma mark → Task
@@ -274,6 +276,7 @@ - (void)captureStandardOutputWithTask:(NSTask *)task{
274276
} else {
275277
[pipe.fileHandleForReading waitForDataInBackgroundAndNotify];
276278
}
279+
[self viewStateForProgress:YES];
277280
}
278281

279282
//Handle Build Response
@@ -336,19 +339,29 @@ - (void)getIPAInfoFromLocalURL:(NSURL *)ipaFileURL{
336339
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"%@-%@",[NSNumber numberWithLong:entryNumber], [NSNumber numberWithLong:total]]];
337340
} completionHandler:^(NSString * _Nonnull path, BOOL succeeded, NSError * _Nonnull error) {
338341
if (error) {
339-
[self progressCompletedViewState];
342+
[self viewStateForProgress:YES];
340343
[Common showAlertWithTitle:@"AppBox - Error" andMessage:error.localizedDescription];
341344
return;
342345
}
346+
343347
//get info.plist
344348
[project setIpaInfoPlist: [NSDictionary dictionaryWithContentsOfFile:[NSTemporaryDirectory() stringByAppendingPathComponent:infoPlistPath]]];
345349
if (project.ipaInfoPlist == nil) {
346-
[self progressCompletedViewState];
350+
[self viewStateForProgress:YES];
347351
[Common showAlertWithTitle:@"AppBox - Error" andMessage:@"AppBox can't able to find Info.plist in you IPA."];
348352
return;
349353
}
350-
[textFieldBundleIdentifier setStringValue: project.identifer];
354+
355+
//set dropbox folder name
356+
if (textFieldBundleIdentifier.stringValue.length == 0){
357+
[textFieldBundleIdentifier setStringValue: project.identifer];
358+
}
351359
[self showStatus:@"Ready to upload..." andShowProgressBar:NO withProgress:-1];
360+
361+
//upload ipa file directly if archive and ipa selected
362+
if (tabView.tabViewItems.firstObject.tabState == NSSelectedTab){
363+
[self uploadIPAFileWithLocalURL:project.ipaFullPath];
364+
}
352365
}];
353366
}else{
354367
[[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"\n\n======\nFile Not Exist - %@\n======\n\n",fromPath]];
@@ -360,6 +373,7 @@ -(void)uploadIPAFileWithLocalURL:(NSURL *)ipaURL{
360373
[Common showAlertWithTitle:@"IPA File Missing" andMessage:@"Please select the IPA file and try again."];
361374
return;
362375
}
376+
[self getIPAInfoFromLocalURL:project.ipaFullPath];
363377
if(![textFieldBundleIdentifier.stringValue isEqualToString:project.identifer] && textFieldBundleIdentifier.stringValue.length>0){
364378
NSString *bundlePath = [NSString stringWithFormat:@"/%@",textFieldBundleIdentifier.stringValue];
365379
bundlePath = [bundlePath stringByReplacingOccurrencesOfString:@" " withString:@""];
@@ -471,7 +485,7 @@ -(void)restClient:(DBRestClient*)client loadFileFailedWithError:(NSError*)error{
471485
//Upload File
472486
-(void)restClient:(DBRestClient *)client uploadFileFailedWithError:(NSError *)error{
473487
[Common showAlertWithTitle:@"Error" andMessage:error.localizedDescription];
474-
[self progressCompletedViewState];
488+
[self viewStateForProgress:YES];;
475489
}
476490

477491
-(void)restClient:(DBRestClient *)client uploadedFile:(NSString *)destPath from:(NSString *)srcPath metadata:(DBMetadata *)metadata{
@@ -507,7 +521,7 @@ -(void)restClient:(DBRestClient *)client uploadProgress:(CGFloat)progress forFil
507521
//Shareable Link
508522
-(void)restClient:(DBRestClient *)restClient loadSharableLinkFailedWithError:(NSError *)error{
509523
[Common showAlertWithTitle:@"Error" andMessage:error.localizedDescription];
510-
[self progressCompletedViewState];
524+
[self viewStateForProgress:YES];
511525
}
512526

513527
-(void)restClient:(DBRestClient *)restClientLocal loadedSharableLink:(NSString *)link forFile:(NSString *)path{
@@ -547,7 +561,7 @@ -(void)restClient:(DBRestClient *)restClientLocal loadedSharableLink:(NSString *
547561
#pragma mark → Dropbox Helper
548562
- (void)authHelperStateChangedNotification:(NSNotification *)notification {
549563
if ([[DBSession sharedSession] isLinked]) {
550-
[self progressCompletedViewState];
564+
[self viewStateForProgress:YES];
551565
}
552566
}
553567

@@ -593,8 +607,24 @@ -(void)createManifestShortSharableUrl{
593607

594608

595609
#pragma mark - Controller Helpers -
596-
-(void)progressCompletedViewState{
597610

611+
-(void)viewStateForProgress:(BOOL)finish{
612+
// [pathBuild setEnabled:finish];
613+
// [pathIPAFile setEnabled:finish];
614+
// [pathProject setEnabled:finish];
615+
// [comboTeamId setEnabled:finish];
616+
// [comboBuildType setEnabled:finish];
617+
// [comboBuildScheme setEnabled:finish];
618+
// [buttonSendMail setEnabled:finish];
619+
// [buttonUniqueLink setEnabled:finish];
620+
// [textFieldBundleIdentifier setEnabled:finish];
621+
// [textFieldEmail setEnabled:finish];
622+
// [textFieldMessage setEnabled:finish];
623+
// if (finish){
624+
// [self updateViewState];
625+
// }else{
626+
// [buttonAction setTitle:@"Stop"];
627+
// }
598628
}
599629

600630
-(void)resetBuildOptions{
@@ -630,10 +660,10 @@ -(void)updateViewState{
630660
BOOL enable = ((comboBuildScheme.stringValue != nil && comboBuildType.stringValue.length > 0 && //build scheme
631661
comboBuildType.stringValue != nil && comboBuildType.stringValue.length > 0 && //build type
632662
comboTeamId.stringValue != nil && comboTeamId.stringValue.length > 0 && //team id
633-
tabView.selectedTabViewItem.tabState == NSSelectedTab) ||
663+
tabView.tabViewItems.firstObject.tabState == NSSelectedTab) ||
634664

635665
//if ipa selected
636-
(project.ipaFullPath != nil && tabView.selectedTabViewItem.tabState == NSSelectedTab));
666+
(project.ipaFullPath != nil && tabView.tabViewItems.lastObject.tabState == NSSelectedTab));
637667
[buttonAction setEnabled:enable];
638668
[buttonAction setTitle:(tabView.selectedTabViewItem.label)];
639669

@@ -692,7 +722,7 @@ -(void)showURL{
692722
}else{
693723
[self performSegueWithIdentifier:@"ShowLink" sender:self];
694724
}
695-
[self progressCompletedViewState];
725+
[self viewStateForProgress:YES];
696726
}
697727

698728
-(void)prepareForSegue:(NSStoryboardSegue *)segue sender:(id)sender{

AppBox/ViewController/MailViewController/MailViewController.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ - (void)webView:(WebView *)sender didReceiveTitle:(NSString *)title forFrame:(We
4141
[self.delegate mailViewLoadedWithWebView:sender];
4242

4343
}else if ([title isEqualToString:@"MailSent"]){
44-
[self.delegate mailSentWithWebView:sender];
45-
[self dismissViewController:self];
44+
if (self.presentingViewController != nil){
45+
[self.delegate mailSentWithWebView:sender];
46+
[self dismissViewController:self];
47+
}
4648

4749
}else if ([title isEqualToString:@"InvalidPerameter"]){
4850
[self.delegate invalidPerametersWithWebView:sender];

0 commit comments

Comments
 (0)