Commit 15393273 authored by Felix Paul Kühne's avatar Felix Paul Kühne

box: add ATV support

parent 91072536
......@@ -92,16 +92,6 @@
return [[BoxSDK sharedSDK].OAuth2Session isAuthorized];
}
- (void)showAlert:(NSString *)title message:(NSString *)message
{
VLCAlertView *alert = [[VLCAlertView alloc] initWithTitle:title
message:message
delegate:nil
cancelButtonTitle:NSLocalizedString(@"BUTTON_OK", nil)
otherButtonTitles:nil];
[alert show];
}
#pragma mark - file management
- (void)requestDirectoryListingAtPath:(NSString *)path
{
......@@ -116,23 +106,6 @@
return _offset < _maxOffset;
}
- (void)downloadFileToDocumentFolder:(BoxItem *)file
{
if (file != nil) {
if ([file.type isEqualToString:BoxAPIItemTypeFolder]) return;
if (!_listOfBoxFilesToDownload)
_listOfBoxFilesToDownload = [NSMutableArray new];
[_listOfBoxFilesToDownload addObject:file];
}
if ([self.delegate respondsToSelector:@selector(numberOfFilesWaitingToBeDownloadedChanged)])
[self.delegate numberOfFilesWaitingToBeDownloadedChanged];
[self _triggerNextDownload];
}
- (void)listFilesWithID:(NSString *)folderId
{
_fileList = nil;
......@@ -196,6 +169,25 @@
return request;
}
#if TARGET_OS_IOS
- (void)downloadFileToDocumentFolder:(BoxItem *)file
{
if (file != nil) {
if ([file.type isEqualToString:BoxAPIItemTypeFolder]) return;
if (!_listOfBoxFilesToDownload)
_listOfBoxFilesToDownload = [NSMutableArray new];
[_listOfBoxFilesToDownload addObject:file];
}
if ([self.delegate respondsToSelector:@selector(numberOfFilesWaitingToBeDownloadedChanged)])
[self.delegate numberOfFilesWaitingToBeDownloadedChanged];
[self _triggerNextDownload];
}
- (void)_triggerNextDownload
{
if (_listOfBoxFilesToDownload.count > 0 && !_downloadInProgress) {
......@@ -219,6 +211,7 @@
_downloadInProgress = YES;
}
#endif
- (BOOL)_supportedFileExtension:(NSString *)filename
{
......@@ -263,6 +256,7 @@
[self.delegate mediaListUpdated];
}
#if TARGET_OS_IOS
- (void)loadFile:(BoxFile *)file intoPath:(NSString*)destinationPath
{
NSOutputStream *outputStream = [NSOutputStream outputStreamToFileAtPath:destinationPath append:NO];
......@@ -293,6 +287,16 @@
[[BoxSDK sharedSDK].filesManager downloadFileWithID:file.modelID outputStream:outputStream requestBuilder:nil success:successBlock failure:failureBlock progress:progressBlock];
}
- (void)showAlert:(NSString *)title message:(NSString *)message
{
VLCAlertView *alert = [[VLCAlertView alloc] initWithTitle:title
message:message
delegate:nil
cancelButtonTitle:NSLocalizedString(@"BUTTON_OK", nil)
otherButtonTitles:nil];
[alert show];
}
- (void)calculateRemainingTime:(CGFloat)receivedDataSize expectedDownloadSize:(CGFloat)expectedDownloadSize
{
CGFloat lastSpeed = receivedDataSize / ([NSDate timeIntervalSinceReferenceDate] - _startDL);
......@@ -334,6 +338,7 @@
[self _triggerNextDownload];
}
#endif
#pragma mark - VLC internal communication and delegate
......
......@@ -13,11 +13,14 @@
#import "VLCBoxTableViewController.h"
#import "VLCCloudStorageTableViewCell.h"
#import "VLCBoxController.h"
#import "VLCAppDelegate.h"
#import <SSKeychain/SSKeychain.h>
#import "UIDevice+VLC.h"
#if TARGET_OS_IOS
@interface VLCBoxTableViewController () <VLCCloudStorageTableViewCell, BoxAuthorizationViewControllerDelegate, VLCCloudStorageDelegate>
#else
@interface VLCBoxTableViewController () <VLCCloudStorageTableViewCell, VLCCloudStorageDelegate>
#endif
{
BoxFile *_selectedFile;
VLCBoxController *_boxController;
......@@ -74,6 +77,7 @@
object:[BoxSDK sharedSDK].OAuth2Session];
}
#if TARGET_OS_IOS
- (UIViewController *)createAuthController
{
NSURL *authorizationURL = [[BoxSDK sharedSDK].OAuth2Session authorizeURL];
......@@ -82,6 +86,7 @@
authorizationController.delegate = self;
return authorizationController;
}
#endif
- (void)viewWillAppear:(BOOL)animated
{
......@@ -94,7 +99,7 @@
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
if ((VLCAppDelegate*)[UIApplication sharedApplication].delegate.window.rootViewController.presentedViewController == nil) {
if ([UIApplication sharedApplication].delegate.window.rootViewController.presentedViewController == nil) {
[_boxController stopSession];
[self.tableView reloadData];
}
......@@ -137,6 +142,7 @@
}
}
#if TARGET_OS_IOS
- (void)triggerDownloadForCell:(VLCCloudStorageTableViewCell *)cell
{
_selectedFile = _boxController.currentListFiles[[self.tableView indexPathForCell:cell].row];
......@@ -157,11 +163,13 @@
[_boxController downloadFileToDocumentFolder:_selectedFile];
_selectedFile = nil;
}
#endif
#pragma mark - box controller delegate
#pragma mark - BoxAuthorizationViewControllerDelegate
#if TARGET_OS_IOS
- (BOOL)authorizationViewController:(BoxAuthorizationViewController *)authorizationViewController shouldLoadReceivedOAuth2RedirectRequest:(NSURLRequest *)request
{
[[BoxSDK sharedSDK].OAuth2Session performAuthorizationCodeGrantWithReceivedURL:request.URL];
......@@ -210,6 +218,7 @@
{
[self.navigationController popViewControllerAnimated:YES];
}
#endif
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
......@@ -224,6 +233,7 @@
}
#pragma mark - login dialog
#if TARGET_OS_IOS
- (IBAction)loginAction:(id)sender
{
if (![_boxController isAuthorized]) {
......@@ -233,5 +243,6 @@
[_boxController logout];
}
}
#endif
@end
......@@ -13,9 +13,9 @@
#import "VLCDropboxController.h"
#import "VLCOneDriveObject.h"
#import <BoxSDK/BoxSDK.h>
#if TARGET_OS_IOS
#import "GTLDrive.h"
#import <BoxSDK/BoxSDK.h>
#endif
@interface VLCCloudStorageTableViewCell : UITableViewCell
......@@ -30,9 +30,9 @@
@property (nonatomic, retain) DBMetadata *dropboxFile;
@property (nonatomic, retain) VLCOneDriveObject *oneDriveFile;
@property (nonatomic, retain) BoxItem *boxFile;
#if TARGET_OS_IOS
@property (nonatomic, retain) GTLDriveFile *driveFile;
@property (nonatomic, retain) BoxItem *boxFile;
#endif
@property (nonatomic, readwrite) BOOL isDownloadable;
......
......@@ -48,6 +48,7 @@
[self performSelectorOnMainThread:@selector(_updatedDisplayedInformation)
withObject:nil waitUntilDone:NO];
}
#endif
- (void)setBoxFile:(BoxItem *)boxFile
{
......@@ -57,7 +58,6 @@
[self performSelectorOnMainThread:@selector(_updatedDisplayedInformation)
withObject:nil waitUntilDone:NO];
}
#endif
- (void)setOneDriveFile:(VLCOneDriveObject *)oneDriveFile
{
......@@ -125,7 +125,9 @@
self.thumbnailView.image = [UIImage imageNamed:@"blank"];
APLog(@"missing icon for type '%@'", self.driveFile.iconLink);
}
} else if(_boxFile != nil) {
}
#endif
else if(_boxFile != nil) {
BOOL isDirectory = [self.boxFile.type isEqualToString:@"folder"];
if (isDirectory) {
self.folderTitleLabel.text = self.boxFile.name;
......@@ -152,9 +154,7 @@
self.thumbnailView.image = [UIImage imageNamed:@"blank"];
APLog(@"missing icon for type '%@'", self.boxFile);
}
}
#endif
else if(_oneDriveFile != nil) {
} else if(_oneDriveFile != nil) {
if (_oneDriveFile.isFolder) {
self.downloadButton.hidden = YES;
self.folderTitleLabel.text = self.oneDriveFile.name;
......
......@@ -135,6 +135,8 @@
7D3E528B1BD7B5E100309D15 /* VLCCloudServicesTVViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D3E52891BD7B5E100309D15 /* VLCCloudServicesTVViewController.m */; };
7D3E528C1BD7B5E100309D15 /* VLCCloudServicesTVViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7D3E528A1BD7B5E100309D15 /* VLCCloudServicesTVViewController.xib */; };
7D3EB014174A353E002062C2 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7D3EB013174A353E002062C2 /* SystemConfiguration.framework */; };
7D4408591BDA8DCA0080FB42 /* VLCBoxController.m in Sources */ = {isa = PBXBuildFile; fileRef = 41CD69591A29D72600E60BCE /* VLCBoxController.m */; };
7D44085A1BDA8DCE0080FB42 /* VLCBoxTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 41CD695B1A29D72600E60BCE /* VLCBoxTableViewController.m */; };
7D4625881A5614A1001A80B4 /* VLCEqualizerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D4625871A5614A1001A80B4 /* VLCEqualizerView.m */; };
7D4DF2181B55209200739326 /* CoreSpotlight.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7D4DF2171B55209200739326 /* CoreSpotlight.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
7D50903218F41C7900180139 /* VLCAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D50903118F41C7900180139 /* VLCAlertView.m */; };
......@@ -2504,6 +2506,7 @@
7D7EF3DD1BD5779F00CD4CEE /* VLCPlaybackController.m in Sources */,
7DEC8BDE1BD67899006E1093 /* VLCFullscreenMovieTVViewController.m in Sources */,
7DEC8BD71BD658E6006E1093 /* VLCPlayerDisplayController.m in Sources */,
7D44085A1BDA8DCE0080FB42 /* VLCBoxTableViewController.m in Sources */,
7DC71D261BC830A5001FACAA /* VLCLocalNetworkTVViewController.m in Sources */,
7D5278E21BD7E06E00D0CA0E /* VLCDropboxController.m in Sources */,
7DEC8BD91BD670EB006E1093 /* VLCPlaybackNavigationController.m in Sources */,
......@@ -2514,6 +2517,7 @@
7D1329441BA1F10100BE647E /* AppleTVAppDelegate.m in Sources */,
7D1329411BA1F10100BE647E /* main.m in Sources */,
7DC71D291BC83590001FACAA /* UIColor+Presets.m in Sources */,
7D4408591BDA8DCA0080FB42 /* VLCBoxController.m in Sources */,
7D5278E41BD7E37300D0CA0E /* VLCCloudStorageController.m in Sources */,
7D60696A1BD93ABF00AB765C /* VLCCloudStorageTableViewController.m in Sources */,
7D3E528B1BD7B5E100309D15 /* VLCCloudServicesTVViewController.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