-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathTweak.xm
More file actions
127 lines (85 loc) · 3.69 KB
/
Tweak.xm
File metadata and controls
127 lines (85 loc) · 3.69 KB
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
#import "JBSCompletedViewController.h"
#import "JBSCustomNavigationController.h"
#import "JBSPasswordManager.h"
#import "JBSDummyViewController.h"
@interface SBHomeScreenViewController : UIViewController
@end
UIWindow *setupWindow;
JBSDummyViewController *ctrl;
BOOL readyToShowSetupUI = NO;
%hook SBHomeScreenViewController
-(void)viewDidLoad {
%orig;
setupWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
setupWindow.windowLevel = UIWindowLevelStatusBar - 10;
ctrl = [[JBSDummyViewController alloc] init];
setupWindow.rootViewController = ctrl;
}
%end
@interface SpringBoard: UIApplication
-(BOOL)isShowingHomescreen;
@end
%hook SpringBoard
-(void)_updateHomeScreenPresenceNotification:(id)arg1 {
%orig;
if (readyToShowSetupUI) {
SpringBoard *sb = (SpringBoard *)[UIApplication sharedApplication];
if (ctrl && ctrl.presentedViewController) {
UIView *statusBar = [[UIApplication sharedApplication] valueForKey:@"_statusBar"];
[statusBar setValue:[UIColor blackColor] forKey:@"foregroundColor"];
[statusBar setValue:@0 forKey:@"legibilityStyle"];
}
if (ctrl && !ctrl.presentedViewController && [sb isShowingHomescreen] && [[JBSPasswordManager sharedManager] shouldChangePassword]) {
ctrl.view.hidden = NO;
[setupWindow makeKeyAndVisible];
UIView *statusBar = [[UIApplication sharedApplication] valueForKey:@"_statusBar"];
ctrl.lastForegroundColor = [statusBar valueForKey:@"foregroundColor"];
JBSCompletedViewController *completedVC = [[JBSCompletedViewController alloc] init];
completedVC.view.backgroundColor = [UIColor whiteColor];
JBSCustomNavigationController *navCon = [[JBSCustomNavigationController alloc] initWithRootViewController:completedVC];
navCon.view.backgroundColor = [UIColor whiteColor];
[ctrl presentViewController:navCon animated:YES completion:nil];
}
}
}
%end
%hook SBDashBoardViewController
-(void)viewDidAppear:(BOOL)animated {
%orig;
readyToShowSetupUI = NO;
if (ctrl.presentedViewController) {
[ctrl dismissViewControllerAnimated:NO completion:nil];
}
ctrl.view.hidden = YES;
setupWindow.hidden = YES;
}
-(void)viewWillAppear:(BOOL)animated {
%orig;
if (ctrl.presentedViewController) {
[ctrl dismissViewControllerAnimated:NO completion:nil];
}
ctrl.view.hidden = YES;
setupWindow.hidden = YES;
}
-(void)viewDidDisappear:(BOOL)animated {
%orig;
SpringBoard *sb = (SpringBoard *)[UIApplication sharedApplication];
readyToShowSetupUI = YES;
if (ctrl && !ctrl.presentedViewController && [sb isShowingHomescreen] && [[JBSPasswordManager sharedManager] shouldChangePassword]) {
ctrl.view.hidden = NO;
[setupWindow makeKeyAndVisible];
UIView *statusBar = [[UIApplication sharedApplication] valueForKey:@"_statusBar"];
ctrl.lastForegroundColor = [statusBar valueForKey:@"foregroundColor"];
JBSCompletedViewController *completedVC = [[JBSCompletedViewController alloc] init];
completedVC.view.backgroundColor = [UIColor whiteColor];
JBSCustomNavigationController *navCon = [[JBSCustomNavigationController alloc] initWithRootViewController:completedVC];
navCon.view.backgroundColor = [UIColor whiteColor];
[ctrl presentViewController:navCon animated:YES completion:nil];
}
}
%end
/*%ctor {
NSString *uuid = [UIDevice currentDevice].identifierForVendor.UUIDString;
NSUserDefaults *defaults = [[NSUserDefaults alloc] initWithSuiteName:@"com.shiftcmdk.jbsetup.preferences"];
[defaults removeObjectForKey:uuid];
}*/