|
3 | 3 | %hook PSListController
|
4 | 4 |
|
5 | 5 | NSArray *map;
|
6 |
| -NSInteger count; |
| 6 | +NSInteger count, cellularSectionNumber; |
7 | 7 | BOOL enabled = YES;
|
8 | 8 |
|
| 9 | +- (NSInteger)numberOfSectionsInTableView:(id)view { |
| 10 | + NSInteger result = %orig; |
| 11 | + if ([[self specifier].identifier isEqualToString:@"MOBILE_DATA_SETTINGS_ID"]) { |
| 12 | + if (![self tableView:view titleForHeaderInSection:result - 2]) |
| 13 | + cellularSectionNumber = result - 3; |
| 14 | + else |
| 15 | + cellularSectionNumber = result - 2; |
| 16 | + } |
| 17 | + return result; |
| 18 | +} |
| 19 | + |
9 | 20 | - (NSInteger)tableView:(id)view numberOfRowsInSection:(NSInteger)section {
|
10 |
| - NSInteger result = %orig(view, section); |
11 |
| - if ([[self specifier].identifier isEqualToString:@"MOBILE_DATA_SETTINGS_ID"] && section == [self numberOfSectionsInTableView:view] - 2) { |
| 21 | + NSInteger result = %orig; |
| 22 | + if ([[self specifier].identifier isEqualToString:@"MOBILE_DATA_SETTINGS_ID"] && section == cellularSectionNumber) { |
12 | 23 | count = 0;
|
13 | 24 | if (result > 1) {
|
14 | 25 | NSInteger num;
|
@@ -53,14 +64,14 @@ - (NSInteger)tableView:(id)view numberOfRowsInSection:(NSInteger)section {
|
53 | 64 | }
|
54 | 65 |
|
55 | 66 | - (id)tableView:(id)view cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
56 |
| - if (enabled && indexPath.row < count && [[self specifier].identifier isEqualToString:@"MOBILE_DATA_SETTINGS_ID"] && indexPath.section == [self numberOfSectionsInTableView:view] - 2) |
| 67 | + if (enabled && indexPath.row < count && [[self specifier].identifier isEqualToString:@"MOBILE_DATA_SETTINGS_ID"] && indexPath.section == cellularSectionNumber) |
57 | 68 | return %orig(view, [NSIndexPath indexPathForRow:((Entry *)map[indexPath.row]).index inSection:indexPath.section]);
|
58 | 69 | else
|
59 |
| - return %orig(view, indexPath); |
| 70 | + return %orig; |
60 | 71 | }
|
61 | 72 |
|
62 | 73 | - (void)tableView:(id)view didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
63 |
| - if ([[self specifier].identifier isEqualToString:@"MOBILE_DATA_SETTINGS_ID"] && indexPath.section == [self numberOfSectionsInTableView:view] - 3) { |
| 74 | + if ([[self specifier].identifier isEqualToString:@"MOBILE_DATA_SETTINGS_ID"] && indexPath.section == cellularSectionNumber - 1) { |
64 | 75 | enabled = !enabled;
|
65 | 76 | [view reloadData];
|
66 | 77 | }
|
|
0 commit comments