Commit 0db1df08 authored by Tamas Timar's avatar Tamas Timar Committed by Felix Paul Kühne

Add import feature from cloud drives via document pickers

Signed-off-by: Felix Paul Kühne's avatarFelix Paul Kühne <fkuehne@videolan.org>
parent 46e49332
B"CHOOSE_AUDIO_TRACK"="Choose Audio Track";
......
......@@ -9,6 +9,7 @@
* Gleb Pinigin <gpinigin # gmail.com>
* Jean-Romain Prévost <jr # 3on.fr>
* Carola Nitz <nitz.carola # googlemail.com>
* Tamas Timar <ttimar.vlc # gmail.com>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
......@@ -20,6 +21,7 @@
#import "VLCMenuTableViewController.h"
#import "VLCDownloadViewController.h"
#import "BWQuincyManager.h"
#import "VLCDocumentPickerController.h"
@class VLCPlaylistViewController;
@class PAPasscodeViewController;
......@@ -44,6 +46,7 @@
@property (nonatomic, readonly) VLCDropboxTableViewController *dropboxTableViewController;
@property (nonatomic, readonly) VLCGoogleDriveTableViewController *googleDriveTableViewController;
@property (nonatomic, readonly) VLCDownloadViewController *downloadViewController;
@property (nonatomic, readonly) VLCDocumentPickerController *documentPickerController;
@property (nonatomic, strong) UIWindow *window;
......
......@@ -10,6 +10,7 @@
* Jean-Romain Prévost <jr # 3on.fr>
* Luis Fernandes <zipleen # gmail.com>
* Carola Nitz <nitz.carola # googlemail.com>
* Tamas Timar <ttimar.vlc # gmail.com>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
......@@ -33,6 +34,7 @@
VLCDropboxTableViewController *_dropboxTableViewController;
VLCGoogleDriveTableViewController *_googleDriveTableViewController;
VLCDownloadViewController *_downloadViewController;
VLCDocumentPickerController *_documentPickerController;
int _idleCounter;
int _networkActivityCounter;
VLCMovieViewController *_movieViewController;
......@@ -259,6 +261,14 @@
return _downloadViewController;
}
- (VLCDocumentPickerController *)documentPickerController
{
if (_documentPickerController == nil)
_documentPickerController = [[VLCDocumentPickerController alloc] init];
return _documentPickerController;
}
#pragma mark - media discovering
- (void)mediaFileAdded:(NSString *)fileName loading:(BOOL)isLoading
......
/*****************************************************************************
* VLCDocumentPickerController.h
* VLC for iOS
*****************************************************************************
* Copyright (c) 2014 VideoLAN. All rights reserved.
* $Id$
*
* Authors: Tamas Timar <ttimar.vlc # gmail.com>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
#import <Foundation/Foundation.h>
@interface VLCDocumentPickerController : NSObject
- (void)showDocumentMenuViewController:(id)sender;
@end
/*****************************************************************************
* VLCDocumentPickerController.m
* VLC for iOS
*****************************************************************************
* Copyright (c) 2014 VideoLAN. All rights reserved.
* $Id$
*
* Authors: Tamas Timar <ttimar.vlc # gmail.com>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
#import "VLCDocumentPickerController.h"
#import <MobileCoreServices/MobileCoreServices.h>
#import "VLCAppDelegate.h"
#import "VLCPlaylistViewController.h"
@interface VLCDocumentPickerController () <UIDocumentMenuDelegate, UIDocumentPickerDelegate>
@end
@implementation VLCDocumentPickerController
#pragma mark - Public Methods
- (void)showDocumentMenuViewController:(id)sender
{
if (![UIDocumentMenuViewController class])
return;
UIDocumentMenuViewController *importMenu = [[UIDocumentMenuViewController alloc] initWithDocumentTypes:@[(id)kUTTypeAudiovisualContent] inMode:UIDocumentPickerModeImport];
importMenu.delegate = self;
UIViewController *rootVC = [UIApplication sharedApplication].keyWindow.rootViewController;
UIPopoverPresentationController *popoverPres = importMenu.popoverPresentationController;
if (popoverPres) { // not-nil on iPad
UIView *sourceView = nil;
if ([sender isKindOfClass:[UIView class]]) {
sourceView = sender;
} else {
sourceView = rootVC.view;
}
popoverPres.sourceView = sourceView;
popoverPres.sourceRect = sourceView.bounds;
popoverPres.permittedArrowDirections = UIPopoverArrowDirectionLeft;
}
[rootVC presentViewController:importMenu animated:YES completion:nil];
}
#pragma mark - UIDocumentMenuDelegate
- (void)documentMenu:(UIDocumentMenuViewController *)documentMenu didPickDocumentPicker:(UIDocumentPickerViewController *)documentPicker
{
documentPicker.delegate = self;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { // on iPhone it's done in menu table vc
VLCAppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
[appDelegate.menuViewController selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:YES scrollPosition:UITableViewScrollPositionNone];
}
[[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:documentPicker animated:YES completion:nil];
}
#pragma mark - UIDocumentPickerDelegate
- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentAtURL:(NSURL *)url
{
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject];
NSString *filePath = [documentsPath stringByAppendingPathComponent:[url lastPathComponent]];
if (![fileManager fileExistsAtPath:filePath]) {
NSError *error = nil;
BOOL succes = [fileManager moveItemAtPath:[url path] toPath:filePath error:&error];
if (succes) {
VLCAppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
[appDelegate updateMediaList];
}
}
}
@end
......@@ -71,6 +71,12 @@
_sectionHeaderTexts = @[@"SECTION_HEADER_LIBRARY", @"SECTION_HEADER_NETWORK", @"Settings"];
_menuItemsSectionOne = @[@"LIBRARY_ALL_FILES", @"LIBRARY_MUSIC", @"LIBRARY_SERIES"];
_menuItemsSectionTwo = @[@"LOCAL_NETWORK", @"OPEN_NETWORK", @"DOWNLOAD_FROM_HTTP", @"WEBINTF_TITLE", @"Dropbox", @"Google Drive"];
if ([UIDocumentPickerViewController class]) { // on iOS 8+ add document picker option
NSMutableArray* expanded = [_menuItemsSectionTwo mutableCopy];
[expanded addObject:@"CLOUD_DRIVES"];
_menuItemsSectionTwo = expanded;
}
_menuItemsSectionThree = @[@"Settings", @"ABOUT_APP"];
_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0.0f, 44.0f + 20.0f, kGHRevealSidebarWidth, CGRectGetHeight(self.view.bounds) - (44.0f + 20.0f)) style:UITableViewStylePlain];
......@@ -211,7 +217,9 @@
} else if ([rawTitle isEqualToString:@"Google Drive"]) {
cell.textLabel.text = rawTitle;
cell.imageView.image = [UIImage imageNamed:@"Drive"];
} else if ([rawTitle isEqualToString:@"WEBINTF_TITLE"]) {
} else if ([rawTitle isEqualToString:@"CLOUD_DRIVES"])
cell.imageView.image = [UIImage imageNamed:@"CloudDrives"];
else if ([rawTitle isEqualToString:@"WEBINTF_TITLE"]) {
_uploadLocationLabel = [(VLCWiFiUploadTableViewCell*)cell uploadAddressLabel];
_uploadButton = [(VLCWiFiUploadTableViewCell*)cell serverOnButton];
[_uploadButton addTarget:self action:@selector(toggleHTTPServer:) forControlEvents:UIControlEventTouchUpInside];
......@@ -370,6 +378,24 @@
[_revealController toggleSidebar:NO duration:kGHRevealSidebarDefaultAnimationDuration];
}
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSUInteger idx = [_menuItemsSectionTwo indexOfObject:@"CLOUD_DRIVES"];
// don't let select CLOUD_DRIVES menu item since there is no view controller to reveal
if (indexPath.section == 1 && indexPath.row == idx) {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
[self.appDelegate.documentPickerController showDocumentMenuViewController:[self.tableView cellForRowAtIndexPath:indexPath]];
} else {
[self.appDelegate.documentPickerController showDocumentMenuViewController:nil];
[self selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:YES scrollPosition:UITableViewScrollPositionNone];
}
return nil;
} else
return indexPath;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self _revealItem:indexPath.row inSection:indexPath.section];
......
......@@ -419,6 +419,7 @@
CC1BBC56170493C100A20CBF /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CC1BBC55170493C100A20CBF /* QuartzCore.framework */; };
CC1BBC58170493E100A20CBF /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CC1BBC57170493E100A20CBF /* CoreData.framework */; };
CCE2A22E17A5859E00D9EAAD /* CoreText.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CCE2A22D17A5859E00D9EAAD /* CoreText.framework */; };
E0C04F951A25B4410080331A /* VLCDocumentPickerController.m in Sources */ = {isa = PBXBuildFile; fileRef = E0C04F941A25B4410080331A /* VLCDocumentPickerController.m */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
......@@ -1241,6 +1242,8 @@
CCE2A22D17A5859E00D9EAAD /* CoreText.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreText.framework; path = System/Library/Frameworks/CoreText.framework; sourceTree = SDKROOT; };
DAF8927B0BE9C328466C0EA7 /* libPods-vlc-ios.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-vlc-ios.a"; sourceTree = BUILT_PRODUCTS_DIR; };
E09EACF57CDD22ABAE66CDD0 /* Pods-vlc-ios.distribution.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-vlc-ios.distribution.xcconfig"; path = "Pods/Target Support Files/Pods-vlc-ios/Pods-vlc-ios.distribution.xcconfig"; sourceTree = "<group>"; };
E0C04F931A25B4410080331A /* VLCDocumentPickerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCDocumentPickerController.h; path = Sources/VLCDocumentPickerController.h; sourceTree = SOURCE_ROOT; };
E0C04F941A25B4410080331A /* VLCDocumentPickerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCDocumentPickerController.m; path = Sources/VLCDocumentPickerController.m; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -1677,6 +1680,7 @@
7D5E39CC174FCDBE007DAFA1 /* Cloud Integration */ = {
isa = PBXGroup;
children = (
E0C04F921A25B41C0080331A /* Document Picker */,
9B51719A17EDEC8900F8FBA7 /* GoogleDrive */,
7DFB1567185CC38A008D49BB /* Dropbox */,
7D3784AF183A990F009EE944 /* VLCCloudStorageTableViewCell.h */,
......@@ -2372,6 +2376,15 @@
name = "External VLC Libraries";
sourceTree = "<group>";
};
E0C04F921A25B41C0080331A /* Document Picker */ = {
isa = PBXGroup;
children = (
E0C04F931A25B4410080331A /* VLCDocumentPickerController.h */,
E0C04F941A25B4410080331A /* VLCDocumentPickerController.m */,
);
name = "Document Picker";
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
......@@ -2847,6 +2860,7 @@
2915543D17490B9C00B86CAD /* HTTPDynamicFileResponse.m in Sources */,
9BADAF45185FBD9D00108BD8 /* VLCFrostedGlasView.m in Sources */,
2915543E17490B9C00B86CAD /* HTTPErrorResponse.m in Sources */,
E0C04F951A25B4410080331A /* VLCDocumentPickerController.m in Sources */,
2915543F17490B9C00B86CAD /* HTTPFileResponse.m in Sources */,
2915544017490B9C00B86CAD /* HTTPRedirectResponse.m in Sources */,
2915544117490B9C00B86CAD /* WebSocket.m in Sources */,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment