-
Notifications
You must be signed in to change notification settings - Fork 2
/
Tweak.xm
executable file
·141 lines (112 loc) · 4.9 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
//
// Motus
// Easily oppen Control Center from the bottom corners of your iPhone X.
// By Simalary (Chris) & MidnightChips
//
#import <objc/runtime.h>
//Prefs
#define PLIST_PATH @"/Users/midnightchip/Documents/Dev/MotusPref/prefs/entry.plist" //Change to your entry.plist path. Include file extension.
inline bool GetPrefBool(NSString *key) {
return [[[NSDictionary dictionaryWithContentsOfFile:PLIST_PATH] valueForKey:key] boolValue];
}
inline int GetPrefInt(NSString *key) {
return [[[NSDictionary dictionaryWithContentsOfFile:PLIST_PATH] valueForKey:key] intValue];
}
inline float GetPrefFloat(NSString *key) {
return [[[NSDictionary dictionaryWithContentsOfFile:PLIST_PATH] valueForKey:key] floatValue];
}
//End Prefs
//Respring function
@interface FBSystemService : NSObject
+(id)sharedInstance;
- (void)exitAndRelaunch:(bool)arg1;
@end
static void RespringDevice()
{
[[%c(FBSystemService) sharedInstance] exitAndRelaunch:YES];
}
%ctor
{
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)RespringDevice, CFSTR("com.simalary-midnightchips.auxiliumdevelopment.motusprefs/respring"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); //Your Prefs Bundle + "/respring" (different form tweak bundle) See reference in /prefs/MotusPrefsRootListController.m
}
//End Respring
@interface CHMotusWindow : UIWindow
@end
@interface CHMotusView : UIView
@end
@interface SBControlCenterController
+(id)sharedInstance;
+(void)presentAnimated:(BOOL)arg1;
@end
@implementation CHMotusWindow
-(BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event {
for (UIWindow *window in self.subviews) {
if (!window.hidden && window.userInteractionEnabled && [window pointInside:[self convertPoint:point toView:window] withEvent:event])
return YES;
}
return NO;
}
@end
@implementation CHMotusView
// -(BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event {
// for (UIView *view in self.subviews) {
// if (!view.hidden && view.userInteractionEnabled && [view pointInside:[self convertPoint:point toView:view] withEvent:event])
// return YES;
// }
// return NO;
// }
- (BOOL) gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer
shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
if ([gestureRecognizer isKindOfClass:[CHMotusView class]]) {
return YES;
} else{
return NO;
}
}
@end
%hook SpringBoard
-(void)applicationDidFinishLaunching:(id)application {
float setNewWidth = GetPrefFloat(@"kWidth");
float setNewAlpha = GetPrefFloat(@"kAlpha");
float setNewHeight = GetPrefFloat(@"kHeight");
UIWindow * screen = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen]bounds]];
CHMotusView * rightView=[[CHMotusView alloc]initWithFrame:CGRectMake(screen.bounds.size.width, screen.bounds.size.height, - setNewWidth, - setNewHeight)];
[rightView setBackgroundColor:[UIColor greenColor]];
[rightView setAlpha: setNewAlpha];
rightView.userInteractionEnabled = TRUE;
CHMotusView * leftView=[[CHMotusView alloc]initWithFrame:CGRectMake(screen.bounds.origin.x, screen.bounds.size.height, setNewWidth, - setNewHeight)];
[leftView setBackgroundColor:[UIColor greenColor]];
[leftView setAlpha: setNewAlpha];
leftView.userInteractionEnabled = TRUE;
CHMotusWindow *window = [[CHMotusWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
window.windowLevel = 1005;
[window setHidden:NO];
[window setAlpha:1.0];
[window setBackgroundColor:[UIColor clearColor]];
[window addSubview:rightView];
[window addSubview:leftView];
UISwipeGestureRecognizer *rightRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(SwipeRecognizer:)];
rightRecognizer.direction=UISwipeGestureRecognizerDirectionUp;
[rightView addGestureRecognizer:rightRecognizer];
UISwipeGestureRecognizer *leftRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(SwipeRecognizer:)];
leftRecognizer.direction=UISwipeGestureRecognizerDirectionUp;
[leftView addGestureRecognizer:leftRecognizer];
%orig;
/*UILabel *betaLabel;
betaLabel = [[UILabel alloc] initWithFrame:CGRectMake(screen.bounds.size.width / 2, screen.bounds.size.height - 35, 0, 0)];
betaLabel.textColor = [UIColor whiteColor];
betaLabel.backgroundColor = [UIColor redColor];
betaLabel.textAlignment = NSTextAlignmentCenter;
betaLabel.text = @"MOTUS BETA";
betaLabel.font = [UIFont fontWithName:@".SFUIText" size:15];
[betaLabel sizeToFit];
[betaLabel setCenter:(CGPointMake(CGRectGetMidX(screen.bounds), betaLabel.center.y))];
[window addSubview:betaLabel];*/
//[upRecognizer release];
//[[[[[UIApplication sharedApplication] keyWindow] subviews] lastObject] addSubview:window];
}
%new
- (void) SwipeRecognizer:(UISwipeGestureRecognizer *)sender {
[[%c(SBControlCenterController) sharedInstance] presentAnimated:TRUE];
}
%end