forked from shrugs/ClearOnOpen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTweak.xm
executable file
·136 lines (108 loc) · 3.61 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
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
// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
// Version 2, December 2004
//
// Copyright (C) 2015 @wolfposd (Mordred666)
//
// Everyone is permitted to copy and distribute verbatim or modified
// copies of this license document, and changing it is allowed as long
// as the name is changed.
//
// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
// TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
//
// 0. You just DO WHAT THE FUCK YOU WANT TO.
#import "headerIOS910.h"
#import "headerIOS78.h"
#import "headerIOS6.h"
#import "substrate.h"
// =============================================================================
// iOS10
// =============================================================================
%group iOS10
%hook SPUISearchViewController
- (bool)clearSearchFieldAfterDismissal
{
return YES;
}
%end // hook SPUISearchViewController
%end // group iOS10
// =============================================================================
// iOS9
// =============================================================================
%group iOS9
%hook SPUISearchViewController
- (void)_didFinishDismissing
{
[self _clearSearchResults];
[self _searchFieldEditingChanged];
%orig;
}
%end // hook SPUISearchViewController
%end // group iOS9
// =============================================================================
// iOS7+8
// =============================================================================
%group iOS7
%hook SBSearchViewController
- (void)searchGesture:(id)arg1 completedShowing:(BOOL)arg2 {
%orig;
if (!arg2) {
SBSearchHeader *h = MSHookIvar<SBSearchHeader *>(self, "_searchHeader");
if (h) {
[h searchField].text = @"";
[self _searchFieldEditingChanged];
}
}
}
%end // hook SBSearchViewController
%end // group iOS7
// =============================================================================
// iOS6
// =============================================================================
%group iOS6
static SBSearchController *sbSearchController;
%hook SBSearchController
- (id)init{
if ((self = %orig) != nil) {
//do stuff
sbSearchController = self;
}
return self;
}
%end // hook SBSearchController
%hook SBSearchView
//make search bar's text nil on init
- (void)addTableView
{
[self searchBar].text = nil;
//- (void)searchBar:(id)arg1 textDidChange:(id)arg2;
[sbSearchController searchBar:self textDidChange:nil];
//- (void)setShowsKeyboard:(BOOL)arg1 animated:(BOOL)arg2;
[self setShowsKeyboard:YES animated:YES];
%orig;
}
%end // hook SBSearchView
%end // group iOS6
// =============================================================================
// group initializer
// =============================================================================
%ctor
{
//float sysVersion = [[[UIDevice currentDevice] systemVersion] floatValue];
if(kCFCoreFoundationVersionNumber >= 1300) // iOS 10
{
%init(iOS10);
}
else if(kCFCoreFoundationVersionNumber >= 1200) // iOS 9
{
%init(iOS9);
}
else if (kCFCoreFoundationVersionNumber >= 847) // iOS7 + 8
{
%init(iOS7);
}
else
{
%init(iOS6);
}
}