Skip to content

Commit

Permalink
Long press on status bar to activate
Browse files Browse the repository at this point in the history
  • Loading branch information
NSExceptional committed May 8, 2018
1 parent 8565550 commit b747016
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 22 deletions.
2 changes: 2 additions & 0 deletions Interfaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ static NSString * const kFLEXingShow = @"com.pantsthief.flexing.show";
static NSString * const kFLEXingToggle = @"com.pantsthief.flexing.toggle";


@interface UIStatusBarWindow : UIWindow @end

@interface UIApplication (Private)
- (id)displayIdentifier;
@end
Expand Down
31 changes: 9 additions & 22 deletions Tweak.xm
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,21 @@

#import "Interfaces.h"

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;

UILongPressGestureRecognizer *tap2 = [[UILongPressGestureRecognizer alloc] initWithTarget:flex action:show];
tap2.minimumPressDuration = .5;
tap2.numberOfTouchesRequired = 3;

[view addGestureRecognizer:tap];
[view addGestureRecognizer:tap2];

return view;
}

%group NoActivator
%hook UIWindow
- (id)initWithFrame:(CGRect)frame {
return AddGestures(%orig(frame));
}

- (BOOL)_shouldCreateContextAsSecure {
return [self isKindOfClass:%c(FLEXWindow)] ? YES : %orig;
}
%end

%hook UIStatusBarWindow
- (id)initWithFrame:(CGRect)frame {
self = %orig;

[self addGestureRecognizer:[[UILongPressGestureRecognizer alloc] initWithTarget:FLEXManager.sharedManager action:@selector(showExplorer)]];

return self;
}
%end
%end

Expand All @@ -45,6 +33,5 @@ UIView * AddGestures(UIView *view) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[[FLEXManager sharedManager] showExplorer];
});

}
}

0 comments on commit b747016

Please sign in to comment.