forked from twodayslate/AnySpot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspotlightanywhere.xm
executable file
·201 lines (168 loc) · 5.64 KB
/
spotlightanywhere.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
#import "FSSwitchDataSource.h"
#import "FSSwitchPanel.h"
#import "CydiaSubstrate.h"
#import <UIKit/UIKit.h>
@interface FlipSLSwitch : NSObject <FSSwitchDataSource>
@end
@interface SBSearchViewController : UIViewController
+(id)sharedInstance;
-(void)searchGesture:(id)arg1 changedPercentComplete:(float)arg2;
-(BOOL)isVisible;
-(void)loadView;
-(void)cancelButtonPressed;
-(void)searchGesture:(id)arg1 completedShowing:(BOOL)arg2 ;
-(void)_setShowingKeyboard:(BOOL)arg1 ;
-(void)_resetViewController;
-(id)_window;
@end
@interface SBSearchHeader : UIView
-(void)searchGesture:(id)arg1 changedPercentComplete:(float)arg2 ;
@end
@interface SBSearchModel
-(id)launchingURLForResult:(id)arg1 withDisplayIdentifier:(id)arg2 andSection:(id)arg3;
@end
@interface SBApplication
-(id)contextHostViewForRequester:(id)requester enableAndOrderFront:(BOOL)front;
@end
@interface SpringBoard
-(void)_menuButtonUp:(id)arg1;
-(void)_revealSpotlight;
-(void)quitTopApplication:(id)arg1 ;
-(void)applicationSuspend:(id)arg1 ;
-(BOOL)isLocked;
-(BOOL)launchApplicationWithIdentifier:(id)arg1 suspended:(BOOL)arg2 ;
@end
@interface UIApplication (extras)
-(id)_accessibilityFrontMostApplication;
@end
@interface SBSearchResultsBackdropView : UIView
@end
@interface UIWindow (extras)
+(void)setAllWindowsKeepContextInBackground:(BOOL)arg1;
-(BOOL)isInternalWindow;
@end
@interface SBRootFolderView : UIView
@end
@interface SBSearchGesture
+(id)sharedInstance;
-(void)revealAnimated:(BOOL)arg1 ;
-(void)resetAnimated:(BOOL)arg1;
@end
@interface SBIcon
-(void)launchFromLocation:(int)arg1 ;
@end
@interface SBApplicationIcon : SBIcon
@end
@implementation FlipSLSwitch
-(FSSwitchState)stateForSwitchIdentifier:(NSString *)switchIdentifier{
SBSearchViewController *vcont = [objc_getClass("SBSearchViewController") sharedInstance];
return [vcont isVisible]?FSSwitchStateOn:FSSwitchStateOff;
}
UIWindow *window = nil;
SBSearchViewController *vcont = nil;
SBRootFolderView *fv = nil;
BOOL willLaunch = FALSE;
-(void)applyState:(FSSwitchState)newState forSwitchIdentifier:(NSString *)switchIdentifier{
vcont = [objc_getClass("SBSearchViewController") sharedInstance];
SBSearchHeader *sheader = MSHookIvar<SBSearchHeader *>(vcont, "_searchHeader");
//UIView *container = MSHookIvar<UIView *>(sheader, "_container");
//UITextField *search = MSHookIvar<UITextField *>(sheader, "_searchField");
//UITableView *table = MSHookIvar<UITableView *>(vcont, "_tableView");
//SBSearchResultsBackdropView *bd = MSHookIvar<SBSearchResultsBackdropView *>(vcont, "_tableBackdrop");
//UIView *ts = MSHookIvar<UIView *>(vcont, "_touchStealingView");
UIView *view = MSHookIvar<UIView *>(vcont, "_view");
SBSearchGesture *ges = [%c(SBSearchGesture) sharedInstance];
if ([[view superview] isKindOfClass:[%c(SBRootFolderView) class]]) {
fv = (SBRootFolderView *)[view superview];
}
//NSLog(@"_view = %@",view);
//NSLog(@"_view superview = %@",[view superview]);
//NSLog(@"sbrootfolderview = %@",fv);
if(newState == FSSwitchStateIndeterminate)
return;
else if(newState == FSSwitchStateOn){
window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
window.windowLevel = 9999*999;
window.hidden = NO;
window.rootViewController = vcont;
[window addSubview:view];
//[window addSubview:sheader];
[window makeKeyAndVisible];
sheader.hidden = NO;
[sheader setAlpha:1.0];
view.hidden = NO;
[view setAlpha:1.0];
//[sheader searchGesture:nil changedPercentComplete:1.0];
//[vcont searchGesture:nil changedPercentComplete:1.0];
//[vcont searchGesture:nil completedShowing:YES];
[ges revealAnimated:TRUE];
} else if(newState == FSSwitchStateOff){
//[vcont searchGesture:nil changedPercentComplete:0.0];
//[vcont searchGesture:nil completedShowing:NO];
[ges resetAnimated:TRUE];
}
}
@end
%hook SBSearchModel
-(id)launchingURLForResult:(id)arg1 withDisplayIdentifier:(id)arg2 andSection:(id)arg3 {
NSLog(@"inside launchingURLForResult"); //not called for top hit?
if([(SpringBoard*)[%c(SpringBoard) sharedApplication] isLocked]) {
NSLog(@"is locked");
}
willLaunch = FALSE;
return %orig;
}
%end
%hook SBSearchGesture
-(void)resetAnimated:(BOOL)arg1 {
%log;
%orig;
if(window) {
[fv addSubview:[[window subviews] objectAtIndex:0]];
[window release];
window = nil;
}
}
%end
%hook UIApplication
-(BOOL)launchApplicationWithIdentifier:(id)arg1 suspended:(BOOL)arg2 {
%log;
return %orig;
if(window) {
[fv addSubview:[[window subviews] objectAtIndex:0]];
[window release];
window = nil;
}
}
%end
%hook SBSearchViewController
-(void)tableView:(id)arg1 didSelectRowAtIndexPath:(id)arg2 {
%log;
willLaunch = TRUE;
%orig;
//willLaunch = TRUE;
}
%end
%hook SpringBoard
-(BOOL)_launchApplicationWithIdentifier:(id)arg1 suspended:(BOOL)arg2 {
%log;
return %orig;
}
-(BOOL)launchApplicationWithIdentifier:(id)arg1 suspended:(BOOL)arg2 {
%log;
return %orig;
}
-(BOOL)_accessibilityShouldAllowAppLaunch { %log; return %orig;}
%end
%hook SBApplicationIcon
- (void)launchFromLocation:(int)location { //0 = SB, 4 = SP
%log;
NSLog(@"displayIdentifier = %@",MSHookIvar<UIView *>(self, "_displayIdentifier"));
if (willLaunch) {
willLaunch = FALSE;
[(SpringBoard *)[UIApplication sharedApplication] launchApplicationWithIdentifier:MSHookIvar<UIView *>(self, "_displayIdentifier") suspended:NO];
}
%orig;
}
-(void)launch { %log; %orig; }
%end