|
@@ -18,10 +18,10 @@
|
|
#define SettingsReUseIdentifier @"SettingsReUseIdentifier"
|
|
#define SettingsReUseIdentifier @"SettingsReUseIdentifier"
|
|
|
|
|
|
@interface VLCSettingsViewController () <UITableViewDataSource, UITableViewDelegate>
|
|
@interface VLCSettingsViewController () <UITableViewDataSource, UITableViewDelegate>
|
|
-{
|
|
|
|
- NSUserDefaults *_userDefaults;
|
|
|
|
- IASKSettingsReader *_settingsReader;
|
|
|
|
-}
|
|
|
|
|
|
+
|
|
|
|
+@property (strong, nonatomic) NSUserDefaults *userDefaults;
|
|
|
|
+@property (strong, nonatomic) IASKSettingsReader *settingsReader;
|
|
|
|
+
|
|
@end
|
|
@end
|
|
|
|
|
|
@implementation VLCSettingsViewController
|
|
@implementation VLCSettingsViewController
|
|
@@ -29,8 +29,8 @@
|
|
- (void)viewDidLoad {
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
[super viewDidLoad];
|
|
|
|
|
|
- _userDefaults = [NSUserDefaults standardUserDefaults];
|
|
|
|
- _settingsReader = [[IASKSettingsReader alloc] init];
|
|
|
|
|
|
+ self.userDefaults = [NSUserDefaults standardUserDefaults];
|
|
|
|
+ self.settingsReader = [[IASKSettingsReader alloc] init];
|
|
|
|
|
|
self.automaticallyAdjustsScrollViewInsets = NO;
|
|
self.automaticallyAdjustsScrollViewInsets = NO;
|
|
self.edgesForExtendedLayout = UIRectEdgeAll ^ UIRectEdgeTop;
|
|
self.edgesForExtendedLayout = UIRectEdgeAll ^ UIRectEdgeTop;
|
|
@@ -47,38 +47,39 @@
|
|
#pragma mark - Table view data source
|
|
#pragma mark - Table view data source
|
|
|
|
|
|
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
|
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
|
- return _settingsReader.numberOfSections;
|
|
|
|
|
|
+ return self.settingsReader.numberOfSections;
|
|
}
|
|
}
|
|
|
|
|
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
|
{
|
|
{
|
|
- return [_settingsReader numberOfRowsForSection:section];
|
|
|
|
|
|
+ return [self.settingsReader numberOfRowsForSection:section];
|
|
}
|
|
}
|
|
|
|
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SettingsReUseIdentifier];
|
|
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SettingsReUseIdentifier];
|
|
|
|
|
|
- if (!cell)
|
|
|
|
|
|
+ if (!cell) {
|
|
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:SettingsReUseIdentifier];
|
|
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:SettingsReUseIdentifier];
|
|
|
|
+ }
|
|
|
|
|
|
- IASKSpecifier *specifier = [_settingsReader specifierForIndexPath:indexPath];
|
|
|
|
|
|
+ IASKSpecifier *specifier = [self.settingsReader specifierForIndexPath:indexPath];
|
|
cell.textLabel.text = [specifier title];
|
|
cell.textLabel.text = [specifier title];
|
|
NSString *specifierType = specifier.type;
|
|
NSString *specifierType = specifier.type;
|
|
if ([specifierType isEqualToString:kIASKPSMultiValueSpecifier]) {
|
|
if ([specifierType isEqualToString:kIASKPSMultiValueSpecifier]) {
|
|
NSArray *titles = [specifier multipleTitles];
|
|
NSArray *titles = [specifier multipleTitles];
|
|
NSArray *values = [specifier multipleValues];
|
|
NSArray *values = [specifier multipleValues];
|
|
- NSUInteger selectedIndex = [values indexOfObject:[_userDefaults objectForKey:[specifier key]]];
|
|
|
|
|
|
+ NSUInteger selectedIndex = [values indexOfObject:[self.userDefaults objectForKey:[specifier key]]];
|
|
NSUInteger titlesCount = titles.count;
|
|
NSUInteger titlesCount = titles.count;
|
|
if (selectedIndex < titlesCount)
|
|
if (selectedIndex < titlesCount)
|
|
- cell.detailTextLabel.text = [_settingsReader titleForStringId:titles[selectedIndex]];
|
|
|
|
|
|
+ cell.detailTextLabel.text = [self.settingsReader titleForStringId:titles[selectedIndex]];
|
|
else {
|
|
else {
|
|
selectedIndex = [values indexOfObject:[specifier defaultValue]];
|
|
selectedIndex = [values indexOfObject:[specifier defaultValue]];
|
|
if (selectedIndex < titlesCount)
|
|
if (selectedIndex < titlesCount)
|
|
- cell.detailTextLabel.text = [_settingsReader titleForStringId:titles[selectedIndex]];
|
|
|
|
|
|
+ cell.detailTextLabel.text = [self.settingsReader titleForStringId:titles[selectedIndex]];
|
|
}
|
|
}
|
|
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
|
|
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
|
|
} else if ([specifierType isEqualToString:kIASKPSToggleSwitchSpecifier]) {
|
|
} else if ([specifierType isEqualToString:kIASKPSToggleSwitchSpecifier]) {
|
|
- cell.detailTextLabel.text = [_userDefaults boolForKey:[specifier key]] ? NSLocalizedString(@"ON", nil) : NSLocalizedString(@"OFF", nil);
|
|
|
|
|
|
+ cell.detailTextLabel.text = [self.userDefaults boolForKey:[specifier key]] ? NSLocalizedString(@"ON", nil) : NSLocalizedString(@"OFF", nil);
|
|
cell.accessoryType = UITableViewCellAccessoryNone;
|
|
cell.accessoryType = UITableViewCellAccessoryNone;
|
|
} else {
|
|
} else {
|
|
cell.detailTextLabel.text = @"";
|
|
cell.detailTextLabel.text = @"";
|
|
@@ -90,12 +91,12 @@
|
|
|
|
|
|
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
|
|
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
|
|
{
|
|
{
|
|
- return [_settingsReader titleForSection:section];
|
|
|
|
|
|
+ return [self.settingsReader titleForSection:section];
|
|
}
|
|
}
|
|
|
|
|
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
|
{
|
|
{
|
|
- IASKSpecifier *specifier = [_settingsReader specifierForIndexPath:indexPath];
|
|
|
|
|
|
+ IASKSpecifier *specifier = [self.settingsReader specifierForIndexPath:indexPath];
|
|
|
|
|
|
NSString *specifierType = specifier.type;
|
|
NSString *specifierType = specifier.type;
|
|
if ([specifierType isEqualToString:kIASKPSMultiValueSpecifier]) {
|
|
if ([specifierType isEqualToString:kIASKPSMultiValueSpecifier]) {
|
|
@@ -104,19 +105,20 @@
|
|
|
|
|
|
NSUInteger count = [specifier multipleValuesCount];
|
|
NSUInteger count = [specifier multipleValuesCount];
|
|
NSArray *titles = [specifier multipleTitles];
|
|
NSArray *titles = [specifier multipleTitles];
|
|
- NSValue *currentValue = [_userDefaults objectForKey:[specifier key]] ?: [specifier defaultValue];
|
|
|
|
|
|
+ NSValue *currentValue = [self.userDefaults objectForKey:[specifier key]] ?: [specifier defaultValue];
|
|
NSUInteger indexOfPreferredAction = [[specifier multipleValues] indexOfObject:currentValue];
|
|
NSUInteger indexOfPreferredAction = [[specifier multipleValues] indexOfObject:currentValue];
|
|
for (NSUInteger i = 0; i < count; i++) {
|
|
for (NSUInteger i = 0; i < count; i++) {
|
|
id value = [[specifier multipleValues][i] copy];
|
|
id value = [[specifier multipleValues][i] copy];
|
|
- UIAlertAction *action = [UIAlertAction actionWithTitle:[_settingsReader titleForStringId:titles[i]]
|
|
|
|
|
|
+ UIAlertAction *action = [UIAlertAction actionWithTitle:[self.settingsReader titleForStringId:titles[i]]
|
|
style:UIAlertActionStyleDefault
|
|
style:UIAlertActionStyleDefault
|
|
handler:^(UIAlertAction * _Nonnull action) {
|
|
handler:^(UIAlertAction * _Nonnull action) {
|
|
- [_userDefaults setObject:value forKey:[specifier key]];
|
|
|
|
|
|
+ [self.userDefaults setObject:value forKey:[specifier key]];
|
|
[self.tableView reloadData];
|
|
[self.tableView reloadData];
|
|
}];
|
|
}];
|
|
[alertController addAction:action];
|
|
[alertController addAction:action];
|
|
- if (i == indexOfPreferredAction)
|
|
|
|
|
|
+ if (i == indexOfPreferredAction) {
|
|
[alertController setPreferredAction:action];
|
|
[alertController setPreferredAction:action];
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
[alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"BUTTON_CANCEL", nil)
|
|
[alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"BUTTON_CANCEL", nil)
|
|
@@ -126,7 +128,7 @@
|
|
[self presentViewController:alertController animated:YES completion:nil];
|
|
[self presentViewController:alertController animated:YES completion:nil];
|
|
} else if ([specifierType isEqualToString:kIASKPSToggleSwitchSpecifier]) {
|
|
} else if ([specifierType isEqualToString:kIASKPSToggleSwitchSpecifier]) {
|
|
NSString *specifierKey = [specifier key];
|
|
NSString *specifierKey = [specifier key];
|
|
- [_userDefaults setBool:![_userDefaults boolForKey:specifierKey] forKey:specifierKey];
|
|
|
|
|
|
+ [self.userDefaults setBool:![self.userDefaults boolForKey:specifierKey] forKey:specifierKey];
|
|
[self.tableView reloadData];
|
|
[self.tableView reloadData];
|
|
} else {
|
|
} else {
|
|
VLCAboutViewController *targetViewController = [[VLCAboutViewController alloc] initWithNibName:nil bundle:nil];
|
|
VLCAboutViewController *targetViewController = [[VLCAboutViewController alloc] initWithNibName:nil bundle:nil];
|