-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTweak.xm
1706 lines (1378 loc) · 62.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
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
#import "allTheHeaders.h"
static ALApplicationList *applicationList = nil;
static NSArray *sortedDisplayIdentifiers = nil;
static NSArray *enabledSections = nil;
static NSMutableArray *favoritesDisplayIdentifiers = nil;
static NSMutableArray *listLauncherDisplayIdentifiers = nil;
static NSMutableArray *recentApplications = nil;
static int maxRecent = 3;
static NSString *recentName = @"RECENT";
static NSString *applicationListName = @"APPLICATION LIST";
static NSString *favoritesName = @"FAVORITES";
static NSString *lockscreenIdentifier = nil;
static NSString *applicationIdentifier = nil;
static _UIBackdropView *background = nil;
static int headerStyle = 2060;
static bool logging, hideKeyboard, selectall, replace_nc, show_badges, clearResults, changeHeader, scrolltop = false;
static bool force_rotation, ls_enabled, blur_section_header_enabled = true;
static NSCache *nameCache = [NSCache new];
static NSCache *iconCache = [NSCache new];
static NSMutableArray *indexValues = nil;
static NSMutableArray *indexPositions = nil;
static UIWindow *window = nil;
static UIWindow *originalWindow = nil;
static SBRootFolderView *fv = nil;
static SBRootFolderController *fvd = nil;
static UIView *gesTargetview = nil;
static int beforeWindowLevel = -1;
static SearchlightViewController *cusViewController = nil;
static bool didAddViewController, didNotAddViewController, statusBarWasHidden = NO;
static void createAlphabet() {
if(logging) NSLog(@"ListLauncher7 - Inside createAlphabet");
NSMutableArray *baseAlphabet = [NSMutableArray arrayWithObjects:@"#",@"A",@"B",@"C",@"D",@"E",@"F",@"G", @"H",@"I",@"J",@"K",@"L",@"M",@"N",@"O",@"P",@"Q",@"R",@"S",@"T",@"U",@"V",@"W",@"X",@"Y",@"Z",nil];
indexValues = [[@[] mutableCopy] retain];
if([enabledSections containsObject:@"Application List"]) {
if(logging) NSLog(@"enabledSections = %@",enabledSections);
for(id spec in enabledSections) {
if([spec isEqual:@"Recent"]) {
[indexValues insertObject:@"▢" atIndex:[indexValues count]];
} else if([spec isEqual:@"Favorites"]) {
[indexValues insertObject:@"☆" atIndex:[indexValues count]];
} else {
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"[a-zA-Z]" options:0 error:NULL];
NSString *firstAppName = [[applicationList valueForKey:@"displayName" forDisplayIdentifier:[listLauncherDisplayIdentifiers objectAtIndex:0]] substringToIndex:1];
NSTextCheckingResult *match = [regex firstMatchInString:firstAppName options:0 range:NSMakeRange(0, [firstAppName length])];
if(match) { NSLog(@" removed first inside");
[baseAlphabet removeObjectAtIndex:0];
}
for(id letter in baseAlphabet) {
[indexValues insertObject:letter atIndex:[indexValues count]];
}
}
}
if(logging) NSLog(@"base index values have been created");
if(logging) NSLog(@"indexValues = %@",indexValues);
indexPositions = [[NSMutableArray arrayWithArray:indexValues] retain];
//NSMutableArray *copyOfIndexes = [NSMutableArray arrayWithArray:indexValues];
for(int i = 0; i < [indexValues count]; i++) {
if([[indexValues objectAtIndex:i] isEqual:@"▢"] || [[indexValues objectAtIndex:i] isEqual:@"☆"] || [[indexValues objectAtIndex:i] isEqual:@"#"]) {
[indexPositions replaceObjectAtIndex:i withObject:[[NSNumber alloc] initWithInt:i]];
} else {
BOOL hasLetter = NO;
for(int j = 0; j < [listLauncherDisplayIdentifiers count]; j++) {
if([[[applicationList valueForKey:@"displayName" forDisplayIdentifier:[listLauncherDisplayIdentifiers objectAtIndex:j]] uppercaseString] hasPrefix:[indexValues objectAtIndex:i]]) {
[indexPositions replaceObjectAtIndex:i withObject:[[NSNumber alloc] initWithInt:j]];
hasLetter = YES;
if(logging) NSLog(@"has letter = %@",[indexValues objectAtIndex:i]);
break;
}
}
if(!hasLetter) {
if(logging) NSLog(@"does NOT have letter = %@",[indexValues objectAtIndex:i]);
[indexValues removeObjectAtIndex:i];
[indexPositions removeObjectAtIndex:i];
i = 0;
}
}
}
if(logging) NSLog(@"done with the awesome loop");
if(logging) NSLog(@"indexValues = %@",indexValues);
if(logging) NSLog(@"indexPositions = %@",indexPositions);
}
}
static void setApplicationListDisplayIdentifiers (NSMutableDictionary *settings) {
if(logging) NSLog(@"inside setApplicationListDisplayIdentifiers");
listLauncherDisplayIdentifiers = [[NSMutableArray arrayWithArray:sortedDisplayIdentifiers] retain];
NSArray *disabledApps = [settings objectForKey:@"disabled"] ?: @[];
for(id spec in disabledApps) {
[listLauncherDisplayIdentifiers removeObject:spec];
}
[disabledApps release];
}
static void setFavorites (NSMutableDictionary *settings) {
if(logging) NSLog(@"inside setFavorites");
favoritesDisplayIdentifiers = [(NSMutableArray *) [settings valueForKey:@"myfavorites"] retain];
// NSMutableArray *favoriteList = [(NSMutableArray *) [settings valueForKey:@"favorites"] retain];
// favoriteList = [[favoriteList sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
// return [[obj1 objectAtIndex:1] integerValue] > [[obj2 objectAtIndex:1] integerValue] ;}] mutableCopy];
// for(id spec in favoriteList) {
// [favoritesDisplayIdentifiers insertObject:[spec objectAtIndex:0] atIndex:[favoritesDisplayIdentifiers count]];
// }
// [favoriteList release];
}
static void generateAppList () {
NSString *plistPath = @"/var/mobile/Library/Preferences/org.thebigboss.searchlight.applist.plist";
NSMutableDictionary *appsettings = [[NSMutableDictionary alloc] initWithContentsOfFile:plistPath];
if(!appsettings) {
appsettings = [NSMutableDictionary dictionary];
[appsettings writeToFile:plistPath atomically:YES];
}
[appsettings setValue:sortedDisplayIdentifiers forKey:@"applications"];
[appsettings writeToFile:plistPath atomically:YES];
}
static void launchApplication() {
@synchronized(applicationIdentifier) {
if(applicationIdentifier) {
if(logging) {
NSLog(@"Searchlight: about to launch = %@",applicationIdentifier);
}
@try {
[[UIApplication sharedApplication] launchApplicationWithIdentifier:applicationIdentifier suspended:NO];
}
@catch (NSException * e) {
NSLog(@"Searchlight: error! = %@ couldn't launch app",e);
}
}
applicationIdentifier = nil;
}
}
static void loadPrefs() {
NSMutableDictionary *settings = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/var/mobile/Library/Preferences/org.thebigboss.searchlight.plist"];
logging = [settings objectForKey:@"logging_enabled"] ? [[settings objectForKey:@"logging_enabled"] boolValue] : NO;
if(logging) NSLog(@"Searchlight Settings = %@",settings);
hideKeyboard = [settings objectForKey:@"hide_keyboard"] ? [[settings objectForKey:@"hide_keyboard"] boolValue] : NO;
selectall = [settings objectForKey:@"hide_keyboard"] ? [[settings objectForKey:@"selectall"] boolValue] : NO;
headerStyle = [settings objectForKey:@"header_style"] ? [[settings objectForKey:@"header_style"] integerValue] : 2060;
force_rotation = [settings objectForKey:@"rotation_enabled"] ? [[settings objectForKey:@"rotation_enabled"] boolValue] : YES;
replace_nc = [settings objectForKey:@"nc_replace_enabled"] ? [[settings objectForKey:@"nc_replace_enabled"] boolValue] : NO;
show_badges = [settings objectForKey:@"show_badges"] ? [[settings objectForKey:@"show_badges"] boolValue] : NO;
ls_enabled = [settings objectForKey:@"ls_enabled"] ? [[settings objectForKey:@"ls_enabled"] boolValue] : YES;
blur_section_header_enabled = [settings objectForKey:@"blur_section_header_enabled"] ? [[settings objectForKey:@"blur_section_header_enabled"] boolValue] : YES;
clearResults = [settings objectForKey:@"clearResults"] ? [[settings objectForKey:@"clearResults"] boolValue] : NO;
changeHeader = [settings objectForKey:@"changeHeader"] ? [[settings objectForKey:@"changeHeader"] boolValue] : NO;
scrolltop = [settings objectForKey:@"scrollTop"] ? [[settings objectForKey:@"scrollTop"] boolValue] : NO;
enabledSections = [settings objectForKey:@"enabledSections"] ?: @[]; [enabledSections retain];
maxRecent = [settings objectForKey:@"maxRecent"] ? [[settings objectForKey:@"maxRecent"] integerValue] : 3;
applicationList = [[ALApplicationList sharedApplicationList] retain];
recentName = [settings objectForKey:@"recentName"] ?: recentName; recentName = [recentName isEqual:@""] ? @"RECENT" : recentName;
applicationListName = [settings objectForKey:@"applicationListName"] ?: applicationListName; applicationListName = [applicationListName isEqual:@""] ? @"APPLICATION LIST" : applicationListName;
favoritesName = [settings objectForKey:@"favoriteName"] ?: favoritesName; favoritesName = [favoritesName isEqual:@""] ? @"FAVORITES" : favoritesName;
//sortedDisplayIdentifiers = [[[applicationList.applications allKeys] sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
// return [[applicationList.applications objectForKey:obj1] caseInsensitiveCompare:[applicationList.applications objectForKey:obj2]];}] retain];
NSDictionary *tempApplications = applicationList.applications;
sortedDisplayIdentifiers = [[[tempApplications allKeys] sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
return [[tempApplications objectForKey:obj1] caseInsensitiveCompare:[tempApplications objectForKey:obj2]];}] retain];
setApplicationListDisplayIdentifiers(settings);
setFavorites(settings);
if(logging) NSLog(@"favorites = %@",favoritesDisplayIdentifiers);
createAlphabet();
if(logging) NSLog(@"Done creating alphabet");
generateAppList();
//[[%c(SBSearchViewController) sharedInstance] setHeaderbyChangingFrame:NO withPushDown:20];
SBAppSwitcherModel *switcherModel = [%c(SBAppSwitcherModel) sharedInstance];
recentApplications = [[[switcherModel snapshotOfFlattenedArrayOfAppIdentifiersWhichIsOnlyTemporary] mutableCopy] retain];
//recentApplications = [[[NSMutableArray alloc] initWithArray:[switcherModel snapshotOfFlattenedArrayOfAppIdentifiersWhichIsOnlyTemporary] copyItems:YES] autorelease];
//NSLog(@"all applications = %@",[[%c(SBApplicationController) sharedInstance] allApplications]);
//NSMutableDictionary *appdic = MSHookIvar<NSMutableDictionary *>([%c(SBApplicationController) sharedInstance], "_applicationsByBundleIdentifer");
//NSLog(@"applciation dictionary = %@",appdic);
//NSLog(@"recent apps = %@", recentApplications);
NSLog(@"snapshot = %@",[[%c(SBAppSwitcherModel) sharedInstance] snapshot]);
NSLog(@"class of snapshot = %@",[[[%c(SBAppSwitcherModel) sharedInstance] snapshot] class]);
//dictionary of "<SBDisplayLayout: 0x170838540> {\n SBDisplayLayoutDisplayItemsPlistKey = (\n {\n SBDisplayItemDisplayIdentifierPlistKey = \"com.apple.Preferences\";\n SBDisplayItemTypePlistKey = App;\n }\n );\n SBDisplayLayoutSizePlistKey = (\n 0\n );\n}",
if(logging) NSLog(@"Done with settings");
}
static void savePrefs() {
loadPrefs();
SBSearchViewController *sview = [%c(SBSearchViewController) sharedInstance];
//[sview _updateTableContents];
UITableView *stable = MSHookIvar<UITableView *>(sview, "_tableView");
[stable reloadData];
}
@implementation CustomTransitionAnimator
- (NSTimeInterval)transitionDuration:(id <UIViewControllerContextTransitioning>)transitionContext {
return 0.3f;
}
- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext {
// Grab the from and to view controllers from the context
UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
// Set our ending frame. We'll modify this later if we have to
CGRect endFrame = [[UIScreen mainScreen] bounds];
SBSearchHeader *sheader = MSHookIvar<SBSearchHeader *>([%c(SBSearchViewController) sharedInstance], "_searchHeader");
UITableView *tableView = MSHookIvar<UITableView *>([%c(SBSearchViewController) sharedInstance], "_tableView");
SBSearchResultsBackdropView *backDrop = MSHookIvar<SBSearchResultsBackdropView *>([%c(SBSearchViewController) sharedInstance], "_tableBackdrop");
if (self.presenting) {
//fromViewController.view.userInteractionEnabled = NO;
[transitionContext.containerView addSubview:fromViewController.view];
[transitionContext.containerView addSubview:toViewController.view];
CGRect startFrame = endFrame;
startFrame.origin.y -= 64;
toViewController.view.frame = startFrame;
sheader.alpha = 1.0;
tableView.alpha = 0.3;
backDrop.alpha = 0.3;
[UIView animateWithDuration:0.1f animations:^{
fromViewController.view.tintAdjustmentMode = UIViewTintAdjustmentModeAutomatic;
toViewController.view.frame = endFrame;
tableView.alpha = 0.6;
backDrop.alpha = 0.6;
} completion:^(BOOL finished) {
[UIView animateWithDuration:[self transitionDuration:transitionContext]-0.1f animations:^{
tableView.alpha = 1.0;
backDrop.alpha = 1.0;
} completion:^(BOOL finished) {
[transitionContext completeTransition:YES];
}];
}];
}
else {
//toViewController.view.userInteractionEnabled = YES;
[transitionContext.containerView addSubview:toViewController.view];
[transitionContext.containerView addSubview:fromViewController.view];
endFrame.origin.y -= 64;
[UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{
toViewController.view.tintAdjustmentMode = UIViewTintAdjustmentModeAutomatic;
fromViewController.view.frame = endFrame;
sheader.alpha = 1.0;
tableView.alpha = 0.0;
backDrop.alpha = 0.0;
} completion:^(BOOL finished) {
if([[%c(SpringBoard) sharedApplication].keyWindow.rootViewController isEqual:cusViewController] || cusViewController) {
dispatch_async(dispatch_get_main_queue(), ^{
//[cusViewController dismissViewControllerAnimated:NO completion:nil];
if(cusViewController && cusViewController.view) {
[cusViewController.view removeFromSuperview];
NSLog(@"this was called - removing cusViewController.view from superview");
}
});
// [cusViewController release];
// cusViewController = nil;
if([%c(SpringBoard) sharedApplication].keyWindow && [%c(SpringBoard) sharedApplication].keyWindow.rootViewController) {
[%c(SpringBoard) sharedApplication].keyWindow.rootViewController = nil;
[%c(SpringBoard) sharedApplication].keyWindow.windowLevel = beforeWindowLevel;
}
}
if(statusBarWasHidden) {
[[%c(SpringBoard) sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
statusBarWasHidden = NO;
}
launchApplication();
[transitionContext completeTransition:YES];
}];
}
}
@end
@implementation SearchlightViewController
-(BOOL)shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
return (NSUInteger)UIInterfaceOrientationMaskAll;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
@end
%hook SBNotificationCenterViewController
-(void)presentGrabberView {
if(!replace_nc) %orig;
}
%end
// %hook SBBacklightController
// -(double)_currentLockScreenIdleTimerInterval {
// if(logging) %log;
// NSLog(@"orig = %f",(float)%orig);
// return %orig;
// }
// -(void)_resetLockScreenIdleTimerWithDuration:(double)delay mode:(int)mode {
// if(logging) %log;
// NSLog(@"_currentLockScreenIdleTimerInterval = %f",(float)[self _currentLockScreenIdleTimerInterval]);
// %orig;
// }
// %end
%hook SBNotificationCenterController
-(void)beginPresentationWithTouchLocation:(CGPoint)arg1 {
%log;
if(!replace_nc) { %orig; } else {
[[%c(SBSearchViewController) sharedInstance] show];
}
}
-(void)updateTransitionWithTouchLocation:(CGPoint)arg1 velocity:(CGPoint)arg2 {
//%log;
if(!replace_nc) { %orig; } else {
// double screenHeight = CGRectGetHeight([UIScreen mainScreen].bounds);
// //double screenHeight = [UIScreen mainScreen].bounds.size.height;
// CGFloat y = arg1.y;
// double ans = y/screenHeight;
// NSLog(@"screen height = %f",screenHeight);
// NSLog(@"y = %f",y);
// NSLog(@"y/screenheight = %f",ans);
// [[%c(SBSearchViewController) sharedInstance] searchGesture:[%c(SBSearchGesture) sharedInstance] changedPercentComplete:ans];
}
}
%end
%hook SBSearchViewController
-(void)_searchFieldEditingChanged {
if(logging) %log;
%orig;
[[%c(SBBacklightController) sharedInstance] resetLockScreenIdleTimer];
}
-(void)viewDidLayoutSubviews {
if(logging) %log;
%orig;
static dispatch_once_t initialPreferenceLoadToken;
dispatch_once(&initialPreferenceLoadToken, ^{
loadPrefs();
});
SBSearchTableView *table = MSHookIvar<SBSearchTableView *>(self, "_tableView");
table.sectionIndexColor = [UIColor whiteColor]; // text color
table.sectionIndexTrackingBackgroundColor = [UIColor clearColor]; //bg touched
table.sectionIndexBackgroundColor = [UIColor clearColor]; //bg touched
[table reloadData];
self.modalPresentationStyle = UIModalPresentationCustom;
self.transitioningDelegate = self;
//SBSearchTableHeaderView *header = [[%c(SBSearchTableHeaderView) alloc] initWithReuseIdentifier:@"SBSearchTableViewHeaderFooterView"];
//[table setTableHeaderView:header];
}
-(BOOL)gestureRecognizerShouldBegin:(id)arg1 { %log; return %orig; }
%new
- (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented
presentingController:(UIViewController *)presenting
sourceController:(UIViewController *)source {
CustomTransitionAnimator *animator = [CustomTransitionAnimator new];
animator.presenting = YES;
return animator;
}
%new
- (id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed {
CustomTransitionAnimator *animator = [CustomTransitionAnimator new];
return animator;
}
%new
-(void)show {
UIView *view = MSHookIvar<UIView *>(self, "_view");
originalWindow = MSHookIvar<UIWindow *>(self, "_presentingWindow");
UIViewController *vc = MSHookIvar<UIViewController *>(self, "_mainViewController");
SBSearchGesture *ges = [%c(SBSearchGesture) sharedInstance];
id topDisplay = [[%c(SpringBoard) sharedApplication] _accessibilityFrontMostApplication];
if(!gesTargetview) gesTargetview = [MSHookIvar<SBIconScrollView *>(ges, "_targetView") retain];
if ([[view superview] isKindOfClass:[%c(SBRootFolderView) class]]) {
fv = [(SBRootFolderView *)[view superview] retain];
if([[fv delegate] isKindOfClass:[%c(SBRootFolderController) class]])
fvd = [[fv delegate] retain];
}
if(logging) {
NSLog(@"Searchlight: presenting Window = %@", originalWindow);
NSLog(@"Searchlight: main View Controller = %@",vc);
NSLog(@"Searchlight: frontmostapplication = %@",topDisplay);
NSLog(@"Searchlight: topDisplay = %@",[[%c(SpringBoard) sharedApplication] _accessibilityTopDisplay]);
NSLog(@"Searchlight: runningapps = %@",[[%c(SpringBoard) sharedApplication] _accessibilityRunningApplications]);
NSLog(@"Searchlight: sharedApplication = %@",[%c(SpringBoard) sharedApplication]);
NSLog(@"Searchlight: keyWindow = %@",[%c(SpringBoard) sharedApplication].keyWindow);
NSLog(@"Searchlight: keyWindow root view Controller = %@",[UIApplication sharedApplication].keyWindow.rootViewController);
NSLog(@"Searchlight: keyWindow root view Controller = %@",[%c(SpringBoard) sharedApplication].keyWindow.rootViewController);
NSLog(@"Searchlight: keyWindow delegate = %@",[[[UIApplication sharedApplication] keyWindow] delegate]);
NSLog(@"Searchlight: keyWindow delegate = %@",[[[%c(SpringBoard) sharedApplication] keyWindow] delegate]);
NSLog(@"Searchlght: SBSearchGesture's observers = %@",MSHookIvar<NSHashTable *>(ges, "_observers"));
NSLog(@"Searchlght: SBSearchGesture's scrollview = %@",MSHookIvar<SBSearchScrollView *>(ges, "_scrollView"));
NSLog(@"Searchlght: SBSearchGesture's _panGestureRecognizer = %@",MSHookIvar<UIPanGestureRecognizer *>(ges, "_panGestureRecognizer"));
}
// HBPassthroughWindow when on homescreen
if(![[%c(SBSearchViewController) sharedInstance] isVisible] && fv && fvd && gesTargetview) {
if([%c(SpringBoard) sharedApplication].keyWindow) {
if(!topDisplay && [[%c(SpringBoard) sharedApplication].keyWindow isKindOfClass:%c(SBAppWindow)] &&
![(SpringBoard*)[%c(SpringBoard) sharedApplication] isLocked] &&
![[%c(SBUIController) sharedInstance] isAppSwitcherShowing]) {
// is on homescreen
NSLog(@"Searchlight: on home screen!");
[[%c(SpringBoard) sharedApplication] _revealSpotlight];
} else if(![%c(SpringBoard) sharedApplication].keyWindow.rootViewController) {
NSLog(@"Searchlight: setting rootViewController to Search");
NSLog(@"Searchlight:window.level = %f",[%c(SpringBoard) sharedApplication].keyWindow.windowLevel);
UIStatusBar *status = [(SpringBoard *)[%c(SpringBoard) sharedApplication] statusBar];
NSLog(@"statusbar = %f",((UIWindow *)[status statusBarWindow]).windowLevel);
NSLog(@"Searchlight: statusbar.windowLevel %f",UIWindowLevelStatusBar);
beforeWindowLevel = [%c(SpringBoard) sharedApplication].keyWindow.windowLevel;
[%c(SpringBoard) sharedApplication].keyWindow.windowLevel = ((UIWindow *)[status statusBarWindow]).windowLevel - 1;
if(!cusViewController)
cusViewController = [[SearchlightViewController alloc] init];
if(logging) NSLog(@"Searchlight: about to set root controller");
NSLog(@"cusViewControllerWindow = %@",cusViewController.window);
NSLog(@"cusViewControllerWindowLevel = %f",cusViewController.window.windowLevel);
//UINavigationController *navController = MSHookIvar<UINavigationController *>([%c(SBSearchViewController) sharedInstance], "_navigationController");
@try {
//[ges setTargetView:[%c(SpringBoard) sharedApplication].keyWindow];
[%c(SpringBoard) sharedApplication].keyWindow.rootViewController = cusViewController;
[ges revealAnimated:YES];
if([UIApplication sharedApplication].statusBarHidden) {
statusBarWasHidden = YES;
NSLog(@"Searchlight: statusbar is hidden");
[[%c(SpringBoard) sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];
}
[cusViewController presentViewController:self animated:YES completion:^{
if([UIApplication sharedApplication].statusBarHidden) {
statusBarWasHidden = YES;
NSLog(@"Searchlight: statusbar is hidden - trying again");
[[%c(SpringBoard) sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationSlide];
}
}];
// this is needed for it to actually show
[ges revealAnimated:YES];
didAddViewController = YES;
} @catch (NSException * e) {
NSLog(@"Searchlight: error! = %@",e);
if(statusBarWasHidden) {
statusBarWasHidden = NO;
[[%c(SpringBoard) sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
}
[[%c(SBSearchGesture) sharedInstance] resetAnimated:YES];
[[%c(SBSearchViewController) sharedInstance] _fadeOutAndHideKeyboardAnimated:YES completionBlock:nil];
}
}
else {
@try {
//[ges setTargetView:[%c(SpringBoard) sharedApplication].keyWindow];
if([UIApplication sharedApplication].statusBarHidden) {
NSLog(@"Searchlight: setting rootViewController to Search");
NSLog(@"Searchlight:window.level = %f",[%c(SpringBoard) sharedApplication].keyWindow.windowLevel);
UIStatusBar *status = [(SpringBoard *)[%c(SpringBoard) sharedApplication] statusBar];
NSLog(@"statusbar = %f",((UIWindow *)[status statusBarWindow]).windowLevel);
beforeWindowLevel = [%c(SpringBoard) sharedApplication].keyWindow.windowLevel;
NSLog(@"Searchlight: statusbar.windowLevel %f",UIWindowLevelStatusBar);
// window.windowLevel = UIWindowLevelStatusBar - 5; //one less than the statusbar
[%c(SpringBoard) sharedApplication].keyWindow.windowLevel = ((UIWindow *)[status statusBarWindow]).windowLevel - 1;
statusBarWasHidden = YES;
NSLog(@"Searchlight: statusbar is hidden");
[[%c(SpringBoard) sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];
}
if(logging) NSLog(@"Searchlight: Attempting to present view controller");
[(UIViewController *)[[UIApplication sharedApplication] keyWindow].rootViewController presentViewController:self animated:YES completion:nil];
[ges revealAnimated:YES];
didNotAddViewController = YES;
} @catch (NSException * e) {
NSLog(@"Searchlight: error! = %@",e);
if(statusBarWasHidden) {
statusBarWasHidden = NO;
[[%c(SpringBoard) sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
}
[[%c(SBSearchGesture) sharedInstance] resetAnimated:YES];
[[%c(SBSearchViewController) sharedInstance] _fadeOutAndHideKeyboardAnimated:YES completionBlock:nil];
}
}
}
}
}
%new
-(void)forceRotation {
if(force_rotation) {
float orientation = [[%c(SpringBoard) sharedApplication] activeInterfaceOrientation];
NSLog(@"Searchlight - activeInterfaceOrientation: %f",(float)[[%c(SpringBoard) sharedApplication] activeInterfaceOrientation]);
NSLog(@"Searchlight - interfaceOrientationForCurrentDeviceOrientation: %f",(float)[(SpringBoard *)[%c(SpringBoard) sharedApplication] interfaceOrientationForCurrentDeviceOrientation]);
NSLog(@"Searchlight - rotatating to %f",orientation);
//is on the home screen so open in the orientation of the icons
// id topDisplay = [[%c(SpringBoard) sharedApplication] _accessibilityFrontMostApplication];
// if(fv && !topDisplay && [[%c(SpringBoard) sharedApplication].keyWindow isKindOfClass:%c(SBAppWindow)] &&
// ![(SpringBoard*)[%c(SpringBoard) sharedApplication] isLocked] &&
// ![[%c(SBUIController) sharedInstance] isAppSwitcherShowing]) {
// NSLog(@"fv orientation = %f",(float)fv.orientation);
// if(fv.orientation >= 0.0) {
// orientation = fv.orientation;
// }
// }
[[%c(SpringBoard) sharedApplication].keyWindow _updateStatusBarToInterfaceOrientation:orientation duration:0.0];
[UIView animateWithDuration:0.5f animations:^{
switch((int)orientation) {
case 1: { // normal
self.view.transform = CGAffineTransformMakeRotation(0);
self.view.frame = [UIScreen mainScreen].bounds;
break;
}
case 2: { //upside down = good
self.view.transform = CGAffineTransformMakeRotation(M_PI);
self.view.frame = [UIScreen mainScreen].bounds;
break;
}
case 3: { // left = good
self.view.transform = CGAffineTransformMakeRotation(M_PI_2);
self.view.frame = [UIScreen mainScreen].bounds;
break;
}
default: {//4 = right
self.view.transform = CGAffineTransformMakeRotation(M_PI + M_PI_2);
self.view.frame = [UIScreen mainScreen].bounds;
break;
}
}
} completion:^(BOOL finished){
[[%c(SBSearchViewController) sharedInstance] setHeaderBackground];
}];
}
}
%new
-(void)setHeaderBackground {
UINavigationController *nav = MSHookIvar<UINavigationController *>([%c(SBSearchViewController) sharedInstance], "_navigationController");
if(logging) {
NSLog(@"before");
NSLog(@"navigation controller view = %@",nav.view);
NSLog(@"navigation controller bar = %@",nav.navigationBar);
}
// nav.navigationBar.clipsToBounds = NO;
// nav.edgesForExtendedLayout = UIRectEdgeNone;
// nav.automaticallyAdjustsScrollViewInsets = NO;
if(changeHeader) {
for(UIView *subview in [nav.navigationBar subviews]) {
if([subview isKindOfClass:[%c(SBWallpaperEffectView) class]]) {
NSLog(@"SBwallpapereffectview = %@",subview);
//subview.alpha = 0.0;
[subview removeFromSuperview];
//[(SBWallpaperEffectView *)subview setStyle:0];
// Creating blur view using settings object
}
}
if(background) {
[background removeFromSuperview];
}
_UIBackdropViewSettings *settings = [_UIBackdropViewSettings settingsForStyle:headerStyle];
// initialization of the blur view
background = [[_UIBackdropView alloc] initWithFrame:CGRectMake(0,-20,nav.navigationBar.frame.size.width,nav.navigationBar.frame.size.height+20) autosizesToFitSuperview:NO settings:settings];
//[nav.navigationBar _setBackgroundView:background];
background.clipsToBounds = NO;
//nav.navigationBar.frame = CGRectMake(0,0,background.frame.size.width,background.frame.size.height+15);
//nav.navigationBar.frame = CGRectMake(-15,0,background.frame.size.width,background.frame.size.height);
//background.frame = CGRectMake(-15,0,background.frame.size.width,background.frame.size.height);
// UIView *bgview = MSHookIvar<UIView *>(nav.navigationBar, "_backgroundView");
// bgview = background;
[nav.navigationBar insertSubview:background atIndex:0];
}
//[nav.navigationBar addSubview:background];
// [nav.navigationBar setBarStyle:UIBarStyleBlack];
//[nav.navigationBar _setBarPosition:UIBarPositionTopAttached];
if(logging) {
NSLog(@"after");
NSLog(@"navigation controller view = %@",nav.view);
NSLog(@"navigation bar = %@",nav.navigationBar);
NSLog(@"navigation bar frame = %@",NSStringFromCGRect(nav.navigationBar.frame));
NSLog(@"nav background frame = %@",NSStringFromCGRect(background.frame));
}
//[[%c(SBSearchViewController) sharedInstance] repositionCells];
//[[%c(SBSearchViewController) sharedInstance] _updateHeaderHeightIfNeeded];
}
%new
- (UIStatusBarStyle) preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}
%new
-(BOOL)shouldDisplayListLauncher {
return [self _hasNoQuery] && [enabledSections count] > 0;
}
%new
- (BOOL) prefersStatusBarHidden {
return NO;
}
%new
-(id)applicationList { return applicationList; }
%new
-(id)sortedDisplayIdentifiers { return sortedDisplayIdentifiers; }
-(id)getIndex {
return nil;
}
-(void)loadView {
%orig;
//[[%c(SBSearchViewController) sharedInstance] setHeaderbyChangingFrame:YES withPushDown:20];
}
-(BOOL)_showFirstTimeView { return false; }
%new
-(id)sectionIndexTitlesForTableView:(UITableView *)arg1 {
if(logging) %log;
if([self shouldDisplayListLauncher]) return indexValues;
return nil;
}
-(void)searchGesture:(id)arg1 changedPercentComplete:(double)arg2 {
if(logging) %log;
%orig;
//[[%c(SBSearchViewController) sharedInstance] repositionCells];
}
-(void)searchGesture:(id)arg1 completedShowing:(BOOL)arg2 {
if(logging) %log;
// https://github.com/Shrugs/ClearOnOpen with permission
if(clearResults) {
SBSearchHeader *sheader = MSHookIvar<SBSearchHeader *>([%c(SBSearchViewController) sharedInstance], "_searchHeader");
sheader.searchField.text = @"";
[self _searchFieldEditingChanged];
}
if(arg2) {
NSLog(@"did competlete %f", (float) scrolltop);
if(scrolltop) {
UITableView *atable = MSHookIvar<UITableView *>([%c(SBSearchViewController) sharedInstance], "_tableView");
//NSLog(@"contentOffset before = %f", (float) atable.contentOffset.y);
//((SBSearchViewController *)[%c(SBSearchViewController) sharedInstance]).edgesForExtendedLayout = UIRectEdgeNone;
//[MSHookIvar<UITableView *>([%c(SBSearchViewController) sharedInstance], "_tableView") setContentOffset:CGPointZero animated:YES];
//NSIndexPath* top = [NSIndexPath indexPathForRow:NSNotFound inSection:0];
//[MSHookIvar<UITableView *>([%c(SBSearchViewController) sharedInstance], "_tableView") scrollToRowAtIndexPath:top atScrollPosition:UITableViewScrollPositionTop animated:NO];
//atable.contentOffset = CGPointMake(0, 0 - atable.contentInset.top);
//NSLog(@"contentOffset = %f", (float) atable.contentOffset.y);
[atable _scrollToTopHidingTableHeader:YES];
//atable.edgesForExtendedLayout = UIRectEdgeNone;
}
}
%orig;
if(arg2) {
if(logging) {
NSLog(@"Searchlight - windows = %@",[UIApplication sharedApplication].windows);
NSLog(@"Searchlight - keyWindow =%@",[UIApplication sharedApplication].keyWindow);
}
// for(UIWindow *aWindow in [UIApplication sharedApplication].windows) {
// if([aWindow isKindOfClass:%c(SBAppWindow)]) {
// [aWindow becomeKeyWindow];
// }
// }
[[%c(SBSearchViewController) sharedInstance] forceRotation];
//UINavigationController *nav = MSHookIvar<UINavigationController *>([%c(SBSearchViewController) sharedInstance], "_navigationController");
[[%c(SBSearchViewController) sharedInstance] setHeaderBackground];
if(![[%c(SBSearchViewController) sharedInstance] _showingKeyboard] && !hideKeyboard) {
[[%c(SBSearchViewController) sharedInstance] _setShowingKeyboard:YES];
SBSearchHeader *sheader = MSHookIvar<SBSearchHeader *>([%c(SBSearchViewController) sharedInstance], "_searchHeader");
if(logging) NSLog(@"can become first responder? = %f",(float)[sheader.searchField canBecomeFirstResponder]);
[sheader.searchField becomeFirstResponder];
}
//[[%c(SBSearchViewController) sharedInstance] repositionCells];
} else {
launchApplication();
}
}
-(void)_setShowingKeyboard:(BOOL)arg1 {
if(arg1 && hideKeyboard) {
return;
}
%orig;
// if(arg1 && selectall) {
// SBSearchHeader *sheader = MSHookIvar<SBSearchHeader *>(self, "_searchHeader");
// if(![[sheader searchField].text isEqual:@""]) {
// [[sheader searchField] selectAll:self];
// }
// }
}
-(int)tableView:(UITableView *)arg1 numberOfRowsInSection:(int)arg2 {
if(logging) %log;
if([self shouldDisplayListLauncher]) {
NSLog(@"should display");
@try {
if(enabledSections && [enabledSections count] > arg2) {
if([[enabledSections objectAtIndex:arg2] isEqual:@"Application List"]) {
if(logging) NSLog(@"inside application list");
//NSLog(@"will return = %f",(float)[listLauncherDisplayIdentifiers count]);
return [listLauncherDisplayIdentifiers count];
} else if([[enabledSections objectAtIndex:arg2] isEqual:@"Favorites"]) {
if(logging) NSLog(@"inside fav");
return [favoritesDisplayIdentifiers count];
} else if([[enabledSections objectAtIndex:arg2] isEqual:@"Recent"]) {
if(logging) NSLog(@"inside recent");
if(maxRecent > [recentApplications count]) return [recentApplications count];
return maxRecent;
}
}
}
@catch (NSException * e) {
NSLog(@"error! = %@",e);
return 0;
}
}
return %orig;
}
-(int)numberOfSectionsInTableView:(id)arg1 {
if(logging) %log;
if([self shouldDisplayListLauncher]) {
return [enabledSections count];
}
return %orig;
}
%new
-(int)tableView:(UITableView *)tableview sectionForSectionIndexTitle:(id)title atIndex:(int)index {
if(logging) %log;
int appSection = [enabledSections indexOfObject:@"Application List"];
int recentSection = [enabledSections indexOfObject:@"Recent"];
int favoriteSection = [enabledSections indexOfObject:@"Favorites"];
SBSearchHeader *sheader = MSHookIvar<SBSearchHeader *>([%c(SBSearchViewController) sharedInstance], "_searchHeader");
[sheader.searchField resignFirstResponder];
if([title isEqual:@"▢"]) {
return recentSection;
} else if([title isEqual:@"☆"]) {
return favoriteSection;
} else {
if(logging) NSLog(@"jump to (%@,%d) for title %@ at index %d",[indexPositions objectAtIndex:index],(int)appSection,title,index);
if([title isEqualToString:@"#"]) return appSection;
[tableview scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:[[indexPositions objectAtIndex:index] integerValue] inSection:appSection] atScrollPosition:UITableViewScrollPositionTop animated:NO];
return 99999999; // this allows for scrolling without jumping to some random ass section
}
return index;
}
-(BOOL)_hasResults {
if(logging) %log;
NSLog(@"number of enabled sections = %f",(float)[enabledSections count]);
if([self shouldDisplayListLauncher] && [enabledSections count] > 0) {
NSLog(@"_hasResults = YES");
return YES;
}
return %orig;
}
-(id)tableView:(UITableView *)arg1 cellForRowAtIndexPath:(NSIndexPath *)arg2 {
if(logging) %log;
if(arg2.row > [listLauncherDisplayIdentifiers count]-1) { return %orig; } // fix for SpotDefine
if([self shouldDisplayListLauncher]) {
NSString *identifier = [@"" retain];
@try {
if([[enabledSections objectAtIndex:arg2.section] isEqual:@"Application List"]) {
if(logging) NSLog(@"inside application list");
identifier = [listLauncherDisplayIdentifiers objectAtIndex:arg2.row];
} else if([[enabledSections objectAtIndex:arg2.section] isEqual:@"Favorites"]) {
if(logging) NSLog(@"inside favs");
identifier = [favoritesDisplayIdentifiers objectAtIndex:arg2.row];
} else if([[enabledSections objectAtIndex:arg2.section] isEqual:@"Recent"]) {
if(logging) NSLog(@"inside recent");
identifier = [recentApplications objectAtIndex:arg2.row];
}
}
@catch (NSException * e) {
NSLog(@"error! %@",e);
identifier = @"com.apple.Preferences";
}
NSString *name = @"";
if ([nameCache objectForKey:identifier] == nil) { // Thanks @daementor
NSString *value = [applicationList valueForKey:@"displayName" forDisplayIdentifier:identifier];
NSString *newValue = value?value:@"";
[nameCache setObject:newValue forKey:identifier];
}
name = [nameCache objectForKey:identifier];
SBSearchStandardCell *cell = [arg1 dequeueReusableCellWithIdentifier:@"searchlight"];
if(cell == nil) {
//[%c(SBSearchImageCell) initialize];
cell = [[[%c(SBSearchImageCell) alloc] initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:@"searchlight"] autorelease];
//cell.titleLabel.frame = CGRectMake(105, cell.titleLabel.frame.origin.y, 0, 0);
//NSLog(@"titleLabel = %@",cell.titleLabel);
//cell.contentView.frame = CGRectMake(50, 0, 328, 20.5);
//cell.leftView.frame = CGRectMake(50, 0, 328, 20.5);
//[cell.titleLabel setFrame:CGRectMake(44, 16, 328, 20.5)];
//cell.leftView.frame = CGRectMake(100, 0, 328, 20.5);
//cell.titleLabel.frame = CGRectMake(100, 0, 328, 20.5);
// [cell layoutSubviews];
// CGRect textLabelFrame = cell.textLabel.frame;
// textLabelFrame.origin.x -= 5;
// textLabelFrame.size.width += 5;
// cell.textLabel.frame = textLabelFrame;
// [cell setNeedsLayout];
[cell clipToTopHeaderWithHeight:52.0f inTableView:arg1];
cell.layer.masksToBounds = YES;
UILabel *lbl = [[UILabel alloc] initWithFrame:CGRectMake(48.0f, 3.0f, 150.0f, 20.0f)];
lbl.text = name;
lbl.tag = 666;
lbl.textColor = [UIColor whiteColor];
[cell.leftView addSubview:lbl];
//[cell.clippingContainer addSubview:lbl];
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(-1.0f, -8.0f, 41.5f, 41.5f)];
imgView.tag = 667;
[cell.leftView addSubview:imgView];
if(show_badges) {
cell.autoresizesSubviews = YES;
cell.leftView.autoresizesSubviews = YES;
UILabel *countlbl = [[UILabel alloc] initWithFrame:CGRectMake(cell.frame.size.width-75.0f,-11.0,50,50)];
countlbl.text = @"";
countlbl.tag = 668;
countlbl.textColor = [[UIColor whiteColor] colorWithAlphaComponent:0.5f];
countlbl.font=[countlbl.font fontWithSize:countlbl.font.pointSize - 6];
countlbl.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
[cell.leftView addSubview:countlbl];
//[cell.clippingContainer addSubview:countlbl];
}
//[cell.clippingContainer addSubview:imgView];
// Instead of doing this... can make a custom cell and do this: http://stackoverflow.com/a/4209039/193772
//UILabel *lbl = [[UILabel alloc] initWithFrame:CGRectMake(64.0f, 14.0f, 150.0f, 20.0f)];
//[cell setBounds:CGRectMake(0.0f, 0.0f, cell.frame.size.width, cell.frame.size.height)];
}
//UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(15.5f, 3.5f, 41.5f, 41.5f)];
// CGRect cellFrame = cell.frame;
// cellFrame.size.height = 20;
// cell.frame = cellFrame;
// cell.auxiliaryTitleLabel.text = @"title";
// cell.auxiliarySubtitleLabel.text = @"asubtitle";
// cell.subtitleLabel.text = @"subtitle";
// cell.summaryLabel.text = @"summary";
if(show_badges) {
UILabel *countlbl = (UILabel *)[cell.leftView viewWithTag:668];
SBIconController *cont = [%c(SBIconController) sharedInstance];
SBIconModel *model = [cont model];
SBIcon *sicon = [model expectedIconForDisplayIdentifier:identifier];
NSLog(@"icon = %@",sicon);
NSLog(@"badge = %@",[sicon badgeNumberOrString]);
//NSLog(@"badge class = @",[[sicon badgeNumberOrString] className]);
if([sicon badgeNumberOrString]) {
if([[sicon badgeNumberOrString] isKindOfClass:[NSNumber class]]) {
if([[sicon badgeNumberOrString] intValue] > 0)
[countlbl setText:[[sicon badgeNumberOrString] stringValue]];
}
}