-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTweak.x
430 lines (370 loc) · 11.9 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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
// Respring function
@interface FBSystemService : NSObject
+(id)sharedInstance;
-(void)exitAndRelaunch:(bool)arg1;
@end
static void RespringDevice() {
[[%c(FBSystemService) sharedInstance] exitAndRelaunch:YES];
}
// Prefs
@interface NSUserDefaults (KagePrefs)
-(id)objectForKey:(NSString *)key inDomain:(NSString *)domain;
-(void)setObject:(id)value forKey:(NSString *)key inDomain:(NSString *)domain;
@end
static NSString *nsDomainString = @"com.yaypixxo.kage";
static NSString *nsNotificationString = @"com.yaypixxo.kage/preferences.changed";
// Declare pref things here (switches, buttons, etc.)
static BOOL enabled;
static BOOL hideQuickActionsBG;
static BOOL gridSwitcher;
static BOOL hideLSBatt;
static BOOL statusBarShowTimeLS;
static BOOL hideLabels;
//static BOOL hideCarPlayLabels;
static BOOL hideFolderBadges;
static BOOL hideFolderTitle;
static BOOL hideFolderBG;
static BOOL hideFolderBGSB;
static BOOL hideFolderDots;
static BOOL hideNoOlderNotifs;
//static BOOL hideStatusBarLS;
static BOOL hideCCGrabber;
static BOOL noBetaAlert;
static BOOL tapFolderClose;
static void notificationCallback(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
NSNumber *eEnabled = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"enabled" inDomain:nsDomainString];
NSNumber *eHideQuickActionsBG = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideQuickActionsBG" inDomain:nsDomainString];
NSNumber *eGridSwitcher = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"gridSwitcher" inDomain:nsDomainString];
NSNumber *eHideLSBatt = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideLSBatt" inDomain:nsDomainString];
NSNumber *eStatusBarShowTimeLS = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"statusBarShowTimeLS" inDomain:nsDomainString];
NSNumber *eHideLabels = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideLabels" inDomain:nsDomainString];
//NSNumber *eHideCarPlayLabels = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideCarPlayLabels" inDomain:nsDomainString];
NSNumber *eHideFolderBadges = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideFolderBadges" inDomain:nsDomainString];
NSNumber *eHideFolderTitle = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideFolderTitle" inDomain:nsDomainString];
NSNumber *eHideFolderBG = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideFolderBG" inDomain:nsDomainString];
NSNumber *eHideFolderBGSB = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideFolderBGSB" inDomain:nsDomainString];
NSNumber *eHideFolderDots = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideFolderDots" inDomain:nsDomainString];
NSNumber *eHideNoOlderNotifs = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideNoOlderNotifs" inDomain:nsDomainString];
//NSNumber *eHideStatusBarLS = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideStatusBarLS" inDomain:nsDomainString];
NSNumber *eHideCCGrabber = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"hideCCGrabber" inDomain:nsDomainString];
NSNumber *eNoBetaAlert = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"noBetaAlert" inDomain:nsDomainString];
NSNumber *eTapFolderClose = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"tapFolderClose" inDomain:nsDomainString];
enabled = (eEnabled) ? [eEnabled boolValue]:NO;
hideQuickActionsBG = (eHideQuickActionsBG) ? [eHideQuickActionsBG boolValue]:NO;
gridSwitcher = (eGridSwitcher) ? [eGridSwitcher boolValue]:NO;
hideLSBatt = (eHideLSBatt) ? [eHideLSBatt boolValue]:NO;
statusBarShowTimeLS = (eStatusBarShowTimeLS) ? [eStatusBarShowTimeLS boolValue]:NO;
hideLabels = (eHideLabels) ? [eHideLabels boolValue]:NO;
//hideCarPlayLabels = (eHideCarPlayLabels) ? [eHideCarPlayLabels boolValue]:NO;
hideFolderBadges = (eHideFolderBadges) ? [eHideFolderBadges boolValue]:NO;
hideFolderTitle = (eHideFolderTitle) ? [eHideFolderTitle boolValue]:NO;
hideFolderBG = (eHideFolderBG) ? [eHideFolderBG boolValue]:NO;
hideFolderBGSB = (eHideFolderBGSB) ? [eHideFolderBGSB boolValue]:NO;
hideFolderDots = (eHideFolderDots) ? [eHideFolderDots boolValue]:NO;
hideNoOlderNotifs = (eHideNoOlderNotifs) ? [eHideNoOlderNotifs boolValue]:NO;
//hideStatusBarLS = (eHideStatusBarLS) ? [eHideStatusBarLS boolValue]:NO;
hideCCGrabber = (eHideCCGrabber) ? [eHideCCGrabber boolValue]:NO;
noBetaAlert = (eNoBetaAlert) ? [eNoBetaAlert boolValue]:NO;
tapFolderClose = (eTapFolderClose) ? [eTapFolderClose boolValue]:NO;
}
// Headers
#import <UIKit/UIKit.h>
@interface SBFloatyFolderView : UIView
@end
@interface SBIconView : UIView
-(void)setLabelHidden:(BOOL)hidden;
@end
@interface SBIcon : NSObject
-(id)badgeNumberOrString;
@end
@interface CSTeachableMomentsContainerView
@property (nonatomic,retain) UIView * controlCenterGrabberView;
@end
@interface SBDashBoardTeachableMomentsContainerView
@property (nonatomic,retain) UIView * controlCenterGrabberView;
@end
@interface SBFolderIconImageView : UIView
@property (nonatomic, retain) UIView *backgroundView;
@end
@interface SBIconListPageControl
@property (nonatomic, assign, readwrite, getter=isHidden) BOOL hidden;
@end
@interface SBIconController : NSObject
+(id)sharedInstance;
-(void)_closeFolderController:(id)arg1 animated:(BOOL)arg2 withCompletion:(id)arg3;
@end
@interface SBUILegibilityLabel : UIView
@property (nonatomic,copy) NSString *string;
@end
@interface NCNotificationListSectionRevealHintView : UIView
@property (nonatomic,retain)SBUILegibilityLabel *revealHintTitle;
@end
/*@interface SBFloatyFolderView : SBFolderView
-(void)_handleOutsideTap:(id)arg1 ;
@end
@interface SBFolderController : UIViewController
@property (nonatomic,readonly) UIView * containerView;
@end
@interface SBFloatyFolderScrollView : UIScrollView
-(void)closeFolder:(id)selector;
-(id)_viewControllerForAncestor;
@end*/
#ifndef kCFCoreFoundationVersionNumber_iOS_13_0
#define kCFCoreFoundationVersionNumber_iOS_13_0 1665.15
#endif
#define kSLSystemVersioniOS13 kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_13_0
%group universal // Stuff that works on both iOS 12 & iOS 13 (and some things 9+)
// Hide no older notifications
%hook NCNotificationListSectionRevealHintView
-(void)didMoveToWindow {
%orig;
if (enabled && hideNoOlderNotifs) {
self.revealHintTitle.string = @"";
}
}
%end
// Hide quick actions BG
%hook UICoverSheetButton
-(id)_backgroundEffectsWithBrightness:(double)arg1 {
if (enabled && hideQuickActionsBG) {
return 0;
}
else {
return %orig;
}
}
%end
// Hide folder badges text
%hook SBIcon
-(id)badgeNumberOrString {
if (enabled && hideFolderBadges) {
return @"";
}
else {
return %orig;
}
}
%end
// Hide icon labels
%hook SBIconView
-(void)setLabelHidden:(BOOL)hidden {
if (enabled && hideLabels) {
hidden = YES;
}
%orig;
}
%end
// Grid switcher
%hook SBAppSwitcherSettings
- (void)setGridSwitcherPageScale:(double)arg1 {
if (enabled && gridSwitcher) {
arg1 = 0.4;
}
%orig;
}
- (void)setGridSwitcherHorizontalInterpageSpacingPortrait:(double)arg1 {
if (enabled && gridSwitcher) {
arg1 = 25.5;
}
%orig;
}
- (void)setGridSwitcherHorizontalInterpageSpacingLandscape:(double)arg1 {
if (enabled && gridSwitcher) {
arg1 = 11.6;
}
%orig;
}
- (void)setGridSwitcherVerticalNaturalSpacingPortrait:(double)arg1 {
if (enabled && gridSwitcher) {
arg1 = 42;
}
%orig;
}
- (void)setGridSwitcherVerticalNaturalSpacingLandscape:(double)arg1 {
if (enabled && gridSwitcher) {
arg1 = 38;
}
%orig;
}
- (void)setSwitcherStyle:(long long)arg1 {
if (enabled && gridSwitcher) {
arg1 = 2;
}
%orig;
}
%end
// Hide LS battery
%hook CSCoverSheetViewController
- (void)_transitionChargingViewToVisible:(bool)arg1 showBattery:(bool)arg2 animated:(bool)arg3 {
if (enabled && hideLSBatt) {
arg1 = 0;
}
%orig;
}
%end
// Hide folder title
%hook SBFloatyFolderView
-(BOOL)_showsTitle {
if (enabled && hideFolderTitle) {
return NO;
}
else {
return %orig;
}
}
%end
// Hide folder backgrounds
%hook SBFloatyFolderView
-(void)setBackgroundAlpha:(CGFloat)arg1 {
if (enabled && hideFolderBG) {
%orig(0.0);
}
else {
%orig;
}
}
%end
%hook SBFolderIconImageView
-(void)layoutSubviews {
%orig;
if (enabled && hideFolderBGSB) {
self.backgroundView.alpha = 0;
self.backgroundView.hidden = 1;
}
}
%end
// Close folder when tapped inside
%hook SBFloatyFolderView
-(BOOL)_tapToCloseGestureRecognizer:(id)arg1 shouldReceiveTouch:(id)arg2 {
%orig;
if (enabled && tapFolderClose) {
return YES;
}
else {
return %orig;
}
}
%end
// Hide folder dots
%hook SBIconListPageControl
-(void)layoutSubviews {
if (enabled && hideFolderDots) {
self.hidden = YES;
}
else {
%orig;
}
}
%end
// Hide beta alert
// iOS 9-10
%hook SBIconController
-(void)showDeveloperBuildExpirationAlertIfNecesarryFromLockscreen:(BOOL)arg1 toLauncher:(BOOL)arg2 {
if (enabled && noBetaAlert) {
}
else {
%orig;
}
}
%end
// iOS 11-13
%hook SBDeveloperBuildExpirationTrigger
-(void)showDeveloperBuildExpirationAlertIfNecesarryFromLockscreen:(BOOL)arg1 toLauncher:(BOOL)arg2 {
if (enabled && noBetaAlert) {
}
else {
%orig;
}
}
%end
%end // End universal group
// Stuff that only works on iOS 13
%group ios13
// Show time in LS statusbar
%hook CSCoverSheetViewController
- (bool)shouldShowLockStatusBarTime {
if (enabled && statusBarShowTimeLS) {
return YES;
}
else {
return %orig;
}
}
%end
// Hide CC LS grabber
%hook CSTeachableMomentsContainerView
- (void)layoutSubviews {
if (enabled && hideCCGrabber) {
[self.controlCenterGrabberView setHidden:YES];
}
else {
[self.controlCenterGrabberView setHidden:NO];
}
return %orig;
}
%end
// Hide CarPlay labels
/*%hook CARIconView
+(CGSize)maxLabelSizeForIconImageSize:(CGSize)imageSize {
if (enabled && hideCarPlayLabels) {
return CGSizeZero;
}
else {
return %orig;
}
}
%end*/
%end // End ios13 group
// Stuff that only works on iOS 12
%group ios12
// Show time in LS statusbar
%hook SBLockScreenViewControllerBase
- (bool)shouldShowLockStatusBarTime {
if (enabled && statusBarShowTimeLS) {
return YES;
}
else {
return %orig;
}
}
%end
// Hide CC LS grabber
%hook SBDashBoardTeachableMomentsContainerView
- (void)layoutSubviews {
if (enabled && hideCCGrabber) {
[self.controlCenterGrabberView setHidden:YES];
}
else {
[self.controlCenterGrabberView setHidden:NO];
}
return %orig;
}
%end
// Hide CarPlay labels
/*%hook SBStarkIconView
+(CGSize)maxLabelSize {
if (enabled && hideCarPlayLabels) {
return CGSizeZero;
}
else {
return %orig;
}
}
%end*/
%end // End ios12 group
// Listeners
%ctor {
%init(universal);
// Check iOS version
if (kSLSystemVersioniOS13) {
%init(ios13);
}
else {
%init(ios12);
}
// Prefs changed listener
notificationCallback(NULL, NULL, NULL, NULL, NULL);
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, notificationCallback, (CFStringRef)nsNotificationString, NULL, CFNotificationSuspensionBehaviorCoalesce);
// Respring listener
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)RespringDevice, CFSTR("com.yaypixxo.kage/respring"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
}