/
TweakUI.xm
executable file
·321 lines (273 loc) · 10.2 KB
/
TweakUI.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
#import <UIKit/UIKit.h>
#include <sys/sysctl.h>
#include <sys/utsname.h>
#define CGRectSetY(rect, y) CGRectMake(rect.origin.x, y, rect.size.width, rect.size.height)
NSInteger statusBarStyle, keyboardSpacing;
BOOL enabled, wantsKeyboardDock,wants11Camera, wantsbottomInset;
BOOL disableGestures = NO, wantsGesturesDisabledWhenKeyboard, wantsiPadMultitasking;
BOOL wantsDeviceSpoofing, wantsCompatabilityMode;
%group ForceDefaultKeyboard
%hook UIKeyboardImpl
+(UIEdgeInsets)deviceSpecificPaddingForInterfaceOrientation:(NSInteger)orientation inputMode:(id)mode {
UIEdgeInsets orig = %orig;
orig.left = 0;
orig.right = 0;
orig.bottom = 0;
return orig;
}
%end
%end
%group StatusBarX
%hook UIScrollView
- (UIEdgeInsets)adjustedContentInset {
UIEdgeInsets orig = %orig;
if (orig.top == 64) orig.top = 88;
else if (orig.top == 32) orig.top = 0;
else if (orig.top == 128) orig.top = 152;
return orig;
}
%end
%end
%group KeyboardDock
%hook UIKeyboardImpl
+(UIEdgeInsets)deviceSpecificPaddingForInterfaceOrientation:(NSInteger)orientation inputMode:(id)mode {
UIEdgeInsets orig = %orig;
if (!(%c(BarmojiCollectionView) || %c(DockXServer)))
orig.bottom = keyboardSpacing;
return orig;
}
%end
%hook UIKeyboardDockView
- (CGRect)bounds {
CGRect bounds = %orig;
return bounds;
}
%end
%end
%group iPhone11Cam
%hook CAMCaptureCapabilities
-(BOOL)isCTMSupported {
return YES;
}
%end
%hook CAMViewfinderViewController
-(BOOL)_wantsHDRControlsVisible{
return NO;
}
%end
%hook CAMViewfinderViewController
-(BOOL)_shouldUseZoomControlInsteadOfSlider {
return YES;
}
%end
%end
// Adds a bottom inset to the camera app.
%group CameraFix
%hook CAMBottomBar
- (void)setFrame:(CGRect)frame {
%orig(CGRectSetY(frame, frame.origin.y -40));
}
%end
%hook CAMZoomControl
- (void)setFrame:(CGRect)frame {
%orig(CGRectSetY(frame, frame.origin.y -30));
}
%end
%end
%group disableGesturesWhenKeyboard // iOS 13.4 and up
%hook SBFluidSwitcherGestureManager
- (void)grabberTongueBeganPulling:(id)arg1 withDistance:(double)arg2 andVelocity:(double)arg3 andGesture:(id)arg4 {
if (!disableGestures)
%orig;
}
%end
%end
%group UIKitiPadMultitasking
%hook UITraitCollection
+(UITraitCollection *)traitCollectionWithHorizontalSizeClass:(UIUserInterfaceSizeClass)arg1 {
if(UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation))
return %orig(2);
return %orig;
}
%end
%end
%group BoundsHack
%hookf(int, sysctl, const int *name, u_int namelen, void *oldp, size_t *oldlenp, const void *newp, size_t newlen) {
if (namelen == 2 && name[0] == CTL_HW && name[1] == HW_MACHINE && oldp) {
int const ret = %orig;
const char *mechine1 = "iPhone12,1";
strncpy((char*)oldp, mechine1, strlen(mechine1));
return ret;
} else {
return %orig;
}
}
%hookf(int, sysctlbyname, const char *name, void *oldp, size_t *oldlenp, void *newp, size_t newlen) {
if (strcmp(name, "hw.machine") == 0) {
int ret = %orig;
const char *mechine1 = "iPhone12,1";
if (oldp) {
strcpy((char *)oldp, mechine1);
}
*oldlenp = sizeof(mechine1);
return ret;
} else {
return %orig;
}
}
%hookf(int, uname, struct utsname *value) {
int const ret = %orig;
NSString *utsmachine = @"iPhone12,1";
const char *utsnameCh = utsmachine.UTF8String;
strcpy(value->machine, utsnameCh);
return ret;
}
%end
%group CompatabilityMode
%hook UIScreen
- (CGRect)bounds {
CGRect bounds = %orig;
bounds.size.height > bounds.size.width ? bounds.size.height = 812 : bounds.size.width = 812;
return bounds;
}
%end
%end
%hook UIWindow
- (UIEdgeInsets)safeAreaInsets {
UIEdgeInsets orig = %orig;
orig.bottom = wantsbottomInset ? 20 : 0;
return orig;
}
%end
%group InstagramFix
%end
%group bottominsetfix // AWE = TikTok, TFN = Twitter, YT = Youtube
%hook AWETabBar
- (void)setFrame:(CGRect)frame {
%orig(CGRectSetY(frame, frame.origin.y + 40));
}
%end
%hook AWEFeedTableView
- (void)setFrame:(CGRect)frame {
%orig(CGRectMake(frame.origin.x,frame.origin.y,frame.size.width,frame.size.height + 40));
}
%end
%hook TFNNavigationBarOverlayView
- (void)setFrame:(CGRect)frame {
%orig(CGRectMake(frame.origin.x,frame.origin.y,frame.size.width,frame.size.height + 6));
}
%end
%hook T1SuggestsModuleHeaderView
- (void)setFrame:(CGRect)frame {
%orig(CGRectSetY(frame, frame.origin.y - 22));
}
%end
%hook YTPivotBarView
- (void)setFrame:(CGRect)frame {
%orig(CGRectSetY(frame, frame.origin.y - 40));
}
%end
%hook YTAppView
- (void)setFrame:(CGRect)frame {
%orig(CGRectMake(frame.origin.x,frame.origin.y,frame.size.width,frame.size.height + 40));
}
%end
%hook YTNGWatchLayerView
-(CGRect)miniBarFrame {
CGRect const frame = %orig;
return CGRectSetY(frame, frame.origin.y - 40);
}
%end
%end
%group YoutubeStatusBarXSpacingFix
%hook YTHeaderContentComboView
- (void)setFrame:(CGRect)frame {
%orig(CGRectSetY(frame, frame.origin.y - 20));
}
%end
%end
// Preferences.
void loadPrefs() {
@autoreleasepool {
NSDictionary const *prefs = [[NSDictionary alloc] initWithContentsOfFile:@"/var/mobile/Library/Preferences/com.ryannair05.little12.plist"];
if (prefs) {
enabled = [[prefs objectForKey:@"enabled"] boolValue];
statusBarStyle = [[prefs objectForKey:@"statusBarStyle"] integerValue];
wantsGesturesDisabledWhenKeyboard = [[prefs objectForKey:@"noGesturesForKeyboard"] boolValue];
wants11Camera = [[prefs objectForKey:@"11Camera"] boolValue];
keyboardSpacing = [[prefs objectForKey:@"keyboardSpacing"]?:@45 integerValue];
wantsiPadMultitasking = [[prefs objectForKey:@"iPadDock"] boolValue] ? [[prefs objectForKey:@"iPadMultitasking"] boolValue] : NO;
NSString const *mainIdentifier = [NSBundle mainBundle].bundleIdentifier;
NSDictionary const *appSettings = [prefs objectForKey:mainIdentifier];
if (appSettings) {
wantsKeyboardDock = [appSettings objectForKey:@"keyboardDock"] ? [[appSettings objectForKey:@"keyboardDock"] boolValue] : [[prefs objectForKey:@"keyboardDock"] boolValue];
wantsbottomInset = [appSettings objectForKey:@"bottomInset"] ? [[appSettings objectForKey:@"bottomInset"] boolValue] : [[prefs objectForKey:@"bottomInset"] boolValue];
wantsDeviceSpoofing = [appSettings objectForKey:@"deviceSpoofing"] ? [[appSettings objectForKey:@"deviceSpoofing"] boolValue] : [[prefs objectForKey:@"deviceSpoofing"] boolValue];
wantsCompatabilityMode = [appSettings objectForKey:@"compatabilityMode"] ? [[appSettings objectForKey:@"compatabilityMode"] boolValue] : [[prefs objectForKey:@"compatabilityMode"] boolValue];
} else {
wantsKeyboardDock = [[prefs objectForKey:@"keyboardDock"] boolValue];
wantsbottomInset = [[prefs objectForKey:@"bottomInset"] boolValue];
wantsDeviceSpoofing = [[prefs objectForKey:@"deviceSpoofing"] boolValue];
wantsCompatabilityMode = [[prefs objectForKey:@"compatabilityMode"] boolValue];
}
}
}
}
%ctor {
@autoreleasepool {
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)loadPrefs, CFSTR("com.ryannair05.little12prefs/prefsupdated"), NULL, CFNotificationSuspensionBehaviorCoalesce);
loadPrefs();
if (enabled) {
bool const isApp = [[[[NSProcessInfo processInfo] arguments] objectAtIndex:0] containsString:@"/Application"];
if (wantsiPadMultitasking) %init(UIKitiPadMultitasking);
if (isApp) {
NSString* const bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
if ([bundleIdentifier containsString:@"com.apple"]) {
if ([bundleIdentifier isEqualToString:@"com.apple.camera"]) {
if (wants11Camera) %init(iPhone11Cam);
else if (wantsbottomInset) %init(CameraFix);
}
}
else if (wantsbottomInset || statusBarStyle > 1) {
if ([bundleIdentifier isEqualToString:@"com.google.ios.youtube"]) {
if (wantsbottomInset || statusBarStyle == 2)
wantsCompatabilityMode = YES;
else
%init(YoutubeStatusBarXSpacingFix);
}
else if ([bundleIdentifier isEqualToString:@"com.burbn.instagram"]) {
wantsCompatabilityMode = NO;
wantsDeviceSpoofing = statusBarStyle == 2;
%init(InstagramFix)
}
else if ([bundleIdentifier isEqualToString:@"com.zhiliaoapp.musically"]) {
wantsCompatabilityMode = NO;
wantsDeviceSpoofing = YES;
statusBarStyle = 2;
}
if (statusBarStyle == 2) {
%init(StatusBarX);
if (!wantsbottomInset)
%init(bottominsetfix);
}
if (wantsCompatabilityMode) %init(CompatabilityMode);
if (wantsDeviceSpoofing) %init(BoundsHack);
}
}
if (![[NSFileManager defaultManager] fileExistsAtPath:@"/Library/MobileSubstrate/DynamicLibraries/KeyboardPlus.dylib"]) {
if (wantsKeyboardDock) %init(KeyboardDock);
else %init(ForceDefaultKeyboard);
if (wantsGesturesDisabledWhenKeyboard) {
[[NSNotificationCenter defaultCenter] addObserverForName:UIKeyboardDidShowNotification object:nil queue:nil usingBlock:^(NSNotification *n){
disableGestures = true;
}];
[[NSNotificationCenter defaultCenter] addObserverForName:UIKeyboardWillHideNotification object:nil queue:nil usingBlock:^(NSNotification *n){
disableGestures = false;
}];
%init(disableGesturesWhenKeyboard);
}
}
%init;
}
}
}