Commit ac717d9b authored by Carola Nitz's avatar Carola Nitz

move the clouds logout button from settings to their controllers

parent ef389642
......@@ -410,38 +410,6 @@
<key>Title</key>
<string>SETTINGS_FILE_SYNC</string>
</dict>
<dict>
<key>Key</key>
<string>UnlinkDropbox</string>
<key>Title</key>
<string>SETTINGS_UNLINK_DROPBOX</string>
<key>Type</key>
<string>IASKButtonSpecifier</string>
</dict>
<dict>
<key>Key</key>
<string>UnlinkGoogleDrive</string>
<key>Title</key>
<string>SETTINGS_UNLINK_GOOGLEDRIVE</string>
<key>Type</key>
<string>IASKButtonSpecifier</string>
</dict>
<dict>
<key>Key</key>
<string>UnlinkBox</string>
<key>Title</key>
<string>SETTINGS_UNLINK_BOX</string>
<key>Type</key>
<string>IASKButtonSpecifier</string>
</dict>
<dict>
<key>Key</key>
<string>UnlinkOneDrive</string>
<key>Title</key>
<string>SETTINGS_UNLINK_ONEDRIVE</string>
<key>Type</key>
<string>IASKButtonSpecifier</string>
</dict>
<dict>
<key>Type</key>
<string>PSMultiValueSpecifier</string>
......
......@@ -13,17 +13,12 @@
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
#import "VLCDropboxTableViewController.h"
#import "VLCGoogleDriveTableViewController.h"
#import "VLCOneDriveTableViewController.h"
#import "VLCBoxTableViewController.h"
#import "VLCHTTPUploaderController.h"
#import "GHRevealViewController.h"
#import "VLCMenuTableViewController.h"
#import "VLCDownloadViewController.h"
#import "BWQuincyManager.h"
#import "VLCDocumentPickerController.h"
@class VLCPlaylistViewController;
@class PAPasscodeViewController;
......@@ -46,11 +41,7 @@
@property (nonatomic, readonly) VLCPlaylistViewController *playlistViewController;
@property (nonatomic, readonly) VLCDropboxTableViewController *dropboxTableViewController;
@property (nonatomic, readonly) VLCGoogleDriveTableViewController *googleDriveTableViewController;
@property (nonatomic, readonly) VLCOneDriveTableViewController *oneDriveTableViewController;
@property (nonatomic, readonly) VLCBoxTableViewController *boxTableViewController;
@property (nonatomic, readonly) VLCDownloadViewController *downloadViewController;
@property (nonatomic, readonly) VLCDocumentPickerController *documentPickerController;
@property (nonatomic, strong) UIWindow *window;
......
......@@ -33,12 +33,8 @@
@interface VLCAppDelegate () <PAPasscodeViewControllerDelegate, VLCMediaFileDiscovererDelegate, BWQuincyManagerDelegate> {
PAPasscodeViewController *_passcodeLockController;
VLCDropboxTableViewController *_dropboxTableViewController;
VLCGoogleDriveTableViewController *_googleDriveTableViewController;
VLCOneDriveTableViewController *_oneDriveTableViewController;
VLCBoxTableViewController *_boxTableViewController;
VLCDownloadViewController *_downloadViewController;
VLCDocumentPickerController *_documentPickerController;
VLCDropboxTableViewController *_dropboxTableViewController;
int _idleCounter;
int _networkActivityCounter;
VLCMovieViewController *_movieViewController;
......@@ -127,7 +123,9 @@
[self.dropboxTableViewController updateViewAfterSessionChange];
return YES;
}
[[BoxSDK sharedSDK].OAuth2Session performAuthorizationCodeGrantWithReceivedURL:url];
if (_playlistViewController && url != nil) {
APLog(@"%@ requested %@ to be opened", sourceApplication, url);
......@@ -235,7 +233,6 @@
}
#pragma mark - properties
- (VLCDropboxTableViewController *)dropboxTableViewController
{
if (_dropboxTableViewController == nil)
......@@ -244,30 +241,6 @@
return _dropboxTableViewController;
}
- (VLCGoogleDriveTableViewController *)googleDriveTableViewController
{
if (_googleDriveTableViewController == nil)
_googleDriveTableViewController = [[VLCGoogleDriveTableViewController alloc] initWithNibName:@"VLCCloudStorageTableViewController" bundle:nil];
return _googleDriveTableViewController;
}
- (VLCOneDriveTableViewController *)oneDriveTableViewController
{
if (_oneDriveTableViewController == nil)
_oneDriveTableViewController = [[VLCOneDriveTableViewController alloc] initWithNibName:@"VLCCloudStorageTableViewController" bundle:nil];
return _oneDriveTableViewController;
}
- (VLCBoxTableViewController *)boxTableViewController
{
if (_boxTableViewController == nil)
_boxTableViewController = [[VLCBoxTableViewController alloc] initWithNibName:@"VLCCloudStorageTableViewController" bundle:nil];
return _boxTableViewController;
}
- (VLCDownloadViewController *)downloadViewController
{
if (_downloadViewController == nil) {
......@@ -280,14 +253,6 @@
return _downloadViewController;
}
- (VLCDocumentPickerController *)documentPickerController
{
if (_documentPickerController == nil)
_documentPickerController = [[VLCDocumentPickerController alloc] init];
return _documentPickerController;
}
#pragma mark - media discovering
- (void)mediaFileAdded:(NSString *)fileName loading:(BOOL)isLoading
......
......@@ -25,6 +25,7 @@
NSString *_currentFolderId;
UIBarButtonItem *_numberOfFilesBarButtonItem;
UIBarButtonItem *_logoutButton;
UIBarButtonItem *_progressBarButtonItem;
VLCProgressView *_progressView;
......@@ -56,6 +57,8 @@
UIBarButtonItem *backButton = [UIBarButtonItem themedBackButtonWithTarget:self andSelector:@selector(goBack:)];
self.navigationItem.leftBarButtonItem = backButton;
_logoutButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"BUTTON_LOGOUT", "") style:UIBarButtonItemStyleBordered target:self action:@selector(logout)];
self.tableView.rowHeight = [VLCCloudStorageTableViewCell heightOfCell];
self.tableView.separatorColor = [UIColor VLCDarkBackgroundColor];
self.view.backgroundColor = [UIColor VLCDarkBackgroundColor];
......@@ -334,6 +337,7 @@
- (void)updateViewAfterSessionChange
{
self.navigationItem.rightBarButtonItem = _logoutButton;
if(_authorizationInProgress) {
if (self.loginToCloudStorageView.superview) {
[self.loginToCloudStorageView removeFromSuperview];
......@@ -356,6 +360,7 @@
- (void)_showLoginPanel
{
self.loginToCloudStorageView.frame = self.tableView.frame;
self.navigationItem.rightBarButtonItem = nil;
[self.view addSubview:self.loginToCloudStorageView];
}
......@@ -369,4 +374,9 @@
}
}
- (void)logout
{
[_boxController logout];
[self updateViewAfterSessionChange];
}
@end
......@@ -31,6 +31,8 @@
UIBarButtonItem *_numberOfFilesBarButtonItem;
UIBarButtonItem *_progressBarButtonItem;
UIBarButtonItem *_logoutButton;
VLCProgressView *_progressView;
UIActivityIndicatorView *_activityIndicator;
......@@ -59,6 +61,8 @@
UIBarButtonItem *backButton = [UIBarButtonItem themedBackButtonWithTarget:self andSelector:@selector(goBack:)];
self.navigationItem.leftBarButtonItem = backButton;
_logoutButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"BUTTON_LOGOUT", "") style:UIBarButtonItemStyleBordered target:self action:@selector(logout)];
self.tableView.rowHeight = [VLCCloudStorageTableViewCell heightOfCell];
self.tableView.separatorColor = [UIColor VLCDarkBackgroundColor];
self.view.backgroundColor = [UIColor VLCDarkBackgroundColor];
......@@ -236,6 +240,7 @@
- (void)updateViewAfterSessionChange
{
self.navigationItem.rightBarButtonItem = _logoutButton;
if (![[DBSession sharedSession] isLinked]) {
[self _showLoginPanel];
return;
......@@ -249,9 +254,17 @@
}
#pragma mark - login dialog
- (void)logout
{
[_dropboxController logout];
[self updateViewAfterSessionChange];
}
- (void)_showLoginPanel
{
self.loginToCloudStorageView.frame = self.tableView.frame;
self.navigationItem.rightBarButtonItem = nil;
[self.view addSubview:self.loginToCloudStorageView];
}
......
......@@ -31,6 +31,7 @@
UIBarButtonItem *_numberOfFilesBarButtonItem;
UIBarButtonItem *_progressBarButtonItem;
UIBarButtonItem *_logoutButton;
VLCProgressView *_progressView;
......@@ -59,6 +60,8 @@
UIBarButtonItem *backButton = [UIBarButtonItem themedBackButtonWithTarget:self andSelector:@selector(goBack)];
self.navigationItem.leftBarButtonItem = backButton;
_logoutButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"BUTTON_LOGOUT", "") style:UIBarButtonItemStyleBordered target:self action:@selector(logout)];
self.tableView.rowHeight = [VLCCloudStorageTableViewCell heightOfCell];
self.tableView.separatorColor = [UIColor VLCDarkBackgroundColor];
self.view.backgroundColor = [UIColor VLCDarkBackgroundColor];
......@@ -161,11 +164,10 @@
[self.navigationController popViewControllerAnimated:YES];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- (void)logout
{
return 1;
[_googleDriveController logout];
[self updateViewAfterSessionChange];
}
#pragma mark - Table view data source
......@@ -279,6 +281,7 @@
- (void)updateViewAfterSessionChange
{
self.navigationItem.rightBarButtonItem = _logoutButton;
if(_authorizationInProgress) {
if (self.loginToCloudStorageView.superview) {
[self.loginToCloudStorageView removeFromSuperview];
......@@ -301,6 +304,7 @@
- (void)_showLoginPanel
{
self.loginToCloudStorageView.frame = self.tableView.frame;
self.navigationItem.rightBarButtonItem = nil;
[self.view addSubview:self.loginToCloudStorageView];
}
......
......@@ -20,6 +20,7 @@
@interface VLCOneDriveTableViewController () <UITableViewDataSource, UITableViewDelegate>
{
UIBarButtonItem *_backButton;
UIBarButtonItem *_logoutButton;
UIActivityIndicatorView *_activityIndicator;
......@@ -42,6 +43,8 @@
_backButton = [UIBarButtonItem themedBackButtonWithTarget:self andSelector:@selector(goBack:)];
self.navigationItem.leftBarButtonItem = _backButton;
_logoutButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"BUTTON_LOGOUT", "") style:UIBarButtonItemStyleBordered target:self action:@selector(logout)];
self.tableView.rowHeight = [VLCCloudStorageTableViewCell heightOfCell];
self.tableView.separatorColor = [UIColor VLCDarkBackgroundColor];
self.view.backgroundColor = [UIColor VLCDarkBackgroundColor];
......@@ -109,9 +112,17 @@ forRowAtIndexPath:(NSIndexPath *)indexPath
}
#pragma mark - login dialog
- (void)logout
{
[_oneDriveController logout];
[self updateViewAfterSessionChange];
}
- (void)_showLoginDialog
{
self.loginToCloudStorageView.frame = self.tableView.frame;
self.navigationItem.rightBarButtonItem = nil;
[self.view addSubview:self.loginToCloudStorageView];
}
......
......@@ -16,7 +16,4 @@
@property (nonatomic, retain) IASKAppSettingsViewController *viewController;
// this should be called when the this view controller is about to become in focus
- (void)willShow;
@end
......@@ -18,16 +18,10 @@
#import "IASKSettingsReader.h"
#import "IASKAppSettingsViewController.h"
#import "PAPasscodeViewController.h"
#import <DropboxSDK/DropboxSDK.h>
#import "VLCGoogleDriveController.h"
#import "VLCOneDriveController.h"
#import "VLCBoxController.h"
@interface VLCSettingsController ()<PAPasscodeViewControllerDelegate, IASKSettingsDelegate>
{
NSString *_currentUnlinkSpecifier;
NSString *_currentUnlinkDialogTitle;
NSString *_currentCloudName;
}
@end
......@@ -47,11 +41,6 @@
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)willShow
{
[self filterCloudStorageCellsWithAnimation:NO];
}
- (void)settingDidChange:(NSNotification*)notification
{
if ([notification.object isEqual:kVLCSettingPasscodeOnKey]) {
......@@ -65,79 +54,11 @@
}
}
- (void)filterCloudStorageCellsWithAnimation:(BOOL)shouldAnimate
{
NSMutableSet * hideKeys = [[NSMutableSet alloc] init];
if (![[DBSession sharedSession] isLinked])
[hideKeys addObject:@"UnlinkDropbox"];
if (![[VLCGoogleDriveController sharedInstance] isAuthorized])
[hideKeys addObject:@"UnlinkGoogleDrive"];
if (![[VLCOneDriveController sharedInstance] activeSession])
[hideKeys addObject:@"UnlinkOneDrive"];
if (![[VLCBoxController sharedInstance] isAuthorized])
[hideKeys addObject:@"UnlinkBox"];
[self.viewController setHiddenKeys:hideKeys animated:shouldAnimate];
}
- (void)settingsViewControllerDidEnd:(IASKAppSettingsViewController*)sender
{
[[(VLCAppDelegate*)[UIApplication sharedApplication].delegate revealController] toggleSidebar:![(VLCAppDelegate*)[UIApplication sharedApplication].delegate revealController].sidebarShowing duration:kGHRevealSidebarDefaultAnimationDuration];
}
- (void)settingsViewController:(IASKAppSettingsViewController*)sender buttonTappedForSpecifier:(IASKSpecifier*)specifier
{
_currentUnlinkSpecifier = specifier.key;
if ([_currentUnlinkSpecifier isEqualToString:@"UnlinkDropbox"]) {
_currentCloudName = @"Dropbox";
_currentUnlinkDialogTitle = NSLocalizedString(@"SETTINGS_UNLINK_DROPBOX", nil);
} else if ([_currentUnlinkSpecifier isEqualToString:@"UnlinkGoogleDrive"]) {
_currentCloudName = @"Google Drive";
_currentUnlinkDialogTitle = NSLocalizedString(@"SETTINGS_UNLINK_GOOGLEDRIVE", nil);
} else if ([_currentUnlinkSpecifier isEqualToString:@"UnlinkOneDrive"]) {
_currentCloudName = @"OneDrive";
_currentUnlinkDialogTitle = NSLocalizedString(@"SETTINGS_UNLINK_ONEDRIVE", nil);
} else if ([_currentUnlinkSpecifier isEqualToString:@"UnlinkBox"]) {
_currentCloudName = @"Box";
_currentUnlinkDialogTitle = NSLocalizedString(@"SETTINGS_UNLINK_BOX", nil);
}
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:_currentUnlinkDialogTitle
message:[NSString stringWithFormat:NSLocalizedString(@"CLOUDUNLINKING", nil), _currentCloudName]
delegate:self
cancelButtonTitle:NSLocalizedString(@"BUTTON_CANCEL", nil)
otherButtonTitles:NSLocalizedString(@"BUTTON_CLOUDUNLINKING", nil), nil];
[alert show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 1) {
if ([_currentUnlinkSpecifier isEqualToString:@"UnlinkDropbox"])
[[DBSession sharedSession] unlinkAll];
else if ([_currentUnlinkSpecifier isEqualToString:@"UnlinkGoogleDrive"])
[[VLCGoogleDriveController sharedInstance] logout];
else if ([_currentUnlinkSpecifier isEqualToString:@"UnlinkOneDrive"])
[[VLCOneDriveController sharedInstance] logout];
else if ([_currentUnlinkSpecifier isEqualToString:@"UnlinkBox"])
[[VLCBoxController sharedInstance] logout];
_currentUnlinkSpecifier = nil;
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:_currentUnlinkDialogTitle
message:[NSString stringWithFormat:NSLocalizedString(@"CLOUDUNLINKING_DONE", nil), _currentCloudName]
delegate:self
cancelButtonTitle:NSLocalizedString(@"BUTTON_DONE", nil)
otherButtonTitles:nil];
[alert show];
[self filterCloudStorageCellsWithAnimation:YES];
_currentUnlinkDialogTitle = nil;
_currentCloudName = nil;
}
}
#pragma mark - PAPasscode delegate
- (void)PAPasscodeViewControllerDidCancel:(PAPasscodeViewController *)controller
......
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