Skip to content

Commit 9e980a3

Browse files
Merge pull request #1356 from wutschel/app_settings
Feature: Add shortcut to app settings to main menu (iPhone) or bottom toolbar (iPad)
2 parents faf5f8a + a97201b commit 9e980a3

12 files changed

+68
-26
lines changed

XBMC Remote/BaseMasterViewController.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
- (void)changeServerStatus:(BOOL)status infoText:(NSString*)infoText icon:(NSString*)iconName;
1717
- (void)handleXBMCServerHasChanged:(NSNotification*)sender;
1818
- (void)connectionStatus:(NSNotification*)note;
19+
- (void)enterAppSettings;
1920
- (void)startClearAppDiskCache:(ClearCacheView*)clearView;
2021

2122
@property (strong, nonatomic) tcpJSONRPC *tcpJSONRPCconnection;

XBMC Remote/BaseMasterViewController.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ - (void)connectionStatus:(NSNotification*)note {
145145
[Utilities setWebImageAuthorizationOnSuccessNotification:note];
146146
}
147147

148+
- (void)enterAppSettings {
149+
NSURL *url = [[NSURL alloc] initWithString:UIApplicationOpenSettingsURLString];
150+
[UIApplication.sharedApplication openURL:url options:@{} completionHandler:nil];
151+
}
152+
148153
#pragma mark - App clear disk cache methods
149154

