-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTweak.xm
48 lines (40 loc) · 1.75 KB
/
Tweak.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
#import <substrate.h>
#import <UIKit/UIKit.h>
@interface SBSearchHeader
@property(readonly, retain, nonatomic) UITextField *searchField;
@end
@interface SpringBoard
- (void)setNextAssistantRecognitionStrings:(id)arg1;
@end
@interface SBAssistantController
+ (id)sharedInstance;
- (void)handleSiriButtonUpEventFromSource:(int)arg1;
- (_Bool)handleSiriButtonDownEventFromSource:(int)arg1 activationEvent:(int)arg2;
@end
@interface SBSearchViewController
- (void)dismissAnimated:(_Bool)arg1 completionBlock:(id)arg2;
- (void)_searchFieldEditingChanged;
@end
%hook SBSearchViewController
- (void)_searchFieldReturnPressed {
SBSearchHeader *_searchHeader = MSHookIvar<SBSearchHeader*>(self, "_searchHeader");
UITextField *searchField = _searchHeader.searchField;
NSString *searchString = [searchField.text lowercaseString];
if ([searchString hasPrefix:@"siri"]) {
NSString *searchStringWithoutSiri = [searchString
stringByReplacingOccurrencesOfString:@"siri" withString:@""];
if (![[searchStringWithoutSiri stringByReplacingOccurrencesOfString:@" " withString:@""] isEqual:@""]) {
NSArray *myStrings = [NSArray arrayWithObjects:searchStringWithoutSiri, nil];
[(SpringBoard *)[UIApplication sharedApplication] setNextAssistantRecognitionStrings:myStrings];
}
SBAssistantController *assistantController = [%c(SBAssistantController) sharedInstance];
[assistantController handleSiriButtonDownEventFromSource:1 activationEvent:1];
[assistantController handleSiriButtonUpEventFromSource:1];
searchField.text = @"";
[self _searchFieldEditingChanged];
[self dismissAnimated:YES completionBlock:nil];
} else {
%orig;
}
}
%end