Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @implementation GENSpecifiers
- - (void)organizeSpecifiers:(NSArray *)specifiers {
- if (hasRun) {
- return;
- } else {
- self.origSpecifiers = specifiers;
- self.allSpecifiers = specifiers;
- groupCell = [PSSpecifier preferenceSpecifierNamed:@"GENESIS_GROUP" target:NULL set:NULL get:NULL detail:NULL cell:PSGroupCell edit:nil];
- groupCell.name = @"";
- hasRun = YES;
- }
- }
- - (NSMutableArray *)mainSpecifiers {
- NSArray<PSSpecifier *> *origSpecifiers = self.allSpecifiers;
- NSMutableArray<PSSpecifier *> *mainSpecifiers = @[].mutableCopy;
- for (int i = 0; i < origSpecifiers.count; i++) {
- PSSpecifier *specifier = origSpecifiers[i];
- if (kGENGroupedSections) {
- if ([specifier.identifier isEqualToString:@"PRIMARY_APPLE_ACCOUNT_GROUP"]) {
- if (!kGENHideAccountCell) {
- [mainSpecifiers addObject:specifier];
- }
- } else if ([specifier.identifier isEqualToString:@"APPLE_ACCOUNT"]) {
- if (!kGENHideAccountCell) {
- [mainSpecifiers addObject:specifier];
- [mainSpecifiers addObject:groupCell];
- }
- PSSpecifier *tweakCell = [PSSpecifier preferenceSpecifierNamed:@"TWEAKS_CELL" target:NULL set:NULL get:NULL detail:%c(GENTweaksListController) cell:PSLinkCell edit:NULL];
- tweakCell.name = @"Tweaks";
- UIImage *tweakIcon = [UIImage imageWithContentsOfFile:@"/var/jb/Library/Tweak Support/Nebbs/Genesis 3/Images/tweaks.png"];
- [tweakCell setProperty:tweakIcon forKey:@"iconImage"];
- [mainSpecifiers addObject:tweakCell];
- PSSpecifier *systemCell = [PSSpecifier preferenceSpecifierNamed:@"SYSTEM_CELL" target:NULL set:NULL get:NULL detail:%c(GENSystemListController) cell:PSLinkCell edit:NULL];
- systemCell.name = @"System";
- UIImage *systemIcon = [UIImage imageWithContentsOfFile:@"/var/jb/Library/Tweak Support/Nebbs/Genesis 3/Images/system.png"];
- [systemCell setProperty:systemIcon forKey:@"iconImage"];
- [mainSpecifiers addObject:systemCell];
- } else {
- if ([specifier.identifier isEqualToString:@"AIRPLANE_MODE"]) {
- [mainSpecifiers addObject:groupCell];
- [mainSpecifiers addObject:specifier];
- } else if ([specifier.identifier isEqualToString:@"WIFI"]) {
- [mainSpecifiers addObject:specifier];
- } else if ([specifier.identifier isEqualToString:@"Bluetooth"]) {
- [mainSpecifiers addObject:specifier];
- } else if ([specifier.identifier isEqualToString:@"MOBILE_DATA_SETTINGS_ID"]) {
- [mainSpecifiers addObject:specifier];
- } else if ([specifier.identifier isEqualToString:@"NOTIFICATIONS_ID"]) {
- [mainSpecifiers addObject:groupCell];
- [mainSpecifiers addObject:specifier];
- } else if ([specifier.identifier isEqualToString:@"Sounds"]) {
- [mainSpecifiers addObject:specifier];
- } else if ([specifier.identifier isEqualToString:@"DO_NOT_DISTURB"]) {
- [mainSpecifiers addObject:specifier];
- } else if ([specifier.identifier isEqualToString:@"SCREEN_TIME"]) {
- [mainSpecifiers addObject:specifier];
- } else if ([specifier.identifier isEqualToString:@"General"]) {
- [mainSpecifiers addObject:groupCell];
- [mainSpecifiers addObject:specifier];
- } else if ([specifier.identifier isEqualToString:@"ControlCenter"]) {
- [mainSpecifiers addObject:specifier];
- } else if ([specifier.identifier isEqualToString:@"DISPLAY"]) {
- [mainSpecifiers addObject:specifier];
- } else if ([specifier.identifier isEqualToString:@"HOME_SCREEN"]) {
- [mainSpecifiers addObject:specifier];
- } else if ([specifier.identifier isEqualToString:@"ACCESSIBILITY"]) {
- [mainSpecifiers addObject:specifier];
- } else if ([specifier.identifier isEqualToString:@"Wallpaper"]) {
- [mainSpecifiers addObject:specifier];
- } else if ([specifier.identifier isEqualToString:@"SIRI"]) {
- [mainSpecifiers addObject:specifier];
- } else if ([specifier.identifier isEqualToString:@"PASSCODE"]) {
- [mainSpecifiers addObject:specifier];
- } else if ([specifier.identifier isEqualToString:@"EMERGENCY_SOS"]) {
- [mainSpecifiers addObject:specifier];
- } else if ([specifier.identifier isEqualToString:@"EXPOSURE_NOTIFICATION"]) {
- [mainSpecifiers addObject:specifier];
- } else if ([specifier.identifier isEqualToString:@"BATTERY_USAGE"]) {
- [mainSpecifiers addObject:specifier];
- } else if ([specifier.identifier isEqualToString:@"Privacy"]) {
- [mainSpecifiers addObject:specifier];
- }
- }
- } else {
- if (kGENHideAccountCell) {
- if ([specifier.identifier isEqualToString:@"PRIMARY_APPLE_ACCOUNT_GROUP"]) {
- // Do Nothing
- } else if ([specifier.identifier isEqualToString:@"APPLE_ACCOUNT"]) {
- // Do Nothing
- } else {
- [mainSpecifiers addObject:specifier];
- }
- } else {
- [mainSpecifiers addObject:specifier];
- }
- }
- }
- if (!kGENGroupedSections) {
- [mainSpecifiers addObject:groupCell];
- [mainSpecifiers addObjectsFromArray:[self tweakSpecifiers]];
- }
- return mainSpecifiers;
- }
- - (NSMutableArray *)tweakSpecifiers {
- NSMutableArray *tweakSpecifiers = [NSMutableArray new];
- NSString *iconName;
- NSString *iconPath;
- NSString *tweakName;
- NSString *bundleIdentifier;
- NSString *detailController;
- NSMutableArray *unsortedTweaksArray = (NSMutableArray *)[[NSFileManager defaultManager] contentsOfDirectoryAtPath:ROOT_PATH_NS(@"/Library/PreferenceBundles/") error:nil];
- NSMutableArray *unsortedPlistsArray = (NSMutableArray *)[[NSFileManager defaultManager] contentsOfDirectoryAtPath:ROOT_PATH_NS(@"/Library/PreferenceLoader/Preferences/") error:nil];
- NSString *libhbangprefs = @"libhbangprefs.bundle";
- NSString *cephei = @"Cephei.bundle";
- [unsortedTweaksArray removeObject:libhbangprefs];
- [unsortedTweaksArray removeObject:cephei];
- NSMutableArray *tweaksArray = (NSMutableArray *)[unsortedTweaksArray sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
- NSMutableArray *plistsArray = (NSMutableArray *)[unsortedPlistsArray sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
- if (tweaksArray.count > 0) {
- for (NSString *file in tweaksArray) {
- NSString *finalFile = [file stringByReplacingOccurrencesOfString:@".bundle" withString:@""];
- NSDictionary *farDictionary;
- for (NSString *plistFile in plistsArray) {
- if ([finalFile containsString:[plistFile stringByReplacingOccurrencesOfString:@".plist" withString:@""]]) {
- farDictionary = [NSDictionary dictionaryWithContentsOfFile:[NSString stringWithFormat:ROOT_PATH_NS(@"/Library/PreferenceLoader/Preferences/%@"), plistFile]];
- NSEnumerator *farEnumerator = [farDictionary objectEnumerator];
- id value;
- while (value = [farEnumerator nextObject]) {
- iconName = [value valueForKey:@"icon"];
- detailController = [value valueForKey:@"detail"];
- tweakName = [value valueForKey:@"label"];
- }
- if (iconName) {
- iconPath = [NSString stringWithFormat:ROOT_PATH_NS(@"/Library/PreferenceBundles/%@/%@"), file, iconName];
- }
- NSDictionary *mainDictionary = [NSDictionary dictionaryWithContentsOfFile:[NSString stringWithFormat:ROOT_PATH_NS(@"/Library/PreferenceBundles/%@/Info.plist"), file]];
- bundleIdentifier = [mainDictionary valueForKey:@"CFBundleIdentifier"];
- NSString *bundlePath = [NSString stringWithFormat:ROOT_PATH_NS(@"/Library/PreferenceBundles/%@"), file];
- NSBundle *bundle = [NSBundle bundleWithPath:bundlePath];
- [bundle load];
- if (detailController) {
- [tweakSpecifiers addObject:({
- PSSpecifier *specifier = [PSSpecifier preferenceSpecifierNamed:tweakName target:self set:NULL get:NULL detail:NSClassFromString(detailController) cell:PSLinkCell edit:nil];
- [specifier setProperty:@YES forKey:@"enabled"];
- [specifier setProperty:finalFile forKey:@"bundle"];
- [specifier setProperty:@"lazyLoadBundle:" forKey:@"loadAction"];
- [specifier setProperty:[UIImage imageWithContentsOfFile:@"/var/jb/Library/Tweak Support/Nebbs/Genesis 3/Images/tweaks.png"] forKey:@"iconImage"];
- if (iconName) {
- [specifier setProperty:[UIImage imageWithContentsOfFile:iconPath] forKey:@"iconImage"];
- }
- specifier;
- })];
- }
- }
- }
- }
- }
- return tweakSpecifiers;
- }
- - (NSMutableArray *)systemSpecifiers {
- NSArray<PSSpecifier *> *origSpecifiers = self.allSpecifiers;
- NSMutableArray<PSSpecifier *> *systemSpecifiers = @[].mutableCopy;
- PSSpecifier *storeCell;
- PSSpecifier *passwordsCell;
- PSSpecifier *walletCell;
- PSSpecifier *booksCell;
- PSSpecifier *calendarCell;
- PSSpecifier *compassCell;
- PSSpecifier *contactsCell;
- PSSpecifier *facetimeCell;
- PSSpecifier *gamecenterCell;
- PSSpecifier *healthCell;
- PSSpecifier *mailCell;
- PSSpecifier *mapsCell;
- PSSpecifier *measureCell;
- PSSpecifier *messagesCell;
- PSSpecifier *newsCell;
- PSSpecifier *notesCell;
- PSSpecifier *phoneCell;
- PSSpecifier *remindersCell;
- PSSpecifier *safariCell;
- PSSpecifier *shortcutsCell;
- PSSpecifier *stocksCell;
- PSSpecifier *translateCell;
- PSSpecifier *memosCell;
- PSSpecifier *cameraCell;
- PSSpecifier *musicCell;
- PSSpecifier *photosCell;
- PSSpecifier *tvCell;
- PSSpecifier *providerCell;
- for (int i = 0; i < origSpecifiers.count; i++) {
- PSSpecifier *specifier = origSpecifiers[i];
- if ([specifier.identifier isEqualToString:@"STORE"]) {
- storeCell = specifier;
- } else if ([specifier.identifier isEqualToString:@"PASSWORDS"]) {
- passwordsCell = specifier;
- } else if ([specifier.identifier isEqualToString:@"PASSBOOK"]) {
- passwordsCell = specifier;
- } else if ([specifier.identifier isEqualToString:@"IBOOKS"]) {
- booksCell = specifier;
- } else if ([specifier.identifier isEqualToString:@"CALENDAR"]) {
- calendarCell = specifier;
- } else if ([specifier.identifier isEqualToString:@"COMPASS"]) {
- compassCell = specifier;
- } else if ([specifier.identifier isEqualToString:@"CONTACTS"]) {
- contactsCell = specifier;
- } else if ([specifier.identifier isEqualToString:@"FACETIME"]) {
- facetimeCell = specifier;
- } else if ([specifier.identifier isEqualToString:@"GAMECENTER"]) {
- gamecenterCell = specifier;
- } else if ([specifier.identifier isEqualToString:@"HEALTH"]) {
- healthCell = specifier;
- } else if ([specifier.identifier isEqualToString:@"MAIL"]) {
- mailCell = specifier;
- } else if ([specifier.identifier isEqualToString:@"MAPS"]) {
- mapsCell = specifier;
- } else if ([specifier.identifier isEqualToString:@"MEASURE"]) {
- measureCell = specifier;
- } else if ([specifier.identifier isEqualToString:@"MESSAGES"]) {
- messagesCell = specifier;
- } else if ([specifier.identifier isEqualToString:@"NEWS"]) {
- newsCell = specifier;
- } else if ([specifier.identifier isEqualToString:@"NOTES"]) {
- notesCell = specifier;
- } else if ([specifier.identifier isEqualToString:@"Phone"]) {
- phoneCell = specifier;
- } else if ([specifier.identifier isEqualToString:@"REMINDERS"]) {
- remindersCell = specifier;
- } else if ([specifier.identifier isEqualToString:@"SAFARI"]) {
- safariCell = specifier;
- } else if ([specifier.identifier isEqualToString:@"SHORTCUTS"]) {
- shortcutsCell = specifier;
- } else if ([specifier.identifier isEqualToString:@"STOCKS"]) {
- stocksCell = specifier;
- } else if ([specifier.identifier isEqualToString:@"TRANSLATE"]) {
- translateCell = specifier;
- } else if ([specifier.identifier isEqualToString:@"VOICE_MEMOS"]) {
- memosCell = specifier;
- } else if ([specifier.identifier isEqualToString:@"CAMERA"]) {
- cameraCell = specifier;
- } else if ([specifier.identifier isEqualToString:@"MUSIC"]) {
- musicCell = specifier;
- } else if ([specifier.identifier isEqualToString:@"Photos"]) {
- photosCell = specifier;
- } else if ([specifier.identifier isEqualToString:@"TVAPP"]) {
- tvCell = specifier;
- } else if ([specifier.identifier isEqualToString:@"VIDEO_SUBSCRIBER"]) {
- providerCell = specifier;
- }
- }
- [systemSpecifiers addObject:groupCell];
- if (storeCell != nil) {
- [systemSpecifiers addObject:storeCell];
- }
- if (passwordsCell != nil) {
- [systemSpecifiers addObject:passwordsCell];
- }
- if (walletCell != nil) {
- [systemSpecifiers addObject:walletCell];
- }
- [systemSpecifiers addObject:groupCell];
- if (booksCell != nil) {
- [systemSpecifiers addObject:booksCell];
- }
- if (calendarCell != nil) {
- [systemSpecifiers addObject:calendarCell];
- }
- if (compassCell != nil) {
- [systemSpecifiers addObject:compassCell];
- }
- if (contactsCell != nil) {
- [systemSpecifiers addObject:contactsCell];
- }
- if (facetimeCell != nil) {
- [systemSpecifiers addObject:facetimeCell];
- }
- if (gamecenterCell != nil) {
- [systemSpecifiers addObject:gamecenterCell];
- }
- if (healthCell != nil) {
- [systemSpecifiers addObject:healthCell];
- }
- if (mailCell != nil) {
- [systemSpecifiers addObject:mailCell];
- }
- if (mapsCell != nil) {
- [systemSpecifiers addObject:mapsCell];
- }
- if (measureCell != nil) {
- [systemSpecifiers addObject:measureCell];
- }
- if (messagesCell != nil) {
- [systemSpecifiers addObject:messagesCell];
- }
- if (newsCell != nil) {
- [systemSpecifiers addObject:newsCell];
- }
- if (notesCell != nil) {
- [systemSpecifiers addObject:notesCell];
- }
- if (phoneCell != nil) {
- [systemSpecifiers addObject:phoneCell];
- }
- if (remindersCell != nil) {
- [systemSpecifiers addObject:remindersCell];
- }
- if (safariCell != nil) {
- [systemSpecifiers addObject:safariCell];
- }
- if (shortcutsCell != nil) {
- [systemSpecifiers addObject:shortcutsCell];
- }
- if (stocksCell != nil) {
- [systemSpecifiers addObject:stocksCell];
- }
- if (translateCell != nil) {
- [systemSpecifiers addObject:translateCell];
- }
- if (memosCell != nil) {
- [systemSpecifiers addObject:memosCell];
- }
- [systemSpecifiers addObject:groupCell];
- if (cameraCell != nil) {
- [systemSpecifiers addObject:cameraCell];
- }
- if (musicCell != nil) {
- [systemSpecifiers addObject:musicCell];
- }
- if (photosCell != nil) {
- [systemSpecifiers addObject:photosCell];
- }
- if (tvCell != nil) {
- [systemSpecifiers addObject:tvCell];
- }
- if (providerCell != nil) {
- [systemSpecifiers addObject:providerCell];
- }
- return systemSpecifiers;
- }
- @end
- static GENSpecifiers *GENSpecs = [GENSpecifiers new];
- @implementation GENTweaksListController
- - (NSArray *)specifiers {
- if (!_specifiers) {
- _specifiers = [GENSpecs tweakSpecifiers];
- }
- return _specifiers;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self reloadSpecifiers];
- }
- - (NSString *)title {
- return @"Tweaks";
- }
- @end
- @implementation GENSystemListController
- - (NSArray *)specifiers {
- if (!_specifiers) {
- _specifiers = [GENSpecs systemSpecifiers];
- }
- return _specifiers;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self reloadSpecifiers];
- }
- - (NSString *)title {
- return @"System";
- }
- @end
- %hook PSUIPrefsListController
- - (NSMutableArray<PSSpecifier *> *)specifiers {
- NSArray<PSSpecifier *> *origSpecifiers = %orig;
- if (kGENGroupedSections || kGENHideAccountCell) {
- [GENSpecs organizeSpecifiers:origSpecifiers];
- NSMutableArray<PSSpecifier *> *specifiers = [GENSpecs mainSpecifiers];
- static dispatch_once_t onceToken;
- dispatch_once(&onceToken, ^{
- MSHookIvar<id>(self, "_specifiers") = specifiers;
- NSMutableDictionary *dict = @{}.mutableCopy;
- for (PSSpecifier *specifier in specifiers) {
- if (specifier.identifier) {
- dict[specifier.identifier] = specifier;
- }
- }
- MSHookIvar<id>(self, "_specifiersByID") = dict;
- });
- return specifiers;
- } else {
- return %orig;
- }
- }
- - (BOOL)_exposureNotificationAvailable {
- if (kGENGroupedSections) {
- return NO;
- } else {
- return %orig;
- }
- }
- - (void)insertSpecifier:(PSSpecifier *)specifier atIndex:(NSInteger)index animated:(BOOL)animated {
- if (kGENGroupedSections) {
- if ([specifier.identifier isEqualToString:@"VPN"]) {
- %orig;
- } else if ([specifier.identifier isEqualToString:@"EMERGENCY_SOS"]) {
- // Do Nothing
- } else if ([specifier.identifier isEqualToString:@"PASSBOOK"]) {
- // Do Nothing
- } else if ([specifier.identifier isEqualToString:@"HOMEKIT"]) {
- // Do Nothing
- } else if ([specifier.identifier isEqualToString:@"com.apple.podcasts"]) {
- // Do Nothing
- } else if ([specifier.identifier isEqualToString:@"VIDEO_SUBSCRIBER"]) {
- // Do Nothing
- }
- } else {
- %orig;
- }
- }
- - (void)reloadSpecifiers {
- if (!kGENHideAccountCell) {
- %orig;
- }
- }
- %end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement