-
Notifications
You must be signed in to change notification settings - Fork 3
/
9.xm
117 lines (90 loc) · 3.16 KB
/
9.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
@class Application, BrowserController, TabController, TabDocument, TiltedTabView;
@interface Application
// Returns the current Application
+ (instancetype)sharedApplication;
// Called when the app resumes from the background
- (void)applicationDidBecomeActive:(UIApplication *)application;
// Called when the app finishes launching
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions;
// Implemented by this tweak
// Brings up the keyboard
- (void)typeTab;
@end
@interface BrowserController
// Returns the current BrowserController
+ (instancetype)sharedBrowserController;
// Brings up the keyboard, use of arg1 us unknown
- (void)navigationBarURLWasTapped:(id)arg1;
// Called on iPad?
- (void)addTabFromButtonBar;
// Returns the current TabController
- (TabController *)tabController;
// Gets the state of private browsing
- (BOOL)privateBrowsingEnabled;
//Determins of the tab view is currently showing
- (BOOL)isShowingTabView;
@end
@interface TabController
// Called when the + button in the TiltedTabView on iPhone is pressed
- (void)_addNewActiveTiltedTabViewTab;
// Returns the currently displayed TabDocument
- (TabDocument *)activeTabDocument;
// Returns the currently loaded TabDocuments
- (NSArray *)currentTabDocuments;
// Returns the tilted tab view if running on an iPhone
- (TiltedTabView *)tiltedTabView;
@end
@interface TabDocument
// Returns if the document is blank or not
- (BOOL)isBlankDocument;
@end
// iOS 9.0+ code
%group 9
%hook Application
// Shows the keyboard if the current tab is blank
%new
- (void)typeTab {
if ([[%c(BrowserController) sharedBrowserController] tabController].activeTabDocument.isBlankDocument && ![[%c(BrowserController) sharedBrowserController] isShowingTabView]) {
[[%c(BrowserController) sharedBrowserController] navigationBarURLWasTapped:nil];
}
}
// Show keyboard on resume if the current tab is blank
- (void)applicationDidBecomeActive:(UIApplication *)application {
%orig;
[self typeTab];
}
// Show keyboard on launch if the current tab is blank
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
BOOL orig = %orig;
[self typeTab];
return orig;
}
// 3D Touch shortcut support
- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL succeeded))completionHandler {
%orig;
if ([shortcutItem.type isEqualToString:@"com.apple.mobilesafari.shortcut.openNewTab"] || [shortcutItem.type isEqualToString:@"com.apple.mobilesafari.shortcut.openNewPrivateTab"]) {
[[%c(BrowserController) sharedBrowserController] navigationBarURLWasTapped:nil];
}
}
%end
// Called on iPad
%hook BrowserController
- (void)addTabFromButtonBar {
%orig;
[[%c(Application) sharedApplication] typeTab];
}
%end
// Called on iPhone
%hook TabController
- (void)_addNewActiveTiltedTabViewTab {
%orig;
[[%c(Application) sharedApplication] typeTab];
}
%end
%end
%ctor {
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 9.0 &&
[[[UIDevice currentDevice] systemVersion] floatValue] < 10.0) {
%init(9);
}
}