-
Notifications
You must be signed in to change notification settings - Fork 5
/
iMoDevTools2-FileBrowser.m
85 lines (74 loc) · 4.48 KB
/
iMoDevTools2-FileBrowser.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
#import "iMoDevTools2-FileBrowser.h"
#import "vendors/UIAlertView+Blocks.h"
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#pragma clang diagnostic ignored "-Wconstant-conversion"
__attribute__((always_inline, visibility("hidden")))
extern BOOL isThisFileExiste(const char *path);
@implementation iMoDevTools (FileBrowser)
// file browser methods
+ (void)showFilePickerFromViewController:(UIViewController *)viewController
didSelectFile:(fbDidSelectBlock)didSelectFile
didLoadPath:(fbDidLoadPathBlock)didLoadPathBlock
cancelBlock:(fbCancelBlock)cancelBlock {
WASFileBrowserViewController *filePicker = [[WASFileBrowserViewController alloc] init];
filePicker.didSelectFileBlock = didSelectFile;
filePicker.didLoadDirectoryBlock = didLoadPathBlock;
filePicker.didCancelBlock = cancelBlock;
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:filePicker];
navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
[viewController presentViewController:navigationController animated:YES completion:nil];
}
+ (void)loadFileBrowserLibrariesIfNeeded {
if ([iMoDevTools isIOS90_OrGreater]) {
if (!isThisFileExiste("/usr/lib/libimounbox.dylib")) {
dispatch_async(dispatch_get_main_queue(), ^{
[UIAlertView showWithTitle:@"WARNING"
message:[NSString stringWithFormat:@"you need to install iMoDevTools library from Cydia if not installed already to make this tweak work probably ( tap install )"]
cancelButtonTitle:@"cancel"
otherButtonTitles:@[@"install"]
tapBlock:^(UIAlertView * __nonnull alertView, NSInteger buttonIndex) {
if ([[alertView buttonTitleAtIndex:buttonIndex] isEqualToString:@"install"]) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"cydia://packages/com.imokhles.imodevtools"]];
}
}];
});
} else {
dlopen("/usr/lib/libimounbox.dylib", RTLD_NOW);
}
} else if ([iMoDevTools isIOS70_OrGreater]) {
if (!isThisFileExiste("/usr/lib/libuaunbox.dylib")) {
dispatch_async(dispatch_get_main_queue(), ^{
[UIAlertView showWithTitle:@"WARNING"
message:[NSString stringWithFormat:@"you need to install uaunbox library from Cydia if not installed already to make this tweak work probably ( tap install )"]
cancelButtonTitle:@"cancel"
otherButtonTitles:@[@"install"]
tapBlock:^(UIAlertView * __nonnull alertView, NSInteger buttonIndex) {
if ([[alertView buttonTitleAtIndex:buttonIndex] isEqualToString:@"install"]) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"cydia://packages/com.unlimapps.uaunbox"]];
}
}];
});
} else {
dlopen("/usr/lib/libuaunbox.dylib", RTLD_NOW);
}
} else {
if (!isThisFileExiste("/usr/lib/libSandCastle.dylib")) {
dispatch_async(dispatch_get_main_queue(), ^{
[UIAlertView showWithTitle:@"WARNING"
message:[NSString stringWithFormat:@"you need to install SandCastle 2 library from Cydia if not installed already to make this tweak work probably ( tap install )"]
cancelButtonTitle:@"cancel"
otherButtonTitles:@[@"install"]
tapBlock:^(UIAlertView * __nonnull alertView, NSInteger buttonIndex) {
if ([[alertView buttonTitleAtIndex:buttonIndex] isEqualToString:@"install"]) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"cydia://packages/co.cocoanuts.sandcastle"]];
}
}];
});
} else {
dlopen("/usr/lib/libSandCastle.dylib", RTLD_NOW);
}
}
}
@end
#pragma clang diagnostic pop