This repository has been archived by the owner on May 9, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCCWallCustomizer2.xm
175 lines (130 loc) · 4.58 KB
/
CCWallCustomizer2.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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#import "CCWallCustomizer2Classes.h"
#import <sys/stat.h>
#import <dlfcn.h>
#define customImgPath @"/var/mobile/Documents/ccwall.png"
#define cImgPath @"/var/mobile/CCWallCustomizer2/ccwall.png"
#define plist @"/var/mobile/Library/Preferences/com.ikilledappl3.ccwallcustomizer2.plist"
static BOOL kEnabled;
#define isiPad ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
UIImageView *ccImageView;
//CCWallCustomizer 2 is a tweak for iOS 11+ that customizes the background of the control center.
//Created by iKilledAppl3 :P
%hook SBFluidSwitcherViewController
-(void)viewDidLoad {
if (kEnabled && isiPad) {
%orig;
ccImageView = [[UIImageView alloc] init];
ccImageView.frame = self.view.frame;
ccImageView.bounds = self.view.bounds;
ccImageView.image = [UIImage imageWithContentsOfFile:cImgPath];
if ([[NSFileManager defaultManager] fileExistsAtPath:customImgPath]) {
system("mv /var/mobile/Documents/ccwall.png /var/mobile/CCWallCustomizer2/");
}
//fit to the view
ccImageView.contentMode = UIViewContentModeScaleAspectFill;
//make the image clips to bounds
//imgView.clipsToBounds = YES;
//fix landscape bug
ccImageView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
ccImageView.alpha = 1.0;
[ccImageView.layer setOpaque:NO];
//add the image view as a sub view of the background view
[self.view addSubview:ccImageView];
[self.view sendSubviewToBack:ccImageView];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.8];
[ccImageView setAlpha:1];
[UIView commitAnimations];
}
else {
%orig;
}
}
-(void)willMoveToParentViewController:(id)arg1 {
if (kEnabled && isiPad) {
%orig;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.8];
[ccImageView setAlpha:0];
[UIView commitAnimations];
}
else {
%orig;
}
}
%end
%hook CCUIModularControlCenterOverlayViewController
-(void)viewDidLoad {
if (kEnabled) {
%orig;
MTMaterialView* backgroundView = [self valueForKey:@"_backgroundView"];
[backgroundView removeFromSuperview];
//Thanks to @laughingquoll probably not needed for my tweak but I added anyhow
self.overlayBackgroundView.tag = 453112;
self.overlayBackgroundView.hidden = YES;
ccImageView = [[UIImageView alloc] init];
ccImageView.frame = self.view.frame;
ccImageView.bounds = self.view.bounds;
ccImageView.image = [UIImage imageWithContentsOfFile:cImgPath];
if ([[NSFileManager defaultManager] fileExistsAtPath:customImgPath]) {
system("mv /var/mobile/Documents/ccwall.png /var/mobile/CCWallCustomizer2/");
}
//fit to the view
ccImageView.contentMode = UIViewContentModeScaleAspectFill;
//make the image clips to bounds
//imgView.clipsToBounds = YES;
//fix landscape bug
ccImageView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
ccImageView.alpha = 1.0;
[ccImageView.layer setOpaque:NO];
//add the image view as a sub view of the background view
[self.view addSubview:ccImageView];
[self.view sendSubviewToBack:ccImageView];
}
else {
%orig;
}
}
-(void)presentAnimated:(BOOL)arg1 withCompletionHandler:(/*^block*/id)arg2 {
if (kEnabled) {
%orig;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.8];
[ccImageView setAlpha:1];
[UIView commitAnimations];
}
else {
%orig;
}
}
-(void)dismissAnimated:(BOOL)arg1 withCompletionHandler:(/*^block*/id)arg2 {
if (kEnabled) {
%orig;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.8];
[ccImageView setAlpha:0];
[UIView commitAnimations];
}
else {
%orig;
}
}
%end
//Thanks to @laughingquoll probably not needed for my tweak but I added anyhow
%hook MTMaterialView
-(void)setWeighting:(CGFloat)arg1 {
if (kEnabled && self.tag == 453112) {
%orig;
ccImageView.alpha = arg1;
}
else {
%orig;
}
}
%end
HBPreferences *myPrefs;
//Prefs new
%ctor {
myPrefs = [[HBPreferences alloc] initWithIdentifier:@"com.ikilledappl3.ccwallcustomizer2"];
[myPrefs registerBool:&kEnabled default:NO forKey:@"kEnabled"];
}