Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions XBMC Remote/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(N
self.serverName = LOCALIZED_STR(@"No connection");
if (IS_IPHONE) {
InitialSlidingViewController *initialSlidingViewController = [[InitialSlidingViewController alloc] initWithNibName:@"InitialSlidingViewController" bundle:nil];
initialSlidingViewController.mainMenu = mainMenuItems;
initialSlidingViewController.mainMenuTable = mainMenuItems;
self.window.rootViewController = initialSlidingViewController;
}
else {
self.windowController = [[ViewControllerIPad alloc] initWithNibName:@"ViewControllerIPad" bundle:nil];
self.windowController.mainMenu = mainMenuItems;
self.windowController.mainMenuTable = mainMenuItems;
self.window.rootViewController = self.windowController;
}
return YES;
Expand Down
2 changes: 1 addition & 1 deletion XBMC Remote/HostManagementViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@

- (id)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil;

@property (nonatomic, strong) NSMutableArray *mainMenu;
@property (nonatomic, strong) NSMutableArray *mainMenuTable;

@end
2 changes: 0 additions & 2 deletions XBMC Remote/HostManagementViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ @interface HostManagementViewController ()

@implementation HostManagementViewController

@synthesize mainMenu;

- (id)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
return self;
Expand Down
2 changes: 1 addition & 1 deletion XBMC Remote/InitialSlidingViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@

- (void)handleMenuButton;

@property (nonatomic, strong) NSMutableArray *mainMenu;
@property (nonatomic, strong) NSMutableArray *mainMenuTable;

@end
8 changes: 3 additions & 5 deletions XBMC Remote/InitialSlidingViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ @interface InitialSlidingViewController ()

@implementation InitialSlidingViewController

@synthesize mainMenu;

- (id)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
return self;
Expand All @@ -28,7 +26,7 @@ - (void)viewDidLoad {
[super viewDidLoad];

MasterViewController *masterViewController = [[MasterViewController alloc] initWithNibName:@"MasterViewController" bundle:nil];
masterViewController.mainMenu = self.mainMenu;
masterViewController.mainMenuTable = self.mainMenuTable;
self.underLeftViewController = masterViewController;

HostManagementViewController *hostManagementViewController = [[HostManagementViewController alloc] initWithNibName:@"HostManagementViewController" bundle:nil];
Expand All @@ -39,12 +37,12 @@ - (void)viewDidLoad {

self.view.tintColor = APP_TINT_COLOR;
[navController hideNavBarBottomLine:YES];
hostManagementViewController.mainMenu = self.mainMenu;
hostManagementViewController.mainMenuTable = self.mainMenuTable;
self.topViewController = navController;

// Hide the inital HostManagementVC in case the "start view" is not main menu to avoid disturbing
// sliding out (this view) and in (the targeted view).
self.topViewController.view.hidden = [Utilities getIndexPathForDefaultController:self.mainMenu] != nil;
self.topViewController.view.hidden = [Utilities getIndexPathForDefaultController:self.mainMenuTable] != nil;

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleTcpJSONRPCShowSetup:)
Expand Down
2 changes: 1 addition & 1 deletion XBMC Remote/MasterViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
MessagesView *messagesView;
}

@property (nonatomic, strong) NSMutableArray *mainMenu;
@property (nonatomic, strong) NSMutableArray *mainMenuTable;

@end
15 changes: 6 additions & 9 deletions XBMC Remote/MasterViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,15 @@

@interface MasterViewController () {
NSMutableArray *_objects;
NSMutableArray *mainMenu;
}
@end

@implementation MasterViewController

@synthesize mainMenu;

- (void)changeServerStatus:(BOOL)status infoText:(NSString*)infoText icon:(NSString*)iconName {
[super changeServerStatus:status infoText:infoText icon:iconName];
itemIsActive = NO;
[Utilities setStyleOfMenuItems:menuList active:status menu:self.mainMenu];
[Utilities setStyleOfMenuItems:menuList active:status menu:self.mainMenuTable];
}

#pragma mark - Table view methods & data source
Expand All @@ -50,11 +47,11 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView*)tableView {
}

