├── .gitignore ├── MakePackageInstall ├── Makefile ├── PreferenceBundles └── cocoPB.bundle │ ├── Info.plist │ ├── cocoPB │ ├── en.lproj │ └── Localizable.strings │ ├── icon.png │ ├── icon@2x.png │ └── zh_CN.lproj │ └── Localizable.strings ├── PreferenceLoader └── Preferences │ └── cocoPB.plist ├── Tweak.xm ├── coco.h ├── coco.plist ├── cocopb ├── CCPBRootListController.h ├── CCPBRootListController.mm ├── MakePackage ├── Makefile ├── PSViewController.h ├── Resources │ ├── Info.plist │ ├── en.lproj │ │ └── Localizable.strings │ ├── icon.png │ ├── icon@2x.png │ └── zh_CN.lproj │ │ └── Localizable.strings ├── control └── entry.plist └── control /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .theos 3 | -------------------------------------------------------------------------------- /MakePackageInstall: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd `dirname $0` 3 | make clean 4 | make package install debug=0 5 | rm ./packages/*.deb 6 | exit 0 7 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | export THEOS_DEVICE_IP = localhost 2 | export THEOS_DEVICE_PORT = 2222 3 | export ARCHS = armv7 arm64 4 | export TARGET = iphone:clang:latest:9.0 5 | 6 | include $(THEOS)/makefiles/common.mk 7 | 8 | TWEAK_NAME = coco 9 | coco_FILES = Tweak.xm 10 | coco_LIBRARIES = applist 11 | coco_CFLAGS = -fobjc-arc 12 | 13 | include $(THEOS_MAKE_PATH)/tweak.mk 14 | 15 | internal-stage:: 16 | $(ECHO_NOTHING)cp -r PreferenceBundles $(THEOS_STAGING_DIR)/Library$(ECHO_END) 17 | $(ECHO_NOTHING)cp -r PreferenceLoader $(THEOS_STAGING_DIR)/Library$(ECHO_END) 18 | 19 | after-install:: 20 | install.exec "killall -9 SpringBoard" 21 | -------------------------------------------------------------------------------- /PreferenceBundles/cocoPB.bundle/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | cocoPB 9 | CFBundleIdentifier 10 | com.naken.cocopb 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1.0 21 | NSPrincipalClass 22 | CCPBRootListController 23 | 24 | 25 | -------------------------------------------------------------------------------- /PreferenceBundles/cocoPB.bundle/cocoPB: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iosre/coco/3afcc7cd2bad0210f2efef15a360ecc6f4e35cab/PreferenceBundles/cocoPB.bundle/cocoPB -------------------------------------------------------------------------------- /PreferenceBundles/cocoPB.bundle/en.lproj/Localizable.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iosre/coco/3afcc7cd2bad0210f2efef15a360ecc6f4e35cab/PreferenceBundles/cocoPB.bundle/en.lproj/Localizable.strings -------------------------------------------------------------------------------- /PreferenceBundles/cocoPB.bundle/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iosre/coco/3afcc7cd2bad0210f2efef15a360ecc6f4e35cab/PreferenceBundles/cocoPB.bundle/icon.png -------------------------------------------------------------------------------- /PreferenceBundles/cocoPB.bundle/icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iosre/coco/3afcc7cd2bad0210f2efef15a360ecc6f4e35cab/PreferenceBundles/cocoPB.bundle/icon@2x.png -------------------------------------------------------------------------------- /PreferenceBundles/cocoPB.bundle/zh_CN.lproj/Localizable.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iosre/coco/3afcc7cd2bad0210f2efef15a360ecc6f4e35cab/PreferenceBundles/cocoPB.bundle/zh_CN.lproj/Localizable.strings -------------------------------------------------------------------------------- /PreferenceLoader/Preferences/cocoPB.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | entry 6 | 7 | bundle 8 | cocoPB 9 | cell 10 | PSLinkCell 11 | detail 12 | CCPBRootListController 13 | icon 14 | icon.png 15 | isController 16 | 17 | label 18 | coco 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /Tweak.xm: -------------------------------------------------------------------------------- 1 | #import "coco.h" 2 | 3 | #ifndef kCFCoreFoundationVersionNumber_iOS_10_0 4 | #define kCFCoreFoundationVersionNumber_iOS_10_0 1300.0 5 | #endif 6 | 7 | #ifndef kCFCoreFoundationVersionNumber_iOS_9_0 8 | #define kCFCoreFoundationVersionNumber_iOS_9_0 1240.10 9 | #endif 10 | 11 | static NSDictionary *settings; 12 | 13 | static void LoadSettings(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) 14 | { 15 | settings = [[NSDictionary alloc] initWithContentsOfFile:@"/var/mobile/Library/Preferences/com.naken.coco.plist"]; 16 | } 17 | 18 | %hook BBBulletin 19 | 20 | - (BOOL)bulletinAlertShouldOverrideQuietMode 21 | { 22 | if (((NSNumber *)settings[self.section]).boolValue) return YES; 23 | return %orig; 24 | } 25 | 26 | %end 27 | 28 | %ctor 29 | { 30 | if (kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_9_0 && kCFCoreFoundationVersionNumber < kCFCoreFoundationVersionNumber_iOS_10_0) 31 | { 32 | %init; 33 | CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, LoadSettings, CFSTR("com.naken.coco.loadsettings"), NULL, CFNotificationSuspensionBehaviorCoalesce); 34 | LoadSettings(NULL, NULL, NULL, NULL, NULL); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /coco.h: -------------------------------------------------------------------------------- 1 | @interface BBBulletin : NSObject 2 | @property (copy, nonatomic) NSString *section; 3 | @end 4 | -------------------------------------------------------------------------------- /coco.plist: -------------------------------------------------------------------------------- 1 | { Filter = { Bundles = ( "com.apple.springboard" ); }; } 2 | -------------------------------------------------------------------------------- /cocopb/CCPBRootListController.h: -------------------------------------------------------------------------------- 1 | #import "PSViewController.h" 2 | 3 | @interface CCPBRootListController: PSViewController 4 | { 5 | UITableView *mainView; 6 | } 7 | @property (nonatomic, retain) NSMutableArray *allAppInfo; 8 | - (void)initSettings; 9 | - (void)initAllAppInfo; 10 | - (void)saveConfig:(UISwitch *)appSwitch; 11 | @end 12 | -------------------------------------------------------------------------------- /cocopb/CCPBRootListController.mm: -------------------------------------------------------------------------------- 1 | #import "CCPBRootListController.h" 2 | #import 3 | #import 4 | 5 | #define SETTINGS @"/var/mobile/Library/Preferences/com.naken.coco.plist" 6 | #define BUNDLE [NSBundle bundleWithPath:@"/Library/PreferenceBundles/cocoPB.bundle"] 7 | #define BLACKLIST @[@"com.apple.Diagnostics.Mitosis", @"com.apple.Diagnostics", @"com.apple.managedconfiguration.MDMRemoteAlertService", @"com.apple.SafariViewService", @"com.apple.CloudKit.ShareBear", @"com.apple.social.SLGoogleAuth", @"com.apple.social.SLYahooAuth", @"com.apple.StoreDemoViewService", @"com.apple.Home.HomeUIService", @"com.apple.ServerDocuments", @"com.apple.Fitness", @"com.apple.appleseed.FeedbackAssistant"] 8 | 9 | @implementation CCPBRootListController 10 | 11 | @synthesize allAppInfo; 12 | 13 | - (instancetype)init 14 | { 15 | if ( (self = [super init]) ) 16 | { 17 | self.title = @"coco"; 18 | mainView = [[UITableView alloc] initWithFrame:[UIScreen mainScreen].bounds style:UITableViewStyleGrouped]; 19 | mainView.delegate = self; 20 | mainView.dataSource = self; 21 | self.view = mainView; 22 | 23 | [self initAllAppInfo]; 24 | [self initSettings]; 25 | } 26 | return self; 27 | } 28 | 29 | - (void)viewDidLoad 30 | { 31 | [super viewDidLoad]; 32 | if ([UIViewController instancesRespondToSelector:@selector(edgesForExtendedLayout)]) self.edgesForExtendedLayout = UIRectEdgeNone; 33 | } 34 | 35 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 36 | { 37 | return 1; 38 | } 39 | 40 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 41 | { 42 | return [self.allAppInfo count]; 43 | } 44 | 45 | - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section 46 | { 47 | return NSLocalizedStringFromTableInBundle(@"Toggle to Disturb", @"Localizable", BUNDLE, nil); 48 | } 49 | 50 | - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section 51 | { 52 | return NSLocalizedStringFromTableInBundle(@"By snakeninny", @"Localizable", BUNDLE, nil); 53 | } 54 | 55 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 56 | { 57 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"any-cell"]; 58 | if (cell == nil) cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"any-cell"]; 59 | 60 | cell.selectionStyle = UITableViewCellSelectionStyleNone; 61 | NSString *appIdentifier = ((NSDictionary *)(self.allAppInfo[indexPath.row])).allKeys[0]; 62 | NSString *appName = ((NSDictionary *)(self.allAppInfo[indexPath.row])).allValues[0]; 63 | cell.imageView.image = [[ALApplicationList sharedApplicationList] iconOfSize:ALApplicationIconSizeSmall forDisplayIdentifier:appIdentifier]; 64 | cell.textLabel.text = appName; 65 | NSMutableDictionary *settings = [[NSMutableDictionary alloc] initWithContentsOfFile:SETTINGS]; 66 | UISwitch *appSwitch = [[UISwitch alloc] initWithFrame:CGRectZero]; 67 | appSwitch.tag = indexPath.row + 1; 68 | appSwitch.on = ((NSNumber *)settings[appIdentifier]).boolValue; 69 | [appSwitch addTarget:self action:@selector(saveConfig:) forControlEvents:UIControlEventValueChanged]; 70 | cell.accessoryView = appSwitch; 71 | 72 | return cell; 73 | } 74 | 75 | - (void)initSettings 76 | { 77 | NSFileManager *fileManager = [NSFileManager defaultManager]; 78 | NSMutableDictionary *settings; 79 | if ([fileManager fileExistsAtPath:SETTINGS]) 80 | { 81 | settings = [[NSMutableDictionary alloc] initWithContentsOfFile:SETTINGS]; 82 | for (NSDictionary *applicationInfo in self.allAppInfo) 83 | { 84 | NSString *appIdentifier = applicationInfo.allKeys[0]; 85 | if (settings[appIdentifier] == nil) settings[appIdentifier] = @NO; 86 | } 87 | } 88 | else 89 | { 90 | settings = [@{} mutableCopy]; 91 | for (NSDictionary *applicationInfo in self.allAppInfo) settings[applicationInfo.allKeys[0]] = @NO; 92 | } 93 | [settings writeToFile:SETTINGS atomically:YES]; 94 | 95 | notify_post("com.naken.coco.loadsettings"); 96 | } 97 | 98 | - (void)initAllAppInfo 99 | { 100 | allAppInfo = [@[] mutableCopy]; 101 | NSArray *sortedDisplayIdentifiers; 102 | ALApplicationList *applicationList = [ALApplicationList sharedApplicationList]; 103 | NSDictionary *applications = [applicationList applicationsFilteredUsingPredicate:nil onlyVisible:YES titleSortedIdentifiers:&sortedDisplayIdentifiers]; 104 | for (NSString *displayIdentifier in sortedDisplayIdentifiers) 105 | { 106 | if (![applicationList applicationWithDisplayIdentifierIsHidden:displayIdentifier] && ![BLACKLIST containsObject:displayIdentifier]) 107 | { 108 | NSString *appName = applications[displayIdentifier]; 109 | [allAppInfo addObject:@{displayIdentifier : appName}]; 110 | } 111 | } 112 | } 113 | 114 | - (void)saveConfig:(UISwitch *)appSwitch 115 | { 116 | NSInteger row = appSwitch.tag - 1; 117 | NSMutableDictionary *settings = [[NSMutableDictionary alloc] initWithContentsOfFile:SETTINGS]; 118 | settings[((NSDictionary *)(self.allAppInfo[row])).allKeys[0]] = [NSNumber numberWithBool:appSwitch.on]; 119 | [settings writeToFile:SETTINGS atomically:YES]; 120 | 121 | notify_post("com.naken.coco.loadsettings"); 122 | } 123 | 124 | @end 125 | -------------------------------------------------------------------------------- /cocopb/MakePackage: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd `dirname $0` 3 | rm ./packages/*.deb 4 | make clean 5 | make package debug=0 6 | exit 0 7 | -------------------------------------------------------------------------------- /cocopb/Makefile: -------------------------------------------------------------------------------- 1 | export THEOS_DEVICE_IP = localhost 2 | export THEOS_DEVICE_PORT = 2222 3 | export ARCHS = armv7 arm64 4 | export TARGET = iphone:clang:10.1:9.0 5 | 6 | include $(THEOS)/makefiles/common.mk 7 | 8 | BUNDLE_NAME = cocoPB 9 | cocoPB_FILES = CCPBRootListController.mm 10 | cocoPB_FRAMEWORKS = UIKit 11 | cocoPB_PRIVATE_FRAMEWORKS = Preferences 12 | cocoPB_INSTALL_PATH = /Library/PreferenceBundles 13 | cocoPB_LIBRARIES = applist 14 | cocoPB_CFLAGS = -fobjc-arc 15 | 16 | include $(THEOS_MAKE_PATH)/bundle.mk 17 | 18 | internal-stage:: 19 | $(ECHO_NOTHING)mkdir -p $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences$(ECHO_END) 20 | $(ECHO_NOTHING)cp entry.plist $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences/cocoPB.plist$(ECHO_END) 21 | -------------------------------------------------------------------------------- /cocopb/PSViewController.h: -------------------------------------------------------------------------------- 1 | @interface PSViewController : UITableViewController 2 | @end 3 | -------------------------------------------------------------------------------- /cocopb/Resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | cocoPB 9 | CFBundleIdentifier 10 | com.naken.cocopb 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1.0 21 | NSPrincipalClass 22 | CCPBRootListController 23 | 24 | 25 | -------------------------------------------------------------------------------- /cocopb/Resources/en.lproj/Localizable.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iosre/coco/3afcc7cd2bad0210f2efef15a360ecc6f4e35cab/cocopb/Resources/en.lproj/Localizable.strings -------------------------------------------------------------------------------- /cocopb/Resources/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iosre/coco/3afcc7cd2bad0210f2efef15a360ecc6f4e35cab/cocopb/Resources/icon.png -------------------------------------------------------------------------------- /cocopb/Resources/icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iosre/coco/3afcc7cd2bad0210f2efef15a360ecc6f4e35cab/cocopb/Resources/icon@2x.png -------------------------------------------------------------------------------- /cocopb/Resources/zh_CN.lproj/Localizable.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iosre/coco/3afcc7cd2bad0210f2efef15a360ecc6f4e35cab/cocopb/Resources/zh_CN.lproj/Localizable.strings -------------------------------------------------------------------------------- /cocopb/control: -------------------------------------------------------------------------------- 1 | Package: com.naken.coco 2 | Name: coco 3 | Depends: mobilesubstrate, preferenceloader, firmware (>= 9.0) 4 | Version: 1.0 5 | Architecture: iphoneos-arm 6 | Description: coco 7 | Maintainer: snakeninny@gmail.com 8 | Author: snakeninny 9 | dev: snakeninny 10 | -------------------------------------------------------------------------------- /cocopb/entry.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | entry 6 | 7 | bundle 8 | cocoPB 9 | cell 10 | PSLinkCell 11 | detail 12 | CCPBRootListController 13 | icon 14 | icon.png 15 | isController 16 | 17 | label 18 | coco 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /control: -------------------------------------------------------------------------------- 1 | Package: com.naken.coco 2 | Name: coco 3 | Depends: mobilesubstrate, com.rpetrich.rocketbootstrap, firmware (>= 9.0), applist 4 | Version: 1.0 5 | Architecture: iphoneos-arm 6 | Description: Make Do Not Disturb customizable for 3rd party Apps 7 | Maintainer: snakeninny 8 | Author: snakeninny 9 | Section: Tweaks 10 | Homepage: http://iosre.com 11 | --------------------------------------------------------------------------------