Skip to content

Instantly share code, notes, and snippets.

@DGh0st
Last active May 17, 2019 06:13
Show Gist options
  • Save DGh0st/853a75ce0306e66797af653d3971931c to your computer and use it in GitHub Desktop.
Save DGh0st/853a75ce0306e66797af653d3971931c to your computer and use it in GitHub Desktop.
SBIconController's implementation app icon force touch related methods for iOS 12 (generated using a disassembler)
@implementation SBIconController
-(BOOL)_isAppIconForceTouchControllerPeekingOrShowing {
if (self->_appIconForceTouchController != nil)
return [self->_appIconForceTouchController state] > 0;
return NO;
}
-(void)_dismissAppIconForceTouchControllerIfNecessaryAnimated:(BOOL)arg1 withCompletionHandler:(id)arg2 {
if (self->_appIconForceTouchController != nil)
[self->_appIconForceTouchController dismissAnimated:arg1 withCompletionHandler:arg2];
else if (arg2 != nil)
arg2();
}
-(void)_handleAppIconForceTouchGestureRecognizer:(id)arg1 {
if (self->_appIconForceTouchEditingScoreTimer) {
[self->_appIconForceTouchEditingScoreTimer cancel];
[self->_appIconForceTouchEditingScoreTimer release];
self->_appIconForceTouchEditingScoreTimer = nil;
}
// fun logging using os_log stuff
switch ([arg1 state]) {
case UIGestureRecognizerStateBegan:
self->_appIconForceTouchEditingScore = 0;
[self->_appIconForceTouchEditingTimer invalidate];
[self->_appIconForceTouchEditingTimer release];
self->_appIconForceTouchEditingTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 repeats:NO block:^(NSTimer *timer) {
if (!((SBUIForceTouchGestureRecognizer *)arg1).forceTouchCompleted)
[self _cancelAppIconForceTouchGestureAndBeginEditing];
}];
break;
case UIGestureRecognizerStateChanged:
if (((SBUIForceTouchGestureRecognizer *)arg1).forceTouchCompleted) {
[self->_appIconForceTouchEditingTimer invalidate];
[self->_appIconForceTouchEditingTimer release];
self->_appIconForceTouchEditingTimer = nil;
// fun logging using os_log stuff
break;
}
if (!(self->_appIconForceTouchEditingScore & 0x8000000000000000LL)) {
// fun logging using os_log stuff
void (^weirdJank)(CGFloat) = ^(CGFloat forceVelocity) {
if (!((SBUIForceTouchGestureRecognizer *)arg1).forceTouchCompleted) {
NSInteger temp = -1;
if (fabs(forceVelocity * 100.0) < 60.0)
temp = 1;
self->_appIconForceTouchEditingScore = (self->_appIconForceTouchEditingScore + temp) & ~((self->_appIconForceTouchEditingScore + temp) >> 63)
// the next part is the weird jank
result = self;
if (result[33] >= 15) // result[33] would be self->_sendITunesNotification but that doesn't really make sense
result = [result _cancelAppIconForceTouchGestureAndBeginEditing];
}
return result;
};
weirdJank(((SBUIForceTouchGestureRecognizer *)arg1).touchForceVelocity);
CGFloat interval = /* not sure how this is gotten */;
[self->_appIconForceTouchEditingScoreTimer release];
self->_appIconForceTouchEditingScoreTimer = [[BSTimer alloc] initWithFireInterval:interval repeatInterval:interval leewayInterval:interval queue:dispatch_get_main_queue() handler:^{
if (self != nil)
// calling some function
}];
[(BSTimer *)self->_appIconForceTouchEditingScoreTimer schedule];
}
break;
case UIGestureRecognizerStateEnded:
[self->_appIconForceTouchEditingTimer invalidate];
[self->_appIconForceTouchEditingTimer release];
self->_appIconForceTouchEditingTimer = nil;
if (!((SBUIForceTouchGestureRecognizer *)arg1).forceTouchCompleted) {
if (((SBUIForceTouchGestureRecognizer *)arg1).pressDuration <= 0.25) {
// fun logging using os_log stuff
BOOL displayed = [self->_appIconForceTouchController state] == 2;
[self _dismissAppIconForceTouchControllerIfNecessaryAnimated:displayed withCompletionHandler:^{
[self iconTapped:[(UIGestureRecognizer *)arg1 view]];
}];
}
}
break;
case UIGestureRecognizerStateCancelled:
case UIGestureRecognizerStateFailed:
[self->_appIconForceTouchEditingTimer invalidate];
[self->_appIconForceTouchEditingTimer release];
self->_appIconForceTouchEditingTimer = nil;
break;
default:
break;
}
}
-(BOOL)_appIconForceTouchGestureRecognizerShouldBegin {
if ([self isEditing] || [self isScrolling] || [self hasAnimatingFolder] || [self _isAppIconForceTouchControllerPeekingOrShowing])
return NO;
else
return ![self _isHostedByCoverSheet];
}
-(void)_cancelAppIconForceTouchGestureAndBeginEditing {
self->_appIconForceTouchEditingScore = -1;
[self->_appIconForceTouchEditingScoreTimer cancel];
[self->_appIconForceTouchEditingScoreTimer release];
self->_appIconForceTouchEditingScoreTimer = nil;
[self->_appIconForceTouchEditingTimer invalidate];
[self->_appIconForceTouchEditingTimer release];
self->_appIconForceTouchEditingTimer = nil;
self->_appIconForceTouchSkipCancelAllTouches = 1;
[self _dismissAppIconForceTouchControllerIfNecessaryAnimated:YES withCompletionHandler:^{
if ([self isEditingAllowed])
[self setIsEditing:YES withFeedbackBehavior:[self iconEditingFeedbackBehavior]];
}];
// fun logging using os_log stuff
}
-(BOOL)_shouldHideAppIconForceTouchInfoForApplication:(id)arg1 {
return [[arg1 info] isBlockedForScreenTimeExpiration];
}
-(id)appIconForceTouchController:(id)arg1 newIconViewCopyForGestureRecognizer:(id)arg2 {
if ([[arg2 view] isKindOfClass:[SBIconView class]]) {
SBIconView *iconView = (SBIconView *)[arg2 view];
SBIcon *icon = [iconView icon];
SBIconView *newIconView = [[[[arg1 view] class] alloc] initWithContentType:1];
[newIconView setEnabled:NO];
[newIconView setIcon:icon];
[newIconView setWallpaperRelativeImageCenter:[iconView wallpaperRelativeImageCenter]];
[newIconView setTimedOut:[iconView isTimedOut]];
if ([icon isApplicationIcon] || [icon isBookmarkIcon] || [icon isFolderIcon])
self->_appIconForceTouchIconView = newIconView;
return newIconView;
} else {
return nil;
}
}
-(CGRect)appIconForceTouchController:(id)arg1 iconViewFrameForGestureRecognizer:(id)arg2 {
SBIconView *iconView = (SBIconView *)[arg2 view];
return [iconView convertRect:[iconView defaultIconImageFrame] toCoordinateSpace:[[UIScreen mainScreen] fixedCoordinateSpace]];
}
-(id)appIconForceTouchController:(id)arg1 applicationBundleIdentifierForGestureRecognizer:(id)arg2 {
SBIconView *iconView = (SBIconView *)[arg2 view];
SBIcon *icon = [iconView icon];
if ([icon isApplicationIcon]) {
id application = [icon application];
if ([self _shouldHideAppIconForceTouchInfoForApplication:application])
return nil;
else
return [application bundleIdentifier];
}
return nil;
}
-(id)appIconForceTouchController:(id)arg1 applicationBundleURLForGestureRecognizer:(id)arg2 {
SBIconView *iconView = (SBIconView *)[arg2 view];
SBIcon *icon = [iconView icon];
if ([icon isApplicationIcon]) {
id application = [icon application];
if ([self _shouldHideAppIconForceTouchInfoForApplication:application])
return nil;
else
return [[application info] bundleURL];
}
return nil;
}
-(id)appIconForceTouchController:(id)arg1 applicationShortcutWidgetBundleIdentifierForGestureRecognizer:(id)arg2 {
SBIconView *iconView = (SBIconView *)[arg2 view];
SBIcon *icon = [iconView icon];
if ([icon isApplicationIcon]) {
id application = [icon application];
if ([self _shouldHideAppIconForceTouchInfoForApplication:application])
return nil;
else
return [[application info] applicationShortcutWidgetBundleIdentifier];
}
return nil;
}
-(id)appIconForceTouchController:(id)arg1 applicationShortcutItemsForGestureRecognizer:(id)arg2 {
SBIconView *iconView = (SBIconView *)[arg2 view];
SBIcon *icon = [iconView icon];
if ([icon isApplicationIcon]) {
id application = [icon application];
if (application == nil || [self _shouldHideAppIconForceTouchInfoForApplication:application])
return nil;
NSMutableArray *items = [[NSMutableArray alloc] init];
NSArray *filteredItems = [SBUIAppIconForceTouchController filteredApplicationShortcutItemsWithStaticApplicationShortcutItems:[[application info] staticApplicationShortcutItems] dynamicApplicationShortcutItems:[[application info] dynamicApplicationShortcutItems]];
[items addObjectsFromArray:filteredItems];
if (![application isSystemApplication] && ![application isInternalApplication]) {
NSUInteger itemID = [[[application info] itemID] unsignedIntegerValue];
if (itemID) {
if ([[application info] isBeta]) {
id testFlightApplication = [[self applicationController] testFlightApplication];
if (testFlightApplication != nil) {
SBSApplicationShortcutItem *shortcutItem = [[SBSApplicationShortcutItem alloc] init];
[shortcutItem setActivationMode:0];
[shortcutItem setBundleIdentifierToLaunch:[testFlightApplication bundleIdentifier]];
SBSApplicationShortcutSystemIcon *systemIcon = [[SBSApplicationShortcutSystemIcon alloc] initWithType:0];
[shortcutItem setIcon:systemIcon];
[systemIcon release];
NSString *localizedString = [[NSBundle mainBundle] localizedStringForKey:CFSTR("SEND_BETA_FEEDBACK_APPLICATION_SHORTCUT_ITEM_TITLE") value:/*something not nil*/nil table:CFSTR("SpringBoard")];
[shortcutItem setLocalizedTitle:localizedString];
[shortcutItem setType:kSBSApplicationShortcutItemTypeSendBetaFeedback];
NSDictionary *userInfo = [NSDictionary dictionaryWithObjects:@[[NSNumber numberWithUnsignedInteger:itemID]] forKeys:@[kSBSApplicationShortcutItemTypeSendBetaFeedbackUserInfoItemIDKey] count:1];
[shortcutItem setUserInfo:userInfo];
[items addObject:shortcutItem];
[shortcutItem release];
}
} else {
NSString *localizedString = [[NSBundle mainBundle] localizedStringForKey:CFSTR("SHARE_APPLICATION_SHORTCUT_ITEM_TITLE") value:/*something not nil (same as previous one)*/nil table:CFSTR("SpringBoard")];
NSString *displayName = [icon displayName];
NSString *formattedString = [NSString stringWithFormat:localizedString, displayName];
// there is a global block which I couldn't figure out that is called here
id shortcutItem = globalBlock(formattedString);
[items addObject:shortcutItem];
}
}
}
if ([items count] > 0) {
NSArray *resultItems = [NSArray arrayWithArray:items];
[items release];
return resultItems;
} else {
[items release];
return nil;
}
}
if ([icon isBookmarkIcon]) {
NSString *localizedString = [[NSBundle mainBundle] localizedStringForKey:CFSTR("SHARE_BOOKMARK_APPLICATION_SHORTCUT_ITEM_TITLE") value:/*something not nil*/nil table:CFSTR("SpringBoard")];
// there is a global block which I couldn't figure out that is called here
id shortcutItem = globalBlock(localizedString);
return [NSArray arrayWithObjects:@[shortcutItem] count:1];
}
if ([icon isDownloadingIcon]) {
id placeholder = [icon appPlaceholder];
NSMutableArray *items = [[NSMutableArray alloc] init];
if (![placeholder isCloudDemoted]) {
if ([placeholder isPrioritizable]) {
if ([[[self applicationPlaceholderController] placeholdersByDisplayID] count] >= 2) {
SBSApplicationShortcutItem *shortcutItem = [[SBSApplicationShortcutItem alloc] init];
UIImage *customImage = [UIImage imageNamed:CFSTR("PrioritizeDownloadApplicationShortcutItemIcon")];
NSData *imageData = UIImagePNGRepresentation(customImage);
SBSApplicationShortcutCustomImageIcon *customImageIcon = [[SBSApplicationShortcutCustomImageIcon alloc] initWithImageData:imageData dataType:0 isTemplate:YES];
[shortcutItem setIcon:customImageIcon];
[customImageIcon release];
NSString *localizedString = [[NSBundle mainBundle] localizedStringForKey:CFSTR("PRIORITIZE_DOWNLOAD_APPLICATION_SHORTCUT_ITEM_TITLE") value:/*something not nil*/nil table:CFSTR("SpringBoard")];
[shortcutItem setLocalizedTitle:localizedString];
[shortcutItem setType:CFSTR("com.apple.springboard.application-shortcut-item.prioritize-download")];
[items addObject:shortcutItem];
[shortcutItem release];
}
}
if ([placeholder isPausable] && ![placeholder isPaused]) {
SBSApplicationShortcutItem *shortcutItem = [[SBSApplicationShortcutItem alloc] init];
UIImage *customImage = [UIImage imageNamed:CFSTR("PauseDownloadApplicationShortcutItemIcon")];
NSData *imageData = UIImagePNGRepresentation(customImage);
SBSApplicationShortcutCustomImageIcon *customImageIcon = [[SBSApplicationShortcutCustomImageIcon alloc] initWithImageData:imageData dataType:0 isTemplate:YES];
[shortcutItem setIcon:customImageIcon];
[customImageIcon release];
NSString *localizedString = [[NSBundle mainBundle] localizedStringForKey:CFSTR("PAUSE_DOWNLOAD_APPLICATION_SHORTCUT_ITEM_TITLE") value:/*something not nil*/nil table:CFSTR("SpringBoard")];
[shortcutItem setLocalizedTitle:localizedString];
[shortcutItem setType:CFSTR("com.apple.springboard.application-shortcut-item.pause-download")];
[items addObject:shortcutItem];
[shortcutItem release];
}
if ([placeholder isPausable] && [placeholder isPaused]) {
SBSApplicationShortcutItem *shortcutItem = [[SBSApplicationShortcutItem alloc] init];
UIImage *customImage = [UIImage imageNamed:CFSTR("ResumeDownloadApplicationShortcutItemIcon")];
NSData *imageData = UIImagePNGRepresentation(customImage);
SBSApplicationShortcutCustomImageIcon *customImageIcon = [[SBSApplicationShortcutCustomImageIcon alloc] initWithImageData:imageData dataType:0 isTemplate:YES];
[shortcutItem setIcon:customImageIcon];
[customImageIcon release];
NSString *localizedString = [[NSBundle mainBundle] localizedStringForKey:CFSTR("RESUME_DOWNLOAD_APPLICATION_SHORTCUT_ITEM_TITLE") value:/*something not nil*/nil table:CFSTR("SpringBoard")];
[shortcutItem setLocalizedTitle:localizedString];
[shortcutItem setType:CFSTR("com.apple.springboard.application-shortcut-item.resume-download")];
[items addObject:shortcutItem];
[shortcutItem release];
}
if ([placeholder isCancelable]) {
SBSApplicationShortcutItem *shortcutItem = [[SBSApplicationShortcutItem alloc] init];
UIImage *customImage = [UIImage imageNamed:CFSTR("CancelDownloadApplicationShortcutItemIcon")];
NSData *imageData = UIImagePNGRepresentation(customImage);
SBSApplicationShortcutCustomImageIcon *customImageIcon = [[SBSApplicationShortcutCustomImageIcon alloc] initWithImageData:imageData dataType:0 isTemplate:YES];
[shortcutItem setIcon:customImageIcon];
[customImageIcon release];
NSString *localizedString = [[NSBundle mainBundle] localizedStringForKey:CFSTR("CANCEL_DOWNLOAD_APPLICATION_SHORTCUT_ITEM_TITLE") value:/*something not nil*/nil table:CFSTR("SpringBoard")];
[shortcutItem setLocalizedTitle:localizedString];
[shortcutItem setType:CFSTR("com.apple.springboard.application-shortcut-item.cancel-download")];
[items addObject:shortcutItem];
[shortcutItem release];
}
}
id applicationProxy = [LSApplicationProxy applicationProxyForIdentifier:[placeholder applicationBundleID]];
if (applicationProxy == nil) {
if ([items count] > 0) {
NSArray *resultItems = [NSArray arrayWithArray:items];
[items release];
return resultItems;
} else {
[items release];
return nil;
}
}
if ([[applicationProxy applicationType] isEqualToString:CFSTR("USER")]) {
if ([[applicationProxy itemID] unsignedIntegerValue] > 0) {
if ([applicationProxy isBetaApp]) {
if ([items count] > 0) {
NSArray *resultItems = [NSArray arrayWithArray:items];
[items release];
return resultItems;
} else {
[items release];
return nil;
}
}
NSString *localizedString = [[NSBundle mainBundle] localizedStringForKey:CFSTR("SHARE_APPLICATION_SHORTCUT_ITEM_TITLE") value:/*something not nil*/nil table:CFSTR("SpringBoard")];
NSString *applicationDisplayName = [icon applicationDisplayName];
NSString *formattedString = [NSString stringWithFormat:localizedString, applicationDisplayName];
// there is a global block which I couldn't figure out that is called here
id shortcutItem = globalBlock(formattedString);
[items addObject:shortcutItem];
}
}
if ([items count] > 0) {
NSArray *resultItems = [NSArray arrayWithArray:items];
[items release];
return resultItems;
} else {
[items release];
return nil;
}
}
if (![icon isFolderIcon]) {
return nil;
}
NSMutableArray *items = [[NSMutableArray alloc] init];
SBForceTouchAppIconInfoProvider *infoProvider = [[SBForceTouchAppIconInfoProvider alloc] init];
id reverseEnumerator = [[icon applicationIconsWithBadgesSortedByImportance] reverseObjectEnumerator];
NSFastEnumerationState state;
id applicationIcons = nil;
NSUInteger numOfIcons = [reverseEnumerator countByEnumeratingWithState:&state objects:&applicationIcons count:16];
if (numOfIcons > 0) {
id icon = applicationIcons[0];
int index = 0;
while (true) {
if (applications[0] != icon)
objc_enumerationMutation(reverseEnumerator);
id curIcon = applications[i];
SBIconBadgeView *iconBadgeView = [[SBIconBadgeView alloc] init];
[iconBadgeView configureForIcon:curIcon infoProvider:infoProvider];
NSData *imageData = UIImagePNGRepresentation([curIcon getIconImage:2]);
SBSApplicationShortcutCustomImageIcon *customImageIcon = [[SBSApplicationShortcutCustomImageIcon alloc] initWithImageData:imageData dataType:0 isTemplate:NO];
SBSApplicationShortcutItem *shortcutItem = [[SBSApplicationShortcutItem alloc] init];
[shortcutItem setBadgeView:iconBadgeView];
[shortcutItem setBundleIdentifierToLaunch:[curIcon applicationBundleID]];
[shortcutItem setIcon:customImage];
[shortcutItem setLocalizedTitle:[curIcon displayName]];
[shortcutItem setType:CFSTR("com.apple.springboard.application-shortcut-item.unread-notifications")];
[items addObject:shortcutItem];
[shortcutItem release];
[customImageIcon release];
[iconBadgeView release];
if ([items count] == 4)
break;
if (++index >= numOfIcons) {
numOfIcons = [reverseEnumerator countByEnumeratingWithState:&state objects:&applicationIcons count:16];
if (numOfIcons > 0) {
index = 0;
} eles {
break; // this part may not be 100% accurate
}
}
}
}
if ([self isEditingAllowed]) {
SBSApplicationShortcutItem *shortcutItem = [[SBSApplicationShortcutItem alloc] init];
SBSApplicationShortcutSystemIcon *systemIcon = [[SBSApplicationShortcutSystemIcon alloc] initWithType:0];
[shortcutItem setIcon:systemIcon];
[systemIcon release];
NSString *localizedString = [[NSBundle mainBundle] localizedStringForKey:CFSTR("RENAME_FOLDER_APPLICATION_SHORTCUT_ITEM_TITLE") value:/*something not nil*/nil table:CFSTR("SpringBoard")];
[shortcutItem setLocalizedTitle:localizedString];
[shortcutItem setType:CFSTR("com.apple.springboard.application-shortcut-item.rename-folder")];
[items addObject:shortcutItem];
[shortcutItem release];
}
if ([items count] > 0) {
NSArray *resultItems = [NSArray arrayWithArray:items];
[items release];
return resultItems;
}
[items release];
// fun logging with os_log stuff
return nil;
}
-(UIEdgeInsets)appIconForceTouchController:(id)arg1 iconImageInsetsForGestureRecognizer:(id)arg2 {
return UIEdgeInsetsZero;
}
-(CGFloat)appIconForceTouchController:(id)arg1 iconImageCornerRadiusForGestureRecognizer:(id)arg2 {
return LIIconContinuousCornerRadiusForVariant([UIImage _iconVariantForUIApplicationIconFormat:2 scale:[UIScreen mainScreen].scale]);
}
-(id)appIconForceTouchController:(id)arg1 parallaxSettingsForGestureRecognizer:(id)arg2 {
if ([self _iconViewInDockOrFolder:[arg2 view]])
return nil;
else
return [[self->_rootFolderController contentView] parallaxSettings];
}
-(id)appIconForceTouchController:(id)arg1 zoomDownViewForGestureRecognizer:(id)arg2 {
if ([self _iconViewInDockOrFolder:[arg2 view]])
return nil;
else
return [[arg2 view] superview];
}
-(CGPoint)appIconForceTouchController:(id)arg1 zoomDownCenterForGestureRecognizer:(id)arg2 {
SBIconView *iconView = [arg2 view];
if ([self _iconViewInDockOrFolder:iconView])
return CGPointZero;
else
return [iconView convertPoint:UIRectGetCenter([SBIconView defaultIconImageFrame]) toView:[iconView superview]];
}
-(BOOL)appIconForceTouchController:(id)arg1 shouldHandleGestureRecognizer:(id)arg2 {
return [self _appIconForceTouchGestureRecognizerShouldBegin];
}
-(void)appIconForceTouchController:(id)arg1 willPresentForGestureRecognizer:(id)arg2 {
[[self->_rootFolderController contentView] _setScrollingDisabled:YES forReason:CFSTR("SBIconControllerDisableScrollingForAppIconForceTouchReason")];
[[self searchGesture] setDisabled:YES forReason:CFSTR("SBIconControllerDisableScrollingForAppIconForceTouchReason")];
SBIconView *iconView = [arg2 view];
[iconView setIconImageAndAccessoryAlpha:0.0];
// fun logging with os_log stuff
}
-(void)appIconForceTouchController:(id)arg1 didPresentForGestureRecognizer:(id)arg2 {
SBIconView *iconView = [arg2 view];
SBIcon *icon = [iconView icon];
NSString *formattedString = [NSString stringWithFormat:CFSTR("com.apple.springboard.quickaction.opened.%@"), [self _aggregateLoggingAppKeyForIcon:icon]];
ADClientAddValueForScalarKey(formattedString, 1); // or YES?
[iconView setHighlighted:NO];
if (self->_appIconForceTouchIconView != nil) {
[self->_appIconForceTouchIconView setDelegate:self];
[iconView setEnabled:YES];
}
// fun logging with os_log stuff
}
-(void)appIconForceTouchController:(id)arg1 willDismissForGestureRecognizer:(id)arg2 {
if (self->_appIconForceTouchIconView != nil) {
[self _removeTouchedIconView:self->_appIconForceTouchIconView];
[self->_appIconForceTouchIconView setDelegate:nil];
[self->_appIconForceTouchIconView setEnabled:NO];
}
// fun logging with os_log stuff
}
-(void)appIconForceTouchController:(id)arg1 didDismissForGestureRecognizer:(id)arg2 {
[self->_appIconForceTouchIconView release];
self->_appIconForceTouchIconView = nil;
SBIconView *iconVew = [arg2 view];
[iconVew setIconImageAndAccessoryAlpha:1.0];
[[self->_rootFolderController contentView] _setScrollingDisabled:NO forReason:CFSTR("SBIconControllerDisableScrollingForAppIconForceTouchReason")];
[[self searchGesture] setDelegate:NO forReason:CFSTR("SBIconControllerDisableScrollingForAppIconForceTouchReason")];
if (self->_appIconForceTouchSkipCancelAllTouches)
self->_appIconForceTouchSkipCancelAllTouches = NO;
else
[[UIApplication sharedApplication] _cancelAllTouches];
// fun logging with os_log stuff
}
-(BOOL)appIconForceTouchController:(id)arg1 shouldActivateApplicationShortcutItem:(id)arg2 atIndex:(NSUInteger)arg3 forGestureRecognizer:(id)arg4 {
void (^displayStoreProductActivityIfNeeded)(NSNumber *itemID) = {
id temp = itemID; // this might not be itemID
if (temp != nil) {
NSDictionary *parameters = [NSDictionary dictionaryWithObjects:@[temp]forKeys:@[SKStoreProductParameterITunesItemIdentifier] count:1];
SKStoreProductActivityViewController *activityViewController = [[SKStoreProductActivityViewController alloc] initWithParameters:parameters];
[self presentViewController:activityViewController animated:YES completion:nil];
[activityViewController release];
}
};
SBIconView *iconView = [arg4 view];
SBIcon *icon = [iconView icon];
NSString *type = [arg2 type];
if ([icon isApplicationIcon]) {
BOOL result = NO;
if ([type isEqualToString:CFSTR("com.apple.springboard.application-shortcut-item.share")])
displayStoreProductActivityIfNeeded([[[icon application] info] itemID]);
else
result = YES;
NSString *formattedString = [NSString stringWithFormat:CFSTR("com.apple.springboard.quickaction.selected.%@"), [self _aggregateLoggingAppKeyForIcon:icon]];
NSUInteger value = arg3;
if ([icon isApplicationIcon]) {
id application = [icon applicaiton];
if (![application isSystemApplication] && ![application isInternalApplication])
value = 1;
} else {
value = 1;
}
ADClientAddValueForScalarKey(formattedString, value);
// fun logging with os_log stuff
return result;
}
if (![icon isBookmarkIcon]) {
if ([icon isDownloadingIcon]) {
id placeholder = [icon appPlaceholder];
if ([type isEqualToString:CFSTR("com.apple.springboard.application-shortcut-item.prioritize-download")]) {
[placeholder prioritize];
} else if ([type isEqualToString:CFSTR("com.apple.springboard.application-shortcut-item.pause-download")]) {
[placeholder pause];
} else if ([type isEqualToString:CFSTR("com.apple.springboard.application-shortcut-item.resume-download")]) {
[placeholder resume];
} else {
if (![type isEqualToString:CFSTR("com.apple.springboard.application-shortcut-item.cancel-download")]) {
if (![type isEqualToString:CFSTR("com.apple.springboard.application-shortcut-item.share")]) {
NSString *formattedString = [NSString stringWithFormat:CFSTR("com.apple.springboard.quickaction.selected.%@"), [self _aggregateLoggingAppKeyForIcon:icon]];
NSUInteger value = arg3;
if ([icon isApplicationIcon]) {
id application = [icon applicaiton];
if (![application isSystemApplication] && ![application isInternalApplication])
value = 1;
} else {
value = 1;
}
ADClientAddValueForScalarKey(formattedString, value);
// fun logging with os_log stuff
return NO;
}
id applicationProxy = [LSApplicationProxy applicationProxyForIdentifier:[placeholder applicationBundleID]];
if (applicationProxy == nil) {
NSString *formattedString = [NSString stringWithFormat:CFSTR("com.apple.springboard.quickaction.selected.%@"), [self _aggregateLoggingAppKeyForIcon:icon]];
NSUInteger value = arg3;
if ([icon isApplicationIcon]) {
id application = [icon applicaiton];
if (![application isSystemApplication] && ![application isInternalApplication])
value = 1;
} else {
value = 1;
}
ADClientAddValueForScalarKey(formattedString, value);
// fun logging with os_log stuff
return NO;
}
displayStoreProductActivityIfNeeded([applicationProxy itemId]);
NSString *formattedString = [NSString stringWithFormat:CFSTR("com.apple.springboard.quickaction.selected.%@"), [self _aggregateLoggingAppKeyForIcon:icon]];
NSUInteger value = arg3;
if ([icon isApplicationIcon]) {
id application = [icon applicaiton];
if (![application isSystemApplication] && ![application isInternalApplication])
value = 1;
} else {
value = 1;
}
ADClientAddValueForScalarKey(formattedString, value);
// fun logging with os_log stuff
return NO;
}
[placeholder cancel];
}
NSString *formattedString = [NSString stringWithFormat:CFSTR("com.apple.springboard.quickaction.selected.%@"), [self _aggregateLoggingAppKeyForIcon:icon]];
NSUInteger value = arg3;
if ([icon isApplicationIcon]) {
id application = [icon applicaiton];
if (![application isSystemApplication] && ![application isInternalApplication])
value = 1;
} else {
value = 1;
}
ADClientAddValueForScalarKey(formattedString, value);
// fun logging with os_log stuff
return NO;
}
BOOL result = NO;
if ([icon isFolderIcon]) {
if (![type isEqualToString:CFSTR("com.apple.springboard.application-shortcut-item.unread-notifications")]) {
if ([type isEqualToString:CFSTR("com.apple.springboard.application-shortcut-item.rename-folder")]) {
[self openFolderIcon:icon animated:YES withCompletion:^{
[self setIsEditing:YES];
id textField = [[[[self _openFolderController] view] folderView] _titleTextField];
if ([textField showingEditUI]) {
[textField becomeFirstResponder];
[textField selectAll:NO];
}
}];
}
NSString *formattedString = [NSString stringWithFormat:CFSTR("com.apple.springboard.quickaction.selected.%@"), [self _aggregateLoggingAppKeyForIcon:icon]];
NSUInteger value = arg3;
if ([icon isApplicationIcon]) {
id application = [icon applicaiton];
if (![application isSystemApplication] && ![application isInternalApplication])
value = 1;
} else {
value = 1;
}
ADClientAddValueForScalarKey(formattedString, value);
// fun logging with os_log stuff
return NO;
}
id application = [[self applicationController] applicationWithBundleIdentifier:[arg2 setBundleIdentifierToLaunch]];
// Below is inside some block (some things in this block may be incorrect)
SBDeviceApplicationSceneEntity *entity = [[SBDeviceApplicationSceneEntity alloc] initWithApplicationForMainDisplay:nil];
id activation = [[SBMainWorkspace sharedInstance] createRequestForApplicationActivation:entity options:nil];
[activation setOriginationProcess:[BSProcessHandle processHandle]];
[[activation applicationContext] setResultBlock:nil];
[[SBMainWorkspace sharedInstance] executeTransitionRequest:activation];
// end of block
} else {
result = YES;
}
NSString *formattedString = [NSString stringWithFormat:CFSTR("com.apple.springboard.quickaction.selected.%@"), [self _aggregateLoggingAppKeyForIcon:icon]];
NSUInteger value = arg3;
if ([icon isApplicationIcon]) {
id application = [icon applicaiton];
if (![application isSystemApplication] && ![application isInternalApplication])
value = 1;
} else {
value = 1;
}
ADClientAddValueForScalarKey(formattedString, value);
// fun logging with os_log stuff
return result;
}
if ([type isEqualToString:CFSTR("com.apple.springboard.application-shortcut-item.share")]) {
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:[NSArray arrayWithObjects:@[[[icon webClip] pageURL]] count:1] applicationActivities:nil];
[self presentViewController:activityViewController animated:YES completion:nil];
[activityViewController release];
}
NSString *formattedString = [NSString stringWithFormat:CFSTR("com.apple.springboard.quickaction.selected.%@"), [self _aggregateLoggingAppKeyForIcon:icon]];
NSUInteger value = arg3;
if ([icon isApplicationIcon]) {
id application = [icon applicaiton];
if (![application isSystemApplication] && ![application isInternalApplication])
value = 1;
} else {
value = 1;
}
ADClientAddValueForScalarKey(formattedString, value);
// fun logging with os_log stuff
return NO;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment