forked from Tweaker177/FolderControllerXI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTweak.xm
861 lines (652 loc) · 24.7 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
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#include <stdlib.h>
#import <objc/runtime.h>
#import <QuartzCore/QuartzCore.h>
#include <CSColorPicker/CSColorPicker.h>
#define PLIST_PATH @"/var/mobile/Library/Preferences/com.i0stweak3r.foldercontroller.plist"
static int kGradientStyleSelection = 0;
static CGFloat kFloatyOpacity;
static bool kEnabled;
static bool kFloatyOpacityEnabled = YES;
static bool kFolderIconOpacityEnabled = YES;
static double kFolderIconOpacityColor;
static double kFolderIconOpacityWhite;
static CGFloat kColoredFolderIconAlpha;
static bool kWantsCornerRadius = YES;
static double kIconCornerRadius;
static bool kWantsTapToClose = YES;
static bool kWantsPinchToClose = YES;
static CGFloat kBackgroundFolderRadius = 35.f;
static bool kWantsStatusBarWithFolder = YES;
static bool kNoFX = YES; //no blur open folders
static bool kReducedTransOn = YES; //dark bg
/* defaults vary for layout of iPad and iPhone, need to address this at some point. Not a big issue though, if used it will be user set and is off by default */
static double kCustomRows;
static double kCustomColumns;
static bool kWantsCustomInsets;
static double kTopInset = 0.f;
static double kBottomInset = 0.f;
static double kSideInset = 0.f;
static bool kCustomLayout = YES;
static bool kHidesTitle;
static NSString *kOpenFolderBorderHex = @"000000";
//Open Folder Border Color Hex
static bool kWantsAutoClose = NO;
static bool kRandomGradientsEnabled = YES;
static CGFloat screenHeight, screenWidth;
static bool kWantsNoFolderDelete;
static bool kColorFolders;
static NSString *kOpenFolderColorHex =
@"FF0000";
static NSString *kOpenGradient2Hex= @"FF0000";
//actually this is gradient 3 now
static CGFloat kCustomBorderWidth = 0;
//closed folders or icons below
static NSString *kIconHex = @"FF0000";
static NSString *kBorderHex = @"000000";
static CGFloat kBorderWidth = 0.f;
static bool kColorIcons;
static bool kWantsNoMiniGrid;
static int kFolderSizeSelection = 0;
static NSString *kOpenGradient3Hex = @"000000";
static bool kFolderGradientsEnabled = YES;
static bool kSupportThemeImages = YES;
/* Currently used to decide whether to color over theme images. If off just adds border if applicable. */
static bool kMultiItem = YES;
UIImageView* _tintView;
@interface SBFolderIconImageView : UIView
@end
//Allows access to all inherited properties of UIViews
@interface SBFolderBackgroundView : UIView
{
UIImageView* _tintView;
}
+(CGSize)folderBackgroundSize;
+(CGFloat)cornerRadiusToInsetContent;
-(id)initWithFrame:(CGRect)frame;
-(void)layoutSubviews;
@end
@interface SBFolderIconBackgroundView : UIView
-(id)initWithFrame:(CGRect)frame;
@end
@interface SBFloatyFolderView : UIView
/* not used, was going to use to adjust title appearance for full page folder and full-width in landscape
-(CGFloat)_titleVerticleOffsetForOrientation:(NSInteger)arg1;
-(CGFloat)_titleFontSize;
*/
@end
%hook SBFolder
-(bool)isEmpty {
if(kWantsNoFolderDelete) {
return 0;
}
return %orig;
}
-(bool)shouldRemoveWhenEmpty {
if(kWantsNoFolderDelete) {
return 0;
}
return %orig;
}
%end
%hook SBFolderIcon
-(BOOL)canBeAddedToMultiItemDrag {
if(kEnabled && kMultiItem) {
return 1;
}
return %orig;
}
%end
%hook SBFolderController
- (void)_addFakeStatusBarView {
if(kEnabled && kWantsStatusBarWithFolder) {
return;
}
return %orig;
}
%end
%hook SBFolderTitleTextField
-(id)initWithFrame:(CGRect)frame {
if(!kEnabled) { return %orig; }
self= %orig;
screenWidth = [[UIScreen mainScreen] bounds].size.width;
screenHeight = [[UIScreen mainScreen] bounds].size.height;
if((kFolderSizeSelection == 1) || (kFolderSizeSelection == 2 && screenWidth > screenHeight)) {
frame = CGRectMake(0, -20, screenWidth, 16.f);
return self;
}
return %orig;
}
%end
%hook SBFloatyFolderView
-(id)initWithFrame:(CGRect)frame {
if((kEnabled) && ((kFolderSizeSelection == 1) || (kFolderSizeSelection==2))) {
self = %orig;
screenHeight = [[UIScreen mainScreen] bounds].size.height;
screenWidth = [[UIScreen mainScreen] bounds].size.width;
self.frame= CGRectMake(0,0,screenWidth,screenHeight);
self.bounds =
CGRectMake(0,0,screenWidth,screenHeight);
return self;
}
return %orig;
}
-(bool)gestureRecognizer:(id)arg1 shouldRecognizeSimultaneouslyWithGestureRecognizer:(id)arg2 {
if(kEnabled && kWantsAutoClose) {
return 1;
%orig;
}
return %orig;
}
%end
%hook SBFolderBackgroundView
+(CGSize)folderBackgroundSize {
screenHeight = [[UIScreen mainScreen] bounds].size.height;
screenWidth = [[UIScreen mainScreen] bounds].size.width;
if((kEnabled) && (kFolderSizeSelection == 1)) {
CGSize folderSize = CGSizeMake(screenWidth-16.f, screenHeight - 77.f);
return folderSize;
}
else if((kEnabled) && (kFolderSizeSelection == 2)&&(screenHeight > screenWidth)) {
CGSize folderSizeSquare = CGSizeMake(screenWidth-16.f, screenWidth-16.f);
return folderSizeSquare;
}
else if((kEnabled) && (kFolderSizeSelection == 2)&&(screenHeight < screenWidth)) {
CGSize folderSizeSquare = CGSizeMake(screenHeight-16.f, screenHeight-16.f);
return folderSizeSquare;
}
else {
return %orig; }
}
-(id)initWithFrame:(CGRect)frame {
SBFolderBackgroundView *view = %orig;
screenHeight = [[UIScreen mainScreen] bounds].size.height;
screenWidth = [[UIScreen mainScreen] bounds].size.width;
if((kEnabled) && (kFolderSizeSelection == 0)&&(screenHeight > screenWidth)) {
CGSize normalSize = [%c(SBFolderBackgroundView)folderBackgroundSize];
view.frame= CGRectMake (0,0, normalSize.width, normalSize.height);
view.bounds = view.frame;
}
if((kEnabled) && (kFolderSizeSelection == 0)&&(screenHeight < screenWidth)) {
CGSize normalSize =
[%c(SBFolderBackgroundView)folderBackgroundSize];
view.frame= CGRectMake (0,0, normalSize.width, normalSize.height);
view.bounds = view.frame;
}
if((kEnabled) && (kFolderSizeSelection == 1)) {
view.frame = CGRectMake(0,0, screenWidth-16.f, screenHeight-77.f);
view.bounds = view.frame;
}
//Trying to create square folder size of device width
if((kEnabled) && (kFolderSizeSelection == 2)) {
if (screenWidth > screenHeight) {
float tempHeight = screenWidth;
screenWidth = screenHeight;
screenHeight = tempHeight;
}
//room for statusBar in landscape
view.frame = CGRectMake(0,0, screenWidth -16.f, screenWidth - 16.f);
view.bounds = view.frame;
} //end of If full width folder
if(kEnabled && kFolderGradientsEnabled) {
view.layer.borderColor = [UIColor colorFromHexString: kOpenFolderBorderHex].CGColor;
view.layer.borderWidth= kCustomBorderWidth;
view.layer.cornerRadius = kBackgroundFolderRadius;
UIImageView* tintView = MSHookIvar<UIImageView *>(self, "_tintView");
tintView = [[UIImageView alloc]initWithFrame: view.frame];
tintView.image = nil;
tintView.backgroundColor = nil;
tintView.layer.backgroundColor = nil;
tintView.alpha = 0;
tintView.userInteractionEnabled = 0;
tintView.opaque = 1;
tintView.hidden= YES;
_tintView= tintView;
[_tintView setHidden: YES];
CAGradientLayer* gradient = [CAGradientLayer layer];
gradient.frame = view.bounds;
int randomInt= arc4random_uniform(7);
if(!kRandomGradientsEnabled) {
switch (kGradientStyleSelection) {
case 0: randomInt= 0; break;
case 1: randomInt= 2; break;
case 2: randomInt= 3; break;
case 3: randomInt= 4; break;
case 4: randomInt= 5; break;
case 5: randomInt= 6; break;
case 6: randomInt = 1; break;
default: randomInt = 0; break; }
}
switch (randomInt) {
case 0: gradient.startPoint = CGPointZero;
gradient.endPoint = CGPointMake(1.0, 1.0);
gradient.colors= [NSArray arrayWithObjects: (id)[UIColor colorFromHexString:kOpenFolderColorHex].CGColor,(id)[UIColor colorFromHexString:kOpenGradient3Hex].CGColor,(id)[UIColor colorFromHexString:kOpenGradient2Hex].CGColor, nil];
[view.layer insertSublayer:gradient atIndex:0];
[view.layer insertSublayer:gradient atIndex:1];
break;
case 1: gradient.startPoint = CGPointMake(1.0, 0.5);
gradient.endPoint = CGPointMake(0, 0.5);
gradient.colors= [NSArray arrayWithObjects: (id)[UIColor colorFromHexString:kOpenFolderColorHex].CGColor,(id)[UIColor colorFromHexString:kOpenGradient3Hex].CGColor,(id)[UIColor colorFromHexString:kOpenGradient2Hex].CGColor, nil];
[view.layer insertSublayer:gradient atIndex:0];
[view.layer insertSublayer:gradient atIndex:1];
break;
case 2: gradient.startPoint = CGPointMake(0.5, 0);
gradient.endPoint = CGPointMake(0.5, 1);
gradient.colors= [NSArray arrayWithObjects: (id)[UIColor colorFromHexString:kOpenFolderColorHex].CGColor, (id)[UIColor colorFromHexString: kOpenGradient2Hex].CGColor, (id)[UIColor colorFromHexString: kOpenGradient3Hex].CGColor, nil];
[view.layer insertSublayer:gradient atIndex:0];
[view.layer insertSublayer:gradient atIndex:1];
break;
case 3:
gradient.colors= [NSArray arrayWithObjects: (id)[UIColor colorFromHexString: kOpenGradient2Hex].CGColor, (id)[UIColor colorFromHexString:kOpenFolderColorHex].CGColor, (id)[UIColor colorFromHexString: kOpenGradient3Hex].CGColor, nil];
gradient.locations= [NSArray arrayWithObjects:[NSNumber numberWithFloat:0.31],[NSNumber numberWithFloat:0.52],[NSNumber numberWithFloat:0.74],nil];
[view.layer insertSublayer:gradient atIndex:0];
[view.layer insertSublayer:gradient atIndex:1];
break;
case 4:
gradient.colors= [NSArray arrayWithObjects:(id)[UIColor colorFromHexString:kOpenGradient3Hex].CGColor, (id)[UIColor colorFromHexString:kOpenFolderColorHex].CGColor, (id)[UIColor colorFromHexString:kOpenGradient2Hex].CGColor, nil];
gradient.locations= [NSArray arrayWithObjects:[NSNumber numberWithFloat:0.15],[NSNumber numberWithFloat:0.37],[NSNumber numberWithFloat:0.80],nil];
[view.layer insertSublayer:gradient atIndex:0];
[view.layer insertSublayer:gradient atIndex:1];
break;
case 5:
gradient.startPoint = CGPointMake(0, 0.5);
gradient.endPoint = CGPointMake(1.0, 0.5);
gradient.colors =[NSArray arrayWithObjects: (id)[UIColor colorFromHexString:kOpenFolderColorHex].CGColor,(id)[UIColor colorFromHexString:kOpenGradient3Hex].CGColor,(id)[UIColor colorFromHexString:kOpenGradient2Hex].CGColor, nil];
[view.layer insertSublayer:gradient atIndex:0];
[view.layer insertSublayer:gradient atIndex:1];
break;
case 6: gradient.startPoint = CGPointMake(0.9, 1.0);
gradient.endPoint = CGPointMake(0.15, 0.05);
gradient.colors =[NSArray arrayWithObjects: (id)[UIColor colorFromHexString:kOpenFolderColorHex].CGColor,(id)[UIColor colorFromHexString:kOpenGradient3Hex].CGColor,(id)[UIColor colorFromHexString:kOpenGradient2Hex].CGColor, nil];
[view.layer insertSublayer:gradient atIndex:0];
[view.layer insertSublayer:gradient atIndex:1];
break;
default:
gradient.startPoint = CGPointMake(0, 0.5);
gradient.endPoint = CGPointMake(1.0, 0.5);
gradient.colors =[NSArray arrayWithObjects: (id)[UIColor colorFromHexString:kOpenFolderColorHex].CGColor,(id)[UIColor colorFromHexString:kOpenGradient3Hex].CGColor,(id)[UIColor colorFromHexString:kOpenGradient2Hex].CGColor, nil];
[view.layer insertSublayer:gradient atIndex:0];
[view.layer insertSublayer:gradient atIndex:1];
break;
} //end of switch
return view;
}
else if(kEnabled && kColorFolders) {
view.backgroundColor = [UIColor colorFromHexString:kOpenFolderColorHex];
view.layer.borderColor = [UIColor colorFromHexString: kOpenFolderBorderHex].CGColor;
view.layer.borderWidth= kCustomBorderWidth;
view.layer.cornerRadius = kBackgroundFolderRadius;
return view;
}
else { return view; }
}
-(id)_tintViewBackgroundColorAtFullAlpha {
if((kEnabled && kColorFolders)&&(!kFolderGradientsEnabled)) {
return [UIColor colorFromHexString:kOpenFolderColorHex];
}
else if(kEnabled && kFolderGradientsEnabled) {
return nil;
}
else {
return %orig; }
}
-(void)_setContinuousCornerRadius:(CGFloat)arg1 {
if(kWantsCornerRadius) {
arg1= kBackgroundFolderRadius;
return %orig(arg1);
}
return %orig;
}
-(void)layoutSubviews {
if(kEnabled && kFolderGradientsEnabled) {
%orig;
_tintView.hidden = YES;
[_tintView setHidden: YES];
_tintView.alpha = 0.01;
_tintView.backgroundColor = [UIColor colorFromHexString: @"00000000"];
_tintView.layer.backgroundColor= [UIColor colorFromHexString: @ "00000000"].CGColor;
return;
}
else { return %orig; }
}
%end
%hook SBFolderSettings
- (void)setPinchToClose:(bool)arg1 {
if ((kEnabled) && (kWantsPinchToClose)) {
arg1 = YES;
return %orig(arg1);
}
return %orig;
}
%end
/* This method changes corner radius of folder icons, but SNOWBOARD
tweak and theme engine makes it not work. works with ANEMONE still. */
%hook SBIconImageView
+(double)cornerRadius {
if ((kEnabled) && (kWantsCornerRadius)) {
return kIconCornerRadius;
}
return %orig;
}
%end
/*
Changing FolderIconImageView radius at layer level works around Snowboard conflict
*/
%hook SBFolderIconImageView
-(id)initWithFrame:(CGRect)frame {
if(!kEnabled) { return %orig; }
SBFolderIconImageView *folderIconImageView = %orig;
if((kWantsCornerRadius) && (kColorIcons)&& (! kSupportThemeImages)) {
folderIconImageView.layer.cornerRadius = kIconCornerRadius;
folderIconImageView.layer.borderWidth = kBorderWidth;
folderIconImageView.layer.borderColor = [UIColor colorFromHexString:kBorderHex].CGColor;
folderIconImageView.layer.masksToBounds = YES;
folderIconImageView.backgroundColor = [[UIColor colorFromHexString:kIconHex] colorWithAlphaComponent: kColoredFolderIconAlpha];
folderIconImageView.layer.backgroundColor = [[UIColor colorFromHexString:kIconHex] colorWithAlphaComponent: kColoredFolderIconAlpha].CGColor;
return folderIconImageView;
}
else if((kWantsCornerRadius)&& (kSupportThemeImages)) {
folderIconImageView.layer.cornerRadius = kIconCornerRadius;
folderIconImageView.layer.masksToBounds = YES;
folderIconImageView.layer.borderColor = [UIColor colorFromHexString:kBorderHex].CGColor;
folderIconImageView.layer.borderWidth = kBorderWidth;
return folderIconImageView;
}
else if(kSupportThemeImages) {
folderIconImageView.layer.cornerRadius = kIconCornerRadius;
folderIconImageView.layer.masksToBounds = YES;
folderIconImageView.layer.borderColor = [UIColor colorFromHexString:kBorderHex].CGColor;
folderIconImageView.layer.borderWidth = kBorderWidth;
folderIconImageView.layer.cornerRadius = kIconCornerRadius;
return folderIconImageView;
}
else if (kColorIcons) {
folderIconImageView.layer.borderWidth = kBorderWidth;
folderIconImageView.layer.cornerRadius = kIconCornerRadius;
folderIconImageView.layer.masksToBounds = YES;
folderIconImageView.layer.borderColor = [UIColor colorFromHexString:kBorderHex].CGColor;
folderIconImageView.backgroundColor = [[UIColor colorFromHexString:kIconHex] colorWithAlphaComponent: kColoredFolderIconAlpha];
return folderIconImageView;
}
else if(kWantsCornerRadius) {
folderIconImageView.layer.cornerRadius = kIconCornerRadius;
folderIconImageView.layer.masksToBounds = YES;
folderIconImageView.layer.borderWidth = kBorderWidth;
folderIconImageView.layer.borderColor = [UIColor colorFromHexString:kBorderHex].CGColor;
return folderIconImageView;
}
else {
return folderIconImageView; }
}
%end
%hook SBFolderIconBackgroundView
-(id)initWithFrame:(CGRect)frame {
SBFolderIconBackgroundView *backgroundView = %orig;
if(kEnabled && kSupportThemeImages) {
backgroundView.layer.cornerRadius = kIconCornerRadius;
backgroundView.layer.masksToBounds = YES;
backgroundView.layer.borderColor = [UIColor colorFromHexString:kBorderHex].CGColor;
backgroundView.layer.borderWidth = kBorderWidth;
return backgroundView;
}
else if(kEnabled && kWantsCornerRadius) {
backgroundView.layer.cornerRadius = kIconCornerRadius;
backgroundView.layer.masksToBounds = YES;
backgroundView.layer.borderColor = [UIColor colorFromHexString:kBorderHex].CGColor;
backgroundView.layer.borderWidth = kBorderWidth;
return backgroundView;
}
/* Just added this to make Border work without color enabled */
else if(kEnabled) {
backgroundView.layer.cornerRadius = kIconCornerRadius;
backgroundView.layer.masksToBounds = YES;
backgroundView.layer.borderColor = [UIColor colorFromHexString:kBorderHex].CGColor;
backgroundView.layer.borderWidth = kBorderWidth;
return backgroundView;
}
else {
return backgroundView;
}
}
%end
%hook SBIcon
- (id)gridCellImage {
if(kEnabled && kWantsNoMiniGrid) {
return nil;
}
else {
return %orig;
}
}
%end
%hook SBFolderView
-(bool)textFieldShouldReturn {
if (kHidesTitle) {
return 0;
}
return %orig;
}
%end
%hook SBFloatyFolderView
-(bool)_showsTitle {
if(kHidesTitle) {
return 0;
}
return %orig;
}
/*******
FROM runtime header, this fixes bug where folder splits to multiple
folders in landscape and loses dark BG. Keeps scrolling as the way to see next
page. **********/
-(bool)_shouldConvertToMultipleIconListsInLandscapeOrientation {
if(kEnabled) {
return NO;
}
return %orig;
}
- (bool)_tapToCloseGestureRecognizer:(id)arg1 shouldReceiveTouch:(id)arg2 {
if ((kEnabled) && ((kWantsTapToClose) || (kWantsAutoClose))) {
return YES;
%orig;
}
return %orig;
}
- (void)setBackgroundAlpha:(CGFloat)arg1 {
if ((kEnabled) && (kFloatyOpacityEnabled)) {
arg1 = (kFloatyOpacity / 100);
return %orig(arg1);
}
return %orig;
}
%end
%hook SBFolderControllerBackgroundView
-(bool)effectActive {
if ((kEnabled) && (kNoFX)) {
// removes blur
return FALSE;
}
return %orig;
}
- (bool)isReduceTransparencyEnabled {
if ((kEnabled) && (kReducedTransOn)) {
return 1;
// makes backgroundViews darker
}
else { return %orig; }
}
- (void)setEffectActive:(bool)arg1 {
if ((kEnabled) && (kNoFX)) {
arg1 = FALSE;
return %orig(arg1);
}
else {
return %orig; }
}
%end
%hook SBFolderBackgroundView
+(void)_setContinuousCornerRadius:(CGFloat)arg1 {
if ((kEnabled) && (kWantsCornerRadius)) {
arg1 = kBackgroundFolderRadius;
return %orig(arg1);
}
return %orig;
}
// this is necessary for open folder radius changes
+ (CGFloat)cornerRadiusToInsetContent {
if ((kEnabled) && (kWantsCornerRadius)) {
return kBackgroundFolderRadius;
}
return %orig;
}
%end
%hook SBIconColorSettings
-(bool)blurryFolderIcons {
if ((kEnabled) && (kFolderIconOpacityEnabled)&&(! kSupportThemeImages)) {
return FALSE;
}
return %orig;
}
- (double)colorAlpha {
if ((kEnabled) && (kFolderIconOpacityEnabled)) {
return (kFolderIconOpacityColor / 100);
}
return %orig;
}
- (double)whiteAlpha {
if ((kEnabled) && (kFolderIconOpacityEnabled)) {
return kFolderIconOpacityWhite / 100;
}
return %orig;
}
%end
//Needed to make opacity zero of background
%hook SBFWallpaperSettings
-(bool)replaceBlurs {
if ((kEnabled) && (kFolderIconOpacityEnabled)&&(! kSupportThemeImages)) {
return TRUE;
}
return %orig;
}
%end
%hook SBFolderIconListView
+(unsigned long long)maxVisibleIconRowsInterfaceOrientation
: (long long)arg1 {
if ((kEnabled && kCustomLayout)&&(kCustomRows >= 1)) {
%orig;
return kCustomRows;
}
return %orig;
}
%end
%hook SBFolderIconListView
+(unsigned long long)iconColumnsForInterfaceOrientation : (long long)arg1 {
if ((kEnabled && kCustomLayout)&& (kCustomColumns >= 1)) {
//Added extra conditional for when settings=nil
%orig;
return kCustomColumns;
}
return %orig;
}
%end
/**
Custom inset tweaking relative to original insets determined by number of icons per row or column
**/
%hook SBFolderIconListView
-(double)bottomIconInset {
if ((kEnabled) && (kWantsCustomInsets)) {
double IconInset = %orig;
IconInset = IconInset - (IconInset * kBottomInset);
return IconInset;
}
return %orig;
}
%end
%hook SBFolderIconListView
-(double)sideIconInset {
if ((kEnabled) && (kWantsCustomInsets)) {
double IconInset = %orig;
IconInset = IconInset - (IconInset * kSideInset);
return IconInset;
}
return %orig;
}
%end
%hook SBFolderIconListView
-(double)topIconInset {
if ((kEnabled) && (kWantsCustomInsets)) {
double IconInset = %orig;
IconInset = IconInset - (IconInset * kTopInset);
return IconInset;
}
return %orig;
}
%end
//Handle Prefs and Set Defaults
static void
loadPrefs() {
static NSUserDefaults *prefs = [[NSUserDefaults alloc]
initWithSuiteName:@"com.i0stweak3r.foldercontroller"];
kEnabled = [[prefs objectForKey:@"enabled"] boolValue] ? [prefs boolForKey:@"enabled"] : NO;
kFloatyOpacityEnabled = [prefs boolForKey:@"floatyOpacityEnabled"];
kFolderIconOpacityEnabled = [prefs boolForKey:@"folderIconOpacityEnabled"];
kFolderIconOpacityWhite =
[[prefs objectForKey:@"folderIconOpacityWhite"] floatValue] ? [[prefs objectForKey:@"folderIconOpacityWhite"] floatValue] : 70.f;
kFolderIconOpacityColor =
[[prefs objectForKey:@"folderIconOpacityColor"] floatValue] ? [[prefs objectForKey:@"folderIconOpacityColor"] floatValue] : 70.f;
kWantsCornerRadius = [prefs boolForKey:@"iconCornerRadiusEnabled"];
kIconCornerRadius = [[prefs objectForKey:@"iconCornerRadius"] floatValue] ? [[prefs objectForKey:@"iconCornerRadius"] floatValue] : 10.f;
kBackgroundFolderRadius =
[[prefs objectForKey:@"backgroundFolderRadius"] floatValue] ? [[prefs objectForKey:@"backgroundFolderRadius"] floatValue] : 38.f;
kWantsTapToClose = [prefs boolForKey:@"wantsTapToClose"];
kWantsPinchToClose = [prefs boolForKey:@"wantsPinchToClose"];
kHidesTitle = [prefs boolForKey:@"hidesTitle"];
kNoFX = [prefs boolForKey:@"noFX"];
kReducedTransOn = [prefs boolForKey:@"reducedTransOn"];
kCustomLayout = [prefs boolForKey:@"customLayout"];
kCustomRows = [prefs integerForKey:@"customRows"];
kCustomColumns = [prefs integerForKey:@"customColumns"];
kWantsCustomInsets = [prefs boolForKey:@"wantsCustomInsets"];
kTopInset = [[prefs objectForKey:@"topInset"] floatValue];
kSideInset = [[prefs objectForKey:@"sideInset"] floatValue];
kBottomInset = [[prefs objectForKey:@"bottomInset"] floatValue];
kMultiItem = [prefs boolForKey:@"multiItem"];
kColorFolders = [prefs boolForKey:@"colorFolders"];
kFolderGradientsEnabled = [prefs boolForKey:@"folderGradientsEnabled"];
kRandomGradientsEnabled = [prefs boolForKey:@"randomGradientsEnabled"];
kOpenFolderColorHex = [[prefs objectForKey:@"openFolderColorHex"] stringValue] ? [prefs stringForKey:@"openFolderColorHex"] : @"FF0000";
kOpenGradient2Hex = [[prefs objectForKey:@"openGradient2Hex"] stringValue] ? [prefs stringForKey:@"openGradient2Hex"] : @"FF0000"; //Actually this is Open gradient 3
kOpenGradient3Hex = [[prefs objectForKey:@"openGradient3Hex"] stringValue] ? [prefs stringForKey:@"openGradient3Hex"] : @"000000";
kCustomBorderWidth = [[prefs objectForKey:@"customBorderWidth"] floatValue] ?
[[prefs objectForKey:@"customBorderWidth"] floatValue] : 0.f;
kIconHex = [[prefs objectForKey:@"iconHex"] stringValue] ? [prefs stringForKey:@"iconHex"] : @"FF0000";
kColoredFolderIconAlpha = [[prefs objectForKey:@"coloredFolderIconAlpha"] floatValue] ?
[[prefs objectForKey:@"coloredFolderIconAlpha"] floatValue] : 0.5f;
kWantsNoMiniGrid= [[prefs objectForKey: @"wantsNoMiniGrid"] boolValue] ? [prefs boolForKey:@"wantsNoMiniGrid"] : NO;
kSupportThemeImages = [[prefs objectForKey:@"supportThemeImages"]boolValue] ? [prefs boolForKey:@"supportThemeImages"] : NO;
kBorderHex = [[prefs objectForKey:@"borderHex"] stringValue] ? [prefs stringForKey:@"borderHex"] : @"000000";
kBorderWidth = [[prefs objectForKey:@"borderWidth"] floatValue] ? [[prefs objectForKey:@"borderWidth"] floatValue] : 0.f;
kColorIcons = [[prefs objectForKey:@"colorIcons"] boolValue] ? [prefs boolForKey:@"colorIcons"] : 0;
kFolderSizeSelection = [[prefs objectForKey:@"folderSizeSelection"] integerValue] ? [[prefs objectForKey:@"folderSizeSelection"] integerValue] : 0;
kOpenFolderBorderHex = [[prefs objectForKey:@"newBorderColor"] stringValue] ?
[prefs stringForKey:@"newBorderColor"] : @"000000";
kGradientStyleSelection = [[prefs objectForKey:@"gradientStyleSelection"] integerValue];
kWantsNoFolderDelete = [prefs boolForKey:@"wantsNoFolderDelete"];
kWantsAutoClose= [prefs boolForKey:@"wantsAutoClose"];
kFloatyOpacity = [[prefs objectForKey: @"floatyOpacity"] floatValue] ? [[prefs objectForKey: @"floatyOpacity"] floatValue] : 100.f;
kWantsStatusBarWithFolder = [prefs boolForKey:@"wantsStatusBar"];
}
%ctor {
CFNotificationCenterAddObserver(
CFNotificationCenterGetDarwinNotifyCenter(), NULL,
(CFNotificationCallback)loadPrefs,
CFSTR("com.i0stweak3r.foldercontroller-prefsreload"), NULL,
CFNotificationSuspensionBehaviorDeliverImmediately);
loadPrefs();
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *pathForDylib = @"/Library/MobileSubstrate/DynamicLibraries/Snowboard.dylib";
if ([fileManager fileExistsAtPath:pathForDylib]){
dlopen("/Library/MobileSubstrate/DynamicLibraries/Snowboard.dylib", RTLD_LAZY);
}
%init;
}