diff --git a/Makefile b/Makefile index 847d975..4c019aa 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ ARCHS = armv7 armv7s arm64 -TARGET = iphone:clang:7.1:7.0 +TARGET = iphone:clang:9.1:7.0 include theos/makefiles/common.mk diff --git a/Tweak.m b/Tweak.m index 12431fc..056c025 100644 --- a/Tweak.m +++ b/Tweak.m @@ -3,12 +3,23 @@ %hook PSListController NSArray *map; -NSInteger count; +NSInteger count, cellularSectionNumber; BOOL enabled = YES; +- (NSInteger)numberOfSectionsInTableView:(id)view { + NSInteger result = %orig; + if ([[self specifier].identifier isEqualToString:@"MOBILE_DATA_SETTINGS_ID"]) { + if (![self tableView:view titleForHeaderInSection:result - 2]) + cellularSectionNumber = result - 3; + else + cellularSectionNumber = result - 2; + } + return result; +} + - (NSInteger)tableView:(id)view numberOfRowsInSection:(NSInteger)section { - NSInteger result = %orig(view, section); - if ([[self specifier].identifier isEqualToString:@"MOBILE_DATA_SETTINGS_ID"] && section == [self numberOfSectionsInTableView:view] - 2) { + NSInteger result = %orig; + if ([[self specifier].identifier isEqualToString:@"MOBILE_DATA_SETTINGS_ID"] && section == cellularSectionNumber) { count = 0; if (result > 1) { NSInteger num; @@ -53,14 +64,14 @@ - (NSInteger)tableView:(id)view numberOfRowsInSection:(NSInteger)section { } - (id)tableView:(id)view cellForRowAtIndexPath:(NSIndexPath *)indexPath { - if (enabled && indexPath.row < count && [[self specifier].identifier isEqualToString:@"MOBILE_DATA_SETTINGS_ID"] && indexPath.section == [self numberOfSectionsInTableView:view] - 2) + if (enabled && indexPath.row < count && [[self specifier].identifier isEqualToString:@"MOBILE_DATA_SETTINGS_ID"] && indexPath.section == cellularSectionNumber) return %orig(view, [NSIndexPath indexPathForRow:((Entry *)map[indexPath.row]).index inSection:indexPath.section]); else - return %orig(view, indexPath); + return %orig; } - (void)tableView:(id)view didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - if ([[self specifier].identifier isEqualToString:@"MOBILE_DATA_SETTINGS_ID"] && indexPath.section == [self numberOfSectionsInTableView:view] - 3) { + if ([[self specifier].identifier isEqualToString:@"MOBILE_DATA_SETTINGS_ID"] && indexPath.section == cellularSectionNumber - 1) { enabled = !enabled; [view reloadData]; } diff --git a/control b/control index 4a07190..4d451f0 100644 --- a/control +++ b/control @@ -1,7 +1,7 @@ Package: com.ccdog.cellularusageorder Name: CellularUsageOrder Depends: firmware (>= 7.0), mobilesubstrate -Version: 1.1 +Version: 1.2 Architecture: iphoneos-arm Description: Order Cellular Data Usage by Size. Author: CC-Dog