150155
- (void)startClearAppDiskCache:(ClearCacheView*)clearView {

XBMC Remote/DetailViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5341,7 +5341,7 @@ - (void)displayData {
53415341
NSDictionary *parameters = menuItem.mainParameters[chosenTab];
53425342

53435343
BOOL mainLabelChanged = menuItem.mainLabel.length && menuItem.type == TypeNone;
5344-
BOOL useMainLabel = mainLabelChanged && !(menuItem.type == TypeSettings || menuItem.type == TypeCustomButtonEntry);
5344+
BOOL useMainLabel = mainLabelChanged && !(menuItem.type == TypeKodiSettings || menuItem.type == TypeCustomButtonEntry);
53455345
NSString *labelText = useMainLabel ? menuItem.mainLabel : parameters[@"label"];
53465346
self.navigationItem.backButtonTitle = labelText;
53475347
if (!albumView) {

XBMC Remote/MasterViewController.m

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ @implementation MasterViewController
4040
- (void)changeServerStatus:(BOOL)status infoText:(NSString*)infoText icon:(NSString*)iconName {
4141
[super changeServerStatus:status infoText:infoText icon:iconName];
4242
itemIsActive = NO;
43-
[Utilities setStyleOfMenuItems:menuList active:status];
43+
[Utilities setStyleOfMenuItems:menuList active:status menu:self.mainMenu];
4444
}
4545

4646
#pragma mark - Table view methods & data source
@@ -54,7 +54,8 @@ - (NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)
5454
}
5555

5656
- (void)tableView:(UITableView*)tableView willDisplayCell:(UITableViewCell*)cell forRowAtIndexPath:(NSIndexPath*)indexPath {
57-
[Utilities setStyleOfMenuItemCell:cell active:AppDelegate.instance.serverOnLine || indexPath.row == 0];
57+
mainMenu *menuItem = self.mainMenu[indexPath.row];
58+
[Utilities setStyleOfMenuItemCell:cell active:AppDelegate.instance.serverOnLine menuType:menuItem.type];
5859
}
5960

6061
- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath {
@@ -100,11 +101,15 @@ - (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSI
100101

101102
- (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath {
102103
mainMenu *item = self.mainMenu[indexPath.row];
103-
if (!AppDelegate.instance.serverOnLine && item.family != FamilyServer) {
104+
if (item.family == FamilyAppSettings) {
105+
[self enterAppSettings];
106+
return;
107+
}
108+
else if (!AppDelegate.instance.serverOnLine && item.family != FamilyServer) {
104109
[menuList selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:indexPath.section] animated:YES scrollPosition:UITableViewScrollPositionNone];
105110
return;
106111
}
107-
if (itemIsActive) {
112+
else if (itemIsActive) {
108113
return;
109114
}
110115

XBMC Remote/Utilities.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#import <Foundation/Foundation.h>
1010
#import <SafariServices/SafariServices.h>
1111
#import "MessagesView.h"
12+
#import "mainMenu.h"
1213
#import "DSJSONRPC.h"
1314

1415
typedef NS_ENUM(NSInteger, JewelType) {
@@ -100,8 +101,8 @@ typedef NS_ENUM(NSInteger, LogoBackgroundType) {
100101
+ (NSString*)getConnectionStatusIconName;
101102
+ (NSString*)getConnectionStatusServerName;
102103
+ (void)addShadowsToView:(UIView*)view viewFrame:(CGRect)frame;
103-
+ (void)setStyleOfMenuItemCell:(UITableViewCell*)cell active:(BOOL)active;
104-
+ (void)setStyleOfMenuItems:(UITableView*)tableView active:(BOOL)active;
104+
+ (void)setStyleOfMenuItemCell:(UITableViewCell*)cell active:(BOOL)active menuType:(MenuItemType)type;
105+
+ (void)setStyleOfMenuItems:(UITableView*)tableView active:(BOOL)active menu:(NSArray*)menuList;
105106
+ (NSIndexPath*)getIndexPathForDefaultController:(NSArray*)menuItems;
106107
+ (void)enableDefaultController:(id<UITableViewDelegate>)viewController tableView:(UITableView*)tableView menuItems:(NSArray*)menuItems;
107108
+ (id)unarchivePath:(NSString*)path file:(NSString*)filename;

XBMC Remote/Utilities.m

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,24 +1103,23 @@ + (void)addShadowsToView:(UIView*)view viewFrame:(CGRect)frame {
11031103
}
11041104
}
11051105

1106-
+ (void)setStyleOfMenuItemCell:(UITableViewCell*)cell active:(BOOL)active {
1106+
+ (void)setStyleOfMenuItemCell:(UITableViewCell*)cell active:(BOOL)active menuType:(MenuItemType)type {
1107+
// Connection status and App settings are always visible. Those should not be faded/unfaded.
1108+
active = active || type == TypeServer || type == TypeAppSettings;
11071109
CGFloat alpha = active ? 1.0 : 0.3;
11081110
UIImageView *icon = (UIImageView*)[cell viewWithTag:XIB_MAIN_MENU_CELL_ICON];
11091111
UILabel *title = (UILabel*)[cell viewWithTag:XIB_MAIN_MENU_CELL_TITLE];
11101112
icon.alpha = alpha;
11111113
title.alpha = alpha;
11121114
}
11131115

1114-
+ (void)setStyleOfMenuItems:(UITableView*)tableView active:(BOOL)active {
1116+
+ (void)setStyleOfMenuItems:(UITableView*)tableView active:(BOOL)active menu:(NSArray*)menuList {
11151117
for (NSIndexPath *indexPath in tableView.indexPathsForVisibleRows) {
1116-
// The iPhone uses the top most cell as connection status. This should not be faded/unfaded.
1117-
if (IS_IPHONE && indexPath.row == 0 && indexPath.section == 0) {
1118-
continue;
1119-
}
1118+
mainMenu *menuItem = menuList[indexPath.row];
11201119
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
11211120
[UIView animateWithDuration:0.3
11221121
animations:^{
1123-
[Utilities setStyleOfMenuItemCell:cell active:active];
1122+
[Utilities setStyleOfMenuItemCell:cell active:active menuType:menuItem.type];
11241123
}];
11251124
}
11261125
}
@@ -1146,7 +1145,7 @@ + (NSIndexPath*)getIndexPathForDefaultController:(NSArray*)menuItems {
11461145
@"start_menu_search": @(TypeGlobalSearch),
11471146
@"start_menu_files": @(TypeFiles),
11481147
@"start_menu_addons": @(TypeAddons),
1149-
@"start_menu_settings": @(TypeSettings),
1148+
@"start_menu_settings": @(TypeKodiSettings),
11501149
};
11511150
MenuItemType startMenuType = [defaultMenus[startId] intValue];
11521151

XBMC Remote/ViewControllerIPad.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
UIButton *xbmcLogo;
3434
UIButton *xbmcInfo;
3535
UIButton *powerButton;
36+
UIButton *settingsButton;
3637
UIImageView *connectionStatus;
3738
VolumeSliderView *volumeSliderView;
3839
BOOL didTouchLeftMenu;

XBMC Remote/ViewControllerIPad.m

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@
2121
#import "RemoteController.h"
2222

2323
#define CONNECTION_TIMEOUT 240.0
24-
#define VIEW_PADDING 10 /* separation between toolbar views */
24+
#define INFO_PADDING 10
25+
#define BUTTON_PADDING 5
2526
#define TOOLBAR_HEIGHT 44
26-
#define XBMCLOGO_WIDTH 30
27+
#define XBMCLOGO_WIDTH 42
2728
#define POWERBUTTON_WIDTH 42
29+
#define SETTINGSBUTTON_WIDTH 42
2830
#define REMOTE_ICON_SIZE 30
2931
#define CONNECTION_ICON_SIZE 18
30-
#define CONNECTION_PADDING 20
32+
#define CONNECTION_PADDING 10
3133
#define REMOTE_PADDING 15
3234
#define DESKTOP_PADDING 25
3335
#define PLAYLIST_HEADER_HEIGHT 24
@@ -97,7 +99,7 @@ - (void)changeServerStatus:(BOOL)status infoText:(NSString*)infoText icon:(NSStr
9799
}
98100
}
99101
[xbmcInfo setTitle:infoText forState:UIControlStateNormal];
100-
[Utilities setStyleOfMenuItems:menuViewController.tableView active:status];
102+
[Utilities setStyleOfMenuItems:menuViewController.tableView active:status menu:mainMenu];
101103
}
102104

103105
- (void)offStackView {
@@ -397,7 +399,7 @@ - (void)viewDidLoad {
397399
[self.view addSubview:showDesktopButton];
398400

399401
// right most element
400-
connectionStatus = [[UIImageView alloc] initWithFrame:CGRectMake(self.view.frame.size.width - CONNECTION_ICON_SIZE - VIEW_PADDING, self.view.frame.size.height - (TOOLBAR_HEIGHT + CONNECTION_ICON_SIZE) / 2 - [Utilities getBottomPadding], CONNECTION_ICON_SIZE, CONNECTION_ICON_SIZE)];
402+
connectionStatus = [[UIImageView alloc] initWithFrame:CGRectMake(self.view.frame.size.width - CONNECTION_ICON_SIZE - CONNECTION_PADDING, self.view.frame.size.height - (TOOLBAR_HEIGHT + CONNECTION_ICON_SIZE) / 2 - [Utilities getBottomPadding], CONNECTION_ICON_SIZE, CONNECTION_ICON_SIZE)];
401403
connectionStatus.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin;
402404
[self.view addSubview:connectionStatus];
403405

@@ -413,17 +415,27 @@ - (void)viewDidLoad {
413415
[self.view addSubview:xbmcLogo];
414416

415417
// 3rd right most element
418+
image = [UIImage imageNamed:@"icon_menu_settings"];
419+
image = [Utilities colorizeImage:image withColor:UIColor.lightGrayColor];
420+
settingsButton = [[UIButton alloc] initWithFrame:CGRectMake(xbmcLogo.frame.origin.x - SETTINGSBUTTON_WIDTH - BUTTON_PADDING, self.view.frame.size.height - TOOLBAR_HEIGHT, SETTINGSBUTTON_WIDTH, TOOLBAR_HEIGHT)];
421+
[settingsButton setImage:image forState:UIControlStateNormal];
422+
[settingsButton setImage:image forState:UIControlStateHighlighted];
423+
settingsButton.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin;
424+
[settingsButton addTarget:self action:@selector(enterAppSettings) forControlEvents:UIControlEventTouchUpInside];
425+
[self.view addSubview:settingsButton];
426+
427+
// 4th right most element
416428
image = [UIImage imageNamed:@"icon_power"];
417429
image = [Utilities colorizeImage:image withColor:UIColor.lightGrayColor];
418-
powerButton = [[UIButton alloc] initWithFrame:CGRectMake(xbmcLogo.frame.origin.x - POWERBUTTON_WIDTH - VIEW_PADDING, self.view.frame.size.height - TOOLBAR_HEIGHT, POWERBUTTON_WIDTH, TOOLBAR_HEIGHT)];
430+
powerButton = [[UIButton alloc] initWithFrame:CGRectMake(settingsButton.frame.origin.x - POWERBUTTON_WIDTH - BUTTON_PADDING, self.view.frame.size.height - TOOLBAR_HEIGHT, POWERBUTTON_WIDTH, TOOLBAR_HEIGHT)];
419431
[powerButton setImage:image forState:UIControlStateNormal];
420432
[powerButton setImage:image forState:UIControlStateHighlighted];
421433
powerButton.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin;
422434
[powerButton addTarget:self action:@selector(powerControl) forControlEvents:UIControlEventTouchUpInside];
423435
[self.view addSubview:powerButton];
424436

425437
// element between left most and 2nd right most uses up free space
426-
CGFloat infoPadding = self.view.frame.size.width - CGRectGetMinX(powerButton.frame) + 2 * VIEW_PADDING;
438+
CGFloat infoPadding = self.view.frame.size.width - CGRectGetMinX(powerButton.frame) + 2 * INFO_PADDING;
427439
CGFloat infoStart = PAD_MENU_TABLE_WIDTH + infoPadding;
428440
CGFloat infoWidth = self.view.frame.size.width - PAD_MENU_TABLE_WIDTH - 2 * infoPadding;
429441
xbmcInfo = [[UIButton alloc] initWithFrame:CGRectMake(infoStart, self.view.frame.size.height - TOOLBAR_HEIGHT, infoWidth, TOOLBAR_HEIGHT)];
@@ -457,6 +469,10 @@ - (void)viewDidLoad {
457469
frame.origin.y -= bottomPadding;
458470
powerButton.frame = frame;
459471

472+
frame = settingsButton.frame;
473+
frame.origin.y -= bottomPadding;
474+
settingsButton.frame = frame;
475+
460476
frame = xbmcInfo.frame;
461477
frame.origin.y -= bottomPadding;
462478
xbmcInfo.frame = frame;

XBMC Remote/en.lproj/Localizable.strings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@
193193

194194
"Programs" = "Programs";
195195
"XBMC Settings" = "Kodi Settings";
196+
"App Settings" = "App Settings";
196197

197198
"Custom button" = "Custom button";
198199
"Modify label:" = "Modify label:";

XBMC Remote/iPad/MenuViewController.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ - (NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)
132132
}
133133

134134
- (void)tableView:(UITableView*)tableView willDisplayCell:(UITableViewCell*)cell forRowAtIndexPath:(NSIndexPath*)indexPath {
135-
[Utilities setStyleOfMenuItemCell:cell active:AppDelegate.instance.serverOnLine];
135+
mainMenu *menuItem = mainMenuItems[indexPath.row];
136+
[Utilities setStyleOfMenuItemCell:cell active:AppDelegate.instance.serverOnLine menuType:menuItem.type];
136137
cell.backgroundColor = UIColor.clearColor;
137138
}
138139

0 commit comments

Comments
 (0)