Commit b2d273ca authored by Quentin Richard's avatar Quentin Richard Committed by Carola Nitz

Update AlertView to AlertViewController

parent bf436a6f
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
*****************************************************************************/ *****************************************************************************/
#import "UIViewController+VLCAlert.h" #import "UIViewController+VLCAlert.h"
#import "VLC_iOS-Swift.h"
@implementation UIViewController (UIViewController_VLCAlert) @implementation UIViewController (UIViewController_VLCAlert)
#if TARGET_OS_TV #if TARGET_OS_TV
- (void)vlc_showAlertWithTitle:(NSString *)title message:(NSString *)message buttonTitle:(NSString *)buttonTitle - (void)vlc_showAlertWithTitle:(NSString *)title message:(NSString *)message buttonTitle:(NSString *)buttonTitle
...@@ -22,12 +22,14 @@ ...@@ -22,12 +22,14 @@
#else #else
- (void)vlc_showAlertWithTitle:(NSString *)title message:(NSString *)message buttonTitle:(NSString *)buttonTitle - (void)vlc_showAlertWithTitle:(NSString *)title message:(NSString *)message buttonTitle:(NSString *)buttonTitle
{ {
VLCAlertView *alert = [[VLCAlertView alloc] initWithTitle:title NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init];
message:message ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: buttonTitle
delegate:self buttonAction: ^(UIAlertAction* action){}];
cancelButtonTitle:buttonTitle [buttonsAction addObject: cancelAction];
otherButtonTitles:nil]; [VLCAlertViewController alertViewManagerWithTitle:title
[alert show]; errorMessage:message
viewController:self
buttonsAction:buttonsAction];
} }
#endif #endif
@end @end
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#import "VLCNetworkLoginDataSourceLogin.h" #import "VLCNetworkLoginDataSourceLogin.h"
#import "VLCNetworkLoginDataSourceSavedLogins.h" #import "VLCNetworkLoginDataSourceSavedLogins.h"
#import "VLCNetworkServerLoginInformation.h" #import "VLCNetworkServerLoginInformation.h"
#import "VLC_iOS-Swift.h"
// for protocol identifier // for protocol identifier
...@@ -171,9 +172,11 @@ ...@@ -171,9 +172,11 @@
self.loginInformation = login; self.loginInformation = login;
NSError *error = nil; NSError *error = nil;
if (![self.savedLoginsDataSource saveLogin:login error:&error]) { if (![self.savedLoginsDataSource saveLogin:login error:&error]) {
[[[VLCAlertView alloc] initWithTitle:error.localizedDescription
message:error.localizedFailureReason NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init];
cancelButtonTitle:NSLocalizedString(@"BUTTON_OK", nil) otherButtonTitles:nil] show]; ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_OK", nil) buttonAction: ^(UIAlertAction* action){}];
[buttonsAction addObject: cancelAction];
[VLCAlertViewController alertViewManagerWithTitle:error.localizedDescription errorMessage: error.localizedFailureReason viewController:self buttonsAction:buttonsAction];
} }
[self.tableView deselectRowAtIndexPath:self.tableView.indexPathForSelectedRow animated:YES]; [self.tableView deselectRowAtIndexPath:self.tableView.indexPathForSelectedRow animated:YES];
...@@ -195,11 +198,15 @@ ...@@ -195,11 +198,15 @@
- (BOOL)protocolSelected - (BOOL)protocolSelected
{ {
if (self.protocolDataSource.protocol == VLCServerProtocolUndefined) { if (self.protocolDataSource.protocol == VLCServerProtocolUndefined) {
VLCAlertView *alertView = [[VLCAlertView alloc] initWithTitle:NSLocalizedString(@"PROTOCOL_NOT_SELECTED", nil)
message:NSLocalizedString(@"PROTOCOL_NOT_SELECTED", nil) NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init];
cancelButtonTitle:NSLocalizedString(@"BUTTON_OK", nil) ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_OK", nil)
otherButtonTitles:nil]; buttonAction: ^(UIAlertAction* action){}];
[alertView performSelectorOnMainThread:@selector(show) withObject:nil waitUntilDone:NO]; [buttonsAction addObject: cancelAction];
[VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"PROTOCOL_NOT_SELECTED", nil)
errorMessage: NSLocalizedString(@"PROTOCOL_NOT_SELECTED", nil)
viewController:self
buttonsAction:buttonsAction];
[self.tableView deselectRowAtIndexPath:self.tableView.indexPathForSelectedRow animated:YES]; [self.tableView deselectRowAtIndexPath:self.tableView.indexPathForSelectedRow animated:YES];
return NO; return NO;
} }
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#import "VLCConstants.h" #import "VLCConstants.h"
#import "UIColor+Presets.h" #import "UIColor+Presets.h"
#import "UIBarButtonItem+Theme.h" #import "UIBarButtonItem+Theme.h"
#import "VLCAlertView.h"
#import "UIViewController+VLCAlert.h" #import "UIViewController+VLCAlert.h"
#ifndef NDEBUG #ifndef NDEBUG
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#import "VLCPlaybackController.h" #import "VLCPlaybackController.h"
#import "VLCMediaFileDiscoverer.h" #import "VLCMediaFileDiscoverer.h"
#import <XKKeychain/XKKeychainGenericPasswordItem.h> #import <XKKeychain/XKKeychainGenericPasswordItem.h>
#import "VLC_iOS-Swift.h"
@interface VLCBoxController () @interface VLCBoxController ()
{ {
...@@ -269,12 +270,14 @@ ...@@ -269,12 +270,14 @@
- (void)showAlert:(NSString *)title message:(NSString *)message - (void)showAlert:(NSString *)title message:(NSString *)message
{ {
VLCAlertView *alert = [[VLCAlertView alloc] initWithTitle:title NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init];
message:message ButtonAction *okAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_OK", nil)
delegate:nil buttonAction: ^(UIAlertAction* action){}];
cancelButtonTitle:NSLocalizedString(@"BUTTON_OK", nil) [buttonsAction addObject: okAction];
otherButtonTitles:nil]; [VLCAlertViewController alertViewManagerWithTitle:title
[alert show]; errorMessage:message
viewController:self.delegate
buttonsAction:buttonsAction];
} }
- (void)calculateRemainingTime:(CGFloat)receivedDataSize expectedDownloadSize:(CGFloat)expectedDownloadSize - (void)calculateRemainingTime:(CGFloat)receivedDataSize expectedDownloadSize:(CGFloat)expectedDownloadSize
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#import <XKKeychain/XKKeychainGenericPasswordItem.h> #import <XKKeychain/XKKeychainGenericPasswordItem.h>
#import "UIDevice+VLC.h" #import "UIDevice+VLC.h"
#import "VLCPlaybackController.h" #import "VLCPlaybackController.h"
#import "VLC_iOS-Swift.h"
#if TARGET_OS_IOS #if TARGET_OS_IOS
@interface VLCBoxTableViewController () <VLCCloudStorageTableViewCell, BoxAuthorizationViewControllerDelegate, VLCCloudStorageDelegate, NSURLConnectionDataDelegate> @interface VLCBoxTableViewController () <VLCCloudStorageTableViewCell, BoxAuthorizationViewControllerDelegate, VLCCloudStorageDelegate, NSURLConnectionDataDelegate>
...@@ -231,20 +232,32 @@ ...@@ -231,20 +232,32 @@
if (_selectedFile.size.longLongValue < [[UIDevice currentDevice] VLCFreeDiskSpace].longLongValue) { if (_selectedFile.size.longLongValue < [[UIDevice currentDevice] VLCFreeDiskSpace].longLongValue) {
/* selected item is a proper file, ask the user if s/he wants to download it */ /* selected item is a proper file, ask the user if s/he wants to download it */
VLCAlertView *alert = [[VLCAlertView alloc] initWithTitle:NSLocalizedString(@"DROPBOX_DOWNLOAD", nil) message:[NSString stringWithFormat:NSLocalizedString(@"DROPBOX_DL_LONG", nil), _selectedFile.name, [[UIDevice currentDevice] model]] delegate:self cancelButtonTitle:NSLocalizedString(@"BUTTON_CANCEL", nil) otherButtonTitles:NSLocalizedString(@"BUTTON_DOWNLOAD", nil), nil]; NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init];
[alert show]; ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_CANCEL", nil)
buttonAction: ^(UIAlertAction* action){}];
ButtonAction *downloadAction = [[ButtonAction alloc] initWithButtonTitle:NSLocalizedString(@"BUTTON_DOWNLOAD", nil)
buttonAction:^(UIAlertAction* action){
[_boxController downloadFileToDocumentFolder:_selectedFile];
_selectedFile = nil;
}];
[buttonsAction addObject: cancelAction];
[buttonsAction addObject: downloadAction];
[VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"DROPBOX_DOWNLOAD", nil)
errorMessage:[NSString stringWithFormat:NSLocalizedString(@"DROPBOX_DL_LONG", nil), _selectedFile.name, [[UIDevice currentDevice] model]]
viewController:self
buttonsAction:buttonsAction];
} else { } else {
VLCAlertView *alert = [[VLCAlertView alloc] initWithTitle:NSLocalizedString(@"DISK_FULL", nil) message:[NSString stringWithFormat:NSLocalizedString(@"DISK_FULL_FORMAT", nil), _selectedFile.name, [[UIDevice currentDevice] model]] delegate:self cancelButtonTitle:NSLocalizedString(@"BUTTON_OK", nil) otherButtonTitles:nil]; NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init];
[alert show]; ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_OK", nil)
buttonAction: ^(UIAlertAction* action){}];
[buttonsAction addObject: cancelAction];
[VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"DISK_FULL", nil)
errorMessage:[NSString stringWithFormat:NSLocalizedString(@"DISK_FULL_FORMAT", nil), _selectedFile.name, [[UIDevice currentDevice] model]]
viewController:self
buttonsAction:buttonsAction];;
} }
} }
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 1)
[_boxController downloadFileToDocumentFolder:_selectedFile];
_selectedFile = nil;
}
#endif #endif
#pragma mark - box controller delegate #pragma mark - box controller delegate
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#import "VLCBugreporter.h" #import "VLCBugreporter.h"
#import "VLC_iOS-Swift.h"
@implementation VLCBugreporter @implementation VLCBugreporter
#pragma mark - Initialization #pragma mark - Initialization
...@@ -33,19 +35,19 @@ ...@@ -33,19 +35,19 @@
- (void)handleBugreportRequest - (void)handleBugreportRequest
{ {
VLCAlertView *alert = [[VLCAlertView alloc] initWithTitle:NSLocalizedString(@"BUG_REPORT_TITLE", nil) NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init];
message:NSLocalizedString(@"BUG_REPORT_MESSAGE", nil) delegate:self ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_CANCEL", nil)
cancelButtonTitle:NSLocalizedString(@"BUTTON_CANCEL", nil) buttonAction: ^(UIAlertAction* action){}];
otherButtonTitles:NSLocalizedString(@"BUG_REPORT_BUTTON", nil), nil];; ButtonAction *reportAction = [[ButtonAction alloc] initWithButtonTitle:NSLocalizedString(@"BUG_REPORT_BUTTON", nil)
[alert show]; buttonAction: ^(UIAlertAction* action){
NSURL *url = [NSURL URLWithString:@"https://trac.videolan.org/vlc/newticket"];
[[UIApplication sharedApplication] openURL:url];
}];
[buttonsAction addObject: cancelAction];
[buttonsAction addObject: reportAction];
[VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"BUG_REPORT_TITLE", nil)
errorMessage:NSLocalizedString(@"BUG_REPORT_MESSAGE", nil)
viewController:[UIApplication sharedApplication].keyWindow.rootViewController
buttonsAction:buttonsAction];
} }
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 1) {
NSURL *url = [NSURL URLWithString:@"https://trac.videolan.org/vlc/newticket"];
[[UIApplication sharedApplication] openURL:url];
}
}
@end @end
...@@ -139,21 +139,17 @@ typedef NS_ENUM(NSUInteger, VLCDownloadScheme) { ...@@ -139,21 +139,17 @@ typedef NS_ENUM(NSUInteger, VLCDownloadScheme) {
if ([self.urlField.text length] > 0) { if ([self.urlField.text length] > 0) {
NSURL *URLtoSave = [NSURL URLWithString:self.urlField.text]; NSURL *URLtoSave = [NSURL URLWithString:self.urlField.text];
if (![URLtoSave.lastPathComponent isSupportedFormat] && ![URLtoSave.lastPathComponent.pathExtension isEqualToString:@""]) { if (![URLtoSave.lastPathComponent isSupportedFormat] && ![URLtoSave.lastPathComponent.pathExtension isEqualToString:@""]) {
VLCAlertView *alert = [[VLCAlertView alloc] initWithTitle:NSLocalizedString(@"FILE_NOT_SUPPORTED", nil) NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init];
message:[NSString stringWithFormat:NSLocalizedString(@"FILE_NOT_SUPPORTED_LONG", nil), URLtoSave.lastPathComponent] ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_CANCEL", nil) buttonAction: ^(UIAlertAction* action){}];
delegate:self [buttonsAction addObject: cancelAction];
cancelButtonTitle:NSLocalizedString(@"BUTTON_CANCEL", nil) [VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"FILE_NOT_SUPPORTED", nil) errorMessage: [NSString stringWithFormat:NSLocalizedString(@"FILE_NOT_SUPPORTED_LONG", nil), URLtoSave.lastPathComponent] viewController:self buttonsAction:buttonsAction];
otherButtonTitles:nil];
[alert show];
return; return;
} }
if (![URLtoSave.scheme isEqualToString:@"http"] & ![URLtoSave.scheme isEqualToString:@"https"] && ![URLtoSave.scheme isEqualToString:@"ftp"]) { if (![URLtoSave.scheme isEqualToString:@"http"] & ![URLtoSave.scheme isEqualToString:@"https"] && ![URLtoSave.scheme isEqualToString:@"ftp"]) {
VLCAlertView *alert = [[VLCAlertView alloc] initWithTitle:NSLocalizedString(@"SCHEME_NOT_SUPPORTED", nil) NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init];
message:[NSString stringWithFormat:NSLocalizedString(@"SCHEME_NOT_SUPPORTED_LONG", nil), URLtoSave.scheme] ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_CANCEL", nil) buttonAction: ^(UIAlertAction* action){}];
delegate:self [buttonsAction addObject: cancelAction];
cancelButtonTitle:NSLocalizedString(@"BUTTON_CANCEL", nil) [VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"SCHEME_NOT_SUPPORTED", nil) errorMessage: [NSString stringWithFormat:NSLocalizedString(@"SCHEME_NOT_SUPPORTED_LONG", nil), URLtoSave.scheme] viewController:self buttonsAction:buttonsAction];
otherButtonTitles:nil];
[alert show];
return; return;
} }
...@@ -317,12 +313,10 @@ typedef NS_ENUM(NSUInteger, VLCDownloadScheme) { ...@@ -317,12 +313,10 @@ typedef NS_ENUM(NSUInteger, VLCDownloadScheme) {
- (void)downloadFailedWithErrorDescription:(NSString *)description - (void)downloadFailedWithErrorDescription:(NSString *)description
{ {
VLCAlertView *alert = [[VLCAlertView alloc] initWithTitle:NSLocalizedString(@"DOWNLOAD_FAILED", nil) NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init];
message:description ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_CANCEL", nil) buttonAction: ^(UIAlertAction* action){}];
delegate:self [buttonsAction addObject: cancelAction];
cancelButtonTitle:NSLocalizedString(@"BUTTON_CANCEL", nil) [VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"SCHEME_NOT_SUPPORTED", nil) errorMessage: description viewController:self buttonsAction:buttonsAction];
otherButtonTitles:nil];
[alert performSelectorOnMainThread:@selector(show) withObject:nil waitUntilDone:NO];
} }
- (void)progressUpdatedTo:(CGFloat)percentage receivedDataSize:(CGFloat)receivedDataSize expectedDownloadSize:(CGFloat)expectedDownloadSize - (void)progressUpdatedTo:(CGFloat)percentage receivedDataSize:(CGFloat)receivedDataSize expectedDownloadSize:(CGFloat)expectedDownloadSize
...@@ -395,13 +389,10 @@ typedef NS_ENUM(NSUInteger, VLCDownloadScheme) { ...@@ -395,13 +389,10 @@ typedef NS_ENUM(NSUInteger, VLCDownloadScheme) {
{ {
_FTPDownloadRequest = nil; _FTPDownloadRequest = nil;
[self downloadEnded]; [self downloadEnded];
NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init];
VLCAlertView *alert = [[VLCAlertView alloc] initWithTitle:[NSString stringWithFormat:NSLocalizedString(@"ERROR_NUMBER", nil), request.error.errorCode] ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_CANCEL", nil) buttonAction: ^(UIAlertAction* action){}];
message:request.error.message [buttonsAction addObject: cancelAction];
delegate:self [VLCAlertViewController alertViewManagerWithTitle:[NSString stringWithFormat:NSLocalizedString(@"ERROR_NUMBER", nil), request.error.errorCode] errorMessage: request.error.message viewController:self buttonsAction:buttonsAction];
cancelButtonTitle:NSLocalizedString(@"BUTTON_CANCEL", nil)
otherButtonTitles:nil];
[alert performSelectorOnMainThread:@selector(show) withObject:nil waitUntilDone:NO];
} }
#pragma mark - table view data source #pragma mark - table view data source
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#import "VLCActivityManager.h" #import "VLCActivityManager.h"
#import "VLCMediaFileDiscoverer.h" #import "VLCMediaFileDiscoverer.h"
#import "VLCDropboxConstants.h" #import "VLCDropboxConstants.h"
#import "VLC_iOS-Swift.h"
@interface VLCDropboxController () @interface VLCDropboxController ()
{ {
...@@ -325,12 +326,14 @@ ...@@ -325,12 +326,14 @@
- (void)_handleError:(NSError *)error - (void)_handleError:(NSError *)error
{ {
#if TARGET_OS_IOS #if TARGET_OS_IOS
VLCAlertView *alert = [[VLCAlertView alloc] initWithTitle:[NSString stringWithFormat:NSLocalizedString(@"ERROR_NUMBER", nil), error.code] NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init];
message:error.localizedDescription ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_CANCEL", nil)
delegate:self buttonAction: ^(UIAlertAction* action){}];
cancelButtonTitle:NSLocalizedString(@"BUTTON_CANCEL", nil) [buttonsAction addObject: cancelAction];
otherButtonTitles:nil]; [VLCAlertViewController alertViewManagerWithTitle:[NSString stringWithFormat:NSLocalizedString(@"ERROR_NUMBER", nil), error.code]
[alert show]; errorMessage:error.localizedDescription
viewController:self.delegate
buttonsAction:buttonsAction];
#else #else
UIAlertController *alert = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:NSLocalizedString(@"ERROR_NUMBER", nil), error.code] UIAlertController *alert = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:NSLocalizedString(@"ERROR_NUMBER", nil), error.code]
message:error.localizedDescription message:error.localizedDescription
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#import "VLCCloudStorageTableViewCell.h" #import "VLCCloudStorageTableViewCell.h"
#import "UIDevice+VLC.h" #import "UIDevice+VLC.h"
#import "VLCAppDelegate.h" #import "VLCAppDelegate.h"
#import "VLC_iOS-Swift.h"
@interface VLCDropboxTableViewController () <VLCCloudStorageTableViewCell, VLCCloudStorageDelegate> @interface VLCDropboxTableViewController () <VLCCloudStorageTableViewCell, VLCCloudStorageDelegate>
{ {
...@@ -168,30 +169,33 @@ ...@@ -168,30 +169,33 @@
if (((DBFILESFileMetadata *)_selectedFile).size.longLongValue < [[UIDevice currentDevice] VLCFreeDiskSpace].longLongValue) { if (((DBFILESFileMetadata *)_selectedFile).size.longLongValue < [[UIDevice currentDevice] VLCFreeDiskSpace].longLongValue) {
/* selected item is a proper file, ask the user if s/he wants to download it */ /* selected item is a proper file, ask the user if s/he wants to download it */
VLCAlertView *alert = [[VLCAlertView alloc] initWithTitle:NSLocalizedString(@"DROPBOX_DOWNLOAD", nil) NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init];
message:[NSString stringWithFormat:NSLocalizedString(@"DROPBOX_DL_LONG", nil), _selectedFile.name, [[UIDevice currentDevice] model]] ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_CANCEL", nil)
delegate:self buttonAction: ^(UIAlertAction* action){}];
cancelButtonTitle:NSLocalizedString(@"BUTTON_CANCEL", nil) ButtonAction *downloadAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_DOWNLOAD", nil)
otherButtonTitles:NSLocalizedString(@"BUTTON_DOWNLOAD", nil), nil]; buttonAction: ^(UIAlertAction* action){
[alert show]; [_dropboxController downloadFileToDocumentFolder:_selectedFile];
_selectedFile = nil;
}];
[buttonsAction addObject: cancelAction];
[buttonsAction addObject: downloadAction];
[VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"DROPBOX_DOWNLOAD", nil)
errorMessage:[NSString stringWithFormat:NSLocalizedString(@"DROPBOX_DL_LONG", nil), _selectedFile.name, [[UIDevice currentDevice] model]]
viewController:self
buttonsAction:buttonsAction];
} else { } else {
VLCAlertView *alert = [[VLCAlertView alloc] initWithTitle:NSLocalizedString(@"DISK_FULL", nil) NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init];
message:[NSString stringWithFormat:NSLocalizedString(@"DISK_FULL_FORMAT", nil), _selectedFile.name, [[UIDevice currentDevice] model]] ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_OK", nil)
delegate:self buttonAction: ^(UIAlertAction* action){}];
cancelButtonTitle:NSLocalizedString(@"BUTTON_OK", nil) [buttonsAction addObject: cancelAction];
otherButtonTitles:nil]; [VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"DISK_FULL", nil)
[alert show]; errorMessage:[NSString stringWithFormat:NSLocalizedString(@"DISK_FULL_FORMAT", nil), _selectedFile.name, [[UIDevice currentDevice] model]]
viewController:self
buttonsAction:buttonsAction];
} }
} }
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 1)
[_dropboxController downloadFileToDocumentFolder:_selectedFile];
_selectedFile = nil;
}
#endif #endif
@end @end
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#import "NSString+SupportedMedia.h" #import "NSString+SupportedMedia.h"
#import "VLCPlaybackController.h" #import "VLCPlaybackController.h"
#import "VLCMediaFileDiscoverer.h" #import "VLCMediaFileDiscoverer.h"
#import "VLC_iOS-Swift.h"
#import <XKKeychain/XKKeychain.h> #import <XKKeychain/XKKeychain.h>
#import <AppAuth/AppAuth.h> #import <AppAuth/AppAuth.h>
...@@ -128,12 +129,14 @@ ...@@ -128,12 +129,14 @@
- (void)showAlert:(NSString *)title message:(NSString *)message - (void)showAlert:(NSString *)title message:(NSString *)message
{ {
VLCAlertView *alert = [[VLCAlertView alloc] initWithTitle: title NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init];
message: message ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_OK", nil)
delegate: nil buttonAction: ^(UIAlertAction* action){}];
cancelButtonTitle: @"OK" [buttonsAction addObject: cancelAction];
otherButtonTitles: nil]; [VLCAlertViewController alertViewManagerWithTitle:title
[alert show]; errorMessage:message
viewController:[UIApplication sharedApplication].keyWindow.rootViewController
buttonsAction:buttonsAction];
} }
#pragma mark - file management #pragma mark - file management
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#import "VLCGoogleDriveController.h" #import "VLCGoogleDriveController.h"
#import "UIDevice+VLC.h" #import "UIDevice+VLC.h"
#import "VLCCloudStorageTableViewCell.h" #import "VLCCloudStorageTableViewCell.h"
#import "VLC_iOS-Swift.h"
#import <AppAuth/AppAuth.h> #import <AppAuth/AppAuth.h>
#import <GTMAppAuth/GTMAppAuth.h> #import <GTMAppAuth/GTMAppAuth.h>
...@@ -127,29 +128,32 @@ ...@@ -127,29 +128,32 @@
if (_selectedFile.size.longLongValue < [[UIDevice currentDevice] VLCFreeDiskSpace].longLongValue) { if (_selectedFile.size.longLongValue < [[UIDevice currentDevice] VLCFreeDiskSpace].longLongValue) {
/* selected item is a proper file, ask the user if s/he wants to download it */ /* selected item is a proper file, ask the user if s/he wants to download it */
VLCAlertView *alert = [[VLCAlertView alloc] initWithTitle:NSLocalizedString(@"DROPBOX_DOWNLOAD", nil) NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init];
message:[NSString stringWithFormat:NSLocalizedString(@"DROPBOX_DL_LONG", nil), _selectedFile.name, [[UIDevice currentDevice] model]] ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_CANCEL", nil)
delegate:self buttonAction: ^(UIAlertAction* action){}];
cancelButtonTitle:NSLocalizedString(@"BUTTON_CANCEL", nil) ButtonAction *downloadAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_DOWNLOAD", nil)
otherButtonTitles:NSLocalizedString(@"BUTTON_DOWNLOAD", nil), nil]; buttonAction: ^(UIAlertAction* action){
[alert show]; [_googleDriveController downloadFileToDocumentFolder:_selectedFile];
_selectedFile = nil;
}];
[buttonsAction addObject: cancelAction];
[buttonsAction addObject: downloadAction];
[VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"DROPBOX_DOWNLOAD", nil)
errorMessage:[NSString stringWithFormat:NSLocalizedString(@"DROPBOX_DL_LONG", nil), _selectedFile.name, [[UIDevice currentDevice] model]]
viewController:self
buttonsAction:buttonsAction];
} else { } else {
VLCAlertView *alert = [[VLCAlertView alloc] initWithTitle:NSLocalizedString(@"DISK_FULL", nil) NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init];
message:[NSString stringWithFormat:NSLocalizedString(@"DISK_FULL_FORMAT", nil), _selectedFile.name, [[UIDevice currentDevice] model]] ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_OK", nil)
delegate:self buttonAction: ^(UIAlertAction* action){}];
cancelButtonTitle:NSLocalizedString(@"BUTTON_OK", nil) [buttonsAction addObject: cancelAction];
otherButtonTitles:nil]; [VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"DISK_FULL", nil)
[alert show]; errorMessage:[NSString stringWithFormat:NSLocalizedString(@"DISK_FULL_FORMAT", nil), _selectedFile.name, [[UIDevice currentDevice] model]]
viewController:self
buttonsAction:buttonsAction];
} }
} }
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 1)
[_googleDriveController downloadFileToDocumentFolder:_selectedFile];
_selectedFile = nil;
}
#pragma mark - login dialog #pragma mark - login dialog
- (IBAction)loginAction:(id)sender - (IBAction)loginAction:(id)sender
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#import "UIDevice+VLC.h" #import "UIDevice+VLC.h"
#import "VLCHTTPUploaderController.h" #import "VLCHTTPUploaderController.h"
#import "VLCMetaData.h" #import "VLCMetaData.h"
#import "VLC_iOS-Swift.h"
#if TARGET_OS_IOS #if TARGET_OS_IOS
#import "VLCThumbnailsCache.h" #import "VLCThumbnailsCache.h"
...@@ -722,15 +723,17 @@ ...@@ -722,15 +723,17 @@
- (void)notifyUserAboutEndOfFreeStorage:(NSString *)filename - (void)notifyUserAboutEndOfFreeStorage:(NSString *)filename
{ {
#if TARGET_OS_IOS #if TARGET_OS_IOS
VLCAlertView *alert = [[VLCAlertView alloc] initWithTitle:NSLocalizedString(@"DISK_FULL", nil) NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init];
message:[NSString stringWithFormat: ButtonAction *okAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_OK", nil)
NSLocalizedString(@"DISK_FULL_FORMAT", nil), buttonAction: ^(UIAlertAction* action){}];
filename, [buttonsAction addObject: okAction];
[[UIDevice currentDevice] model]] [VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"DISK_FULL", nil)
delegate:self errorMessage:[NSString stringWithFormat:
cancelButtonTitle:NSLocalizedString(@"BUTTON_OK", nil) NSLocalizedString(@"DISK_FULL_FORMAT", nil),
otherButtonTitles:nil]; filename,
[alert show]; [[UIDevice currentDevice] model]]
viewController:[UIApplication sharedApplication].keyWindow.rootViewController
buttonsAction:buttonsAction];
#else #else
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"DISK_FULL", nil) UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"DISK_FULL", nil)
message:[NSString stringWithFormat: message:[NSString stringWithFormat:
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@