-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTweak.xm
executable file
·1811 lines (1307 loc) · 51.2 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
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
_____
/\ | __ \
/ \ _ __ _ __ | | | |_ __ __ ___ _____ _ __
/ /\ \ | '_ \| '_ \| | | | '__/ _` \ \ /\ / / _ \ '__|
/ ____ \| |_) | |_) | |__| | | | (_| |\ V V / __/ |
/_/ \_\ .__/| .__/|_____/|_| \__,_| \_/\_/ \___|_|
| | | |
|_| |_|
*/
#import <SpringBoard/SpringBoard.h>
#define registerNotification(c, n) CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (c), CFSTR(n), NULL, CFNotificationSuspensionBehaviorCoalesce);
#define PREFS_DOMAIN @"com.gmoran.index_prefs"
#define PREFS_CHANGED_NOTIF "com.gmoran.index.prefs-changed"
#define PREFS_FILE_PATH @"/var/mobile/Library/Preferences/com.gmoran.index.plist"
#define DRAWER_ID @"com.gmoran.index"
#define kBundlePath @"/Library/Application Support/AppDrawer/IndexBundle.bundle"
#define APP_SUPPORT_PATH @"/Library/Application Support/AppDrawer"
#define ICON_PREFS_PATH @"/Library/Application Support/AppDrawer/icon.plist"
#define ICON_FOLDER [[NSArray arrayWithContentsOfFile:@"/Library/Application Support/AppDrawer/icon.plist"] objectAtIndex:0]
//Preferences
static BOOL preferencesChanged = NO;
static NSDictionary *prefs = nil;
extern "C" CFNotificationCenterRef CFNotificationCenterGetDistributedCenter(void);
static void prefsChanged(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
// reload prefs
[prefs release];
//Delete old prefs file
if ((prefs = [[NSDictionary alloc] initWithContentsOfFile:PREFS_FILE_PATH]) == nil) {
//NSLog(@"CREATING PREFERENCE FILE");
//prefs = @{@"HorizontalScrollingEnabled": @NO};
[prefs writeToFile:PREFS_FILE_PATH atomically:YES];
prefs = [[NSDictionary alloc] initWithContentsOfFile:PREFS_FILE_PATH];
}
preferencesChanged = YES;
}
/*
static BOOL verticalScrollingEnabled(void) {
return (prefs) ? [prefs[@"HorizontalScrollingEnabled"] boolValue] : NO;
}
*/
static BOOL verticalScrollingEnabled = NO;
//Icon Stuffs
@interface SBDrawerIcon : SBLeafIcon
-(id)initWithIdentifier:(NSString *)identifier;
@end
@interface SBIconModel : NSObject {}
-(void)addIcon:(id)icon;
-(void)loadAllIcons;
@end
@interface SBDrawerIconView : SBIconView
@end
@interface SBIconImageView (iOS7)
@property (nonatomic, retain) SBIcon *icon;
@end
@interface SBDrawerIconImageView : SBIconImageView
@end
@interface SBFolderIconBackgroundView : UIView
-(id)initWithDefaultSize;
-(void)setWallpaperRelativeCenter:(CGPoint)wallpaperRelativeCenter;
@end
//SpringBoard Stuffs
@interface SBUIController : NSObject {
UIView* _contentView;
}
+(id)sharedInstance;
-(id)contentView;
-(void)activateApplicationAnimated:(id)animated;
-(void)activateApplication:(id)application; //iOS 9
@end
@interface SBApplication : NSObject
-(id)bundleIdentifier;
@end
//Party Starts
%subclass SBDrawerIcon : SBLeafIcon
%new
- (id)initWithIdentifier:(NSString *)identifier
{
if ([self respondsToSelector:@selector(initWithLeafIdentifier:applicationBundleID:)]) {
self = [self initWithLeafIdentifier:identifier applicationBundleID:identifier];
}
else {
self = [self initWithLeafIdentifier:identifier]; //iOS 6
}
return self;
}
- (void)dealloc {
%orig();
}
- (UIImage *)getGenericIconImage:(int)image {
NSBundle *bundle = [[NSBundle alloc] initWithPath:kBundlePath];
//dlopen("/Library/MobileSubstrate/DynamicLibraries/WinterBoard.dylib", RTLD_NOW);
//NSBundle* imageBundle = [NSBundle bundleWithIdentifier:@"me.gmoran.appdrawer"];
NSString *imagePath = [bundle pathForResource:@"DrawerIcon" ofType:@"png"];
UIImage *iconImage = [UIImage imageWithContentsOfFile:imagePath];
[bundle release];
//[imageBundle release];
return iconImage;
/*
if ([[NSFileManager defaultManager] fileExistsAtPath:ICON_PREFS_PATH]) {
NSString *imagePath = [NSString stringWithFormat:@"%@/%@/AppDrawer.png", APP_SUPPORT_PATH, ICON_FOLDER];
UIImage *iconImage = [UIImage imageWithContentsOfFile:imagePath];
return iconImage;
}
else {
NSString *imagePath = [NSString stringWithFormat:@"%@/Default Icon/AppDrawer.png", APP_SUPPORT_PATH];
UIImage *iconImage = [UIImage imageWithContentsOfFile:imagePath];
return iconImage;
}
*/
}
- (UIImage *)generateIconImage:(int)image {
NSBundle *bundle = [[NSBundle alloc] initWithPath:kBundlePath];
//dlopen("/Library/MobileSubstrate/DynamicLibraries/WinterBoard.dylib", RTLD_NOW);
//NSBundle* imageBundle = [NSBundle bundleWithIdentifier:@"me.gmoran.appdrawer"];
NSString *imagePath = [bundle pathForResource:@"DrawerIcon" ofType:@"png"];
UIImage *iconImage = [UIImage imageWithContentsOfFile:imagePath];
[bundle release];
//[imageBundle release];
return iconImage;
/*
if ([[NSFileManager defaultManager] fileExistsAtPath:ICON_PREFS_PATH]) {
NSString *imagePath = [NSString stringWithFormat:@"%@/%@/AppDrawer.png", APP_SUPPORT_PATH, ICON_FOLDER];
UIImage *iconImage = [UIImage imageWithContentsOfFile:imagePath];
return iconImage;
}
else {
NSString *imagePath = [NSString stringWithFormat:@"%@/Default Icon/AppDrawer.png", APP_SUPPORT_PATH];
UIImage *iconImage = [UIImage imageWithContentsOfFile:imagePath];
return iconImage;
}
*/
}
//iOS 11
-(void)launchFromLocation:(long long)arg1 context:(id)arg2 activationSettings:(id)arg3 actions:(id)arg4 {
SBUIController* uiController = [%c(SBUIController) sharedInstance];
[uiController openAppDrawer];
}
- (void)launchFromViewSwitcher
{
SBUIController* uiController = [%c(SBUIController) sharedInstance];
[uiController openAppDrawer];
}
- (void)launch
{
SBUIController* uiController = [%c(SBUIController) sharedInstance];
[uiController openAppDrawer];
}
- (void)launchFromLocation:(int)location
{
SBUIController* uiController = [%c(SBUIController) sharedInstance];
[uiController openAppDrawer];
}
//iOS 8.4
- (void)launchFromLocation:(int)location context:(id)context {
SBUIController* uiController = [%c(SBUIController) sharedInstance];
[uiController openAppDrawer];
}
- (BOOL)launchEnabled
{
return YES;
}
- (NSString *)displayName
{
return @"Apps";
}
- (id)displayNameForLocation:(int)location {
//This is for iOS 9
return @"Apps";
}
- (BOOL)canEllipsizeLabel
{
return NO;
}
- (NSString *)folderFallbackTitle
{
return @"Index";
}
- (NSString *)applicationBundleID
{
return DRAWER_ID;
}
-(id)description {
return @"Application Drawer";
}
- (Class)iconViewClassForLocation:(int)location
{
return %orig;
}
- (Class)iconImageViewClassForLocation:(int)location
{
return %orig;
}
%end
%hook SBIconModel
- (void)addIcon:(id)icon {
NSArray* hiddenApps = [[NSMutableArray alloc] init];
id allApps = [[%c(SBApplicationController) sharedInstance] allApplications];
NSMutableDictionary* appsDictionary = [[NSMutableDictionary alloc] init];
for (SBApplication* app in allApps) {
//[installedApps addObject: [app bundleIdentifier]];
BOOL applicationIsHiddenFromSB = [[prefs objectForKey:[@"HiddenSBApps-" stringByAppendingString:[app bundleIdentifier]]] boolValue];
if (applicationIsHiddenFromSB) {
@try {
[appsDictionary setObject:[app displayName] forKey:[app bundleIdentifier]];
}
@catch (NSException *e) {
//fuck you
}
}
}
NSArray *sortedKeys = [appsDictionary keysSortedByValueUsingSelector:@selector(caseInsensitiveCompare:)];
hiddenApps = sortedKeys;
[appsDictionary release];
if (![hiddenApps containsObject:[icon leafIdentifier]]) {
%orig;
}
}
- (void)_addNewIconToDesignatedLocation:(id)icon {
NSArray* hiddenApps = [[NSMutableArray alloc] init];
id allApps = [[%c(SBApplicationController) sharedInstance] allApplications];
NSMutableDictionary* appsDictionary = [[NSMutableDictionary alloc] init];
for (SBApplication* app in allApps) {
//[installedApps addObject: [app bundleIdentifier]];
BOOL applicationIsHiddenFromSB = [[prefs objectForKey:[@"HiddenSBApps-" stringByAppendingString:[app bundleIdentifier]]] boolValue];
if (applicationIsHiddenFromSB) {
@try {
[appsDictionary setObject:[app displayName] forKey:[app bundleIdentifier]];
}
@catch (NSException *e) {
//fuck you
}
}
}
NSArray *sortedKeys = [appsDictionary keysSortedByValueUsingSelector:@selector(caseInsensitiveCompare:)];
hiddenApps = sortedKeys;
[appsDictionary release];
if (![hiddenApps containsObject:[icon leafIdentifier]]) {
%orig;
}
}
- (void)dealloc
{
%orig();
}
- (void)loadAllIcons {
%orig();
//NSLog(@"Adding App Drawer to SpringBoard");
//Load Drawer Icon
SBDrawerIcon *icon = [[%c(SBDrawerIcon) alloc] initWithIdentifier:DRAWER_ID];
[self addIcon:icon];
[icon release];
}
%end
@interface SBUIController (Drawer) {}
-(void)openAppDrawer;
-(void)dismissAppDrawer;
-(void)launchAppFromDrawer:(id)application;
-(void)loadAppDrawer;
-(int)iconColumns;
-(int)iconPadding;
-(int)currentOrientation;
-(void)loadBlurView;
-(void)loadInstalledApps;
-(void)loadAppButtons;
-(void)loadMainDrawerView;
-(void)loadFavoriteApps;
-(UIScrollView*)drawerAppsView;
-(UIScrollView*)favoriteAppsView;
-(UIView*)drawerAppIconWithIdentifier:(id)kek;
-(UIColor*)drawerAppLabelColor;
// Gesture Recognizers
- (void)didSwipe:(UISwipeGestureRecognizer*)swipe;
//2.0
//-(void)setUpDragView;
//-(int)dockHeight;
//-(int)initialDragPosition;
@end
//SBUIController
#define HORIZONTAL_PAGING_ENABLED verticalScrollingEnabled
#define SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width
#define SCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height
#define IS_OS_7_OR_LATER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
#define IS_OS_8_OR_LATER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
#define IS_OS_9_OR_LATER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 9.0)
#define IS_OS_11_OR_LATER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 11.0)
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPHONE_4 ([[UIScreen mainScreen] bounds].size.height < 568)
#define IS_IPHONE_5 ([[UIScreen mainScreen] bounds].size.height == 568.0)
#define IS_STANDARD_IPHONE_6 ([[UIScreen mainScreen] bounds].size.height == 667.0)
#define IS_ZOOMED_IPHONE_6 ([[UIScreen mainScreen] bounds].size.height == 568.0)
#define IS_STANDARD_IPHONE_6_PLUS ([[UIScreen mainScreen] bounds].size.height == 736.0)
#define IS_ZOOMED_IPHONE_6_PLUS ([[UIScreen mainScreen] bounds].size.height == 667.0)
static UIView* mainDrawerView = nil;
static UIScrollView* drawerAppsView = nil;
static UIScrollView* favoriteAppsView = nil;
static UIButton* appsTab;
static UIButton* favoritesTab;
static UIView* blurView = nil;
static NSArray* installedApps = nil;
static NSArray* favoriteApps = nil;
static NSMutableArray* appButtons = nil;
static NSMutableArray* favoriteButtons = nil;
static int something = 0;
static int tabIndex = 0;
static BOOL drawerIsShowing = NO;
static int previousOrientation = 0;
//static UIView* dragView = nil;
%hook SBUIController
#include <dispatch/dispatch.h>
// Just an idea. Ignore me.
/*
#define PAN_MIN 20
#define PAN_MAX 600
#define INITIAL_POSITION [self initialDragPosition]
%new
-(int)initialDragPosition {
UIView* uiContentView = [self contentView];
return (uiContentView.frame.size.height - [self dockHeight]);
}
%new
-(int)dockHeight {
return 95;
}
%new
-(void)setUpDragView {
UIView* uiContentView = (UIView*)[self contentView];
int dockHeight = [self dockHeight];
dragView = [[UIView alloc] initWithFrame:CGRectMake(0, uiContentView.frame.size.height - dockHeight, uiContentView.frame.size.width, 10)];
dragView.backgroundColor = [UIColor redColor];
[uiContentView addSubview:dragView];
UIPanGestureRecognizer * pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panDrawer:)];
pan.maximumNumberOfTouches = pan.minimumNumberOfTouches = 1;
[dragView addGestureRecognizer:pan];
}
%new
- (void)panDrawer:(UIPanGestureRecognizer *)aPan {
//NSLog(@"Pan");
UIView* uiContentView = (UIView*)[self contentView];
CGPoint currentPoint = [aPan locationInView:uiContentView];
CGRect fr = dragView.frame;
if ((currentPoint.y - fr.origin.y) < 40 && (fr.size.height <= PAN_MAX) )
{
float nh = (currentPoint.y >= (int)INITIAL_POSITION - PAN_MAX) ? (int)INITIAL_POSITION-currentPoint.y : PAN_MAX;
if (nh < PAN_MIN) {
nh = PAN_MIN;
}
[UIView animateWithDuration:0.01f animations:^{
[dragView setFrame:CGRectMake(0, INITIAL_POSITION - nh, dragView.frame.size.width, nh)];
}];
if (nh == PAN_MAX) {
//[t setUserInteractionEnabled:YES];
}
else
{
//[t setUserInteractionEnabled:NO];
}
}
if(aPan.state == UIGestureRecognizerStateEnded)
{
NSLog(@"Pan Stopped");
}
}
*/
//Background queue
%new
-(UIColor*)drawerAppLabelColor {
if (IS_OS_8_OR_LATER) {
return [UIColor whiteColor];
}
else {
if ([[prefs objectForKey:@"nightModeEnabled"] boolValue] == YES) {
return [UIColor whiteColor];
}
else {
return [UIColor blackColor];
}
}
return [UIColor whiteColor];
}
%new
-(int)currentOrientation {
int lel;
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
if ((orientation == UIInterfaceOrientationPortrait) || (orientation == UIInterfaceOrientationPortraitUpsideDown)) {
lel = 0; //Portait
}
else {
lel= 1; //Landscape
}
return lel;
}
%new
-(int)iconPadding {
if (IS_IPHONE_4 || IS_IPHONE_5) {
return 20;
}
if (IS_STANDARD_IPHONE_6) {
return 25;
}
else { //6+
return 30;
}
}
%new
-(int)iconColumns {
if ([self currentOrientation] == 0) {
return 4;
}
return 6; //classic.
}
static int timesDrawerOpened = 0;
%new
- (void)openAppDrawer {
if (([self currentOrientation] != previousOrientation) || preferencesChanged) {
[self loadAppDrawer];
previousOrientation = [self currentOrientation];
if (preferencesChanged) {
preferencesChanged = NO;
}
}
timesDrawerOpened++;
//[self loadAppDrawer];
//NSLog(@"Opening Drawer");
UIView* mainView = [self contentView];
/*
[mainView addSubview:mainDrawerView];
[UIView animateWithDuration:0.5 animations:^{
[mainDrawerView setAlpha:1];
if (tabIndex == 0) {
[drawerAppsView setAlpha:1];
[favoriteAppsView setAlpha:0];
}
else {
[drawerAppsView setAlpha:0];
[favoriteAppsView setAlpha:1];
}
//mainDrawerView.transform = CGAffineTransformMakeScale(1,1);
}];
*/
mainDrawerView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.001, 0.001);
[mainView addSubview:mainDrawerView];
[mainDrawerView setAlpha:1];
if (tabIndex == 0) {
[drawerAppsView setAlpha:1];
[favoriteAppsView setAlpha:0];
}
else {
[drawerAppsView setAlpha:0];
[favoriteAppsView setAlpha:1];
}
[UIView animateWithDuration:0.3/1.5 animations:^{
mainDrawerView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.1, 1.1);
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.3/2.5 animations:^{
mainDrawerView.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.97, 0.97);
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.3/2.5 animations:^{
mainDrawerView.transform = CGAffineTransformIdentity;
}];
}];
}];
drawerIsShowing = YES;
}
%new
- (void)dismissAppDrawer {
[UIView animateWithDuration:0.3/1.5 animations:^{
mainDrawerView.transform = CGAffineTransformMakeScale(0.01,0.01);
[mainDrawerView setAlpha:0];
[drawerAppsView setAlpha:0];
[favoriteAppsView setAlpha:0];
}];
drawerIsShowing = NO;
}
%new
-(void)switchTabs:(id)sender {
if (sender == appsTab) {
tabIndex = 0;
[UIView animateWithDuration:0.5 animations:^{
[drawerAppsView setAlpha:1];
[favoriteAppsView setAlpha:0];
}];
[appsTab setTintColor:[UIColor whiteColor]];
[favoritesTab setTintColor:[UIColor grayColor]];
}
if (sender == favoritesTab) {
tabIndex = 1;
[UIView animateWithDuration:0.5 animations:^{
[drawerAppsView setAlpha:0];
[favoriteAppsView setAlpha:1];
}];
[appsTab setTintColor:[UIColor grayColor]];
[favoritesTab setTintColor:[UIColor whiteColor]];
}
}
%new
-(void)loadBlurView {
if (blurView) {
//[blurView release];
}
UIVisualEffect *blurEffect;
if ([[prefs objectForKey:@"nightModeEnabled"] boolValue] == YES) {
blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
}
else {
blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
}
blurView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
blurView.alpha = 1;
if ([self currentOrientation] == 0) {
blurView.frame = CGRectMake(0,0,SCREEN_WIDTH,SCREEN_HEIGHT);
}
else {
blurView.frame = CGRectMake(0,0,SCREEN_WIDTH,SCREEN_WIDTH);
}
}
%new
-(void)loadMainDrawerView {
mainDrawerView = [[UIView alloc] init];
UIView* mainView = [self contentView];
mainDrawerView.frame = CGRectMake(0,0,mainView.bounds.size.width,mainView.bounds.size.height);
//mainDrawerView.frame = CGRectMake(0,0,SCREEN_WIDTH,SCREEN_HEIGHT);
mainDrawerView.alpha = 0;
//mainDrawerView.transform =CGAffineTransformMakeScale(0,0);
if (IS_OS_8_OR_LATER) {
if(![blurView isDescendantOfView:mainDrawerView]) {
[mainDrawerView addSubview:blurView];
}
}
else {
if ([[prefs objectForKey:@"nightModeEnabled"] boolValue] == YES) {
[mainDrawerView setBackgroundColor:[[UIColor blackColor] colorWithAlphaComponent:0.9]];
}
else {
[mainDrawerView setBackgroundColor:[[UIColor whiteColor] colorWithAlphaComponent:1.0]];
}
}
// DRM Stuff
if (![[NSFileManager defaultManager] fileExistsAtPath:@"/var/lib/dpkg/info/me.gmoran.appdrawer.list"] && ![[NSFileManager defaultManager] fileExistsAtPath:@"/var/lib/dpkg/info/org.thebigboss.appdrawer.list"]) {
UILabel* label = [[UILabel alloc] init];
label.text = @"TRIAL VERSION";
label.font = [UIFont systemFontOfSize:50];
label.backgroundColor = [UIColor clearColor];
label.textColor = [UIColor colorWithRed:0.87 green:0.87 blue:0.87 alpha:1.0];
label.textAlignment = NSTextAlignmentCenter;
label.alpha = 0.6;
[label setFrame:CGRectMake(0,0,400,90)];
[label setCenter:CGPointMake(mainDrawerView.frame.size.width / 2, mainDrawerView.frame.size.height / 2)];
[mainDrawerView addSubview: label];
[label release];
}
// End DRM Stuff
[mainDrawerView addSubview:drawerAppsView];
[mainDrawerView addSubview:favoriteAppsView];
if (tabIndex == 0) {
[favoriteAppsView setAlpha:0];
[drawerAppsView setAlpha:1];
}
else {
[favoriteAppsView setAlpha:1];
[drawerAppsView setAlpha:0];
}
if (!HORIZONTAL_PAGING_ENABLED) {
drawerAppsView.center = CGPointMake(mainDrawerView.center.x, drawerAppsView.center.y);
favoriteAppsView.center = CGPointMake(mainDrawerView.center.x, drawerAppsView.center.y);
}
UIView* separatorView = [[UIView alloc] init];
[separatorView setFrame:CGRectMake(0,90, SCREEN_WIDTH-20, 3)];
[separatorView setBackgroundColor:[UIColor colorWithRed:0/255.0f green:163/255.0f blue:235/255.0f alpha:1.0f]];
[mainDrawerView addSubview:separatorView];
[separatorView release];
//////
appsTab = [UIButton buttonWithType:UIButtonTypeSystem];
[appsTab addTarget:self action:@selector(switchTabs:) forControlEvents:UIControlEventTouchUpInside];
[appsTab setTitle:@"Apps" forState:UIControlStateNormal];
if (tabIndex == 0) {
[appsTab setTintColor:[UIColor whiteColor]];
}
else {
[appsTab setTintColor:[UIColor grayColor]];
}
appsTab.frame = CGRectMake(0.0, 45.0, 70.0, 60.0);
appsTab.titleLabel.font = [UIFont systemFontOfSize:18];
[mainDrawerView addSubview:appsTab];
//////
favoritesTab = [UIButton buttonWithType:UIButtonTypeSystem];
[favoritesTab addTarget:self action:@selector(switchTabs:) forControlEvents:UIControlEventTouchUpInside];
[favoritesTab setTitle:@"Favorites" forState:UIControlStateNormal];
if (tabIndex == 0) {
[favoritesTab setTintColor:[UIColor grayColor]];
}
else {
[favoritesTab setTintColor:[UIColor whiteColor]];
}
favoritesTab.frame = CGRectMake(80.0, 45.0, 90.0, 60.0);
favoritesTab.titleLabel.font = [UIFont systemFontOfSize:18];
[mainDrawerView addSubview:favoritesTab];
//////
/*
UILabel* titleLabel = [[UILabel alloc] init];
titleLabel.text = @"Apps";
titleLabel.font = [UIFont systemFontOfSize:18];
titleLabel.backgroundColor = [UIColor clearColor];
titleLabel.textColor = [UIColor whiteColor];
titleLabel.textAlignment = NSTextAlignmentCenter;
[titleLabel setFrame:CGRectMake(0,60,70,30)];
[mainDrawerView addSubview:titleLabel];
[titleLabel release];
*/
//[backgroundView release];
}
#define PADDING [self iconPadding]
#define HORIZONTAL_PADDING PADDING + 5
#define COLUMNS [self iconColumns]
#define LS_COLUMNS 8
#define WIDTH 65
#define HEIGHT 65
#if verticalScrollingEnabled
#define X 5
#define Y 0
#else
#define X 0
#define Y 0
#endif
#define TOTALBUTTONS [installedApps count]
%new
-(void)loadDrawerAppsView {
if (drawerAppsView) {
//[drawerAppsView release];
}
drawerAppsView = [[UIScrollView alloc] init];
[drawerAppsView setShowsHorizontalScrollIndicator:NO];
[drawerAppsView setShowsVerticalScrollIndicator:NO];
//mainDrawerView.frame = CGRectMake(0,0,SCREEN_WIDTH,SCREEN_HEIGHT);
int viewWidth = ((WIDTH + PADDING) * COLUMNS) - PADDING;
int viewHeight = SCREEN_HEIGHT;
if (HORIZONTAL_PAGING_ENABLED) {
drawerAppsView.frame = CGRectMake(0,100,SCREEN_WIDTH,viewHeight);
}
else {
drawerAppsView.frame = CGRectMake(0,100,viewWidth,viewHeight);
}
[drawerAppsView setBackgroundColor:[UIColor clearColor]];
drawerAppsView.pagingEnabled = NO;
//unsigned int roundedHeight = 20.5 * [[self installedApps] count];
int roundedHeight = ((HEIGHT + HORIZONTAL_PADDING + Y) * ([installedApps count] / COLUMNS)) + 95;
if (([installedApps count] % [self iconColumns]) != 0) {
roundedHeight = roundedHeight + 95;
}
int roundedWidth = ((WIDTH + PADDING) * COLUMNS);
if (HORIZONTAL_PAGING_ENABLED) {
[drawerAppsView setContentSize:CGSizeMake(roundedWidth, viewHeight)];
}
else {
[drawerAppsView setContentSize:CGSizeMake(viewWidth, roundedHeight)];
}
for (UIButton* appIcon in appButtons) {
if ([[drawerAppsView subviews] count] <= [appButtons count]) {
[drawerAppsView addSubview:appIcon];
}
}
drawerAppsView.autoresizingMask = (UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleHeight);
}
%new
-(void)loadFavoriteAppsView {
favoriteAppsView = [[UIScrollView alloc] init];
//mainDrawerView.frame = CGRectMake(0,0,SCREEN_WIDTH,SCREEN_HEIGHT);
int viewWidth = ((WIDTH + PADDING) * COLUMNS) - PADDING;
int viewHeight = SCREEN_HEIGHT;
if (HORIZONTAL_PAGING_ENABLED) {
favoriteAppsView.frame = CGRectMake(0,100,SCREEN_WIDTH,viewHeight);
}
else {
favoriteAppsView.frame = CGRectMake(0,100,viewWidth,viewHeight);
}
[favoriteAppsView setBackgroundColor:[UIColor clearColor]];
favoriteAppsView.pagingEnabled = NO;
//unsigned int roundedHeight = 20.5 * [[self installedApps] count];
int roundedHeight = ((HEIGHT + HORIZONTAL_PADDING + Y) * ([favoriteApps count] / COLUMNS)) + 95;
if (([favoriteApps count] % [self iconColumns]) != 0) {
roundedHeight = roundedHeight + 95;
}
int roundedWidth = ((WIDTH + PADDING) * COLUMNS);
if (HORIZONTAL_PAGING_ENABLED) {
[favoriteAppsView setContentSize:CGSizeMake(roundedWidth, viewHeight)];
}
else {
[favoriteAppsView setContentSize:CGSizeMake(viewWidth, roundedHeight)];
}
for (UIButton* appIcon in favoriteButtons) {
if ([[favoriteAppsView subviews] count] <= [appButtons count]) {
[favoriteAppsView addSubview:appIcon];
}