Commit 4900ef1f authored by Quentin Richard's avatar Quentin Richard Committed by Carola Nitz

Refactoring on VLCAlertViewController

parent 08197551
...@@ -22,10 +22,9 @@ ...@@ -22,10 +22,9 @@
#else #else
- (void)vlc_showAlertWithTitle:(NSString *)title message:(NSString *)message buttonTitle:(NSString *)buttonTitle - (void)vlc_showAlertWithTitle:(NSString *)title message:(NSString *)message buttonTitle:(NSString *)buttonTitle
{ {
NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init]; NSArray<VLCAlertButton *> *buttonsAction = @[[[VLCAlertButton alloc] initWithTitle: buttonTitle
ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: buttonTitle action: ^(UIAlertAction* action){}]
buttonAction: ^(UIAlertAction* action){}]; ];
[buttonsAction addObject: cancelAction];
[VLCAlertViewController alertViewManagerWithTitle:title [VLCAlertViewController alertViewManagerWithTitle:title
errorMessage:message errorMessage:message
viewController:self viewController:self
......
...@@ -172,11 +172,12 @@ ...@@ -172,11 +172,12 @@
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]) {
[VLCAlertViewController alertViewManagerWithTitle:error.localizedDescription
NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init]; errorMessage: error.localizedFailureReason
ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_OK", nil) buttonAction: ^(UIAlertAction* action){}]; viewController:self
[buttonsAction addObject: cancelAction]; buttonsAction:@[[[VLCAlertButton alloc]
[VLCAlertViewController alertViewManagerWithTitle:error.localizedDescription errorMessage: error.localizedFailureReason viewController:self buttonsAction:buttonsAction]; initWithTitle: NSLocalizedString(@"BUTTON_OK", nil)
action: ^(UIAlertAction* action){}]]];
} }
[self.tableView deselectRowAtIndexPath:self.tableView.indexPathForSelectedRow animated:YES]; [self.tableView deselectRowAtIndexPath:self.tableView.indexPathForSelectedRow animated:YES];
...@@ -198,19 +199,14 @@ ...@@ -198,19 +199,14 @@
- (BOOL)protocolSelected - (BOOL)protocolSelected
{ {
if (self.protocolDataSource.protocol == VLCServerProtocolUndefined) { if (self.protocolDataSource.protocol == VLCServerProtocolUndefined) {
NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init];
ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_OK", nil)
buttonAction: ^(UIAlertAction* action){}];
[buttonsAction addObject: cancelAction];
[VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"PROTOCOL_NOT_SELECTED", nil) [VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"PROTOCOL_NOT_SELECTED", nil)
errorMessage: NSLocalizedString(@"PROTOCOL_NOT_SELECTED", nil) errorMessage: NSLocalizedString(@"PROTOCOL_NOT_SELECTED", nil)
viewController:self viewController:self
buttonsAction:buttonsAction]; buttonsAction:@[[[VLCAlertButton alloc] initWithTitle: NSLocalizedString(@"BUTTON_OK", nil)
action: ^(UIAlertAction* action){}]]];
[self.tableView deselectRowAtIndexPath:self.tableView.indexPathForSelectedRow animated:YES]; [self.tableView deselectRowAtIndexPath:self.tableView.indexPathForSelectedRow animated:YES];
return NO; return NO;
} }
return YES; return YES;
} }
......
...@@ -270,14 +270,11 @@ ...@@ -270,14 +270,11 @@
- (void)showAlert:(NSString *)title message:(NSString *)message - (void)showAlert:(NSString *)title message:(NSString *)message
{ {
NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init];
ButtonAction *okAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_OK", nil)
buttonAction: ^(UIAlertAction* action){}];
[buttonsAction addObject: okAction];
[VLCAlertViewController alertViewManagerWithTitle:title [VLCAlertViewController alertViewManagerWithTitle:title
errorMessage:message errorMessage:message
viewController:self.delegate viewController:[UIApplication sharedApplication].keyWindow.rootViewController
buttonsAction:buttonsAction]; buttonsAction:@[[[VLCAlertButton alloc] initWithTitle: NSLocalizedString(@"BUTTON_OK", nil)
action: ^(UIAlertAction* action){}]]];
} }
- (void)calculateRemainingTime:(CGFloat)receivedDataSize expectedDownloadSize:(CGFloat)expectedDownloadSize - (void)calculateRemainingTime:(CGFloat)receivedDataSize expectedDownloadSize:(CGFloat)expectedDownloadSize
......
...@@ -232,29 +232,25 @@ ...@@ -232,29 +232,25 @@
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 */
NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init]; NSArray<VLCAlertButton *> *buttonsAction = @[[[VLCAlertButton alloc] initWithTitle: NSLocalizedString(@"BUTTON_CANCEL", nil)
ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_CANCEL", nil) action: ^(UIAlertAction* action){
buttonAction: ^(UIAlertAction* action){}]; _selectedFile = nil;
ButtonAction *downloadAction = [[ButtonAction alloc] initWithButtonTitle:NSLocalizedString(@"BUTTON_DOWNLOAD", nil) }],
buttonAction:^(UIAlertAction* action){ [[VLCAlertButton alloc] initWithTitle:NSLocalizedString(@"BUTTON_DOWNLOAD", nil)
action:^(UIAlertAction* action){
[_boxController downloadFileToDocumentFolder:_selectedFile]; [_boxController downloadFileToDocumentFolder:_selectedFile];
_selectedFile = nil; _selectedFile = nil;
}]; }]];
[buttonsAction addObject: cancelAction];
[buttonsAction addObject: downloadAction];
[VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"DROPBOX_DOWNLOAD", nil) [VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"DROPBOX_DOWNLOAD", nil)
errorMessage:[NSString stringWithFormat:NSLocalizedString(@"DROPBOX_DL_LONG", nil), _selectedFile.name, [[UIDevice currentDevice] model]] errorMessage:[NSString stringWithFormat:NSLocalizedString(@"DROPBOX_DL_LONG", nil), _selectedFile.name, [[UIDevice currentDevice] model]]
viewController:self viewController:self
buttonsAction:buttonsAction]; buttonsAction:buttonsAction];
} else { } else {
NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init];
ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_OK", nil)
buttonAction: ^(UIAlertAction* action){}];
[buttonsAction addObject: cancelAction];
[VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"DISK_FULL", nil) [VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"DISK_FULL", nil)
errorMessage:[NSString stringWithFormat:NSLocalizedString(@"DISK_FULL_FORMAT", nil), _selectedFile.name, [[UIDevice currentDevice] model]] errorMessage:[NSString stringWithFormat:NSLocalizedString(@"DISK_FULL_FORMAT", nil), _selectedFile.name, [[UIDevice currentDevice] model]]
viewController:self viewController:self
buttonsAction:buttonsAction];; buttonsAction:@[[[VLCAlertButton alloc] initWithTitle: NSLocalizedString(@"BUTTON_OK", nil)
action: ^(UIAlertAction* action){}]]];;
} }
} }
......
...@@ -35,16 +35,14 @@ ...@@ -35,16 +35,14 @@
- (void)handleBugreportRequest - (void)handleBugreportRequest
{ {
NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init]; NSArray<VLCAlertButton *> *buttonsAction = @[[[VLCAlertButton alloc] initWithTitle: NSLocalizedString(@"BUTTON_CANCEL", nil)
ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_CANCEL", nil) action: ^(UIAlertAction* action){}],
buttonAction: ^(UIAlertAction* action){}]; [[VLCAlertButton alloc] initWithTitle:NSLocalizedString(@"BUG_REPORT_BUTTON", nil)
ButtonAction *reportAction = [[ButtonAction alloc] initWithButtonTitle:NSLocalizedString(@"BUG_REPORT_BUTTON", nil) action: ^(UIAlertAction* action){
buttonAction: ^(UIAlertAction* action){
NSURL *url = [NSURL URLWithString:@"https://trac.videolan.org/vlc/newticket"]; NSURL *url = [NSURL URLWithString:@"https://trac.videolan.org/vlc/newticket"];
[[UIApplication sharedApplication] openURL:url]; [[UIApplication sharedApplication] openURL:url];
}]; }]
[buttonsAction addObject: cancelAction]; ];
[buttonsAction addObject: reportAction];
[VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"BUG_REPORT_TITLE", nil) [VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"BUG_REPORT_TITLE", nil)
errorMessage:NSLocalizedString(@"BUG_REPORT_MESSAGE", nil) errorMessage:NSLocalizedString(@"BUG_REPORT_MESSAGE", nil)
viewController:[UIApplication sharedApplication].keyWindow.rootViewController viewController:[UIApplication sharedApplication].keyWindow.rootViewController
......
...@@ -139,17 +139,19 @@ typedef NS_ENUM(NSUInteger, VLCDownloadScheme) { ...@@ -139,17 +139,19 @@ 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:@""]) {
NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init]; [VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"FILE_NOT_SUPPORTED", nil)
ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_CANCEL", nil) buttonAction: ^(UIAlertAction* action){}]; errorMessage: [NSString stringWithFormat:NSLocalizedString(@"FILE_NOT_SUPPORTED_LONG", nil), URLtoSave.lastPathComponent]
[buttonsAction addObject: cancelAction]; viewController:self
[VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"FILE_NOT_SUPPORTED", nil) errorMessage: [NSString stringWithFormat:NSLocalizedString(@"FILE_NOT_SUPPORTED_LONG", nil), URLtoSave.lastPathComponent] viewController:self buttonsAction:buttonsAction]; buttonsAction:@[[[VLCAlertButton alloc] initWithTitle: NSLocalizedString(@"BUTTON_CANCEL", nil)
action: ^(UIAlertAction* action){}]]];
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"]) {
NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init]; [VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"SCHEME_NOT_SUPPORTED", nil)
ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_CANCEL", nil) buttonAction: ^(UIAlertAction* action){}]; errorMessage: [NSString stringWithFormat:NSLocalizedString(@"SCHEME_NOT_SUPPORTED_LONG", nil), URLtoSave.scheme]
[buttonsAction addObject: cancelAction]; viewController:self
[VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"SCHEME_NOT_SUPPORTED", nil) errorMessage: [NSString stringWithFormat:NSLocalizedString(@"SCHEME_NOT_SUPPORTED_LONG", nil), URLtoSave.scheme] viewController:self buttonsAction:buttonsAction]; buttonsAction:@[[[VLCAlertButton alloc] initWithTitle: NSLocalizedString(@"BUTTON_CANCEL", nil)
action: ^(UIAlertAction* action){}]]];
return; return;
} }
...@@ -313,10 +315,11 @@ typedef NS_ENUM(NSUInteger, VLCDownloadScheme) { ...@@ -313,10 +315,11 @@ typedef NS_ENUM(NSUInteger, VLCDownloadScheme) {
- (void)downloadFailedWithErrorDescription:(NSString *)description - (void)downloadFailedWithErrorDescription:(NSString *)description
{ {
NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init]; [VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"SCHEME_NOT_SUPPORTED", nil)
ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_CANCEL", nil) buttonAction: ^(UIAlertAction* action){}]; errorMessage: description
[buttonsAction addObject: cancelAction]; viewController:self
[VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"SCHEME_NOT_SUPPORTED", nil) errorMessage: description viewController:self buttonsAction:buttonsAction]; buttonsAction:@[[[VLCAlertButton alloc] initWithTitle: NSLocalizedString(@"BUTTON_CANCEL", nil)
action: ^(UIAlertAction* action){}]]];
} }
- (void)progressUpdatedTo:(CGFloat)percentage receivedDataSize:(CGFloat)receivedDataSize expectedDownloadSize:(CGFloat)expectedDownloadSize - (void)progressUpdatedTo:(CGFloat)percentage receivedDataSize:(CGFloat)receivedDataSize expectedDownloadSize:(CGFloat)expectedDownloadSize
...@@ -389,10 +392,11 @@ typedef NS_ENUM(NSUInteger, VLCDownloadScheme) { ...@@ -389,10 +392,11 @@ typedef NS_ENUM(NSUInteger, VLCDownloadScheme) {
{ {
_FTPDownloadRequest = nil; _FTPDownloadRequest = nil;
[self downloadEnded]; [self downloadEnded];
NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init]; [VLCAlertViewController alertViewManagerWithTitle:[NSString stringWithFormat:NSLocalizedString(@"ERROR_NUMBER", nil), request.error.errorCode]
ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_CANCEL", nil) buttonAction: ^(UIAlertAction* action){}]; errorMessage: request.error.message
[buttonsAction addObject: cancelAction]; viewController:self
[VLCAlertViewController alertViewManagerWithTitle:[NSString stringWithFormat:NSLocalizedString(@"ERROR_NUMBER", nil), request.error.errorCode] errorMessage: request.error.message viewController:self buttonsAction:buttonsAction]; buttonsAction:@[[[VLCAlertButton alloc] initWithTitle: NSLocalizedString(@"BUTTON_CANCEL", nil)
action: ^(UIAlertAction* action){}]]];
} }
#pragma mark - table view data source #pragma mark - table view data source
......
...@@ -326,14 +326,12 @@ ...@@ -326,14 +326,12 @@
- (void)_handleError:(NSError *)error - (void)_handleError:(NSError *)error
{ {
#if TARGET_OS_IOS #if TARGET_OS_IOS
NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init];
ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_CANCEL", nil)
buttonAction: ^(UIAlertAction* action){}];
[buttonsAction addObject: cancelAction];
[VLCAlertViewController alertViewManagerWithTitle:[NSString stringWithFormat:NSLocalizedString(@"ERROR_NUMBER", nil), error.code] [VLCAlertViewController alertViewManagerWithTitle:[NSString stringWithFormat:NSLocalizedString(@"ERROR_NUMBER", nil), error.code]
errorMessage:error.localizedDescription errorMessage:error.localizedDescription
viewController:self.delegate viewController:[UIApplication sharedApplication].keyWindow.rootViewController
buttonsAction:buttonsAction]; buttonsAction:@[[[VLCAlertButton alloc] initWithTitle: NSLocalizedString(@"BUTTON_CANCEL", nil)
action: ^(UIAlertAction* action){}]
]];
#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
......
...@@ -169,30 +169,27 @@ ...@@ -169,30 +169,27 @@
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 */
NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init]; NSArray<VLCAlertButton *> *buttonsAction = @[[[VLCAlertButton alloc] initWithTitle: NSLocalizedString(@"BUTTON_CANCEL", nil)
ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_CANCEL", nil) action: ^(UIAlertAction* action){
buttonAction: ^(UIAlertAction* action){}]; _selectedFile = nil;
ButtonAction *downloadAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_DOWNLOAD", nil) }],
buttonAction: ^(UIAlertAction* action){ [[VLCAlertButton alloc] initWithTitle: NSLocalizedString(@"BUTTON_DOWNLOAD", nil)
action: ^(UIAlertAction* action){
[_dropboxController downloadFileToDocumentFolder:_selectedFile]; [_dropboxController downloadFileToDocumentFolder:_selectedFile];
_selectedFile = nil; _selectedFile = nil;
}]; }]
[buttonsAction addObject: cancelAction]; ];
[buttonsAction addObject: downloadAction];
[VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"DROPBOX_DOWNLOAD", nil) [VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"DROPBOX_DOWNLOAD", nil)
errorMessage:[NSString stringWithFormat:NSLocalizedString(@"DROPBOX_DL_LONG", nil), _selectedFile.name, [[UIDevice currentDevice] model]] errorMessage:[NSString stringWithFormat:NSLocalizedString(@"DROPBOX_DL_LONG", nil), _selectedFile.name, [[UIDevice currentDevice] model]]
viewController:self viewController:self
buttonsAction:buttonsAction]; buttonsAction:buttonsAction];
} else { } else {
NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init];
ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_OK", nil)
buttonAction: ^(UIAlertAction* action){}];
[buttonsAction addObject: cancelAction];
[VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"DISK_FULL", nil) [VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"DISK_FULL", nil)
errorMessage:[NSString stringWithFormat:NSLocalizedString(@"DISK_FULL_FORMAT", nil), _selectedFile.name, [[UIDevice currentDevice] model]] errorMessage:[NSString stringWithFormat:NSLocalizedString(@"DISK_FULL_FORMAT", nil), _selectedFile.name, [[UIDevice currentDevice] model]]
viewController:self viewController:self
buttonsAction:buttonsAction]; buttonsAction:@[[[VLCAlertButton alloc] initWithTitle: NSLocalizedString(@"BUTTON_OK", nil)
action: ^(UIAlertAction* action){}]]];
} }
} }
......
...@@ -129,14 +129,11 @@ ...@@ -129,14 +129,11 @@
- (void)showAlert:(NSString *)title message:(NSString *)message - (void)showAlert:(NSString *)title message:(NSString *)message
{ {
NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init];
ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_OK", nil)
buttonAction: ^(UIAlertAction* action){}];
[buttonsAction addObject: cancelAction];
[VLCAlertViewController alertViewManagerWithTitle:title [VLCAlertViewController alertViewManagerWithTitle:title
errorMessage:message errorMessage:message
viewController:[UIApplication sharedApplication].keyWindow.rootViewController viewController:[UIApplication sharedApplication].keyWindow.rootViewController
buttonsAction:buttonsAction]; buttonsAction:@[[[VLCAlertButton alloc] initWithTitle: NSLocalizedString(@"BUTTON_OK", nil)
action: ^(UIAlertAction* action){}]]];
} }
#pragma mark - file management #pragma mark - file management
......
...@@ -128,30 +128,26 @@ ...@@ -128,30 +128,26 @@
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 */
NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init]; NSArray<VLCAlertButton *> *buttonsAction = @[[[VLCAlertButton alloc] initWithTitle: NSLocalizedString(@"BUTTON_CANCEL", nil)
ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_CANCEL", nil) action: ^(UIAlertAction* action){
buttonAction: ^(UIAlertAction* action){}]; _selectedFile = nil;
ButtonAction *downloadAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_DOWNLOAD", nil) }],
buttonAction: ^(UIAlertAction* action){ [[VLCAlertButton alloc] initWithTitle: NSLocalizedString(@"BUTTON_DOWNLOAD", nil)
action: ^(UIAlertAction* action){
[_googleDriveController downloadFileToDocumentFolder:_selectedFile]; [_googleDriveController downloadFileToDocumentFolder:_selectedFile];
_selectedFile = nil; _selectedFile = nil;
}]; }]
];
[buttonsAction addObject: cancelAction];
[buttonsAction addObject: downloadAction];
[VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"DROPBOX_DOWNLOAD", nil) [VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"DROPBOX_DOWNLOAD", nil)
errorMessage:[NSString stringWithFormat:NSLocalizedString(@"DROPBOX_DL_LONG", nil), _selectedFile.name, [[UIDevice currentDevice] model]] errorMessage:[NSString stringWithFormat:NSLocalizedString(@"DROPBOX_DL_LONG", nil), _selectedFile.name, [[UIDevice currentDevice] model]]
viewController:self viewController:self
buttonsAction:buttonsAction]; buttonsAction:buttonsAction];
} else { } else {
NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init];
ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_OK", nil)
buttonAction: ^(UIAlertAction* action){}];
[buttonsAction addObject: cancelAction];
[VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"DISK_FULL", nil) [VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"DISK_FULL", nil)
errorMessage:[NSString stringWithFormat:NSLocalizedString(@"DISK_FULL_FORMAT", nil), _selectedFile.name, [[UIDevice currentDevice] model]] errorMessage:[NSString stringWithFormat:NSLocalizedString(@"DISK_FULL_FORMAT", nil), _selectedFile.name, [[UIDevice currentDevice] model]]
viewController:self viewController:self
buttonsAction:buttonsAction]; buttonsAction:@[[[VLCAlertButton alloc] initWithTitle: NSLocalizedString(@"BUTTON_OK", nil)
action: ^(UIAlertAction* action){}]]];
} }
} }
#pragma mark - login dialog #pragma mark - login dialog
......
...@@ -723,17 +723,14 @@ ...@@ -723,17 +723,14 @@
- (void)notifyUserAboutEndOfFreeStorage:(NSString *)filename - (void)notifyUserAboutEndOfFreeStorage:(NSString *)filename
{ {
#if TARGET_OS_IOS #if TARGET_OS_IOS
NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init];
ButtonAction *okAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_OK", nil)
buttonAction: ^(UIAlertAction* action){}];
[buttonsAction addObject: okAction];
[VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"DISK_FULL", nil) [VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"DISK_FULL", nil)
errorMessage:[NSString stringWithFormat: errorMessage:[NSString stringWithFormat:
NSLocalizedString(@"DISK_FULL_FORMAT", nil), NSLocalizedString(@"DISK_FULL_FORMAT", nil),
filename, filename,
[[UIDevice currentDevice] model]] [[UIDevice currentDevice] model]]
viewController:[UIApplication sharedApplication].keyWindow.rootViewController viewController:[UIApplication sharedApplication].keyWindow.rootViewController
buttonsAction:buttonsAction]; buttonsAction:@[[[VLCAlertButton alloc] initWithTitle: NSLocalizedString(@"BUTTON_OK", nil)
action: ^(UIAlertAction* action){}]]];
#else #else
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"DISK_FULL", nil) UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"DISK_FULL", nil)
message:[NSString stringWithFormat: message:[NSString stringWithFormat:
......
...@@ -112,14 +112,11 @@ ...@@ -112,14 +112,11 @@
_expectedDownloadSize = [response expectedContentLength]; _expectedDownloadSize = [response expectedContentLength];
APLog(@"expected download size: %lli", _expectedDownloadSize); APLog(@"expected download size: %lli", _expectedDownloadSize);
if (_expectedDownloadSize > [[UIDevice currentDevice] VLCFreeDiskSpace].longLongValue) { //handle too big a download if (_expectedDownloadSize > [[UIDevice currentDevice] VLCFreeDiskSpace].longLongValue) { //handle too big a download
NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init];
ButtonAction *okAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_OK", nil)
buttonAction: ^(UIAlertAction* action){}];
[buttonsAction addObject: okAction];
[VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"DISK_FULL", nil) [VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"DISK_FULL", nil)
errorMessage:[NSString stringWithFormat:NSLocalizedString(@"DISK_FULL_FORMAT", nil), _fileName, [[UIDevice currentDevice] model]] errorMessage:[NSString stringWithFormat:NSLocalizedString(@"DISK_FULL_FORMAT", nil), _fileName, [[UIDevice currentDevice] model]]
viewController:self.delegate viewController:self.delegate
buttonsAction:buttonsAction]; buttonsAction:@[[[VLCAlertButton alloc] initWithTitle: NSLocalizedString(@"BUTTON_OK", nil)
action: ^(UIAlertAction* action){}]]];
[_sessionTask cancel]; [_sessionTask cancel];
[self _downloadEnded]; [self _downloadEnded];
return; return;
......
...@@ -198,29 +198,27 @@ ...@@ -198,29 +198,27 @@
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 */
NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init]; NSArray<VLCAlertButton *> *buttonsAction = @[[[VLCAlertButton alloc] initWithTitle: NSLocalizedString(@"BUTTON_CANCEL", nil)
ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_CANCEL", nil) action: ^(UIAlertAction* action){
buttonAction: ^(UIAlertAction* action){}]; _selectedFile = nil;
ButtonAction *downloadAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_DOWNLOAD", nil) }],
buttonAction: ^(UIAlertAction* action){ [[VLCAlertButton alloc] initWithTitle: NSLocalizedString(@"BUTTON_DOWNLOAD", nil)
action: ^(UIAlertAction* action){
[_oneDriveController downloadObject:_selectedFile]; [_oneDriveController downloadObject:_selectedFile];
_selectedFile = nil; _selectedFile = nil;
}]; }]];
[buttonsAction addObject: cancelAction];
[buttonsAction addObject: downloadAction];
[VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"DROPBOX_DOWNLOAD", nil) [VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"DROPBOX_DOWNLOAD", nil)
errorMessage:[NSString stringWithFormat:NSLocalizedString(@"DROPBOX_DL_LONG", nil), _selectedFile.name, [[UIDevice currentDevice] model]] errorMessage:[NSString stringWithFormat:NSLocalizedString(@"DROPBOX_DL_LONG", nil), _selectedFile.name, [[UIDevice currentDevice] model]]
viewController:self viewController:self
buttonsAction:buttonsAction]; buttonsAction:buttonsAction];
} else { } else {
NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init];
ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_OK", nil)
buttonAction: ^(UIAlertAction* action){}];
[buttonsAction addObject: cancelAction];
[VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"DISK_FULL", nil) [VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"DISK_FULL", nil)
errorMessage:[NSString stringWithFormat:NSLocalizedString(@"DISK_FULL_FORMAT", nil), _selectedFile.name, [[UIDevice currentDevice] model]] errorMessage:[NSString stringWithFormat:NSLocalizedString(@"DISK_FULL_FORMAT", nil), _selectedFile.name, [[UIDevice currentDevice] model]]
viewController:self viewController:self
buttonsAction:buttonsAction]; buttonsAction:@[[[VLCAlertButton alloc] initWithTitle: NSLocalizedString(@"BUTTON_OK", nil)
action: ^(UIAlertAction* action){
_selectedFile = nil;
}]]];
} }
} }
#endif #endif
......
...@@ -85,14 +85,11 @@ ...@@ -85,14 +85,11 @@
} else if (count == 1) { } else if (count == 1) {
[self presentDocumentInteractionControllerWithFileURL:[_fileURLs firstObject]]; [self presentDocumentInteractionControllerWithFileURL:[_fileURLs firstObject]];
} else { } else {
NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init];
ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_OK", nil)
buttonAction: ^(UIAlertAction* action){}];
[buttonsAction addObject: cancelAction];
[VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"SHARING_ERROR_NO_FILES", nil) [VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"SHARING_ERROR_NO_FILES", nil)
errorMessage:nil errorMessage:nil
viewController:self.activityViewController viewController:self.activityViewController
buttonsAction:buttonsAction]; buttonsAction:@[[[VLCAlertButton alloc] initWithTitle: NSLocalizedString(@"BUTTON_OK", nil)
action: ^(UIAlertAction* action){}]]];
[self activityDidFinish:NO]; [self activityDidFinish:NO];
} }
} }
...@@ -129,15 +126,12 @@ ...@@ -129,15 +126,12 @@
controllerWasPresentedSuccessfully = [self->_documentInteractionController presentOpenInMenuFromBarButtonItem:self.presentingBarButtonItem animated:YES]; controllerWasPresentedSuccessfully = [self->_documentInteractionController presentOpenInMenuFromBarButtonItem:self.presentingBarButtonItem animated:YES];
if (!controllerWasPresentedSuccessfully) { if (!controllerWasPresentedSuccessfully) {
NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init];
ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_OK", nil)
buttonAction: ^(UIAlertAction* action){}];
[buttonsAction addObject: cancelAction];
[VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"SHARING_ERROR_NO_APPLICATIONS", nil) [VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"SHARING_ERROR_NO_APPLICATIONS", nil)
errorMessage:nil errorMessage:nil
viewController:self.activityViewController viewController:self.activityViewController
buttonsAction:buttonsAction]; buttonsAction:@[[[VLCAlertButton alloc] initWithTitle: NSLocalizedString(@"BUTTON_OK", nil)
action: ^(UIAlertAction* action){}]
]];
[self activityDidFinish:NO]; [self activityDidFinish:NO];
} }
}; };
......
...@@ -203,14 +203,11 @@ ...@@ -203,14 +203,11 @@
- (IBAction)openButtonAction:(id)sender - (IBAction)openButtonAction:(id)sender
{ {
if ([self.urlField.text length] <= 0 || [NSURL URLWithString:self.urlField.text] == nil) { if ([self.urlField.text length] <= 0 || [NSURL URLWithString:self.urlField.text] == nil) {
NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init];
ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_OK", nil)
buttonAction: ^(UIAlertAction* action){}];
[buttonsAction addObject: cancelAction];
[VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"URL_NOT_SUPPORTED", nil) [VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"URL_NOT_SUPPORTED", nil)
errorMessage: NSLocalizedString(@"PROTOCOL_NOT_SELECTED", nil) errorMessage: NSLocalizedString(@"PROTOCOL_NOT_SELECTED", nil)
viewController:self viewController:self
buttonsAction:buttonsAction]; buttonsAction:@[[[VLCAlertButton alloc] initWithTitle: NSLocalizedString(@"BUTTON_OK", nil)
action: ^(UIAlertAction* action){}]]];
return; return;
} }
if (!self.privateToggleSwitch.on) { if (!self.privateToggleSwitch.on) {
...@@ -424,10 +421,11 @@ forRowAtIndexPath:(NSIndexPath *)indexPath ...@@ -424,10 +421,11 @@ forRowAtIndexPath:(NSIndexPath *)indexPath
} }
[receivedSub writeToFile:fileSubtitlePath atomically:YES]; [receivedSub writeToFile:fileSubtitlePath atomically:YES];
} else { } else {
NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init]; [VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"DISK_FULL", nil)
ButtonAction *okAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_OK", nil) buttonAction: ^(UIAlertAction* action){}]; errorMessage: [NSString stringWithFormat:NSLocalizedString(@"DISK_FULL_FORMAT", nil), fileName, [[UIDevice currentDevice] model]]
[buttonsAction addObject: okAction]; viewController:self
[VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"DISK_FULL", nil) errorMessage: [NSString stringWithFormat:NSLocalizedString(@"DISK_FULL_FORMAT", nil), fileName, [[UIDevice currentDevice] model]] viewController:self buttonsAction:buttonsAction]; buttonsAction:@[[[VLCAlertButton alloc] initWithTitle: NSLocalizedString(@"BUTTON_OK", nil)
action: ^(UIAlertAction* action){}]]];
} }
return fileSubtitlePath; return fileSubtitlePath;
......
...@@ -1173,18 +1173,16 @@ typedef NS_ENUM(NSUInteger, VLCAspectRatio) { ...@@ -1173,18 +1173,16 @@ typedef NS_ENUM(NSUInteger, VLCAspectRatio) {
if (continuePlayback == 1) { if (continuePlayback == 1) {
[self setPlaybackPosition:lastPosition]; [self setPlaybackPosition:lastPosition];
} else if (continuePlayback == 0) { } else if (continuePlayback == 0) {
NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init]; NSArray<VLCAlertButton *> *buttonsAction = @[[[VLCAlertButton alloc] initWithTitle: NSLocalizedString(@"BUTTON_CANCEL", nil)
ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_CANCEL", nil) action: ^(UIAlertAction* action){}],
buttonAction: ^(UIAlertAction* action){}]; [[VLCAlertButton alloc] initWithTitle: NSLocalizedString(@"BUTTON_CONTINUE", nil)
ButtonAction *continueAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_CONTINUE", nil) action: ^(UIAlertAction* action){
buttonAction: ^(UIAlertAction* action){
[self setPlaybackPosition:lastPosition]; [self setPlaybackPosition:lastPosition];
}]; }]
[buttonsAction addObject: cancelAction]; ];
[buttonsAction addObject: continueAction];
[VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"CONTINUE_PLAYBACK", nil) [VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"CONTINUE_PLAYBACK", nil)
errorMessage:[NSString stringWithFormat:NSLocalizedString(@"CONTINUE_PLAYBACK_LONG", nil), item.title] errorMessage:[NSString stringWithFormat:NSLocalizedString(@"CONTINUE_PLAYBACK_LONG", nil), item.title]
viewController:self viewController:self.delegate
buttonsAction:buttonsAction]; buttonsAction:buttonsAction];
} }
} }
......
...@@ -188,10 +188,6 @@ static NSString *const VLCPlayerDisplayControllerDisplayModeKey = @"VLCPlayerDis ...@@ -188,10 +188,6 @@ static NSString *const VLCPlayerDisplayControllerDisplayModeKey = @"VLCPlayerDis
{ {
NSString *failedString = NSLocalizedString(@"PLAYBACK_FAILED", nil); NSString *failedString = NSLocalizedString(@"PLAYBACK_FAILED", nil);
#if TARGET_OS_IOS #if TARGET_OS_IOS
NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init];
ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: NSLocalizedString(@"BUTTON_OK", nil)
buttonAction: ^(UIAlertAction* action){}];
[buttonsAction addObject: cancelAction];
switch (self.displayMode) { switch (self.displayMode) {
case VLCPlayerDisplayControllerDisplayModeFullscreen: case VLCPlayerDisplayControllerDisplayModeFullscreen: