Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %hook SBUIAppIconForceTouchControllerDataProvider
- //Array containing all force touch items
- -(NSArray *)applicationShortcutItems {
- if (!forceTouchOptionEnabled) return %orig;
- NSString *bundleIdentifier = [self applicationBundleIdentifier];
- if (!bundleIdentifier) return %orig;
- //Create a mutable (editable) version of the original array
- NSMutableArray *orig = [%orig mutableCopy];
- //If there is no original array, create a new one
- if (!orig) orig = [NSMutableArray new];
- //Create the new force touch item and set title / subtitle
- SBSApplicationShortcutItem *item = [[%c(SBSApplicationShortcutItem) alloc] init];
- item.localizedTitle = @"UnSub";
- item.localizedSubtitle = @"Disable tweaks";
- //Change subtitle if unsub is already enabled for the app
- for (NSString *bundleId in disabledApps) {
- if ([bundleIdentifier isEqualToString: bundleId]) {
- item.localizedSubtitle = @"Tweaks already disabled";
- break;
- }
- }
- //Set the app for the shortcut to launch and add a type for identification later, then add the new item to the array
- item.bundleIdentifierToLaunch = bundleIdentifier;
- item.type = @"UnSubItem";
- [orig addObject:item];
- return orig;
- }
- %end
- %hook SBUIAppIconForceTouchController
- -(void)appIconForceTouchShortcutViewController:(id)arg1 activateApplicationShortcutItem:(SBSApplicationShortcutItem *)item {
- if (!forceTouchOptionEnabled) return %orig;
- //If identified as unsub item type from earlier, do the custom action. If the action is inside of the app, you should use a message server to interact with it
- if ([[item type] isEqualToString:@"UnSubItem"]) {
- NSString *bundleId = [item bundleIdentifierToLaunch];
- forceTouchBundleId = [bundleId copy];
- twice = NO;
- BKSTerminateApplicationForReasonAndReportWithDescription(bundleId, 5, false, @"UnSub - force touch, killed");
- }
- %orig;
- }
- %end
- %hook SBUIAction
- -(id)initWithTitle:(id)title subtitle:(id)arg2 image:(id)image badgeView:(id)arg4 handler:(/*^block*/id)arg5 {
- //Set custom icon
- if ([title isEqualToString:@"UnSub"]) {
- image = [[UIImage imageWithContentsOfFile:@"/Library/PreferenceBundles/UnSubPrefs.bundle/forcetouch.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
- }
- return %orig;
- }
- %end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement