-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathTweakUI.x
70 lines (61 loc) · 2.06 KB
/
TweakUI.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
#import "UIKitPrivate.h"
#import <rootless.h>
static BOOL forcePadKBIdiom = YES, showShortcutButtonsOnKeyboard;
// Unlock iPadOS keyboard
UIUserInterfaceIdiom UIKeyboardGetSafeDeviceIdiom();
%hookf(UIUserInterfaceIdiom, UIKeyboardGetSafeDeviceIdiom) {
return forcePadKBIdiom ? UIUserInterfaceIdiomPad : %orig;
}
// Fix bottom padding
%hook UIKeyboardImpl
+ (UIEdgeInsets)deviceSpecificPaddingForInterfaceOrientation:(NSUInteger)arg1 inputMode:(id)arg2 {
forcePadKBIdiom = NO;
UIEdgeInsets result = %orig;
forcePadKBIdiom = YES;
return result;
}
%end
// Fix bottom padding when floating
%hook UIKeyboardDockView
- (CGRect)bounds {
CGRect bounds = %orig;
if (!UIDevice._hasHomeButton && UIKeyboardImpl.isFloating) {
bounds.origin.y = -25;
} else {
bounds.origin.y = 0;
}
return bounds;
}
%end
%hook UISystemInputAssistantViewController
// Fix predictive bar not occupying entire area
- (CGFloat)_centerViewWidthForTraitCollection:(id)tc interfaceOrientation:(UIInterfaceOrientation)orientation {
forcePadKBIdiom = NO;
NSInteger result = %orig;
forcePadKBIdiom = YES;
return result;
}
// Show assistant buttons when enabled
- (void)setInputAssistantButtonItemsForResponder:(id)item {
forcePadKBIdiom = showShortcutButtonsOnKeyboard;
%orig;
forcePadKBIdiom = YES;
}
%end
%hook UIInputWindowControllerHosting
- (UIEdgeInsets)_inputViewPadding {
UIEdgeInsets result = %orig;
if (!UIDevice._hasHomeButton && UIKeyboardImpl.isFloating) {
result.bottom -= 25;
}
return result;
}
%end
static void loadPrefs() {
NSMutableDictionary *settings = [[NSMutableDictionary alloc] initWithContentsOfFile:@(ROOT_PATH("/var/mobile/Library/Preferences/com.kdt.trollpad.plist"))];
showShortcutButtonsOnKeyboard = [[settings objectForKey:@"TPShowShortcutButtonsOnKeyboard"] boolValue];
}
%ctor {
loadPrefs();
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)loadPrefs, CFSTR("com.kdt.trollpad/saved"), NULL, CFNotificationSuspensionBehaviorCoalesce);
}