-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTweak.xm
executable file
·160 lines (149 loc) · 5.57 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "CCSwipe.h"
#define IS_OS_8_OR_LATER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
#define SCREEN ([UIScreen mainScreen].bounds)
%group iOS7
%hook SBUIController
- (void)_showControlCenterGestureBeganWithLocation:(struct CGPoint)arg1 {
NSUserDefaults *prefs = [[NSUserDefaults alloc] initWithSuiteName:@"com.sinisterindustries.ccswipe~prefs"];
BOOL ccswipeEnabled = [prefs boolForKey:@"ccswipeEnabled"];
BOOL reverseEnabled = [prefs boolForKey:@"reverseEnabled"];
BOOL lockHomescreenEnabled = [prefs boolForKey:@"lockHomescreenEnabled"];
int leftTarget = [prefs integerForKey:@"leftBound"];
int rightTarget = [prefs integerForKey:@"rightBound"];
//scales numbers for landscape orientation
if (ccswipeEnabled && UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation)) {
rightTarget = (rightTarget * SCREEN.size.height) / SCREEN.size.width;
leftTarget = (leftTarget * SCREEN.size.height) / SCREEN.size.width;
}
if (ccswipeEnabled) {
// left
if (arg1.x < leftTarget) {
if (reverseEnabled) {
// go home / lock
UIApplication *frontApp = ((SpringBoard *)[UIApplication sharedApplication])._accessibilityFrontMostApplication;
if (lockHomescreenEnabled && frontApp == nil) {
// lock
[[%c(SBUserAgent) sharedUserAgent] lockAndDimDevice];
}
else {
// go home
[self clickedMenuButton];
}
}
else {
// open switcher
[self _toggleSwitcher];
}
return;
}
// middle
else if (arg1.x > leftTarget && arg1.x < rightTarget) {
// activate cc normally
%orig;
}
// right
else if (arg1.x > rightTarget) {
if (reverseEnabled) {
// open switcher
[self _toggleSwitcher];
}
else {
// go home / lock
UIApplication *frontApp = ((SpringBoard *)[UIApplication sharedApplication])._accessibilityFrontMostApplication;
if (lockHomescreenEnabled && frontApp == nil) {
// lock
[[%c(SBUserAgent) sharedUserAgent] lockAndDimDevice];
}
else {
// go home
[self clickedMenuButton];
}
}
return;
}
}
else {
%orig;
}
}
%end
%end
%group iOS8_iOS9_iOS10
%hook SBControlCenterController
- (void)_showControlCenterGestureBeganWithGestureRecognizer:(UIGestureRecognizer*)arg1 {
CGPoint point = [arg1 locationInView:arg1.view];
NSUserDefaults *prefs = [[NSUserDefaults alloc] initWithSuiteName:@"com.sinisterindustries.ccswipe~prefs"];
BOOL ccswipeEnabled = [prefs boolForKey:@"ccswipeEnabled"];
BOOL reverseEnabled = [prefs boolForKey:@"reverseEnabled"];
BOOL lockHomescreenEnabled = [prefs boolForKey:@"lockHomescreenEnabled"];
int leftTarget = [prefs integerForKey:@"leftBound"];
int rightTarget = [prefs integerForKey:@"rightBound"];
//scales numbers for landscape orientation
if (ccswipeEnabled && UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation)) {
rightTarget = (rightTarget * SCREEN.size.height) / SCREEN.size.width;
leftTarget = (leftTarget * SCREEN.size.height) / SCREEN.size.width;
}
if (ccswipeEnabled) {
// left
if (point.x < leftTarget) {
if (reverseEnabled) {
// go home / lock
UIApplication *frontApp = ((SpringBoard *)[UIApplication sharedApplication])._accessibilityFrontMostApplication;
if (lockHomescreenEnabled && frontApp == nil) {
// lock
[[%c(SBUserAgent) sharedUserAgent] lockAndDimDevice];
}
else {
// go home
[[%c(SBUIController) sharedInstance] clickedMenuButton];
}
}
else {
// open switcher
// [[%c(SBUIController) sharedInstance] _toggleSwitcher];
[[%c(SBUIController) sharedInstance] handleMenuDoubleTap];
}
return;
}
// middle
else if (point.x > leftTarget && point.x < rightTarget) {
// activate cc normally
%orig;
}
// right
else if (point.x > rightTarget) {
if (reverseEnabled) {
// open switcher
// [[%c(SBUIController) sharedInstance] _toggleSwitcher];
[[%c(SBUIController) sharedInstance] handleMenuDoubleTap];
}
else {
// go home / lock
UIApplication *frontApp = ((SpringBoard *)[UIApplication sharedApplication])._accessibilityFrontMostApplication;
if (lockHomescreenEnabled && frontApp == nil) {
// lock
[[%c(SBUserAgent) sharedUserAgent] lockAndDimDevice];
}
else {
// go home
[[%c(SBUIController) sharedInstance] clickedMenuButton];
}
}
return;
}
}
else {
%orig;
}
}
%end
%end
%ctor {
if (kCFCoreFoundationVersionNumber > 0xB57) {
%init(iOS7);
} else {
%init(iOS8_iOS9_iOS10);
}
}