-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTweak.x
207 lines (173 loc) · 5.05 KB
/
Tweak.x
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#import <UIKit/UIKit.h>
static BOOL hideDockEnabled;
static BOOL hideDockIcons;
static BOOL hideTopBar;
static BOOL hideLabel;
static BOOL hidedots;
static BOOL hideNotification;
static BOOL hideBatteryIcon;
static BOOL hideWifiIcon;
static BOOL changeBatteryText;
static BOOL hideHome;
static BOOL hideTime;
static BOOL changeCarrierText;
static BOOL hideDockBackground;
static NSString *carrierLabel;
static NSString *batteryLabel;
@interface SBDockView : UIView
@end
@interface SBRootFolderDockIconListView : UIView
@end
@interface SBFLockScreenDateView : UIView
@end
@interface _UIStatusBarStringView : UIView
@end
@interface _UIStatusBarWifiSignalView : UIView
@end
@interface SBIconLegibilityLabelView : UIView
@end
@interface _UIPageIndicatorView : UIView
@end
@interface SBDarkeningImageView : UIView
@end
@interface _UIStaticBatteryView : UIView
@end
@interface BSUIScrollView : UIView
@end
@interface _UIStatusBarForegroundView : UIView
@end
@interface SBBatteryView : UIView
@end
%hook SBDockView
- (void)didMoveToWindow {
%orig;
if (hideDockEnabled) {
self.hidden = true;
}
if (hideDockBackground) {
[self.subviews[0] removeFromSuperview];
}
}
%end
%hook SBRootFolderDockIconListView
- (void)didMoveToWindow {
%orig;
if (hideDockIcons) {
self.hidden = YES;
}
}
%end
%hook _UIStatusBarForegroundView
-(void)didMoveToWindow{
if (hideTopBar){
self.hidden = YES;
}
}
%end
%hook SBIconLegibilityLabelView
-(void)updateIconLabelWithSettings:(id)arg0 imageParameters:(id)arg1 {
if (hideLabel) {
return;
} else {
%orig;
}
}
%end
%hook _UIPageIndicatorView
- (void)didMoveToWindow{
if (hidedots){
self.hidden = YES;
}
}
%end
%hook SBDarkeningImageView
- (void)didMoveToWindow {
%orig;
if (hideNotification){
self.hidden = true;
}
}
%end
%hook _UIStaticBatteryView
- (void)didMoveToWindow{
%orig;
if (hideBatteryIcon){
self.hidden = YES;
}
}
%end
%hook _UIStatusBarWifiSignalView
- (void)didMoveToWindow{
%orig;
if (hideWifiIcon) {
self.hidden = YES;
}
}
%end
%hook SBFLockScreenDateView
- (void)didMoveToWindow{
%orig;
if (hideHome){
self.hidden = YES;
}
}
%end
%hook _UIStatusBarStringView
- (void)setText:(NSString *)text {
if ([text containsString:@"%"]) {
if (changeBatteryText) {
%orig(batteryLabel);
}
}
if (![text containsString:@"%"]) {
if (![text containsString:@":"]) {
if (changeCarrierText) {
%orig(carrierLabel);
}
}
}
if ([text containsString:@":"]) {
%orig(text);
}
if ([text containsString:@"%"]) {
if (!changeBatteryText){
%orig(text);
}
}
if (![text containsString:@"%"]) {
if (![text containsString:@":"]) {
if (!changeCarrierText) {
%orig(text);
}
}
}
if ([text containsString:@":"]) {
if (hideTime){
self.hidden = YES;
}
}
}
%end
void preferencesChanged() {
NSDictionary *prefs = [[NSUserDefaults standardUserDefaults] persistentDomainForName:@"com.justdie.hidyprefs"];
hideDockEnabled = (prefs && [prefs objectForKey:@"hideDockEnabled"] ? [[prefs valueForKey:@"hideDockEnabled"] boolValue] : YES );
hideDockIcons = (prefs && [prefs objectForKey:@"hideDockIcons"] ? [[prefs valueForKey:@"hideDockIcons"] boolValue] : YES );
hideTopBar = (prefs && [prefs objectForKey:@"hideTopBar"] ? [[prefs valueForKey:@"hideTopBar"] boolValue] : YES );
hideLabel = (prefs && [prefs objectForKey:@"hideLabels"] ? [[prefs valueForKey:@"hideLabels"] boolValue] : YES );
hidedots = (prefs && [prefs objectForKey:@"Hide3Dots"] ? [[prefs valueForKey:@"Hide3Dots"] boolValue] : YES );
hideNotification = (prefs && [prefs objectForKey:@"hideBubble"] ? [[prefs valueForKey:@"hideBubble"] boolValue] : YES );
hideBatteryIcon= (prefs && [prefs objectForKey:@"hideBatteryIcon"] ? [[prefs valueForKey:@"hideBatteryIcon"] boolValue] : YES );
hideWifiIcon= (prefs && [prefs objectForKey:@"hideWifiIcon"] ? [[prefs valueForKey:@"hideWifiIcon"] boolValue] : YES );
changeCarrierText= (prefs && [prefs objectForKey:@"changeCarrierText"] ? [[prefs valueForKey:@"changeCarrierText"] boolValue] : YES );
changeBatteryText= (prefs && [prefs objectForKey:@"changeBatteryText"] ? [[prefs valueForKey:@"changeBatteryText"] boolValue] : YES );
hideHome= (prefs && [prefs objectForKey:@"HideHome"] ? [[prefs valueForKey:@"HideHome"] boolValue] : YES );
hideTime= (prefs && [prefs objectForKey:@"HideTime"] ? [[prefs valueForKey:@"HideTime"] boolValue] : YES );
hideDockBackground= (prefs && [prefs objectForKey:@"hideDockBackground"] ? [[prefs valueForKey:@"hideDockBackground"] boolValue] : YES );
carrierLabel= prefs[@"carrierLabel"] ? prefs[@"carrierLabel"] : nil;
batteryLabel= prefs[@"batteryLabel"] ? prefs[@"batteryLabel"] : nil;
}
// and then finally, your constructor, which gets called when the tweak is loaded into memory
%ctor {
preferencesChanged();
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)preferencesChanged, CFSTR("com.justdie.hidyprefschanged"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
}