Skip to content

Commit 93439e1

Browse files
committed
ipad support and cleanup
1 parent 90f880b commit 93439e1

12 files changed

+80
-115
lines changed

notiblockpref/NBPAddFilterPreferenceBundle.h

Lines changed: 0 additions & 5 deletions
This file was deleted.

notiblockpref/NBPAddFilterPreferenceBundle.m

Lines changed: 0 additions & 56 deletions
This file was deleted.

notiblockpref/NBPAddViewController.m

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ @interface NBPAddViewController ()
4040

4141
@implementation NBPAddViewController
4242

43-
- (void)loadView {
44-
[super loadView];
45-
self.view = [[UIView alloc]initWithFrame:[UIScreen mainScreen].applicationFrame];
43+
- (void)viewDidLoad {
44+
[super viewDidLoad];
45+
4646
self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];
4747

4848
UIBarButtonItem* cancelBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(onTapCancel:)];
@@ -99,8 +99,8 @@ - (void)loadView {
9999

100100

101101

102-
int screenHeight = [[UIScreen mainScreen] bounds].size.height;
103-
int screenWidth = [[UIScreen mainScreen] bounds].size.width;
102+
int screenHeight = self.view.frame.size.height;
103+
int screenWidth = self.view.frame.size.width;
104104
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0,screenWidth,screenHeight) style:UITableViewStyleGrouped];
105105
self.tableView.delegate = self;
106106
self.tableView.dataSource = self;
@@ -145,7 +145,6 @@ - (void)viewDidLayoutSubviews {
145145
self.tableView.frame = CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height);
146146
}
147147

148-
149148
- (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
150149
switch (indexPath.section) {
151150
case 0:
@@ -298,7 +297,7 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa
298297
} else if (indexPath.section == 6 && indexPath.row == 2) {
299298
return (self.endTimeCell.datePicker.tag == 0 ? 50 : 200);
300299
} else if (indexPath.section == 1) {
301-
return [[UIScreen mainScreen] bounds].size.width * 0.27;
300+
return self.view.frame.size.width * 0.27;
302301
}
303302
return 50;
304303
}

notiblockpref/NBPAppChooserViewController.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ - (void)viewDidLoad {
6969
[self.view addSubview:self.tableView];
7070
}
7171

72+
- (void)viewDidLayoutSubviews {
73+
[super viewDidLayoutSubviews];
74+
self.tableView.frame = CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height);
75+
}
76+
7277
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
7378
AppListTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AppCell"];
7479
ALApplicationList *appList = [ALApplicationList sharedApplicationList];

notiblockpref/NBPAppListTableViewCell.m

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,22 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
1414
{
1515
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
1616
if (self) {
17-
int screenWidth = [[UIScreen mainScreen] bounds].size.width;
18-
19-
self.appIcon = [[UIImageView alloc] initWithFrame:CGRectMake(17.5, 7.5, 35, 35)];
17+
self.appIcon = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,0,0)];
2018
[self addSubview:self.appIcon];
2119

22-
self.appName = [[UILabel alloc] initWithFrame:CGRectMake(70, 0, screenWidth-70, 50)];
20+
self.appName = [[UILabel alloc] initWithFrame:CGRectMake(0,0,0,0)];
2321
self.appName.numberOfLines = 1;
2422
[self addSubview:self.appName];
25-
2623
}
2724
return self;
2825
}
2926

27+
- (void)layoutSubviews {
28+
[super layoutSubviews];
29+
int screenWidth = self.frame.size.width;
30+
self.appIcon.frame = CGRectMake(17.5, 7.5, 35, 35);
31+
self.appName.frame = CGRectMake(70, 0, screenWidth-70, 50);
32+
}
33+
3034
@end
3135

notiblockpref/NBPButtonTableViewCell.m

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,20 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
1414
{
1515
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
1616
if (self) {
17-
int screenWidth = [[UIScreen mainScreen] bounds].size.width;
18-
self.buttonTextLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 0, screenWidth, 50)];
17+
self.buttonTextLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
1918
self.buttonTextLabel.text = @"Select App To Filter...";
2019
[self.buttonTextLabel setTextColor:[UIColor colorWithRed:0.0 green:122.0/255.0 blue:1.0 alpha:1.0]];
2120
[self addSubview:self.buttonTextLabel];
2221
}
2322
return self;
2423
}
24+
25+
26+
- (void)layoutSubviews {
27+
[super layoutSubviews];
28+
int screenWidth = self.frame.size.width;
29+
self.buttonTextLabel.frame = CGRectMake(15, 0, screenWidth, 50);
30+
}
31+
32+
2533
@end

notiblockpref/NBPImageTableViewCell.m

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,24 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
1515
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
1616
if (self) {
1717
[self setSelectionStyle:UITableViewCellSelectionStyleNone];
18-
19-
int screenWidth = [[UIScreen mainScreen] bounds].size.width;
20-
self.cellImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, screenWidth, screenWidth * 0.27)];
21-
18+
self.cellImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
2219

