From 7a058bbec8c3aebca2cf40799264b73b81f2f3c5 Mon Sep 17 00:00:00 2001 From: Tanner Bennett Date: Fri, 26 Jan 2018 19:31:24 -0600 Subject: [PATCH] Drop Activator dependency --- Makefile | 2 +- Tweak.xm | 79 ++++++++++++++++++-------------------------------------- control | 2 +- 3 files changed, 27 insertions(+), 56 deletions(-) diff --git a/Makefile b/Makefile index 415f1ed..21f580b 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ IMPORTS = -I$(FLEX_ROOT)/Classes/ $(call dtoim, $(_IMPORTS)) TWEAK_NAME = FLEXing FLEXing_FRAMEWORKS = CoreGraphics UIKit ImageIO QuartzCore FLEXing_FILES = Tweak.xm $(SOURCES) -FLEXing_LIBRARIES = sqlite3 z activator objcipc +FLEXing_LIBRARIES = sqlite3 z #objcipc #activator FLEXing_CFLAGS += -fobjc-arc -w $(IMPORTS) include $(THEOS_MAKE_PATH)/tweak.mk diff --git a/Tweak.xm b/Tweak.xm index ec4aee6..4f609f2 100644 --- a/Tweak.xm +++ b/Tweak.xm @@ -9,67 +9,38 @@ #import "Interfaces.h" - -@interface FLEXingActivatorListenerInstance : NSObject -@end - -@implementation FLEXingActivatorListenerInstance - -- (void)activator:(LAActivator *)activator receiveEvent:(LAEvent *)event forListenerName:(NSString *)listenerName { - NSString *frontmostAppID = [(SpringBoard *)[UIApplication sharedApplication] _accessibilityFrontMostApplication].bundleIdentifier; +UIView * AddGestures(UIView *view) { + id flex = [FLEXManager sharedManager]; + SEL show = @selector(showExplorer); + UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:flex action:show]; + tap.numberOfTapsRequired = 2; + tap.numberOfTouchesRequired = 2; - if ([listenerName isEqualToString:kFLEXingShow] ){ - if (frontmostAppID) { - [OBJCIPC sendMessageToAppWithIdentifier:frontmostAppID messageName:kFLEXingShow dictionary:nil replyHandler:^(NSDictionary *response) { - event.handled = YES; - }]; - } else { - [[FLEXManager sharedManager] showExplorer]; - event.handled = YES; - } - } - else if ([listenerName isEqualToString:kFLEXingToggle]) { - if (frontmostAppID) { - [OBJCIPC sendMessageToAppWithIdentifier:frontmostAppID messageName:kFLEXingToggle dictionary:nil replyHandler:^(NSDictionary *response) { - event.handled = YES; - }]; - } else { - [[FLEXManager sharedManager] toggleExplorer]; - event.handled = YES; - } - } else { - event.handled = NO; - } -} + UILongPressGestureRecognizer *tap2 = [[UILongPressGestureRecognizer alloc] initWithTarget:flex action:show]; + tap2.minimumPressDuration = .5; + tap2.numberOfTouchesRequired = 3; + + [view addGestureRecognizer:tap]; + [view addGestureRecognizer:tap2]; -@end + return view; +} +%group NoActivator +%hook UIWindow +- (id)initWithFrame:(CGRect)frame { + return AddGestures(%orig(frame)); +} -%hook UIApplication +%end +%end -- (id)init { - // Register activator handlers in springboard +%ctor { + %init(NoActivator); if ([[NSBundle mainBundle].bundleIdentifier isEqualToString:@"com.apple.springboard"]) { - FLEXingActivatorListenerInstance *FLEXALI = [FLEXingActivatorListenerInstance new]; - [[LAActivator sharedInstance] registerListener:FLEXALI forName:kFLEXingShow]; - [[LAActivator sharedInstance] registerListener:FLEXALI forName:kFLEXingToggle]; - } else if (NSClassFromString(@"OBJCIPC")) { - - // Register message handlers - [OBJCIPC registerIncomingMessageFromSpringBoardHandlerForMessageName:kFLEXingShow handler:^NSDictionary *(NSDictionary *message) { + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [[FLEXManager sharedManager] showExplorer]; - return nil; - }]; + }); - [OBJCIPC registerIncomingMessageFromSpringBoardHandlerForMessageName:kFLEXingToggle handler:^NSDictionary *(NSDictionary *message) { - [[FLEXManager sharedManager] toggleExplorer]; - return nil; - }]; - } else { - NSLog(@"FLEXing: OBJCIPC class not found"); } - - return %orig; } - -%end diff --git a/control b/control index 49f961e..6c6c6dc 100644 --- a/control +++ b/control @@ -1,7 +1,7 @@ Package: com.pantsthief.flexing Name: FLEXing Pre-Depends: firmware (>= 8.0) -Depends: mobilesubstrate, libactivator, cc.tweak.libobjcipc +Depends: Version: 0.0.5 Architecture: iphoneos-arm Description: Open FLEX anywhere with Activator!