#import "RootViewController.h"
#import "ProvidersViewController.h"
-#import "AccountHomeViewController.h"
#import "OpenStackAccount.h"
#import "Provider.h"
#import "Archiver.h"
#import "Keychain.h"
#import "PasscodeViewController.h"
#import "OpenStackAppDelegate.h"
+#import "AccountHomeViewController.h"
+#import "PithosImageViewController.h"
@implementation RootViewController
@synthesize tableView, popoverController, detailItem;
+@synthesize restoreAccountView;
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) || (toInterfaceOrientation == UIInterfaceOrientationPortrait);
}
+- (void)restoreProviderView:(AccountDetailsViewController *)accountDetailsViewController {
+ OpenStackAppDelegate *app = [[UIApplication sharedApplication] delegate];
+ ProvidersViewController *vc = [[ProvidersViewController alloc] initWithNibName:@"ProvidersViewController" bundle:nil];
+ vc.rootViewController = self;
+ if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
+ vc.modalPresentationStyle = UIModalPresentationFormSheet;
+ if (app.rootViewController.popoverController != nil) {
+ [app.rootViewController.popoverController dismissPopoverAnimated:YES];
+ }
+ }
+ [self presentModalViewControllerWithNavigation:vc animated:NO];
+ [vc restoreAccountDetailsViewController:accountDetailsViewController];
+ [vc release];
+}
+
+- (void)restoreAccountView:(AccountSettingsViewController *)accountSettingsViewController {
+ /*NSArray *pathList = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+ NSString *path = [pathList objectAtIndex:0];
+ NSString *filePath = [NSString stringWithFormat:@"%@/iostestfile.txt", path];
+ */
+ /* self.navigationItem.title = @"Accounts";
+
+ self.navigationItem.leftBarButtonItem = self.editButtonItem;
+
+ UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addButtonPressed:)];
+ self.navigationItem.rightBarButtonItem = addButton;
+ [addButton release];
+*/
+ AccountHomeViewController *vc = [[AccountHomeViewController alloc] initWithNibName:@"AccountHomeViewController" bundle:nil];
+ vc.account = accountSettingsViewController.account;
+ vc.account.hasBeenRefreshed = NO;
+ vc.rootViewController = self;
+ [self.navigationController pushViewController:vc animated:YES];
+ [vc release];
+}
+
#pragma mark -
#pragma mark Split view support
- (void)viewDidLoad {
[super viewDidLoad];
+
self.navigationItem.title = @"Accounts";
self.navigationItem.leftBarButtonItem = self.editButtonItem;
UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addButtonPressed:)];
self.navigationItem.rightBarButtonItem = addButton;
- [addButton release];
-
- if ([[OpenStackAccount accounts] count] == 0) {
- // if there are no accounts, go straight to the add account screen on launch
- ProvidersViewController *vc = [[ProvidersViewController alloc] initWithNibName:@"ProvidersViewController" bundle:nil];
- vc.rootViewController = self;
- if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
- vc.modalPresentationStyle = UIModalPresentationFormSheet;
- }
- [self presentModalViewControllerWithNavigation:vc animated:NO];
- [vc release];
-
- } else if ([[OpenStackAccount accounts] count] == 1 && UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad) {
- // if there's only one account, go to its home screen
- // NOTE: not doing this on iPad because it screws up the split view controller.
- // TODO: make this work well with split view on iPad
- AccountHomeViewController *vc = [[AccountHomeViewController alloc] initWithNibName:@"AccountHomeViewController" bundle:nil];
- vc.account = [[OpenStackAccount accounts] objectAtIndex:0];
- vc.rootViewController = self;
- vc.rootViewIndexPath = [NSIndexPath indexPathForRow:0 inSection:0];
- [self.navigationController pushViewController:vc animated:NO];
- [vc release];
- }
-
+ [addButton release];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
- [self.tableView reloadData];
+ [self.tableView reloadData];
+
+ if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
+ PithosImageViewController *vc = [[PithosImageViewController alloc] initWithNibName:@"PithosImageViewController" bundle:nil];
+ [self.navigationController presentPrimaryViewController:vc];
+ [vc release];
+ }
+
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
+
+ if (!viewHasAppearedBefore) {
+ if ([[OpenStackAccount accounts] count] == 0) {
+ // if there are no accounts, go straight to the add account screen on launch
+ ProvidersViewController *vc = [[ProvidersViewController alloc] initWithNibName:@"ProvidersViewController" bundle:nil];
+ vc.rootViewController = self;
+ if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
+ vc.modalPresentationStyle = UIModalPresentationFormSheet;
+ }
+ [self presentModalViewControllerWithNavigation:vc];
+ [vc release];
+ } else if (([[OpenStackAccount accounts] count] == 1) && (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad)) {
+ // if there's only one account, go to its home screen
+ // NOTE: not doing this on iPad because it screws up the split view controller.
+ // TODO: make this work well with split view on iPad
+ AccountHomeViewController *vc = [[AccountHomeViewController alloc] initWithNibName:@"AccountHomeViewController" bundle:nil];
+ vc.account = [[OpenStackAccount accounts] objectAtIndex:0];
+ vc.rootViewController = self;
+ vc.rootViewIndexPath = [NSIndexPath indexPathForRow:0 inSection:0];
+ [self.navigationController pushViewController:vc animated:NO];
+ [vc release];
+ }
+ viewHasAppearedBefore = YES;
+ }
}
/*
if (account.provider.logoURLs && [account.provider.logoURLs objectForKey:@"provider_icon"]) {
cell.imageView.image = [UIImage imageNamed:[account.provider.logoURLs objectForKey:@"provider_icon"]];
} else {
- cell.imageView.image = [UIImage imageNamed:@"openstack-icon.png"];
+ cell.imageView.image = [UIImage imageNamed:@"pithos-solo-smallest.png"];
}
return cell;