forked from a3tweaks/Flipswitch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FSLaunchURL.x
66 lines (57 loc) · 2.23 KB
/
FSLaunchURL.x
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
#import "FSLaunchURL.h"
#import <UIKit/UIKit.h>
@interface UIApplication (Private)
- (void)applicationOpenURL:(NSURL *)url;
- (void)applicationOpenURL:(NSURL *)url publicURLsOnly:(BOOL)publicURLsOnly;
@end
@interface SBUnlockActionContext : NSObject
- (id)initWithLockLabel:(NSString *)lockLabel shortLockLabel:(NSString *)label unlockAction:(void (^)())action identifier:(NSString *)id;
- (void)setDeactivateAwayController:(BOOL)deactivate;
@end
@interface SBAlert : UIViewController
@end
@interface SBLockScreenViewControllerBase : SBAlert
- (void)setCustomUnlockActionContext:(SBUnlockActionContext *)context;
- (void)setPasscodeLockVisible:(BOOL)visibile animated:(BOOL)animated completion:(void (^)())completion;
@end
@interface SBLockScreenManager : NSObject
+ (SBLockScreenManager *)sharedInstance;
@property (nonatomic, readonly) BOOL isUILocked;
@property (nonatomic, readonly) SBLockScreenViewControllerBase *lockScreenViewController;
@end
@interface SBDeviceLockController : NSObject
+ (SBDeviceLockController *)sharedController;
- (BOOL)isPasscodeLocked;
@end
static void FSLaunchURLDirect(NSURL *url)
{
UIApplication *app = [UIApplication sharedApplication];
if ([app respondsToSelector:@selector(applicationOpenURL:publicURLsOnly:)])
[app applicationOpenURL:url publicURLsOnly:NO];
else
[app applicationOpenURL:url];
}
void FSLaunchURL(NSURL *url)
{
if (!url)
return;
SBDeviceLockController *lockController = [%c(SBDeviceLockController) sharedController];
if ([lockController respondsToSelector:@selector(isPasscodeLocked)]) {
if (lockController.isPasscodeLocked) {
SBLockScreenManager *manager = (SBLockScreenManager *)[%c(SBLockScreenManager) sharedInstance];
if (manager.isUILocked) {
void (^action)() = ^() {
FSLaunchURLDirect(url);
};
SBLockScreenViewControllerBase *controller = [manager lockScreenViewController];
SBUnlockActionContext *context = [[%c(SBUnlockActionContext) alloc] initWithLockLabel:nil shortLockLabel:nil unlockAction:action identifier:nil];
[context setDeactivateAwayController:YES];
[controller setCustomUnlockActionContext:context];
[controller setPasscodeLockVisible:YES animated:YES completion:nil];
[context release];
return;
}
}
}
FSLaunchURLDirect(url);
}