-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathTweakSpring.xm
executable file
·481 lines (406 loc) · 13.9 KB
/
TweakSpring.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
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
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
#import <UIKit/UIKit.h>
#define CGRectSetY(rect, y) CGRectMake(rect.origin.x, y, rect.size.width, rect.size.height)
NSInteger statusBarStyle, screenRoundness, appswitcherRoundness;
BOOL enabled, wantsHomeBarSB, wantsHomeBarLS, wantsRoundedAppSwitcher, wantsReduceRows, wantsRoundedCorners, wantsXButtons;
BOOL wantsCCGrabber, wantsProudLock, wantsHideSBCC,wantsLSShortcuts, wantsBatteryPercent, wantsiPadDock;
BOOL wantsiPadMultitasking;
%hook BSPlatform
- (NSInteger)homeButtonType {
return 2;
}
%end
@interface CSQuickActionsView : UIView
- (UIEdgeInsets)_buttonOutsets;
@property (nonatomic, retain) UIControl *flashlightButton;
@property (nonatomic, retain) UIControl *cameraButton;
@end
%hook CSQuickActionsView
- (BOOL)_prototypingAllowsButtons {
return wantsLSShortcuts;
}
- (void)_layoutQuickActionButtons {
CGRect const screenBounds = [UIScreen mainScreen].bounds;
int const y = screenBounds.size.height - 90 - [self _buttonOutsets].top;
[self flashlightButton].frame = CGRectMake(46, y, 50, 50);
[self cameraButton].frame = CGRectMake(screenBounds.size.width - 96, y, 50, 50);
}
%end
%group HideSBCC
%hook CCUIModularControlCenterOverlayViewController
- (CCUIHeaderPocketView*)overlayHeaderView {
return nil;
}
%end
%end
%group batteryPercent
%hook _UIBatteryView
-(BOOL)_currentlyShowsPercentage {
return YES;
}
-(BOOL)_shouldShowBolt {
return NO;
}
%end
%hook _UIStatusBarStringView
- (void)setText:(NSString *)text {
if ([text containsString:@"%"])
return;
else
%orig(text);
}
%end
%end
%hook SBReachabilitySettings
- (void)setSystemWideSwipeDownHeight:(double) systemWideSwipeDownHeight {
%orig(100);
}
%end
%group StatusBarX
%hook _UIStatusBarVisualProvider_iOS
+ (Class)class {
return %c(_UIStatusBarVisualProvider_Split58);
}
%end
%hook SBIconListGridLayoutConfiguration
- (UIEdgeInsets)portraitLayoutInsets {
UIEdgeInsets const x = %orig;
NSUInteger const locationRows = MSHookIvar<NSUInteger>(self, "_numberOfPortraitRows");
if (locationRows == 3 || statusBarStyle == 3) {
return x;
}
return UIEdgeInsetsMake(x.top+10, x.left, x.bottom, x.right);
}
%end
%end
%group StatusBarXSpacing
%hook _UIStatusBarVisualProvider_Split58
+(CGSize)notchSize {
CGSize const orig = %orig;
return CGSizeMake(orig.width, 18);
}
+(double)height {
return 20;
}
%end
%end
%group StatusBariPad
%hook _UIStatusBarVisualProvider_iOS
+ (Class)class {
if (wantsRoundedCorners && screenRoundness > 15) return %c(_UIStatusBarVisualProvider_RoundedPad_ForcedCellular);
return %c(_UIStatusBarVisualProvider_Pad_ForcedCellular);
}
%end
%hook CCUIHeaderPocketView
- (void)setFrame:(CGRect)frame {
if (wantsRoundedCorners && screenRoundness > 15) %orig(CGRectSetY(frame, -20));
else %orig(CGRectSetY(frame, -24));
}
%end
%end
%hook SBFHomeGrabberSettings
- (BOOL)isEnabled {
return wantsHomeBarSB;
}
%end
%group hideHomeBarLS
%hook CSTeachableMomentsContainerView
-(void)setHomeAffordanceContainerView:(UIView *)arg1{
return;
}
%end
%end
%group completelyRemoveHomeBar
%hook MTLumaDodgePillSettings
- (void)setHeight:(double)arg1 {
arg1 = 0;
%orig;
}
%end
%end
%group roundedDock
%hook UITraitCollection
- (CGFloat)displayCornerRadius {
return appswitcherRoundness;
}
%end
%end
%hook SBIconListView
-(unsigned long long)iconRowsForCurrentOrientation{
int const orig = %orig;
if (orig < 4) return orig;
return orig - wantsReduceRows + wantsiPadDock;
}
%end
%group ccGrabber
@interface CSTeachableMomentsContainerView : UIView
@property(retain, nonatomic) UIView *controlCenterGrabberView;
@property(retain, nonatomic) UIView *controlCenterGrabberEffectContainerView;
@property (retain, nonatomic) UIImageView * controlCenterGlyphView;
@end
%hook CSTeachableMomentsContainerView
- (void)_layoutControlCenterGrabberAndGlyph {
%orig;
if (statusBarStyle == 2) {
self.controlCenterGrabberEffectContainerView.frame = CGRectMake(self.frame.size.width - 73,36,46,2.5);
self.controlCenterGrabberView.frame = CGRectMake(0,0,46,2.5);
self.controlCenterGlyphView.frame = CGRectMake(315,45,16.6,19.3);
} else {
self.controlCenterGrabberEffectContainerView.frame = CGRectMake(self.frame.size.width - 75.5,24,60.5,2.5);
self.controlCenterGrabberView.frame = CGRectMake(0,0,60.5,2.5);
self.controlCenterGlyphView.frame = CGRectMake(320,35,16.6,19.3);
}
}
%end
%end
// Allows you to use the non-X iPhone button combinations. For some reason only works on some devices - Just as the iPhone X Combinations
%group originalButtons
%hook SBLockHardwareButtonActions
- (id)initWithHomeButtonType:(long long)arg1 proximitySensorManager:(id)arg2 {
return %orig(1, arg2);
}
%end
%hook SBHomeHardwareButtonActions
- (id)initWitHomeButtonType:(long long)arg1 {
return %orig(1);
}
%end
int applicationDidFinishLaunching = 2;
%hook SBPressGestureRecognizer
- (void)setAllowedPressTypes:(NSArray *)arg1 {
NSArray *lockHome = @[@104, @101];
NSArray *lockVol = @[@104, @102, @103];
if ([arg1 isEqual:lockVol] && applicationDidFinishLaunching == 2) {
%orig(lockHome);
applicationDidFinishLaunching--;
return;
}
%orig;
}
%end
%hook SBClickGestureRecognizer
- (void)addShortcutWithPressTypes:(id)arg1 {
if (applicationDidFinishLaunching == 1) {
applicationDidFinishLaunching--;
return;
}
%orig;
}
%end
%hook SBHomeHardwareButton
- (id)initWithScreenshotGestureRecognizer:(id)arg1 homeButtonType:(long long)arg2 buttonActions:(id)arg3 gestureRecognizerConfiguration:(id)arg4 {
return %orig(arg1,1,arg3,arg4);
}
- (id)initWithScreenshotGestureRecognizer:(id)arg1 homeButtonType:(long long)arg2 {
return %orig(arg1,1);
}
%end
%hook SBLockHardwareButton
- (id)initWithScreenshotGestureRecognizer:(id)arg1 shutdownGestureRecognizer:(id)arg2 proximitySensorManager:(id)arg3 homeHardwareButton:(id)arg4 volumeHardwareButton:(id)arg5 buttonActions:(id)arg6 homeButtonType:(long long)arg7 createGestures:(_Bool)arg8 {
return %orig(arg1,arg2,arg3,arg4,arg5,arg6,1,arg8);
}
- (id)initWithScreenshotGestureRecognizer:(id)arg1 shutdownGestureRecognizer:(id)arg2 proximitySensorManager:(id)arg3 homeHardwareButton:(id)arg4 volumeHardwareButton:(id)arg5 homeButtonType:(long long)arg6 {
return %orig(arg1,arg2,arg3,arg4,arg5,1);
}
%end
%hook SBVolumeHardwareButton
- (id)initWithScreenshotGestureRecognizer:(id)arg1 shutdownGestureRecognizer:(id)arg2 homeButtonType:(long long)arg3 {
return %orig(arg1,arg2,1);
}
%end
%end
%group roundedCorners
@interface _UIRootWindow : UIView
@property (setter=_setContinuousCornerRadius:, nonatomic) double _continuousCornerRadius;
@end
%hook _UIRootWindow
-(void)layoutSubviews {
%orig;
self.clipsToBounds = YES;
self._continuousCornerRadius = screenRoundness;
return;
}
%end
%hook SBReachabilityBackgroundView
- (double)_displayCornerRadius {
return screenRoundness;
}
%end
%end
%group ProudLock
%hook SBUIPasscodeBiometricResource
-(BOOL)hasPearlSupport {
return YES;
}
-(BOOL)hasMesaSupport {
return NO;
}
%end
@interface SBDashBoardMesaUnlockBehaviorConfiguration : NSObject
- (BOOL)_isAccessibilityRestingUnlockPreferenceEnabled;
@end
@interface SBDashBoardBiometricUnlockController : NSObject
@end
@interface SBLockScreenController : NSObject
+ (id)sharedInstance;
- (BOOL)_finishUIUnlockFromSource:(int)arg1 withOptions:(id)arg2;
@end
CGFloat offset = 0;
%hook SBFLockScreenDateView
-(id)initWithFrame:(CGRect)arg1 {
CGFloat const screenWidth = UIScreen.mainScreen.bounds.size.width;
if (screenWidth <= 320) {
offset = 20;
} else if (screenWidth <= 375) {
offset = 35;
} else if (screenWidth <= 414) {
offset = 28;
}
return %orig;
}
- (void)layoutSubviews {
%orig;
UIView* timeView = MSHookIvar<UIView*>(self, "_timeLabel");
UIView* dateSubtitleView = MSHookIvar<UIView*>(self, "_dateSubtitleView");
UIView* customSubtitleView = MSHookIvar<UIView*>(self, "_customSubtitleView");
[timeView setFrame:CGRectSetY(timeView.frame, timeView.frame.origin.y + offset)];
[dateSubtitleView setFrame:CGRectSetY(dateSubtitleView.frame, dateSubtitleView.frame.origin.y + offset)];
[customSubtitleView setFrame:CGRectSetY(customSubtitleView.frame, customSubtitleView.frame.origin.y + offset)];
}
%end
%hook SBDashBoardLockScreenEnvironment
- (void)handleBiometricEvent:(unsigned long long)arg1 {
%orig;
if (arg1 == 4) {
SBDashBoardBiometricUnlockController* biometricUnlockController = MSHookIvar<SBDashBoardBiometricUnlockController*>(self, "_biometricUnlockController");
SBDashBoardMesaUnlockBehaviorConfiguration* unlockBehavior = MSHookIvar<SBDashBoardMesaUnlockBehaviorConfiguration*>(biometricUnlockController, "_biometricUnlockBehaviorConfiguration");
if ([unlockBehavior _isAccessibilityRestingUnlockPreferenceEnabled]) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[[%c(SBLockScreenManager) sharedInstance] _finishUIUnlockFromSource:12 withOptions:nil];
});
}
}
}
%end
%hook BSUICAPackageView
- (id)initWithPackageName:(id)packageName inBundle:(id)arg2 {
if (![packageName hasPrefix:@"lock"]) return %orig;
packageName = [packageName stringByAppendingString:@"-896h"];
return %orig(packageName, [NSBundle bundleWithPath:@"/System/Library/PrivateFrameworks/SpringBoardUIServices.framework"]);
}
%end
%hook CSCombinedListViewController
- (UIEdgeInsets)_listViewDefaultContentInsets {
UIEdgeInsets orig = %orig;
orig.top += offset;
return orig;
}
%end
%hook SBUIBiometricResource
- (id)init {
id r = %orig;
MSHookIvar<BOOL>(r, "_hasMesaHardware") = NO;
MSHookIvar<BOOL>(r, "_hasPearlHardware") = YES;
return r;
}
%end
@interface WGWidgetGroupViewController : UIViewController
@end
%hook WGWidgetGroupViewController
- (void)updateViewConstraints {
%orig;
[self.view setFrame:CGRectSetY(self.view.frame, self.view.frame.origin.y + (offset/2))];
}
%end
%end
%group iPadDock
%hook SBFloatingDockController
+ (BOOL)isFloatingDockSupported {
return YES;
}
%end
%end
%group iPadMultitasking
%hook SBApplication
- (BOOL)isMedusaCapable {
return YES;
}
%end
%hook SBPlatformController
-(long long)medusaCapabilities {
return 2;
}
%end
%hook SBMainWorkspace
-(BOOL)isMedusaEnabled {
return YES;
}
%end
%end
// Preferences.
void loadPrefs() {
@autoreleasepool {
NSDictionary const *prefs = [[NSDictionary alloc] initWithContentsOfFile:@"/var/mobile/Library/Preferences/com.ryannair05.little11prefs.plist"];
if (prefs) {
enabled = [[prefs objectForKey:@"enabled"] boolValue];
statusBarStyle = [[prefs objectForKey:@"statusBarStyle"] integerValue];
screenRoundness = [[prefs objectForKey:@"screenRoundness"] integerValue];
appswitcherRoundness = [[prefs objectForKey:@"appswitcherRoundness"] integerValue];
wantsHomeBarSB = [[prefs objectForKey:@"homeBarSB"] boolValue];
wantsHomeBarLS = [[prefs objectForKey:@"homeBarLS"] boolValue];
wantsRoundedAppSwitcher =[[prefs objectForKey:@"roundedAppSwitcher"] boolValue];
wantsReduceRows = [[prefs objectForKey:@"reduceRows"] boolValue];
wantsCCGrabber = [[prefs objectForKey:@"ccGrabber"] boolValue];
wantsBatteryPercent = [[prefs objectForKey:@"batteryPercent"] boolValue];
wantsiPadDock = [[prefs objectForKey:@"iPadDock"] boolValue];
wantsiPadMultitasking = wantsiPadDock ? [[prefs objectForKey:@"iPadMultitasking"] boolValue] : NO;
wantsXButtons = [[prefs objectForKey:@"xButtons"] boolValue];
wantsRoundedCorners = [[prefs objectForKey:@"roundedCorners"] boolValue];
wantsProudLock = [[prefs objectForKey:@"ProudLock"] boolValue];
wantsHideSBCC = [[prefs objectForKey:@"HideSBCC"] boolValue];
wantsLSShortcuts = [[prefs objectForKey:@"lsShortcutsEnabled"] boolValue];
}
else {
NSString *path = @"/System/Library/PrivateFrameworks/CameraUI.framework/CameraUI-d4x-n104.strings";
NSString *pathDefault = @"/Library/PreferenceBundles/little11prefs.bundle/CameraUI-d4x-n104.strings";
NSFileManager const *fileManager = [NSFileManager defaultManager];
if (![fileManager fileExistsAtPath:path]) {
[fileManager copyItemAtPath:pathDefault toPath:path error:nil];
}
path = @"/User/Library/Preferences/com.ryannair05.little11prefs.plist";
pathDefault = @"/Library/PreferenceBundles/little11prefs.bundle/defaults.plist";
if (![fileManager fileExistsAtPath:path]) {
[fileManager copyItemAtPath:pathDefault toPath:path error:nil];
loadPrefs();
}
}
}
}
%ctor {
@autoreleasepool {
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)loadPrefs, CFSTR("com.ryannair05.little11prefs/prefsupdated"), NULL, CFNotificationSuspensionBehaviorCoalesce);
loadPrefs();
if (enabled) {
if (statusBarStyle == 1) %init(StatusBariPad);
else if (statusBarStyle > 1) {
%init(StatusBarX);
if (statusBarStyle == 3)
%init(StatusBarXSpacing);
}
else wantsHideSBCC = YES;
if (!wantsHomeBarLS) {
%init(hideHomeBarLS);
if (!wantsHomeBarSB) %init(completelyRemoveHomeBar);
}
if (wantsCCGrabber) %init(ccGrabber);
if (wantsBatteryPercent) %init(batteryPercent);
if (!wantsXButtons) %init(originalButtons);
if (wantsHideSBCC) %init(HideSBCC);
if (wantsRoundedAppSwitcher) %init(roundedDock);
if (wantsRoundedCorners) %init(roundedCorners);
if (wantsiPadDock) %init(iPadDock);
if (wantsiPadMultitasking) %init(iPadMultitasking)
if (wantsProudLock) %init(ProudLock);
%init;
}
}
}