2320
NSBundle *bundle = [[[NSBundle alloc] initWithPath:@"/Library/PreferenceBundles/NotiBlockPref.bundle"] autorelease];
2421
NSString *imagePath = [bundle pathForResource:@"example" ofType:@"png"];
2522
UIImage *myImage = [UIImage imageWithContentsOfFile:imagePath];
23+
self.cellImageView.contentMode = UIViewContentModeScaleAspectFit;
2624
self.cellImageView.image = myImage;
27-
28-
self.cellImageView.backgroundColor = [UIColor redColor];
2925
[self addSubview:self.cellImageView];
3026
}
3127
return self;
3228
}
3329

3430

31+
- (void)layoutSubviews {
32+
[super layoutSubviews];
33+
int screenWidth = self.frame.size.width;
34+
self.cellImageView.frame = CGRectMake(0, 0, screenWidth, screenWidth * 0.27);
35+
}
36+
37+
3538
@end

notiblockpref/NBPPickerTableViewCell.m

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,35 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
1515
{
1616
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
1717
if (self) {
18-
//self.options = [NSArray arrayWithObjects:@"If it starts with:",@"If it ends with:",@"If it contains the text:",@"if it is the exact text:",@"If it matches regex:",@"Always",nil];
19-
int vertHeight = 0;
20-
int screenWidth = [[UIScreen mainScreen] bounds].size.width;
21-
self.descriptionLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, vertHeight, 200, 50)];
22-
//self.descriptionLabel.text = @"Block the notification";
18+
self.descriptionLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
2319
[self addSubview:self.descriptionLabel];
2420

25-
self.selectedLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, vertHeight, screenWidth-15, 50)];
26-
//self.selectedLabel.text = (NSString *)self.options[0];
21+
self.selectedLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
2722
self.selectedLabel.textAlignment = NSTextAlignmentRight;
2823
[self addSubview:self.selectedLabel];
29-
vertHeight+=50;
3024

31-
self.picker = [[UIPickerView alloc] initWithFrame:CGRectMake((screenWidth - 225)/2, vertHeight, 225, 150)];
25+
self.picker = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
3226
self.picker.dataSource = self;
3327
self.picker.delegate = self;
3428
self.picker.hidden = NO;
3529
self.picker.tag = 1;
3630

3731
[self addSubview:self.picker];
38-
vertHeight += 150;
3932
}
4033
return self;
4134
}
4235

36+
- (void)layoutSubviews {
37+
[super layoutSubviews];
38+
int screenWidth = self.frame.size.width;
39+
int vertHeight = 0;
40+
self.descriptionLabel.frame = CGRectMake(15, vertHeight, 200, 50);
41+
self.selectedLabel.frame = CGRectMake(0, vertHeight, screenWidth-15, 50);
42+
vertHeight+=50;
43+
self.picker.frame = CGRectMake((screenWidth - 225)/2, vertHeight, 225, 150);
44+
}
45+
46+
4347
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
4448
{
4549
return (NSString *)self.options[row];

notiblockpref/NBPRootPreferenceController.m

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,6 @@
55
//its the whole root preference controller. need to rename
66
@implementation NBPRootPreferenceController
77

8-
// - (void)loadView {
9-
// [super loadView];
10-
// //self.title = @"New Notification Filter";
11-
12-
13-
// //UIBarButtonItem* doneBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(onTapDone:)];
14-
// //self.navigationController.navigationBar.topItem.rightBarButtonItem = doneBtn;
15-
16-
17-
// //CGRect(x,y,width,height)
18-
// }
19-
208
- (NSArray *)specifiers {
219
if (!_specifiers) {
2210
_specifiers = [[self loadSpecifiersFromPlistName:@"Root" target:self] retain];

notiblockpref/NBPSwitchTableViewCell.m

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,24 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
1616
if (self) {
1717
[self setSelectionStyle:UITableViewCellSelectionStyleNone];
1818

19-
int screenWidth = [[UIScreen mainScreen] bounds].size.width;
20-
21-
self.switchLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 0, 250, 50)];
22-
//self.switchLabel.text = @"Filter On Schedule";
19+
self.switchLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
2320
[self addSubview:self.switchLabel];
2421

25-
26-
self.cellSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(screenWidth-66, 9, 51, 31)];
22+
self.cellSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
2723
[self.cellSwitch setOn:NO animated:NO];
2824
[self addSubview:self.cellSwitch];
2925
}
3026
return self;
3127
}
3228

29+
- (void)layoutSubviews {
30+
[super layoutSubviews];
31+
int screenWidth = self.frame.size.width;
32+
self.switchLabel.frame = CGRectMake(15, 0, 250, 50);
33+
self.cellSwitch.frame = CGRectMake(screenWidth-66, 9, 51, 31);
34+
}
35+
36+
3337
- (void) setSwitchListener:(UIViewController *)viewController {
3438
[self.cellSwitch addTarget:viewController action:@selector(switchChanged:) forControlEvents:UIControlEventValueChanged];
3539
}

0 commit comments

Comments
 (0)