This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
张国晔
committed
Apr 20, 2014
0 parents
commit 3359253
Showing
10 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.DS_Store | ||
*.deb | ||
obj/ | ||
_/ | ||
*theos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{ Filter = { Bundles = ( "com.apple.preferences-framework" ); }; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@interface Entry : NSObject | ||
@property(nonatomic) NSInteger index; | ||
@property(strong, nonatomic) NSNumber *data; | ||
- (id)initWithIndex:(NSInteger)index data:(NSNumber *)data; | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#import "Entry.h" | ||
|
||
@implementation Entry | ||
- (id)initWithIndex:(NSInteger)index data:(NSNumber *)data { | ||
self.index = index; | ||
self.data = data; | ||
return self; | ||
} | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Copyright (c) 2014, 张国晔 | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, | ||
are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above copyright notice, this | ||
list of conditions and the following disclaimer in the documentation and/or | ||
other materials provided with the distribution. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR | ||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
ARCHS = armv7 armv7s arm64 | ||
TARGET = iphone:clang:7.1:7.0 | ||
|
||
include theos/makefiles/common.mk | ||
|
||
TWEAK_NAME = CellularUsageOrder | ||
CellularUsageOrder_FILES = Tweak.x Entry.m | ||
|
||
include $(THEOS_MAKE_PATH)/tweak.mk | ||
ADDITIONAL_OBJCFLAGS = -fobjc-arc | ||
|
||
after-install:: | ||
install.exec "killall -9 Preferences" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#import "Entry.h" | ||
|
||
@interface PSSpecifier | ||
@property(strong, nonatomic) NSString *identifier; | ||
@end | ||
|
||
@interface PSListController | ||
- (PSSpecifier *)specifier; | ||
- (NSInteger)numberOfSectionsInTableView:(id)view; | ||
- (id)tableView:(id)view cellForRowAtIndexPath:(NSIndexPath *)indexPath; | ||
@end | ||
|
||
@interface PSSubtitleSwitchTableCell | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#import "Tweak.h" | ||
|
||
%hook PSListController | ||
|
||
NSArray *map; | ||
NSInteger count = 0; | ||
|
||
- (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) { | ||
count = 0; | ||
if (result > 1) { | ||
NSInteger num; | ||
if ([[self tableView:view cellForRowAtIndexPath:[NSIndexPath indexPathForRow:result - 2 inSection:section]] isKindOfClass:[%c(PSSubtitleSwitchTableCell) class]]) | ||
num = result - 1; | ||
else | ||
num = result - 2; | ||
NSMutableArray *data = [NSMutableArray arrayWithCapacity:num]; | ||
for (NSInteger i = 0; i < num; i++) { | ||
NSString *size = [[(UITableViewCell *)[self tableView:view cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:section]] detailTextLabel] text]; | ||
NSArray *parts = [size componentsSeparatedByString:@" "]; | ||
if ([parts count] == 2) | ||
[data addObject:[[Entry alloc] initWithIndex:i data:@([parts[0] floatValue] * [@{@"KB": @1, @"MB": @1000, @"GB": @1000000, @"TB": @1000000000}[parts[1]] intValue])]]; | ||
else | ||
[data addObject:[[Entry alloc] initWithIndex:i data:@0]]; | ||
} | ||
map = [data sortedArrayUsingComparator:^NSComparisonResult(Entry *a, Entry *b) { | ||
return [b.data compare: a.data]; | ||
}]; | ||
count = num; | ||
} | ||
} | ||
return result; | ||
} | ||
|
||
- (id)tableView:(id)view cellForRowAtIndexPath:(NSIndexPath *)indexPath { | ||
if (indexPath.row < count && [[self specifier].identifier isEqualToString:@"MOBILE_DATA_SETTINGS_ID"] && indexPath.section == [self numberOfSectionsInTableView:view] - 2) | ||
return %orig(view, [NSIndexPath indexPathForRow:((Entry *)map[indexPath.row]).index inSection:indexPath.section]); | ||
else | ||
return %orig(view, indexPath); | ||
} | ||
|
||
- (void)viewWillDisappear:(BOOL)animated { | ||
%orig(animated); | ||
map = nil; | ||
count = 0; | ||
} | ||
|
||
%end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Tweak.m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Package: com.ccdog.cellularusageorder | ||
Name: CellularUsageOrder | ||
Depends: firmware (>= 7.0), mobilesubstrate | ||
Version: 1.0 | ||
Architecture: iphoneos-arm | ||
Description: Order Cellular Data Usage by Size. | ||
Author: CC-Dog <[email protected]> | ||
Section: Tweaks |