-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathAVTools.h
190 lines (131 loc) · 6.26 KB
/
AVTools.h
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
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wprotocol"
#pragma GCC diagnostic ignored "-Wmacro-redefined"
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#pragma GCC diagnostic ignored "-Wincomplete-implementation"
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
#pragma GCC diagnostic ignored "-Wformat"
#pragma GCC diagnostic ignored "-Wunknown-warning-option"
#pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
#pragma GCC diagnostic ignored "-Wunused-value"
#pragma GCC diagnostic ignored "-Wnullability-completeness"
#define rgbValue
#define UIColorFromHEX(rgbValue) [UIColor \
colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
static UIViewController *_topMostController(UIViewController *cont) {
UIViewController *topController = cont;
while (topController.presentedViewController) {
topController = topController.presentedViewController;
}
if ([topController isKindOfClass:[UINavigationController class]]) {
UIViewController *visible = ((UINavigationController *)topController).visibleViewController;
if (visible) {
topController = visible;
}
}
return (topController != cont ? topController : nil);
}
static UIViewController *topMostController() {
UIViewController *topController = [UIApplication sharedApplication].keyWindow.rootViewController;
UIViewController *next = nil;
while ((next = _topMostController(topController)) != nil) {
topController = next;
}
return topController;
}
void WriteData(id Data, NSString *DataFileName) {
NSString *StringOfDate = [NSString stringWithFormat:@"%@",Data];
NSString *DataFile = [NSString stringWithFormat:@"%@/Documents/%@",NSHomeDirectory(),DataFileName];
if (![[NSFileManager defaultManager] fileExistsAtPath:DataFile])
[[NSFileManager defaultManager] createFileAtPath:DataFile contents:nil attributes:nil];
NSString *PrevData = [NSString stringWithContentsOfFile:DataFile encoding:NSUTF8StringEncoding error:nil];
NSString *NewData = [NSString stringWithFormat:@"%@\n\n-----------\n\n%@",PrevData,StringOfDate];
[NewData writeToFile:DataFile atomically:YES encoding:NSUTF8StringEncoding error:nil];
}
void Alert(float Timer,id Message, ...) {
va_list args;
va_start(args, Message);
NSString *Formated = [[NSString alloc] initWithFormat:Message arguments:args];
va_end(args);
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[NSThread sleepForTimeInterval:Timer];
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Hola" message:Formated preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *action = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
}];
[alert addAction:action];
[topMostController() presentViewController:alert animated:true completion:nil];
});
});
}
@interface CMManagerMini : NSObject
+(void) InitTextFieldAlertWithTitle:(NSString *)Title Message:(NSString *)Message Buttons:(NSArray *)Buttons CancelButtonTitle:(NSString *)CancelButtonTitle handler:(void(^_Nullable)(NSString * ButtonTitle, NSString * Text, UITextField * TextField))handler;
@end
@implementation CMManagerMini
+(void) InitTextFieldAlertWithTitle:(NSString *)Title Message:(NSString *)Message Buttons:(NSArray *)Buttons CancelButtonTitle:(NSString *)CancelButtonTitle handler:(void(^)(NSString * ButtonTitle, NSString * Text, UITextField * TextField))handler {
UIAlertController *alert = [UIAlertController alertControllerWithTitle:Title message:Message preferredStyle:UIAlertControllerStyleAlert];
[alert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.clearButtonMode = UITextFieldViewModeWhileEditing;
[textField resignFirstResponder];
handler(nil,nil,textField);
}];
for (NSString *EachButton in Buttons) {
NSArray *fields = alert.textFields;
UITextField *getText = [fields firstObject];
UIAlertAction *action = [UIAlertAction actionWithTitle:EachButton style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
handler(action.title,getText.text,nil);
}];
[alert addAction:action];
}
if (!(CancelButtonTitle == NULL)) {
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:CancelButtonTitle style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
}];
[alert addAction:cancelAction];
}
[topMostController() presentViewController:alert animated:true completion:nil];
}
@end
UIButton *InitButtonWithName(NSString *BuName, UIView *View, id Target,SEL Action){
UIButton *Button = [UIButton buttonWithType:UIButtonTypeCustom];
[Button setTitle:BuName forState:UIControlStateNormal];
[Button addTarget:Target action:Action forControlEvents:UIControlEventTouchUpInside];
[View addSubview:Button];
return Button;
}
#define MainPlist @"/var/jb/var/mobile/Library/Preferences/AVTools.plist"
void WriteToPlist(BOOL isLock) {
NSMutableDictionary *MainDictionary = [NSMutableDictionary dictionaryWithContentsOfFile:MainPlist];
isLock ? [MainDictionary setValue:@"1" forKey:@"isLock"] : [MainDictionary setValue:@"2" forKey:@"isLock"];
if (!MainDictionary[@"SeekTime"])
[MainDictionary setValue:@"15" forKey:@"SeekTime"];
[MainDictionary writeToFile:MainPlist atomically:YES];
}
BOOL isLocked(void) {
if ([[NSMutableDictionary dictionaryWithContentsOfFile:MainPlist][@"isLock"] isEqual:@"1"]) return YES;
return NO;
}
@interface SBControlCenterSystemAgent : NSObject
-(void) unlockOrientation;
-(void) lockOrientation;
-(BOOL) isOrientationLocked;
@end
@interface SBLockScreenManager : NSObject
-(void) NotificationAction:(NSString *)Name userInfo:(NSDictionary *)Info;
@end
@interface AVPlayerViewController : UIViewController
@end
@interface AVLayoutView : UIView
@property NSString *debugIdentifier;
@end
@interface AVTouchIgnoringView : UIView
@end
@interface AVPlaybackControlsController : NSObject
-(void)_seekByTimeInterval:(double)arg1 toleranceBefore:(double)arg2 toleranceAfter:(double)arg3;
@end
@interface AVButton : NSObject
@property NSString *imageName;
@end