- (NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section {
return self.mainMenu.count;
return self.mainMenuTable.count;
}

- (void)tableView:(UITableView*)tableView willDisplayCell:(UITableViewCell*)cell forRowAtIndexPath:(NSIndexPath*)indexPath {
mainMenu *menuItem = self.mainMenu[indexPath.row];
mainMenu *menuItem = self.mainMenuTable[indexPath.row];
[Utilities setStyleOfMenuItemCell:cell active:AppDelegate.instance.serverOnLine menuType:menuItem.type];
}

Expand All @@ -69,7 +66,7 @@ - (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSI
backgroundView.backgroundColor = MAINMENU_SELECTED_COLOR;
cell.selectedBackgroundView = backgroundView;
}
mainMenu *item = self.mainMenu[indexPath.row];
mainMenu *item = self.mainMenuTable[indexPath.row];
NSString *iconName = item.icon;
UIImageView *icon = (UIImageView*)[cell viewWithTag:XIB_MAIN_MENU_CELL_ICON];
UILabel *title = (UILabel*)[cell viewWithTag:XIB_MAIN_MENU_CELL_TITLE];
Expand Down Expand Up @@ -100,7 +97,7 @@ - (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSI
}

- (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath {
mainMenu *item = self.mainMenu[indexPath.row];
mainMenu *item = self.mainMenuTable[indexPath.row];
if (item.family == FamilyAppSettings) {
[self enterAppSettings];

Expand Down Expand Up @@ -320,7 +317,7 @@ - (void)connectionStatus:(NSNotification*)note {
}

- (void)handleEnablingDefaultController {
[Utilities enableDefaultController:self tableView:menuList menuItems:self.mainMenu];
[Utilities enableDefaultController:self tableView:menuList menuItems:self.mainMenuTable];
}

- (BOOL)shouldAutorotate {
Expand Down
3 changes: 2 additions & 1 deletion XBMC Remote/ViewControllerIPad.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
MenuViewController *menuViewController;
NowPlaying *nowPlayingController;
StackScrollViewController *stackScrollViewController;
NSUInteger maxVisibleMenuItems;
int YPOS;
UIButton *xbmcLogo;
UIButton *xbmcInfo;
Expand All @@ -49,7 +50,7 @@
MessagesView *messagesView;
}

@property (nonatomic, strong) NSMutableArray *mainMenu;
@property (nonatomic, strong) NSMutableArray *mainMenuTable;
@property (nonatomic, strong) MenuViewController *menuViewController;
@property (nonatomic, strong) NowPlaying *nowPlayingController;
@property (nonatomic, strong) StackScrollViewController *stackScrollViewController;
Expand Down
51 changes: 30 additions & 21 deletions XBMC Remote/ViewControllerIPad.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@
#define PLAYLIST_ACTION_HEIGHT 44
#define PLAYLIST_CELL_HEIGHT 53

@interface ViewControllerIPad () {
NSMutableArray *mainMenu;
}
@end

@interface UIViewExt : UIView {}
@end

Expand Down Expand Up @@ -72,7 +67,6 @@ - (UIView*)hitTest:(CGPoint)pt withEvent:(UIEvent*)event {

@implementation ViewControllerIPad

@synthesize mainMenu;
@synthesize menuViewController, stackScrollViewController;
@synthesize nowPlayingController;
@synthesize hostPickerViewController = _hostPickerViewController;
Expand All @@ -98,7 +92,7 @@ - (void)changeServerStatus:(BOOL)status infoText:(NSString*)infoText icon:(NSStr
}
}
[xbmcInfo setTitle:infoText forState:UIControlStateNormal];
[Utilities setStyleOfMenuItems:menuViewController.tableView active:status menu:mainMenu];
[Utilities setStyleOfMenuItems:menuViewController.tableView active:status menu:self.mainMenuTable];
}

- (void)offStackView {
Expand Down Expand Up @@ -205,9 +199,8 @@ - (void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event {
CGPoint locationPoint = [touch locationInView:leftMenuView];
if ([leftMenuView pointInside:locationPoint withEvent:event]) {
// Change the left menu layout
CGFloat maxMenuItems = locationPoint.y / PAD_MENU_HEIGHT;
CGFloat tableHeight = MIN([(NSMutableArray*)mainMenu count], maxMenuItems) * PAD_MENU_HEIGHT;
[self changeLeftMenu:tableHeight];
CGFloat separatorPosition = MIN(locationPoint.y, CGRectGetHeight(leftMenuView.frame) - PLAYLIST_HEADER_HEIGHT);
[self changeLeftMenu:separatorPosition];
}
}

Expand All @@ -220,12 +213,15 @@ - (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event {
playlistHeader.backgroundColor = UIColor.clearColor;
playlistHeader.textColor = UIColor.lightGrayColor;

// Finalize the left menu layout
NSInteger maxMenuItems = round(CGRectGetMinY(playlistHeader.frame) / PAD_MENU_HEIGHT);
CGFloat tableHeight = MIN([(NSMutableArray*)mainMenu count], maxMenuItems) * PAD_MENU_HEIGHT;
[self changeLeftMenu:tableHeight];
// Finalize the left menu layout. Snap back to last menu item with separator above playlist toolbar
NSUInteger maxMenuItems = round(CGRectGetMinY(playlistHeader.frame) / PAD_MENU_HEIGHT);
if (maxMenuItems * PAD_MENU_HEIGHT > CGRectGetHeight(leftMenuView.frame) - PLAYLIST_HEADER_HEIGHT) {
maxMenuItems -= 1;
}
[self changeLeftMenu:maxMenuItems * PAD_MENU_HEIGHT];

// Save configuration
maxVisibleMenuItems = maxMenuItems;
[self saveLeftMenuSplit:maxMenuItems];
didTouchLeftMenu = NO;
}
Expand Down Expand Up @@ -265,10 +261,17 @@ - (void)layoutPlaylistNowplayingForTableHeight:(CGFloat)tableHeight {
}

- (void)changeLeftMenu:(CGFloat)tableHeight {
tableHeight = MIN(self.mainMenuTable.count * PAD_MENU_HEIGHT, tableHeight);

// Keep separator above playlist toolbar
if (tableHeight > CGRectGetHeight(leftMenuView.frame) - PLAYLIST_HEADER_HEIGHT) {
tableHeight -= PAD_MENU_HEIGHT;
}

// Main menu
[menuViewController setMenuHeight:tableHeight];

// Seperator
// Separator
CGRect frame = playlistHeader.frame;
frame.origin.y = tableHeight;
playlistHeader.frame = frame;
Expand All @@ -282,18 +285,18 @@ - (void)changeLeftMenu:(CGFloat)tableHeight {
}

- (void)createLeftMenu:(NSInteger)maxMenuItems {
NSInteger tableHeight = MIN([(NSMutableArray*)mainMenu count], maxMenuItems) * PAD_MENU_HEIGHT;
NSInteger tableHeight = MIN(self.mainMenuTable.count, maxMenuItems) * PAD_MENU_HEIGHT;

// Create left menu
leftMenuView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, PAD_MENU_TABLE_WIDTH, self.view.frame.size.height)];
leftMenuView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, PAD_MENU_TABLE_WIDTH, self.view.frame.size.height - [Utilities getTopPadding] - [Utilities getBottomPadding] - TOOLBAR_HEIGHT - PLAYLIST_ACTION_HEIGHT)];
leftMenuView.autoresizingMask = UIViewAutoresizingFlexibleHeight;

// Main menu
menuViewController = [[MenuViewController alloc] initWithFrame:CGRectMake(0, 0, leftMenuView.frame.size.width, leftMenuView.frame.size.height) mainMenu:mainMenu menuHeight:tableHeight];
menuViewController = [[MenuViewController alloc] initWithFrame:CGRectMake(0, 0, leftMenuView.frame.size.width, leftMenuView.frame.size.height) mainMenu:self.mainMenuTable menuHeight:tableHeight];
menuViewController.view.backgroundColor = UIColor.clearColor;
[leftMenuView addSubview:menuViewController.view];

// Seperator
// Separator
playlistHeader = [[UILabel alloc] initWithFrame:CGRectMake(0, tableHeight, PAD_MENU_TABLE_WIDTH, PLAYLIST_HEADER_HEIGHT)];
playlistHeader.backgroundColor = UIColor.clearColor;
playlistHeader.textColor = UIColor.lightGrayColor;
Expand Down Expand Up @@ -322,8 +325,8 @@ - (void)viewDidLoad {
AppDelegate.instance.obj = [GlobalData getInstance];

// Create the left menu
NSInteger maxMenuItems = [self loadLeftMenuSplit];
[self createLeftMenu:maxMenuItems];
maxVisibleMenuItems = [self loadLeftMenuSplit];
[self createLeftMenu:maxVisibleMenuItems];

rootView = [[UIViewExt alloc] initWithFrame:CGRectMake(0, deltaY, self.view.frame.size.width, self.view.frame.size.height - deltaY)];
rootView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
Expand Down Expand Up @@ -519,6 +522,11 @@ - (void)viewDidLoad {
object:nil];
}

- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self changeLeftMenu:maxVisibleMenuItems * PAD_MENU_HEIGHT];
}

- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
BOOL showSetup = AppDelegate.instance.obj.serverIP.length == 0;
Expand Down Expand Up @@ -632,6 +640,7 @@ - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIVi
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) {
[menuViewController viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
[stackScrollViewController viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
[self changeLeftMenu:maxVisibleMenuItems * PAD_MENU_HEIGHT];
}
completion:^(id<UIViewControllerTransitionCoordinatorContext> context) {
// restore state
Expand Down
Loading