Advertisement
Guest User

Untitled

a guest
Jul 10th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. %hook SBUIAppIconForceTouchControllerDataProvider
  2.  
  3. //Array containing all force touch items
  4. -(NSArray *)applicationShortcutItems {
  5.     if (!forceTouchOptionEnabled) return %orig;
  6.     NSString *bundleIdentifier = [self applicationBundleIdentifier];
  7.     if (!bundleIdentifier) return %orig;
  8.     //Create a mutable (editable) version of the original array
  9.     NSMutableArray *orig = [%orig mutableCopy];
  10.     //If there is no original array, create a new one
  11.     if (!orig) orig = [NSMutableArray new];
  12.  
  13.     //Create the new force touch item and set title / subtitle
  14.     SBSApplicationShortcutItem *item = [[%c(SBSApplicationShortcutItem) alloc] init];
  15.     item.localizedTitle = @"UnSub";
  16.     item.localizedSubtitle = @"Disable tweaks";
  17.     //Change subtitle if unsub is already enabled for the app
  18.     for (NSString *bundleId in disabledApps) {
  19.         if ([bundleIdentifier isEqualToString: bundleId]) {
  20.             item.localizedSubtitle = @"Tweaks already disabled";
  21.             break;
  22.         }
  23.     }
  24.     //Set the app for the shortcut to launch and add a type for identification later, then add the new item to the array
  25.     item.bundleIdentifierToLaunch = bundleIdentifier;
  26.     item.type = @"UnSubItem";
  27.     [orig addObject:item];
  28.     return orig;
  29. }
  30.  
  31. %end
  32.  
  33. %hook SBUIAppIconForceTouchController
  34. -(void)appIconForceTouchShortcutViewController:(id)arg1 activateApplicationShortcutItem:(SBSApplicationShortcutItem *)item {
  35.     if (!forceTouchOptionEnabled) return %orig;
  36.     //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
  37.     if ([[item type] isEqualToString:@"UnSubItem"]) {
  38.         NSString *bundleId = [item bundleIdentifierToLaunch];
  39.         forceTouchBundleId = [bundleId copy];
  40.         twice = NO;
  41.         BKSTerminateApplicationForReasonAndReportWithDescription(bundleId, 5, false, @"UnSub - force touch, killed");
  42.     }
  43.  
  44.     %orig;
  45. }
  46.  
  47. %end
  48.  
  49. %hook SBUIAction
  50.  
  51. -(id)initWithTitle:(id)title subtitle:(id)arg2 image:(id)image badgeView:(id)arg4 handler:(/*^block*/id)arg5 {
  52.     //Set custom icon
  53.     if ([title isEqualToString:@"UnSub"]) {
  54.         image = [[UIImage imageWithContentsOfFile:@"/Library/PreferenceBundles/UnSubPrefs.bundle/forcetouch.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
  55.     }
  56.  
  57.     return %orig;
  58. }
  59.  
  60. %end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement