-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathTweak.xm
102 lines (76 loc) · 3.15 KB
/
Tweak.xm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#import "RPScreenRecorder+Additions.h"
/*Created by iKilledAppl3 on 7/22/18 at 7:38 pm
This is for my buddy domlast425
Concept was by him :)
*/
%hook UIStatusBar
-(void)layoutSubviews {
if (kEnabled) {
%orig;
self.userInteractionEnabled = YES;
/* thanks to ipadkid358 for this part! (self.gestureRecognizers) :P
*/
if (self.gestureRecognizers) {
return;
}
UISwipeGestureRecognizer *swipeGestureLeft = [[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(leftSwipe:)] autorelease];
[swipeGestureLeft setDirection:(UISwipeGestureRecognizerDirectionLeft)];
swipeGestureLeft.numberOfTouchesRequired = 1;
[self addGestureRecognizer:swipeGestureLeft];
UISwipeGestureRecognizer *swipeGestureRight = [[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(rightSwipe:)] autorelease];
[swipeGestureRight setDirection:(UISwipeGestureRecognizerDirectionRight)];
swipeGestureRight.numberOfTouchesRequired = 1;
[self addGestureRecognizer:swipeGestureRight];
}
else {
%orig;
}
}
%new -(void)rightSwipe:(UISwipeGestureRecognizer *)sender {
RPScreenRecorder *screenRecorder = [%c(RPScreenRecorder) sharedRecorder];
[screenRecorder stopSystemRecording:(/*^block*/id)nil];
}
%new -(void)leftSwipe:(UISwipeGestureRecognizer *)sender {
RPScreenRecorder *screenRecorder = [%c(RPScreenRecorder) sharedRecorder];
[screenRecorder startRecordingWithMicrophoneEnabled:kUseMicrophone windowToRecord:self systemRecording:YES handler:nil];
}
%end
%hook UIStatusBar_Modern
-(void)layoutSubviews {
if (kEnabled) {
%orig;
self.userInteractionEnabled = YES;
/* thanks to ipadkid358 for this part! (self.gestureRecognizers) :P
*/
if (self.gestureRecognizers) {
return;
}
UISwipeGestureRecognizer *swipeGestureLeft = [[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(leftSwipe:)] autorelease];
[swipeGestureLeft setDirection:(UISwipeGestureRecognizerDirectionLeft)];
swipeGestureLeft.numberOfTouchesRequired = 1;
[self addGestureRecognizer:swipeGestureLeft];
UISwipeGestureRecognizer *swipeGestureRight = [[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(rightSwipe:)] autorelease];
[swipeGestureRight setDirection:(UISwipeGestureRecognizerDirectionRight)];
swipeGestureRight.numberOfTouchesRequired = 1;
[self addGestureRecognizer:swipeGestureRight];
}
else {
%orig;
}
}
%new -(void)rightSwipe:(UISwipeGestureRecognizer *)sender {
RPScreenRecorder *screenRecorder = [%c(RPScreenRecorder) sharedRecorder];
[screenRecorder stopSystemRecording:(/*^block*/id)nil];
}
%new -(void)leftSwipe:(UISwipeGestureRecognizer *)sender {
RPScreenRecorder *screenRecorder = [%c(RPScreenRecorder) sharedRecorder];
[screenRecorder startRecordingWithMicrophoneEnabled:kUseMicrophone windowToRecord:self systemRecording:YES handler:nil];
}
%end
extern NSString *const HBPreferencesDidChangeNotification;
%ctor
{
preferences = [[HBPreferences alloc] initWithIdentifier:@"com.ikilledappl3.swipe2rec"];
[preferences registerBool:&kEnabled default:NO forKey:@"kEnabled"];
[preferences registerBool:&kUseMicrophone default:NO forKey:@"kUseMicrophone"];
}