From 55ad1cc9b0c7bc564df180d3f73ac19d56006d13 Mon Sep 17 00:00:00 2001 From: gilshahar7 Date: Sat, 18 Feb 2017 12:11:50 +0200 Subject: [PATCH] Initial release --- Makefile | 12 ++++++++++ SpotlightSiri10.plist | 1 + Tweak.xm | 55 +++++++++++++++++++++++++++++++++++++++++++ control | 9 +++++++ 4 files changed, 77 insertions(+) create mode 100644 Makefile create mode 100644 SpotlightSiri10.plist create mode 100644 Tweak.xm create mode 100644 control diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5ff093a --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +ARCHS = armv7 arm64 +DEBUG = 0 +include $(THEOS)/makefiles/common.mk + +TWEAK_NAME = SpotlightSiri10 +SpotlightSiri10_FILES = Tweak.xm +SpotlightSiri10_FRAMEWORKS = UIKit + +include $(THEOS_MAKE_PATH)/tweak.mk + +after-install:: + install.exec "killall -9 SpringBoard" diff --git a/SpotlightSiri10.plist b/SpotlightSiri10.plist new file mode 100644 index 0000000..10dc654 --- /dev/null +++ b/SpotlightSiri10.plist @@ -0,0 +1 @@ +{ Filter = { Bundles = ( "com.apple.springboard" ); }; } diff --git a/Tweak.xm b/Tweak.xm new file mode 100644 index 0000000..87ba143 --- /dev/null +++ b/Tweak.xm @@ -0,0 +1,55 @@ +#import +#import + +@interface SPUITextField:UITextField +@end + +@interface SPUISearchHeader +@property (retain) SPUITextField * 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 SPUISearchViewController +- (void)cancelButtonPressed; +@end +static SpringBoard *springBoard = nil; +%hook SpringBoard + +- (void)applicationDidFinishLaunching:(id)fp8 { + %orig; + springBoard = self; +} +%end + +%hook SPUISearchViewController + +- (void)cancelButtonPressed{ + SPUISearchHeader *_searchHeader = MSHookIvar(self, "_searchHeader"); + SPUITextField *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 setNextAssistantRecognitionStrings:myStrings]; + } + SBAssistantController *assistantController = [%c(SBAssistantController) sharedInstance]; + [assistantController handleSiriButtonDownEventFromSource:1 activationEvent:1]; + [assistantController handleSiriButtonUpEventFromSource:1]; + searchField.text = @""; + } + %orig; +} + +%end \ No newline at end of file diff --git a/control b/control new file mode 100644 index 0000000..79d976f --- /dev/null +++ b/control @@ -0,0 +1,9 @@ +Package: com.gilshahar7.spotlightsiri10 +Name: SpotlightSiri10 +Depends: mobilesubstrate +Version: 1.1 +Architecture: iphoneos-arm +Description: Use Siri by prefixing Spotlight searches with "Siri" and pressing cancel. +Maintainer: gilshahar7 +Author: gilshahar7 +Section: Tweaks