-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKBAppManager.m
76 lines (64 loc) · 2.14 KB
/
KBAppManager.m
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
//
// KBAppManager.m
// KBDOCK
//
// Created by 开发者 on 2019/3/28.
// Copyright © 2019年 开发者 . All rights reserved.
//
#import "KBAppManager.h"
#import <AppList/AppList.h>
static KBAppManager *_sharedManager = nil;
@implementation KBAppManager
+ (instancetype)sharedManager
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
if (_sharedManager == nil) {
_sharedManager = [[self alloc]init];
}
});
return _sharedManager;
}
+ (instancetype)allocWithZone:(struct _NSZone *)zone
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_sharedManager = [super allocWithZone:zone];
});
return _sharedManager;
}
- (id)copyWithZone:(NSZone *)zone
{
return _sharedManager;
}
- (id)mutableCopyWithZone:(NSZone *)zone {
return _sharedManager;
}
- (NSMutableArray *)getAppListToArrayWithAppPlistPath:(NSString *)plistPath{
NSDictionary *appListDict= [NSDictionary dictionaryWithContentsOfFile:plistPath];
NSMutableArray *array = [NSMutableArray array];
for (NSString *displayIdentifier in appListDict) {
BOOL canOpenApp = [[appListDict objectForKey:displayIdentifier]boolValue];
if (canOpenApp) {
[array addObject:displayIdentifier];
}
}
return array;
}
- (NSMutableArray *)getSortedAppListArrayFromPath:(NSString *)path{
NSMutableArray *array = [NSMutableArray array];
array = [NSMutableArray arrayWithContentsOfFile:path];
return array;
}
- (UIImage *)getImageWithDisplayIdentifier:(NSString *)displayIdentifier{
UIImage *image = [[ALApplicationList sharedApplicationList] iconOfSize:ALApplicationIconSizeSmall forDisplayIdentifier:displayIdentifier];
return image;
}
- (void)updateAppListWithNewArray:(NSMutableArray *)array toPath:(NSString *)path{
[array writeToFile:path atomically:YES];
}
- (NSString *)getApplicationNameFromDisplayIdentifier:(NSString *)displayIdentifier{
NSDictionary *applications = [[ALApplicationList sharedApplicationList] applicationsFilteredUsingPredicate:nil onlyVisible:nil titleSortedIdentifiers:nil];
return [applications objectForKey:displayIdentifier];
}
@end