Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passcode fix #178

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
VLCAppDelegate: move openURLcalls behind passcode validation
  • Loading branch information
carolanitz committed Nov 27, 2018
commit d84d7c0a94eb7fba202d2c5fc3739276d2d3986f
47 changes: 31 additions & 16 deletions Sources/VLCAppDelegate.m
Expand Up @@ -110,22 +110,12 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
// enable crash preventer
void (^setupBlock)() = ^{
__weak typeof(self) weakSelf = self;
void (^setupLibraryBlock)() = ^{
_libraryViewController = [[VLCLibraryViewController alloc] init];
UINavigationController *navCon = [[UINavigationController alloc] initWithRootViewController:_libraryViewController];

VLCSidebarController *sidebarVC = [VLCSidebarController sharedInstance];
sidebarVC.contentViewController = navCon;

VLCPlayerDisplayController *playerDisplayController = [VLCPlayerDisplayController sharedInstance];
playerDisplayController.childViewController = sidebarVC.fullViewController;

weakSelf.window.rootViewController = playerDisplayController;
};
UINavigationController *navCon = [[UINavigationController alloc] initWithRootViewController:[[UIViewController alloc] init]];
self.window.rootViewController = navCon;
[self.window makeKeyAndVisible];
[self validatePasscodeIfNeededWithCompletion:setupLibraryBlock];
[self validatePasscodeIfNeededWithCompletion:^{
[weakSelf setupLibrary];
}];

BOOL spotlightEnabled = ![VLCKeychainCoordinator passcodeLockEnabled];
[[MLMediaLibrary sharedMediaLibrary] setSpotlightIndexingEnabled:spotlightEnabled];
Expand Down Expand Up @@ -202,6 +192,20 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
return YES;
}

- (void)setupLibrary
{
_libraryViewController = [[VLCLibraryViewController alloc] init];
UINavigationController *navCon = [[UINavigationController alloc] initWithRootViewController:_libraryViewController];

VLCSidebarController *sidebarVC = [VLCSidebarController sharedInstance];
sidebarVC.contentViewController = navCon;

VLCPlayerDisplayController *playerDisplayController = [VLCPlayerDisplayController sharedInstance];
playerDisplayController.childViewController = sidebarVC.fullViewController;

_window.rootViewController = playerDisplayController;
}

- (void)setupAppearence
{
UIColor *vlcOrange = [UIColor VLCOrangeTintColor];
Expand Down Expand Up @@ -294,6 +298,17 @@ - (void)application:(UIApplication *)application

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
__weak typeof(self) weakSelf = self;
[self validatePasscodeIfNeededWithCompletion:^{
if (!_libraryViewController) {
[weakSelf setupLibrary];
}
[weakSelf openURL:url options:options];
}];
return YES;
}

- (BOOL)openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
//Handles Dropbox Authorization flow.
DBOAuthResult *authResult = [DBClientsManager handleRedirectURL:url];
if (authResult != nil) {
Expand Down Expand Up @@ -346,12 +361,12 @@ - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDiction
[self playWithURL:movieURL completion:^(BOOL success) {
NSURL *callback = success ? successCallback : errorCallback;
if (@available(iOS 10, *)) {
[[UIApplication sharedApplication] openURL:callback options:@{} completionHandler:nil];
[[UIApplication sharedApplication] openURL:callback options:@{} completionHandler:nil];
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
/* UIApplication's replacement calls require iOS 10 or later, which we can't enforce as of yet */
[[UIApplication sharedApplication] openURL:callback];
[[UIApplication sharedApplication] openURL:callback];
#pragma clang diagnostic pop
}
}];
Expand All @@ -369,7 +384,7 @@ - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDiction

/* Safari & al mangle vlc://http:// so fix this */
if (location != NSNotFound && [parsedString characterAtIndex:location - 1] != 0x3a) { // :
parsedString = [NSString stringWithFormat:@"%@://%@", [parsedString substringToIndex:location], [parsedString substringFromIndex:location+2]];
parsedString = [NSString stringWithFormat:@"%@://%@", [parsedString substringToIndex:location], [parsedString substringFromIndex:location+2]];
} else {
parsedString = [receivedUrl substringFromIndex:6];
if (![parsedString hasPrefix:@"http://"] && ![parsedString hasPrefix:@"https://"] && ![parsedString hasPrefix:@"ftp://"]) {
Expand Down