|
9 | 9 |
|
10 | 10 | #import "Interfaces.h" |
11 | 11 |
|
12 | | - |
13 | | -@interface FLEXingActivatorListenerInstance : NSObject <LAListener> |
14 | | -@end |
15 | | - |
16 | | -@implementation FLEXingActivatorListenerInstance |
17 | | - |
18 | | -- (void)activator:(LAActivator *)activator receiveEvent:(LAEvent *)event forListenerName:(NSString *)listenerName { |
19 | | - NSString *frontmostAppID = [(SpringBoard *)[UIApplication sharedApplication] _accessibilityFrontMostApplication].bundleIdentifier; |
| 12 | +UIView * AddGestures(UIView *view) { |
| 13 | + id flex = [FLEXManager sharedManager]; |
| 14 | + SEL show = @selector(showExplorer); |
| 15 | + UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:flex action:show]; |
| 16 | + tap.numberOfTapsRequired = 2; |
| 17 | + tap.numberOfTouchesRequired = 2; |
20 | 18 |
|
21 | | - if ([listenerName isEqualToString:kFLEXingShow] ){ |
22 | | - if (frontmostAppID) { |
23 | | - [OBJCIPC sendMessageToAppWithIdentifier:frontmostAppID messageName:kFLEXingShow dictionary:nil replyHandler:^(NSDictionary *response) { |
24 | | - event.handled = YES; |
25 | | - }]; |
26 | | - } else { |
27 | | - [[FLEXManager sharedManager] showExplorer]; |
28 | | - event.handled = YES; |
29 | | - } |
30 | | - } |
31 | | - else if ([listenerName isEqualToString:kFLEXingToggle]) { |
32 | | - if (frontmostAppID) { |
33 | | - [OBJCIPC sendMessageToAppWithIdentifier:frontmostAppID messageName:kFLEXingToggle dictionary:nil replyHandler:^(NSDictionary *response) { |
34 | | - event.handled = YES; |
35 | | - }]; |
36 | | - } else { |
37 | | - [[FLEXManager sharedManager] toggleExplorer]; |
38 | | - event.handled = YES; |
39 | | - } |
40 | | - } else { |
41 | | - event.handled = NO; |
42 | | - } |
43 | | -} |
| 19 | + UILongPressGestureRecognizer *tap2 = [[UILongPressGestureRecognizer alloc] initWithTarget:flex action:show]; |
| 20 | + tap2.minimumPressDuration = .5; |
| 21 | + tap2.numberOfTouchesRequired = 3; |
| 22 | + |
| 23 | + [view addGestureRecognizer:tap]; |
| 24 | + [view addGestureRecognizer:tap2]; |
44 | 25 |
|
45 | | -@end |
| 26 | + return view; |
| 27 | +} |
46 | 28 |
|
| 29 | +%group NoActivator |
| 30 | +%hook UIWindow |
| 31 | +- (id)initWithFrame:(CGRect)frame { |
| 32 | + return AddGestures(%orig(frame)); |
| 33 | +} |
47 | 34 |
|
48 | | -%hook UIApplication |
| 35 | +%end |
| 36 | +%end |
49 | 37 |
|
50 | | -- (id)init { |
51 | | - // Register activator handlers in springboard |
| 38 | +%ctor { |
| 39 | + %init(NoActivator); |
52 | 40 | if ([[NSBundle mainBundle].bundleIdentifier isEqualToString:@"com.apple.springboard"]) { |
53 | | - FLEXingActivatorListenerInstance *FLEXALI = [FLEXingActivatorListenerInstance new]; |
54 | | - [[LAActivator sharedInstance] registerListener:FLEXALI forName:kFLEXingShow]; |
55 | | - [[LAActivator sharedInstance] registerListener:FLEXALI forName:kFLEXingToggle]; |
56 | | - } else if (NSClassFromString(@"OBJCIPC")) { |
57 | | - |
58 | | - // Register message handlers |
59 | | - [OBJCIPC registerIncomingMessageFromSpringBoardHandlerForMessageName:kFLEXingShow handler:^NSDictionary *(NSDictionary *message) { |
| 41 | + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ |
60 | 42 | [[FLEXManager sharedManager] showExplorer]; |
61 | | - return nil; |
62 | | - }]; |
| 43 | + }); |
63 | 44 |
|
64 | | - [OBJCIPC registerIncomingMessageFromSpringBoardHandlerForMessageName:kFLEXingToggle handler:^NSDictionary *(NSDictionary *message) { |
65 | | - [[FLEXManager sharedManager] toggleExplorer]; |
66 | | - return nil; |
67 | | - }]; |
68 | | - } else { |
69 | | - NSLog(@"FLEXing: OBJCIPC class not found"); |
70 | 45 | } |
71 | | - |
72 | | - return %orig; |
73 | 46 | } |
74 | | - |
75 | | -%end |
0 commit comments