Commit 55b4af4b authored by Felix Paul Kühne's avatar Felix Paul Kühne

Clouds: reimplement OneDrive TableVC to have proper navigation

Should be ported to iOS with the old VC removed
parent 6b480235
//
// VLCOneDriveTableViewController2.h
// VLC for iOS
//
// Created by Felix Paul Kühne on 30/10/15.
// Copyright © 2015 VideoLAN. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "VLCCloudStorageTVTableViewController.h"
@class VLCOneDriveObject;
@interface VLCOneDriveTableViewController2 : VLCCloudStorageTVTableViewController
- (instancetype)initWithOneDriveObject:(VLCOneDriveObject *)object;
@end
//
// VLCOneDriveTableViewController2.m
// VLC for iOS
//
// Created by Felix Paul Kühne on 30/10/15.
// Copyright © 2015 VideoLAN. All rights reserved.
//
#import "VLCOneDriveTableViewController2.h"
#import "VLCOneDriveController.h"
#import "VLCCloudStorageTableViewCell.h"
@interface VLCOneDriveTableViewController2 () <VLCCloudStorageDelegate>
{
VLCOneDriveObject *_currentFolder;
VLCOneDriveController *_oneDriveController;
}
@end
@implementation VLCOneDriveTableViewController2
- (instancetype)initWithOneDriveObject:(VLCOneDriveObject *)object
{
self = [super init];
if (self) {
_oneDriveController = [VLCOneDriveController sharedInstance];
self.controller = _oneDriveController;
_oneDriveController.delegate = self;
_currentFolder = object;
_oneDriveController.currentFolder = object;
[_oneDriveController loadCurrentFolder];
}
return self;
}
- (void)viewWillAppear:(BOOL)animated
{
if (_currentFolder != nil)
self.title = _currentFolder.name;
else
self.title = @"OneDrive";
[self updateViewAfterSessionChange];
self.authorizationInProgress = NO;
[super viewWillAppear:animated];
}
#pragma mark - table view data source
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"OneDriveCell";
VLCCloudStorageTableViewCell *cell = (VLCCloudStorageTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
cell = [VLCCloudStorageTableViewCell cellWithReuseIdentifier:CellIdentifier];
if (_currentFolder == nil)
_currentFolder = _oneDriveController.rootFolder;
if (_currentFolder) {
NSArray *items = _currentFolder.items;
if (indexPath.row < items.count) {
cell.oneDriveFile = items[indexPath.row];
cell.delegate = self;
}
}
return cell;
}
#pragma mark - table view delegate
- (void)mediaListUpdated
{
[self.tableView reloadData];
[self.activityIndicator stopAnimating];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self.tableView deselectRowAtIndexPath:indexPath animated:NO];
if (_currentFolder == nil)
return;
NSArray *folderItems = _currentFolder.items;
NSInteger row = indexPath.row;
if (row >= folderItems.count)
return;
VLCOneDriveObject *selectedObject = folderItems[row];
if (selectedObject.isFolder) {
/* dive into sub folder */
VLCOneDriveTableViewController2 *targetViewController = [[VLCOneDriveTableViewController2 alloc] initWithOneDriveObject:selectedObject];
[self.navigationController pushViewController:targetViewController animated:YES];
} else {
/* stream file */
NSURL *url = [NSURL URLWithString:selectedObject.downloadPath];
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
[vpc playURL:url successCallback:nil errorCallback:nil];
#if TARGET_OS_TV
VLCFullscreenMovieTVViewController *movieVC = [VLCFullscreenMovieTVViewController fullscreenMovieTVViewController];
[self presentViewController:movieVC
animated:YES
completion:nil];
#endif
}
}
#pragma mark - onedrive controller delegation
- (void)sessionWasUpdated
{
[self updateViewAfterSessionChange];
}
@end
......@@ -14,7 +14,6 @@
#import "VLCOneDriveController.h"
#import "VLCCloudStorageTableViewCell.h"
#import "VLCPlaybackController.h"
#import "VLCOneDriveController.h"
#import "VLCProgressView.h"
#import "UIDevice+VLC.h"
......
......@@ -13,6 +13,8 @@
@interface VLCCloudServicesTVViewController : UIViewController
@property (readwrite, nonatomic, weak) IBOutlet UIButton *oneDriveButton;
- (IBAction)dropbox:(id)sender;
- (IBAction)onedrive:(id)sender;
- (IBAction)box:(id)sender;
......
......@@ -15,13 +15,16 @@
#import "VLCDropboxTableViewController.h"
#import "SSKeychain.h"
#import "VLCPlayerDisplayController.h"
#import "VLCOneDriveTableViewController.h"
#import "VLCOneDriveController.h"
#import "VLCOneDriveTableViewController2.h"
#import "VLCBoxTableViewController.h"
@interface VLCCloudServicesTVViewController ()
{
VLCOneDriveController *_oneDriveController;
}
@property (nonatomic) VLCDropboxTableViewController *dropboxTableViewController;
@property (nonatomic) VLCOneDriveTableViewController *oneDriveTableViewController;
@property (nonatomic) VLCBoxTableViewController *boxTableViewController;
@end
......@@ -31,9 +34,19 @@
- (void)viewDidLoad {
[super viewDidLoad];
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
[center addObserver:self selector:@selector(oneDriveSessionUpdated:) name:VLCOneDriveControllerSessionUpdated object:nil];
_oneDriveController = [VLCOneDriveController sharedInstance];
self.dropboxTableViewController = [[VLCDropboxTableViewController alloc] initWithNibName:nil bundle:nil];
self.oneDriveTableViewController = [[VLCOneDriveTableViewController alloc] initWithNibName:nil bundle:nil];
self.boxTableViewController = [[VLCBoxTableViewController alloc] initWithNibName:nil bundle:nil];
[self oneDriveSessionUpdated:nil];
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (NSString *)title
......@@ -67,9 +80,15 @@
[self presentViewController:alert animated:YES completion:nil];
}
- (void)oneDriveSessionUpdated:(NSNotification *)aNotification
{
self.oneDriveButton.enabled = _oneDriveController.activeSession;
}
- (IBAction)onedrive:(id)sender
{
[self.navigationController pushViewController:self.oneDriveTableViewController animated:YES];
VLCOneDriveTableViewController2 *newKid = [[VLCOneDriveTableViewController2 alloc] initWithOneDriveObject:nil];
[self.navigationController pushViewController:newKid animated:YES];
}
- (IBAction)box:(id)sender
......
......@@ -6,6 +6,7 @@
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="VLCCloudServicesTVViewController">
<connections>
<outlet property="oneDriveButton" destination="gFm-4V-QFs" id="eWx-9Y-RDg"/>
<outlet property="view" destination="iN0-l3-epB" id="Eym-vH-oyN"/>
</connections>
</placeholder>
......
......@@ -202,6 +202,7 @@
7DD2A3A9179C04A7003EB537 /* OpenSans-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 7DD2A3A8179C04A6003EB537 /* OpenSans-Regular.ttf */; };
7DDD0429172D98E5005A7B10 /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7DDD0428172D98E5005A7B10 /* CFNetwork.framework */; };
7DDFF4251BDFD23300913BD1 /* VLCCone512x512.png in Resources */ = {isa = PBXBuildFile; fileRef = 7DDFF4241BDFD23300913BD1 /* VLCCone512x512.png */; };
7DE0648D1BE3F36700C706BE /* VLCOneDriveTableViewController2.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DE0648C1BE3F36700C706BE /* VLCOneDriveTableViewController2.m */; };
7DE56C1A1AD93F9100E8CA00 /* VLCPlaybackController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DE56C191AD93F9100E8CA00 /* VLCPlaybackController.m */; };
7DEC8BD91BD670EB006E1093 /* VLCPlaybackNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D9CB9DB1A4C55EF00BB74B4 /* VLCPlaybackNavigationController.m */; };
7DEC8BDA1BD67112006E1093 /* VLCFrostedGlasView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BADAF44185FBD9D00108BD8 /* VLCFrostedGlasView.m */; };
......@@ -815,6 +816,8 @@
7DD32D22194F1946002510A9 /* zh-Hant */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hant"; path = "zh-Hant.lproj/Localizable.strings"; sourceTree = "<group>"; };
7DDD0428172D98E5005A7B10 /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = System/Library/Frameworks/CFNetwork.framework; sourceTree = SDKROOT; };
7DDFF4241BDFD23300913BD1 /* VLCCone512x512.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = VLCCone512x512.png; path = Resources/VLCCone512x512.png; sourceTree = SOURCE_ROOT; };
7DE0648B1BE3F36700C706BE /* VLCOneDriveTableViewController2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCOneDriveTableViewController2.h; path = SharedSources/Clouds/VLCOneDriveTableViewController2.h; sourceTree = SOURCE_ROOT; };
7DE0648C1BE3F36700C706BE /* VLCOneDriveTableViewController2.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCOneDriveTableViewController2.m; path = SharedSources/Clouds/VLCOneDriveTableViewController2.m; sourceTree = SOURCE_ROOT; };
7DE56C181AD93F9100E8CA00 /* VLCPlaybackController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCPlaybackController.h; path = Sources/VLCPlaybackController.h; sourceTree = SOURCE_ROOT; };
7DE56C191AD93F9100E8CA00 /* VLCPlaybackController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCPlaybackController.m; path = Sources/VLCPlaybackController.m; sourceTree = SOURCE_ROOT; };
7DEB3B5F17647DE30038FC70 /* iTunesArtwork@2x */ = {isa = PBXFileReference; lastKnownFileType = file; path = "iTunesArtwork@2x"; sourceTree = "<group>"; };
......@@ -1279,6 +1282,8 @@
7D1052EB1A4DCC4B00295F08 /* VLCOneDriveConstants.h */,
7D1052E71A4DCC1100295F08 /* VLCOneDriveTableViewController.h */,
7D1052E81A4DCC1100295F08 /* VLCOneDriveTableViewController.m */,
7DE0648B1BE3F36700C706BE /* VLCOneDriveTableViewController2.h */,
7DE0648C1BE3F36700C706BE /* VLCOneDriveTableViewController2.m */,
7D1052EC1A4DCD1E00295F08 /* VLCOneDriveController.h */,
7D1052ED1A4DCD1E00295F08 /* VLCOneDriveController.m */,
7DB847D51A5871570002DC30 /* VLCOneDriveObject.h */,
......@@ -2665,6 +2670,7 @@
files = (
DD3EFF441BDEBCE500B68579 /* VLCSharedLibraryParser.m in Sources */,
DD3EFF5E1BDEBCE500B68579 /* VLCLocalServerDiscoveryController.m in Sources */,
7DE0648D1BE3F36700C706BE /* VLCOneDriveTableViewController2.m in Sources */,
7D0C35371BD97E870058CD19 /* VLCOneDriveTableViewController.m in Sources */,
DD8095E01BE3EFC20065D8E1 /* VLCPlaybackInfoTVViewController.m in Sources */,
7DEC8C1F1BD6A113006E1093 /* UIDevice+VLC.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