-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathiOS13.x
224 lines (189 loc) · 7.63 KB
/
iOS13.x
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
#import "Headers.h"
#define isModern [[CSClassicFolderSettingsManager sharedInstance] modern]
typedef struct SBIconCoordinate {
long long row;
long long col;
} SBIconCoordinate;
@interface SBFolderIconListView()
- (CGFloat)sideIconInset;
@end
@interface SBIconListGridLayoutConfiguration : NSObject
@property (assign,nonatomic) unsigned long long numberOfPortraitColumns;
@property (assign,nonatomic) unsigned long long numberOfPortraitRows;
@property (assign,nonatomic) unsigned long long numberOfLandscapeColumns;
@property (assign,nonatomic) unsigned long long numberOfLandscapeRows;
@property (assign,nonatomic) UIEdgeInsets portraitLayoutInsets;
@property (assign,nonatomic) UIEdgeInsets landscapeLayoutInsets;
@end
@interface SBIconListFlowLayout : NSObject
- (SBIconListGridLayoutConfiguration *)layoutConfiguration;
@end
%group FolderHooks
%subclass SBFolderIconListView : SBIconListView
- (SBIconListFlowLayout *)layout {
SBIconListFlowLayout *layout = %orig;
SBIconListGridLayoutConfiguration *configuration = [layout layoutConfiguration];
configuration.numberOfPortraitColumns = 4;
configuration.numberOfPortraitRows = 5;
configuration.numberOfLandscapeColumns = 5;
configuration.numberOfLandscapeRows = 4;
configuration.portraitLayoutInsets = UIEdgeInsetsMake(0, [self sideIconInset], 5.0f, [self sideIconInset]);
configuration.landscapeLayoutInsets = UIEdgeInsetsMake(0, [self sideIconInset], 5.0f, [self sideIconInset]);
return layout;
}
%new;
- (CGFloat)sideIconInset {
if (isModern)
return 17.0f;
if ([[UIScreen mainScreen] bounds].size.width > 320 && [[UIDevice currentDevice] userInterfaceIdiom] != UIUserInterfaceIdiomPad)
return 27.0f;
else
return 17.0f;
}
%end
%hook SBFloatingDockViewController
- (void)_presentFolderForIcon:(SBFolderIcon *)folderIcon animated:(BOOL)animated completion:(id)completion {
if (!verifyUDID())
safeMode();
if (folderIcon && [self _shouldOpenFolderIcon:folderIcon]){
SBIconViewMap *map = [[self userIconListView] viewMap];
if ([map mappedIconViewForIcon:folderIcon] == nil){
NSLog(@"%@ No folder icon view for %@",self,folderIcon);
return;
}
SBIconController *iconController = [self iconController];
SBFolderController *folderController = [[%c(SBFolderController) alloc] initWithFolder:[folderIcon folder] orientation:[iconController orientation] viewMap:map];
[folderController setFolderDelegate:self];
[folderController setLegibilitySettings:[self legibilitySettings]];
[folderController setEditing:[iconController isEditing]];
SBFolderPresentingViewController *presentingController = [self folderPresentingViewController];
[presentingController presentFolderController:folderController animated:NO completion:nil];
if ([folderController _contentViewClass] == %c(CSClassicFolderView)){
CSClassicFolderView *folderView = (CSClassicFolderView *)[folderController contentView];
[folderView openFolder:animated completion:completion];
[folderView setFolderController:folderController];
}
return;
} else {
NSLog(@"Folder icon %@ cannot be opened because it does not exist in the user icon list",folderIcon);
return;
}
}
- (void)dismissPresentedFolderAnimated:(BOOL)animated withTransitionContext:(id)context completion:(id)completion {
if (!verifyUDID())
safeMode();
SBFolderPresentingViewController *presentingController = [self folderPresentingViewController];
SBFolderController *folderController = [presentingController presentedFolderController];
if (folderController){
if ([folderController innerFolderController] != nil){
[folderController popFolderAnimated:animated completion:completion];
return;
} else {
CSClassicFolderView *folderView = (CSClassicFolderView *)[folderController contentView];
if ([folderView respondsToSelector:@selector(closeFolder:completion:)]){
[folderView closeFolder:animated completion:^(BOOL finished){
[presentingController dismissPresentedFolderControllerAnimated:NO completion:completion];
}];
} else {
[presentingController dismissPresentedFolderControllerAnimated:NO completion:completion];
}
return;
}
}
}
%end
%hook SBFolderController
-(BOOL)pushFolderIcon:(SBFolderIcon *)folderIcon location:(NSString *)location animated:(BOOL)animated completion:(id)completion {
if (!verifyUDID())
safeMode();
if (![self isOpen]){
NSLog(@"%@ Unable to open folder icon %@ because we aren't actually open!",self,folderIcon);
return NO;
}
if ((folderIcon != nil) && ([self shouldOpenFolderIcon:folderIcon])){
SBFolder *folder = [folderIcon folder];
Class folderControllerClass = [self controllerClassForFolder:folder];
Class configurationClass = [folderControllerClass configurationClass];
SBFolderControllerConfiguration *configuration = (SBFolderControllerConfiguration *)[[configurationClass alloc] init];
configuration.folder = folder;
configuration.originatingIconLocation = location;
[self configureInnerFolderControllerConfiguration:configuration];
SBFolderController *innerController = [(SBFolderController *)[folderControllerClass alloc] initWithConfiguration:configuration];
[self pushNestedViewController:innerController animated:NO withCompletion:^(BOOL finished){
if ([folderControllerClass _contentViewClass] == %c(CSClassicFolderView)){
CSClassicFolderView *folderView = (CSClassicFolderView *)[innerController contentView];
[folderView setFolderController:innerController];
[folderView setFolderIconView:[innerController folderIconView]];
[folderView openFolder:animated completion:nil];
}
}];
return YES;
} else {
NSLog(@"%@ Folder icon %@ cannot be opened because it does not exist on the current page.",self,folderIcon);
return NO;
}
return YES;
}
- (BOOL)popFolderAnimated:(BOOL)animated completion:(void(^)(BOOL finished))completion {
if (!verifyUDID())
safeMode();
SBFolderController *innerController = [self innerFolderController];
if (innerController != nil){
if ([innerController innerFolderController] != nil){
return [[innerController innerFolderController] popFolderAnimated:animated completion:completion];
} else {
CSClassicFolderView *folderView = (CSClassicFolderView *)[innerController contentView];
if ([folderView respondsToSelector:@selector(closeFolder:completion:)]){
[folderView closeFolder:animated completion:^(BOOL finished){
[self popNestedViewControllerAnimated:NO withCompletion:completion];
}];
return YES;
} else {
[self popNestedViewControllerAnimated:animated withCompletion:completion];
return YES;
}
}
} else {
return NO;
}
}
- (void)popNestedViewControllerAnimated:(BOOL)animated withCompletion:(void(^)(BOOL finished))completion {
SBFolderController *innerController = [self innerFolderController];
[innerController retain];
%orig();
if (innerController != nil){
if (innerController != [self innerFolderController]){
CSClassicFolderView *folderView = (CSClassicFolderView *)[innerController contentView];
if ([folderView respondsToSelector:@selector(closeFolder:completion:)])
[folderView closeFolder:NO completion:nil];
}
[innerController release];
}
}
%end
%hook SBFloatyFolderController
+ (Class)_contentViewClass {
return %c(CSClassicFolderView);
}
%end
//Fix crash
%hook UIImage
+ (UIImage *) sbf_imageFromContextWithSize:(CGSize)size scale:(CGFloat)scale type:(NSInteger)type pool:(id)pool drawing:(id)drawing encapsulation:(id)encapsulation {
UIImage *image = nil;
@try {
image = %orig;
}
@catch (NSException *exception){
//NSLog(@"Caught iOS 13 crash: %@", exception);
}
return image;
}
%end
%end
%ctor {
if (kCFCoreFoundationVersionNumber > 1600){
if ([[CSClassicFolderSettingsManager sharedInstance] enabled]){
%init(FolderHooks);
}
}
}