Skip to content

Commit

Permalink
Drop Activator dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
NSExceptional committed Jan 27, 2018
1 parent 58d6a41 commit 7a058bb
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 56 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
79 changes: 25 additions & 54 deletions Tweak.xm
Original file line number Diff line number Diff line change
Expand Up @@ -9,67 +9,38 @@

#import "Interfaces.h"


@interface FLEXingActivatorListenerInstance : NSObject <LAListener>
@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
2 changes: 1 addition & 1 deletion control
Original file line number Diff line number Diff line change
@@ -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!
Expand Down

0 comments on commit 7a058bb

Please sign in to comment.