-
Notifications
You must be signed in to change notification settings - Fork 73
/
BHIManager.m
149 lines (144 loc) · 6.36 KB
/
BHIManager.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
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
#import "BHIManager.h"
#import "TikTokHeaders.h"
@implementation BHIManager
+ (BOOL)hideAds {
return [[NSUserDefaults standardUserDefaults] boolForKey:@"hide_ads"];
}
+ (BOOL)downloadVideos {
return [[NSUserDefaults standardUserDefaults] boolForKey:@"dw_videos"];
}
+ (BOOL)downloadMusics {
return [[NSUserDefaults standardUserDefaults] boolForKey:@"dw_musics"];
}
+ (BOOL)hideElementButton {
return [[NSUserDefaults standardUserDefaults] boolForKey:@"remove_elements_button"];
}
+ (BOOL)copyVideoDecription {
return [[NSUserDefaults standardUserDefaults] boolForKey:@"copy_decription"];
}
+ (BOOL)copyMusicLink {
return [[NSUserDefaults standardUserDefaults] boolForKey:@"copy_music_link"];
}
+ (BOOL)copyVideoLink {
return [[NSUserDefaults standardUserDefaults] boolForKey:@"copy_video_link"];
}
+ (BOOL)autoPlay {
return [[NSUserDefaults standardUserDefaults] boolForKey:@"auto_play"];
}
+ (BOOL)progressBar {
return [[NSUserDefaults standardUserDefaults] boolForKey:@"show_porgress_bar"];
}
+ (BOOL)likeConfirmation {
return [[NSUserDefaults standardUserDefaults] boolForKey:@"like_confirm"];
}
+ (BOOL)likeCommentConfirmation {
return [[NSUserDefaults standardUserDefaults] boolForKey:@"like_comment_confirm"];
}
+ (BOOL)dislikeCommentConfirmation {
return [[NSUserDefaults standardUserDefaults] boolForKey:@"dislike_comment_confirm"];
}
+ (BOOL)followConfirmation {
return [[NSUserDefaults standardUserDefaults] boolForKey:@"follow_confirm"];
}
+ (BOOL)profileSave {
return [[NSUserDefaults standardUserDefaults] boolForKey:@"save_profile"];
}
+ (BOOL)profileCopy {
return [[NSUserDefaults standardUserDefaults] boolForKey:@"copy_profile_information"];
}
+ (BOOL)alwaysOpenSafari {
return [[NSUserDefaults standardUserDefaults] boolForKey:@"openInBrowser"];
}
+ (BOOL)regionChangingEnabled {
return [[NSUserDefaults standardUserDefaults] boolForKey:@"en_region"];
}
+ (NSDictionary *)selectedRegion {
return [[NSUserDefaults standardUserDefaults] dictionaryForKey:@"region"];
}
+ (BOOL)fakeChangesEnabled {
return [[NSUserDefaults standardUserDefaults] boolForKey:@"en_fake"];
}
+ (BOOL)fakeVerified {
return [[NSUserDefaults standardUserDefaults] boolForKey:@"fake_verify"];
}
+ (BOOL)extendedBio {
return [[NSUserDefaults standardUserDefaults] boolForKey:@"extended_bio"];
}
+ (BOOL)extendedComment {
return [[NSUserDefaults standardUserDefaults] boolForKey:@"extendedComment"];
}
+ (BOOL)appLock {
return [[NSUserDefaults standardUserDefaults] boolForKey:@"padlock"];
}
+ (void)cleanCache {
NSArray <NSURL *> *DocumentFiles = [[NSFileManager defaultManager] contentsOfDirectoryAtURL:[NSURL fileURLWithPath:NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, true).firstObject] includingPropertiesForKeys:@[] options:NSDirectoryEnumerationSkipsHiddenFiles error:nil];
for (NSURL *file in DocumentFiles) {
if ([file.pathExtension.lowercaseString isEqualToString:@"mp4"]) {
[[NSFileManager defaultManager] removeItemAtURL:file error:nil];
}
if ([file.pathExtension.lowercaseString isEqualToString:@"png"]) {
[[NSFileManager defaultManager] removeItemAtURL:file error:nil];
}
if ([file.pathExtension.lowercaseString isEqualToString:@"jpeg"]) {
[[NSFileManager defaultManager] removeItemAtURL:file error:nil];
}
if ([file.pathExtension.lowercaseString isEqualToString:@"mp3"]) {
[[NSFileManager defaultManager] removeItemAtURL:file error:nil];
}
if ([file.pathExtension.lowercaseString isEqualToString:@"m4a"]) {
[[NSFileManager defaultManager] removeItemAtURL:file error:nil];
}
}
NSArray <NSURL *> *TempFiles = [[NSFileManager defaultManager] contentsOfDirectoryAtURL:[NSURL fileURLWithPath:NSTemporaryDirectory()] includingPropertiesForKeys:@[] options:NSDirectoryEnumerationSkipsHiddenFiles error:nil];
for (NSURL *file in TempFiles) {
if ([file.pathExtension.lowercaseString isEqualToString:@"mp4"]) {
[[NSFileManager defaultManager] removeItemAtURL:file error:nil];
}
if ([file.pathExtension.lowercaseString isEqualToString:@"mov"]) {
[[NSFileManager defaultManager] removeItemAtURL:file error:nil];
}
if ([file.pathExtension.lowercaseString isEqualToString:@"tmp"]) {
[[NSFileManager defaultManager] removeItemAtURL:file error:nil];
}
if ([file.pathExtension.lowercaseString isEqualToString:@"png"]) {
[[NSFileManager defaultManager] removeItemAtURL:file error:nil];
}
if ([file.pathExtension.lowercaseString isEqualToString:@"jpeg"]) {
[[NSFileManager defaultManager] removeItemAtURL:file error:nil];
}
if ([file.pathExtension.lowercaseString isEqualToString:@"mp3"]) {
[[NSFileManager defaultManager] removeItemAtURL:file error:nil];
}
if ([file.pathExtension.lowercaseString isEqualToString:@"m4a"]) {
[[NSFileManager defaultManager] removeItemAtURL:file error:nil];
}
if ([file hasDirectoryPath]) {
if ([BHIManager isEmpty:file]) {
[[NSFileManager defaultManager] removeItemAtURL:file error:nil];
}
}
}
}
+ (BOOL)isEmpty:(NSURL *)url {
NSArray *FolderFiles = [[NSFileManager defaultManager] contentsOfDirectoryAtURL:url includingPropertiesForKeys:@[] options:NSDirectoryEnumerationSkipsHiddenFiles error:nil];
if (FolderFiles.count == 0) {
return true;
} else {
return false;
}
}
+ (void)showSaveVC:(id)item {
UIActivityViewController *acVC = [[UIActivityViewController alloc] initWithActivityItems:item applicationActivities:nil];
if (is_iPad()) {
acVC.popoverPresentationController.sourceView = topMostController().view;
acVC.popoverPresentationController.sourceRect = CGRectMake(topMostController().view.bounds.size.width / 2.0, topMostController().view.bounds.size.height / 2.0, 1.0, 1.0);
}
[topMostController() presentViewController:acVC animated:true completion:nil];
}
+ (NSString *)getDownloadingPersent:(float)per {
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
[numberFormatter setNumberStyle:NSNumberFormatterPercentStyle];
NSNumber *number = [NSNumber numberWithFloat:per];
return [numberFormatter stringFromNumber:number];
}
@end