-
Notifications
You must be signed in to change notification settings - Fork 3
/
Tweak.xm
executable file
·581 lines (517 loc) · 22.3 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
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
//Created by LonestarX © 2018
#import <UIKit/UIKit.h>
#import <SpringBoard/SpringBoard.h>
#import <SpringBoard/SBFolderView.h>
#import <libcolorpicker.h>
#import <AudioToolbox/AudioToolbox.h>
#import <AudioToolbox/AudioServices.h>
FOUNDATION_EXTERN void AudioServicesPlaySystemSoundWithVibration(unsigned long, objc_object*, NSDictionary*);
#define kIdentifier @"com.lnx.leadmehome"
#define kSettingsChangedNotification (CFStringRef)@"com.lnx.leadmehome/ReloadPrefs"
#define kColorChangedNotification (CFStringRef)@"com.lnx.leadmehome/colorChanged"
#define kSettingsResetNotification (CFStringRef)@"com.lnx.leadmehome/settingsReset"
#define kColorPath @"/var/mobile/Library/Preferences/com.lnx.leadmehome.color.plist"
#define kSettingsPath @"/var/mobile/Library/Preferences/com.lnx.leadmehome.plist"
@interface SBIcon : NSObject
-(id)applicationBundleID;
@end
@interface SBFolderIcon
-(id)children;
-(id)folder;
-(id)rootFolder;
@end
@interface SBFolder : NSObject
-(SBFolder *)parentFolder;
-(void)setOpen:(BOOL)arg1 ;
-(SBFolderIcon *)icon;
@end
@interface SBRootFolder : SBFolder
-(id)children;
-(id)nodeIdentifier;
-(NSString *)displayName;
@end
@interface SBRootFolderWithDock : SBRootFolder
@end
@class SBRootFolder;
@interface SBRootFolderView
@property (nonatomic,retain) SBRootFolderWithDock * folder;
-(id)iconListViewAtIndex:(unsigned long long)arg1 ;
-(NSArray *)iconListViews;
-(unsigned long long)iconListViewCount;
@end
@interface SPUISearchHeader
-(void)cancelButtonClicked:(id)arg1 ;
@end
@interface SPUISearchViewController : UIViewController
@end
@interface SBSpotlightNavigationController : UINavigationController
@end
@interface SBIsolationTankController : UIViewController
@end
@interface SBHomeScreenViewController : UIViewController
@end
@interface SFSearchResult : NSObject
@property (nonatomic,copy) NSString * identifier;
@end
@interface SBIconView : UIView
+(id)_jitterPositionAnimation;
+(id)_jitterTransformAnimation;
+(id)_jitterXTranslationAnimation;
+(id)_jitterYTranslationAnimation;
-(SBIcon *)icon;
@end
@interface SBIconViewMap : NSObject
-(id)mappedIconViewForIcon:(id)arg1 ;
-(id)_iconViewForIcon:(id)arg1 ;
-(id)allIcons;
@end
@interface SBIconController : UIViewController
+(id)sharedInstance;
-(void)openFolderIcon:(id)arg1 animated:(BOOL)arg2 withCompletion:(/*^block*/id)arg3;
-(id)_rootFolderController;
-(id)_currentFolderController;
-(id)dockListView;
@end
@interface SBRootFolderController
@property (nonatomic,readonly) SBRootFolderView * contentView;
-(BOOL)setCurrentPageIndex:(long long)arg1 animated:(BOOL)arg2 completion:(/*^block*/id)arg3 ;
-(BOOL)setCurrentPageIndex:(long long)arg1 animated:(BOOL)arg2;
@property (nonatomic,readonly) long long currentPageIndex;
@end
@interface SBIconIndexMutableList : NSObject
@end
@interface SBRootIconListView : UIView
@end
@interface SBIconListModel : NSObject
-(NSArray *)children;
@end
@interface SBApplicationIcon : SBIcon
-(id)applicationBundleID;
@end
@interface SBSearchEtceteraNavigationController : UINavigationController
@end
@interface SBSearchEtceteraIsolatedViewController : UIViewController
@end
@interface SBFolderController
-(BOOL)setCurrentPageIndex:(long long)arg1 animated:(BOOL)arg2 ;
-(void)setOpen:(BOOL)arg1 ;
-(SBIconViewMap *)viewMap;
-(BOOL)setCurrentPageIndex:(long long)arg1 animated:(BOOL)arg2 completion:(/*^block*/id)arg3 ;
@end
static NSInteger wantedFolderPageIndex = 0;
static SBFolderIcon *wantedFolder = nil;
static NSInteger wantedScreenIndex = 0;
static NSString *searchedBundle;
static SBIcon *desiredIcon;
static NSTimer *nukeAnimTimer;
static UIColor *glowColor;
static BOOL slamVibration;
static BOOL glowEnabled;
static NSInteger animType;
static SBIconView *targetIV;
static SBFolderIcon* findIcon(SBFolderIcon *fIcon) {
SBFolder *ficonFolder = fIcon.folder;
SBIconIndexMutableList *sbfIconList = [ficonFolder valueForKey:@"_lists"];
NSMutableArray *folderNodesArray = [sbfIconList valueForKey:@"_nodes"];
//searching all the pages in the current folder
for (int k = 0; k < folderNodesArray.count; k++) {
SBIconListModel *folderIconModel = folderNodesArray[k];
SBIconIndexMutableList *folderIconIndexList = [folderIconModel valueForKey:@"_icons"];
NSMutableArray *folderContentIcons = [folderIconIndexList valueForKey:@"_nodes"];
//searching all the icons in the current page
for (int m = 0; m < folderContentIcons.count; m++) {
if (![folderContentIcons[m] isKindOfClass:%c(SBFolderIcon)]) {
SBIcon *appIcon = folderContentIcons[m];
if ([[appIcon applicationBundleID] isEqualToString:searchedBundle]) {
desiredIcon = appIcon;
wantedFolder = fIcon;
wantedFolderPageIndex = k;
return wantedFolder;
}
}
}
//no icon found in the current folder, searching inside folders
for (int m = 0; m < folderContentIcons.count; m++) {
if ([folderContentIcons[m] isKindOfClass:%c(SBFolderIcon)]) {
findIcon(folderContentIcons[m]);
}
}
}
return nil;
}
static void wiggleMe(SBIconView *targetIconView) {
targetIV = targetIconView;
NSString *iconImgvKey = @"_currentImageView";
if ((kCFCoreFoundationVersionNumber >= 1443.00)) {
iconImgvKey = @"currentImageView";
}
UIView *curImgv = [targetIconView valueForKey:iconImgvKey];
__weak UIView *weakImgv = curImgv;
dispatch_async(dispatch_get_main_queue(), ^{
CALayer *iconImageLayer = weakImgv.layer;
if (glowEnabled) {
iconImageLayer.shadowColor = glowColor.CGColor;
iconImageLayer.shadowRadius = 5;
iconImageLayer.shadowOpacity = 1;
iconImageLayer.shadowOffset = CGSizeZero;
}
nukeAnimTimer = [NSTimer scheduledTimerWithTimeInterval:5 repeats:NO block:^(NSTimer * _Nonnull timer) {
[iconImageLayer removeAllAnimations];
iconImageLayer.shadowOpacity = 0;
iconImageLayer.shadowColor = [UIColor clearColor].CGColor;
iconImageLayer.shadowRadius = 0;
}];
if (animType == 0) {
[CATransaction begin];
[CATransaction setCompletionBlock:^{
CABasicAnimation *radiusAnimation = [CABasicAnimation animationWithKeyPath:@"shadowRadius"];
radiusAnimation.beginTime = 0;
radiusAnimation.duration = 0.7;
radiusAnimation.fromValue = [NSNumber numberWithFloat:5.0f];
radiusAnimation.toValue = [NSNumber numberWithFloat:40.0f];
radiusAnimation.removedOnCompletion = NO;
radiusAnimation.fillMode = kCAFillModeBoth;
radiusAnimation.additive = NO;
[weakImgv.layer addAnimation:radiusAnimation forKey:@"dustSpreadAnim"];
CABasicAnimation *opacityAnimation = [CABasicAnimation animationWithKeyPath:@"shadowOpacity"];
opacityAnimation.beginTime = 0;
opacityAnimation.duration = 0.6;
opacityAnimation.fromValue = [NSNumber numberWithFloat:1.0f];
opacityAnimation.toValue = [NSNumber numberWithFloat:0.0f];
opacityAnimation.removedOnCompletion = NO;
opacityAnimation.fillMode = kCAFillModeBoth;
opacityAnimation.additive = NO;
[weakImgv.layer addAnimation:opacityAnimation forKey:@"dustFadeAnim"];
if ((kCFCoreFoundationVersionNumber < 1443.00)) {
if (![weakImgv.layer animationForKey:@"iconFoundTransformAnimation"]) {
[weakImgv.layer addAnimation:[%c(SBIconView) _jitterTransformAnimation] forKey:@"iconFoundTransformAnimation"];
}
if (![weakImgv.layer animationForKey:@"iconFoundPositionAnimation"]) {
[weakImgv.layer addAnimation:[%c(SBIconView) _jitterPositionAnimation] forKey:@"iconFoundPositionAnimation"];
}
}
else {
if (![weakImgv.layer animationForKey:@"iconFoundTransformAnimation"]) {
[weakImgv.layer addAnimation:[%c(SBIconView) _jitterXTranslationAnimation] forKey:@"iconFoundTransformAnimation"];
}
if (![weakImgv.layer animationForKey:@"iconFoundPositionAnimation"]) {
[weakImgv.layer addAnimation:[%c(SBIconView) _jitterYTranslationAnimation] forKey:@"iconFoundPositionAnimation"];
}
}
if (slamVibration) {
NSMutableDictionary* dict = [NSMutableDictionary dictionary];
NSMutableArray* arr = [NSMutableArray array];
[arr addObject:[NSNumber numberWithBool:YES]];
[arr addObject:[NSNumber numberWithInt:50]];
[arr addObject:[NSNumber numberWithBool:NO]];
[arr addObject:[NSNumber numberWithInt:50]];
[dict setObject:arr forKey:@"VibePattern"];
[dict setObject:[NSNumber numberWithFloat:.35] forKey:@"Intensity"];
AudioServicesPlaySystemSoundWithVibration(1352, nil, dict);
}
[NSTimer scheduledTimerWithTimeInterval:0.2 repeats:NO block:^(NSTimer * _Nonnull timer) {
[weakImgv.layer removeAnimationForKey:@"iconFoundTransformAnimation"];
[weakImgv.layer removeAnimationForKey:@"iconFoundPositionAnimation"];
}];
}];
CAKeyframeAnimation * transformAnim = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
transformAnim.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0, 1.0, 1)],
[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.7, 1.7, 1)],
[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0, 1.0, 1)]];
transformAnim.keyTimes = @[@0, @0.8, @0.85];
transformAnim.duration = 0.85;
[iconImageLayer addAnimation:transformAnim forKey:@"slamAnimation"];
[CATransaction commit];
}
else if (animType == 1) {
if ((kCFCoreFoundationVersionNumber < 1443.00)) {
if (![weakImgv.layer animationForKey:@"iconFoundTransformAnimation"]) {
[weakImgv.layer addAnimation:[%c(SBIconView) _jitterTransformAnimation] forKey:@"iconFoundTransformAnimation"];
}
if (![weakImgv.layer animationForKey:@"iconFoundPositionAnimation"]) {
[weakImgv.layer addAnimation:[%c(SBIconView) _jitterPositionAnimation] forKey:@"iconFoundPositionAnimation"];
}
}
else {
if (![weakImgv.layer animationForKey:@"iconFoundTransformAnimation"]) {
[weakImgv.layer addAnimation:[%c(SBIconView) _jitterXTranslationAnimation] forKey:@"iconFoundTransformAnimation"];
}
if (![weakImgv.layer animationForKey:@"iconFoundPositionAnimation"]) {
[weakImgv.layer addAnimation:[%c(SBIconView) _jitterYTranslationAnimation] forKey:@"iconFoundPositionAnimation"];
}
}
}
else if (animType == 2) {
CABasicAnimation *radiusAnimation = [CABasicAnimation animationWithKeyPath:@"shadowRadius"];
radiusAnimation.beginTime = 0;
radiusAnimation.duration = 1;
radiusAnimation.fromValue = [NSNumber numberWithFloat:5.0f];
radiusAnimation.toValue = [NSNumber numberWithFloat:30.0f];
radiusAnimation.removedOnCompletion = NO;
radiusAnimation.fillMode = kCAFillModeForwards;
radiusAnimation.autoreverses = YES;
radiusAnimation.repeatCount = HUGE_VALF;
[iconImageLayer addAnimation:radiusAnimation forKey:@"dustSpreadAnim"];
}
else if (animType == 3) {
CABasicAnimation *radiusAnimation = [CABasicAnimation animationWithKeyPath:@"shadowRadius"];
radiusAnimation.beginTime = 0;
radiusAnimation.duration = 1;
radiusAnimation.fromValue = [NSNumber numberWithFloat:5.0f];
radiusAnimation.toValue = [NSNumber numberWithFloat:30.0f];
radiusAnimation.removedOnCompletion = NO;
radiusAnimation.fillMode = kCAFillModeForwards;
radiusAnimation.autoreverses = YES;
radiusAnimation.repeatCount = HUGE_VALF;
[iconImageLayer addAnimation:radiusAnimation forKey:@"dustSpreadAnim"];
if ((kCFCoreFoundationVersionNumber < 1443.00)) {
if (![weakImgv.layer animationForKey:@"iconFoundTransformAnimation"]) {
[weakImgv.layer addAnimation:[%c(SBIconView) _jitterTransformAnimation] forKey:@"iconFoundTransformAnimation"];
}
if (![weakImgv.layer animationForKey:@"iconFoundPositionAnimation"]) {
[weakImgv.layer addAnimation:[%c(SBIconView) _jitterPositionAnimation] forKey:@"iconFoundPositionAnimation"];
}
}
else {
if (![weakImgv.layer animationForKey:@"iconFoundTransformAnimation"]) {
[weakImgv.layer addAnimation:[%c(SBIconView) _jitterXTranslationAnimation] forKey:@"iconFoundTransformAnimation"];
}
if (![weakImgv.layer animationForKey:@"iconFoundPositionAnimation"]) {
[weakImgv.layer addAnimation:[%c(SBIconView) _jitterYTranslationAnimation] forKey:@"iconFoundPositionAnimation"];
}
}
}
});
}
@interface SBDockIconListView : SBRootIconListView
-(SBIconListModel *)model;
@end
static void doTheMagic(id self) {
if ([nukeAnimTimer isValid]) {
[nukeAnimTimer invalidate];
nukeAnimTimer = nil;
}
searchedBundle = [[self result] identifier];
SBIconController *iconCT = [%c(SBIconController) sharedInstance];
SBRootFolderController *rootFolderCT = [iconCT valueForKey:@"_rootFolderController"];
SBRootFolderView *rootFV = rootFolderCT.contentView;
NSArray *iconLVs = [rootFV iconListViews];
//first searching the dock, for optimisation reasons aka starting from the fastest search up
SBDockIconListView *dockLV = [iconCT dockListView];
for (SBIcon *dockIcon in [[dockLV model] children]) {
if ([[dockIcon applicationBundleID] isEqualToString:[[self result] identifier]]) {
desiredIcon = dockIcon;
wantedScreenIndex = rootFolderCT.currentPageIndex;
goto done;
}
}
//nothing found in the dock, proceeding further
//searching all the pages on homescreen
for (int i = 0; i < iconLVs.count; i++) {
SBRootIconListView *lv = iconLVs[i];
SBIconListModel *iconModel = [lv valueForKey:@"_model"];
SBIconIndexMutableList *iconIndexList = [iconModel valueForKey:@"_icons"];
NSMutableArray *nodesArray = [iconIndexList valueForKey:@"_nodes"];
for (int j = 0; j < nodesArray.count; j++) {
//searching all the icons in the current page
SBIcon *icon = nodesArray[j];
if (![icon isKindOfClass:%c(SBFolderIcon)]) {
//icon is not folder, checking match
if ([[icon applicationBundleID] isEqualToString:[[self result] identifier]]) {
//icon found, done searching
desiredIcon = icon;
wantedScreenIndex = i;
goto done;
}
}
}
//no icon match found in current page, searching folders
for (int j = 0; j < nodesArray.count; j++) {
SBIcon *icon = nodesArray[j];
if ([icon isKindOfClass:%c(SBFolderIcon)]) {
if(findIcon((SBFolderIcon *)icon)) {
wantedScreenIndex = i;
goto done;
}
}
}
}
done:;
//Magic done, going to the icon
SBIsolationTankController *sbITC = (SBIsolationTankController *)[self window].rootViewController;
if ((kCFCoreFoundationVersionNumber >= 1443.00)) {
SBSpotlightNavigationController *sbSNC = [sbITC valueForKey:@"_isolatedViewController"];
SPUISearchViewController *searchVC = (SPUISearchViewController *)sbSNC.topViewController;
SPUISearchHeader *searchHeader = [searchVC valueForKey:@"_searchHeader"];
[searchHeader cancelButtonClicked:nil];
}
else {
SBSearchEtceteraNavigationController *sbSENC = [sbITC valueForKey:@"_isolatedViewController"];
SBSearchEtceteraIsolatedViewController *sbSEIVC = (SBSearchEtceteraIsolatedViewController *)sbSENC.topViewController;
SPUISearchViewController *searchVC = [sbSEIVC valueForKey:@"_searchViewController"];
SPUISearchHeader *searchHeader = [searchVC valueForKey:@"_searchHeader"];
[searchHeader cancelButtonClicked:nil];
}
[rootFolderCT setCurrentPageIndex:wantedScreenIndex animated:NO];
if (wantedFolder) {
SBFolder *iteratingFolder = [[wantedFolder folder] parentFolder];
NSMutableArray *folderTreeArray = [NSMutableArray new];
[folderTreeArray addObject:wantedFolder];
while(iteratingFolder) {
if (![iteratingFolder isKindOfClass:%c(SBRootFolderWithDock)]) {
[folderTreeArray insertObject:[iteratingFolder icon] atIndex:0];
iteratingFolder = [iteratingFolder parentFolder];
}
else iteratingFolder = nil;
}
for (SBFolderIcon *obj in folderTreeArray) {
[iconCT openFolderIcon:obj animated:NO withCompletion:^{
if (obj == [folderTreeArray lastObject]) {
[[iconCT _currentFolderController] setCurrentPageIndex:wantedFolderPageIndex animated:NO];
SBIconView *targetIconView = [[[iconCT _currentFolderController] viewMap] mappedIconViewForIcon:desiredIcon];
wiggleMe(targetIconView);
}
}];
}
}
else {
SBIconView *targetIconView = [[[iconCT _currentFolderController] viewMap] mappedIconViewForIcon:desiredIcon];
wiggleMe(targetIconView);
}
wantedScreenIndex = 0;
wantedFolderPageIndex = 0;
wantedFolder = nil;
searchedBundle = nil;
desiredIcon = nil;
}
%group iOS12
@interface SearchUIAppIconButton : UIButton
@property (retain) SFSearchResult * result;
- (void)handleLongPress:(UILongPressGestureRecognizer *)sender;
-(void)updateWithResult:(id)arg1 ;
@property (nonatomic, retain) UILongPressGestureRecognizer *searchIconGesture;
@end
%hook SearchUIAppIconButton
%property (nonatomic, retain) UILongPressGestureRecognizer *searchIconGesture;
-(void)updateWithResult:(id)arg1 {
%orig;
if (!self.searchIconGesture) {
self.searchIconGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self
action:@selector(handleLongPress:)];
self.searchIconGesture.minimumPressDuration = 1.0;
[self addGestureRecognizer:self.searchIconGesture];
}
}
%new - (void)handleLongPress:(UILongPressGestureRecognizer *)sender {
if (sender.state == UIGestureRecognizerStateBegan) {
doTheMagic(self);
}
}
%end
%end
%group iOS11
@interface SearchUIIconView : UIView
@property (retain) SFSearchResult * result; //@synthesize result=_result - In the implementation block
- (void)handleLongPress:(UILongPressGestureRecognizer *)sender;
@property (nonatomic, retain) UILongPressGestureRecognizer *searchIconGesture;
@end
%hook SearchUIIconView
%property (nonatomic, retain) UILongPressGestureRecognizer *searchIconGesture;
-(void)updateWithResult:(id)arg1 {
%orig;
if (!self.searchIconGesture) {
self.searchIconGesture = [[UILongPressGestureRecognizer alloc]
initWithTarget:self
action:@selector(handleLongPress:)];
self.searchIconGesture.minimumPressDuration = 1.0;
[self addGestureRecognizer:self.searchIconGesture];
}
}
%new
- (void)handleLongPress:(UILongPressGestureRecognizer *)sender {
if (sender.state == UIGestureRecognizerStateBegan) {
doTheMagic(self);
}
}
%end
@interface SearchUISingleResultTableViewCell : UITableViewCell
- (void)handleLongPress:(UILongPressGestureRecognizer *)sender;
@property (retain) SFSearchResult *result; //@synthesize result=_result - In the implementation block
@property (nonatomic, retain) UILongPressGestureRecognizer *searchIconGesture;
@end
%hook SearchUISingleResultTableViewCell
%property (nonatomic, retain) UILongPressGestureRecognizer *searchIconGesture;
%new
- (void)handleLongPress:(UILongPressGestureRecognizer *)sender {
if (sender.state == UIGestureRecognizerStateBegan) {
doTheMagic(self);
}
}
-(void)setResult:(SFSearchResult *)arg1 {
%orig;
if (!self.searchIconGesture) {
self.searchIconGesture = [[UILongPressGestureRecognizer alloc]
initWithTarget:self
action:@selector(handleLongPress:)];
self.searchIconGesture.minimumPressDuration = 1.0;
[self addGestureRecognizer:self.searchIconGesture];
}
}
%end
%end
%hook SBFolderController
-(BOOL)setCurrentPageIndex:(long long)arg1 animated:(BOOL)arg2 {
if ([nukeAnimTimer isValid]) {
NSString *iconImgvKey = @"_currentImageView";
if ((kCFCoreFoundationVersionNumber >= 1443.00)) {
iconImgvKey = @"currentImageView";
}
dispatch_async(dispatch_get_main_queue(), ^{
UIView *curImgv = [targetIV valueForKey:iconImgvKey];
CALayer *iconImageLayer = curImgv.layer;
[iconImageLayer removeAllAnimations];
iconImageLayer.shadowOpacity = 0;
iconImageLayer.shadowColor = [UIColor clearColor].CGColor;
iconImageLayer.shadowRadius = 0;
});
}
return %orig;
}
%end
static void reloadColorPrefs() {
NSDictionary *preferences = [NSDictionary dictionaryWithContentsOfFile:kColorPath];
glowColor = [preferences objectForKey:@"glowColor"] ? LCPParseColorString([preferences objectForKey:@"glowColor"], @"#FFFFFF") : [UIColor redColor];
}
static void reloadPrefs() {
CFPreferencesAppSynchronize((CFStringRef)kIdentifier);
NSDictionary *prefs = nil;
if ([NSHomeDirectory() isEqualToString:@"/var/mobile"]) {
CFArrayRef keyList = CFPreferencesCopyKeyList((CFStringRef)kIdentifier, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
if (keyList != nil) {
prefs = (NSDictionary *)CFBridgingRelease(CFPreferencesCopyMultiple(keyList, (CFStringRef)kIdentifier, kCFPreferencesCurrentUser, kCFPreferencesAnyHost));
if (prefs == nil)
prefs = [NSDictionary dictionary];
CFRelease(keyList);
}
} else {
prefs = [NSDictionary dictionaryWithContentsOfFile:kSettingsPath];
}
glowEnabled = [prefs objectForKey:@"glowEnabled"] ? [(NSNumber *)[prefs objectForKey:@"glowEnabled"] boolValue] : true;
slamVibration = [prefs objectForKey:@"slamVibration"] ? [(NSNumber *)[prefs objectForKey:@"slamVibration"] boolValue] : true;
animType = [prefs objectForKey:@"animType"] ? [[prefs objectForKey:@"animType"] integerValue] : 0;
}
%ctor {
NSLog(@"LMHLOG hodor");
%init;
if (kCFCoreFoundationVersionNumber >= 1535.12) {
NSLog(@"LMHLOG init 12");
%init(iOS12);
}
else {
%init(iOS11);
}
reloadPrefs();
reloadColorPrefs();
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)reloadPrefs, kSettingsChangedNotification, NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)reloadColorPrefs, kColorChangedNotification, NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
}