diff --git a/contrib/mobile/iOS/Onelab/AppDelegate.h b/contrib/mobile/iOS/Onelab/AppDelegate.h index e3292f2be7b2f147000ce23f079168e10f1ac8cd..2fd35b8dd91c24207b0fd7e6820188c4ff172a47 100644 --- a/contrib/mobile/iOS/Onelab/AppDelegate.h +++ b/contrib/mobile/iOS/Onelab/AppDelegate.h @@ -12,6 +12,7 @@ @interface AppDelegate : UIResponder <UIApplicationDelegate>{ @public + bool compute; } @property (strong, nonatomic) UIWindow *window; diff --git a/contrib/mobile/iOS/Onelab/AppDelegate.mm b/contrib/mobile/iOS/Onelab/AppDelegate.mm index e7dce443139e728250f7c9f0f0253227f7c2e812..f4dc901f95e680d309dd7bb2f5404fd1c8b4f285 100644 --- a/contrib/mobile/iOS/Onelab/AppDelegate.mm +++ b/contrib/mobile/iOS/Onelab/AppDelegate.mm @@ -14,10 +14,12 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. - UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"iPadStoryboard" bundle:nil]; self.modelListController = (ModelListController *)self.window.rootViewController; - if([[UIDevice currentDevice].model isEqualToString:@"iPad"] || [[UIDevice currentDevice].model isEqualToString:@"iPad Simulator"]) + if([[UIDevice currentDevice].model isEqualToString:@"iPad"] || [[UIDevice currentDevice].model isEqualToString:@"iPad Simulator"]) { + UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"iPadStoryboard" bundle:nil]; self.splitViewController = [storyboard instantiateViewControllerWithIdentifier:@"SplitViewController"]; + } + compute = false; return YES; } diff --git a/contrib/mobile/iOS/Onelab/DetailViewController.mm b/contrib/mobile/iOS/Onelab/DetailViewController.mm index de42265e17250c5a82bbfb1e9ae0f9f51e3336f3..77364f12dce8050fae95de39823963c773827c66 100644 --- a/contrib/mobile/iOS/Onelab/DetailViewController.mm +++ b/contrib/mobile/iOS/Onelab/DetailViewController.mm @@ -125,6 +125,12 @@ - (void) showModelsList { + if(((AppDelegate *)[UIApplication sharedApplication].delegate)->compute) { + UIAlertView *alert; + alert = [[UIAlertView alloc] initWithTitle:@"Can't show the models list" message:@"The compute have to be finished before you can select an other model." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil]; + [alert show]; + return; + } if([[UIDevice currentDevice].model isEqualToString:@"iPad"] || [[UIDevice currentDevice].model isEqualToString:@"iPad Simulator"]){ AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate; [UIView transitionWithView:appDelegate.window diff --git a/contrib/mobile/iOS/Onelab/MasterViewController.mm b/contrib/mobile/iOS/Onelab/MasterViewController.mm index 3b2b5dac98c24c5dc0c652517d1174540d8ae46f..0780bdb7653719b1c69229a242a2b8faad97c1f4 100644 --- a/contrib/mobile/iOS/Onelab/MasterViewController.mm +++ b/contrib/mobile/iOS/Onelab/MasterViewController.mm @@ -8,6 +8,7 @@ #import "MasterViewController.h" #import "DetailViewController.h" +#import "AppDelegate.h" #import "parameter.h" @interface MasterViewController () { @@ -30,8 +31,16 @@ // Do any additional setup after loading the view, typically from a nib. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshParameters:) name:@"refreshParameters" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(resetParameters:) name:@"resetParameters" object:nil]; - runButton = [[UIBarButtonItem alloc] initWithTitle:@"Run" style:UIBarButtonItemStyleBordered target:self action:@selector(runWithNewParameter)]; - [runButton setTitle:@"Run"]; + if(((AppDelegate *)[UIApplication sharedApplication].delegate)->compute){ // Only on iPhone/iPod + runButton = [[UIBarButtonItem alloc] initWithTitle:@"Stop" style:UIBarButtonItemStyleBordered target:self action:@selector(stopRunning)]; + [runButton setTitle:@"Stop"]; + + } + else { + runButton = [[UIBarButtonItem alloc] initWithTitle:@"Run" style:UIBarButtonItemStyleBordered target:self action:@selector(runWithNewParameter)]; + [runButton setTitle:@"Run"]; + } + self.navigationItem.leftItemsSupplementBackButton = YES; // Only on iPhone/iPod self.navigationItem.leftBarButtonItem = runButton; UIBarButtonItem *refresh = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(resetParameters:)]; @@ -175,17 +184,21 @@ - (void)runWithNewParameter { - dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ // TODO fix Run/Stop for iPhone + dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate; + appDelegate->compute = YES; [runButton setTitle:@"Stop"]; [self.view setNeedsDisplay]; [runButton setAction:@selector(stopRunning)]; self.navigationItem.rightBarButtonItem.enabled = NO; onelab_cb("compute"); - [runButton setTitle:@"Run"]; - [self.view setNeedsDisplay]; - [runButton setAction:@selector(runWithNewParameter)]; - self.navigationItem.rightBarButtonItem.enabled = YES; - //[[NSNotificationCenter defaultCenter] postNotificationName:@"refreshParameters" object:nil]; + if([[UIDevice currentDevice].model isEqualToString:@"iPad"] || [[UIDevice currentDevice].model isEqualToString:@"iPad Simulator"]){ + [runButton setTitle:@"Run"]; + [self.view setNeedsDisplay]; + [runButton setAction:@selector(runWithNewParameter)]; + self.navigationItem.rightBarButtonItem.enabled = YES; + } + appDelegate->compute = NO; }); if(![[UIDevice currentDevice].model isEqualToString:@"iPad"] && ![[UIDevice currentDevice].model isEqualToString:@"iPad Simulator"]) [self.navigationController popViewControllerAnimated:YES]; @@ -194,6 +207,10 @@ - (void)stopRunning { onelab_cb("stop"); + if(![[UIDevice currentDevice].model isEqualToString:@"iPad"] && ![[UIDevice currentDevice].model isEqualToString:@"iPad Simulator"]){ + ((AppDelegate *)[UIApplication sharedApplication].delegate)->compute = NO; + [self.navigationController popViewControllerAnimated:YES]; + } } #pragma mark - Table View