You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 line
1.6KB

  1. #import <substrate.h>
  2. #import <UIKit/UIKit.h>
  3. @interface SPUITextField:UITextField
  4. @end
  5. @interface SPUISearchHeader
  6. @property (retain) SPUITextField * searchField;
  7. -(void)cancelButtonClicked:(id)arg1;
  8. @end
  9. @interface SpringBoard
  10. - (void)setNextAssistantRecognitionStrings:(id)arg1;
  11. @end
  12. @interface SBAssistantController
  13. + (id)sharedInstance;
  14. - (void)handleSiriButtonUpEventFromSource:(int)arg1;
  15. - (_Bool)handleSiriButtonDownEventFromSource:(int)arg1 activationEvent:(int)arg2;
  16. @end
  17. static SpringBoard *springBoard = nil;
  18. %hook SpringBoard
  19. - (void)applicationDidFinishLaunching:(id)fp8 {
  20. %orig;
  21. springBoard = self;
  22. }
  23. %end
  24. %hook SPUISearchHeader
  25. -(BOOL)textFieldShouldReturn:(id)arg1{
  26. SPUITextField *searchField = self.searchField;
  27. NSString *searchString = [searchField.text lowercaseString];
  28. if ([searchString hasPrefix:@"siri"]) {
  29. NSString *searchStringWithoutSiri = [searchString
  30. stringByReplacingOccurrencesOfString:@"siri" withString:@""];
  31. if (![[searchStringWithoutSiri stringByReplacingOccurrencesOfString:@" " withString:@""] isEqual:@""]) {
  32. NSArray *myStrings = [NSArray arrayWithObjects:searchStringWithoutSiri, nil];
  33. [springBoard setNextAssistantRecognitionStrings:myStrings];
  34. }
  35. SBAssistantController *assistantController = [%c(SBAssistantController) sharedInstance];
  36. [assistantController handleSiriButtonDownEventFromSource:1 activationEvent:1];
  37. [assistantController handleSiriButtonUpEventFromSource:1];
  38. searchField.text = @"";
  39. [self cancelButtonClicked:nil];
  40. }
  41. return %orig(arg1);
  42. }
  43. %end