Commit 7ded3c60 authored by Carola Nitz's avatar Carola Nitz

VLCAlertViewController: added a convenience method to omit the buttonsAction

parent 28c8bb0b
......@@ -174,8 +174,7 @@
if (![self.savedLoginsDataSource saveLogin:login error:&error]) {
[VLCAlertViewController alertViewManagerWithTitle:error.localizedDescription
errorMessage:error.localizedFailureReason
viewController:self
buttonsAction:nil];
viewController:self];
}
[self.tableView deselectRowAtIndexPath:self.tableView.indexPathForSelectedRow animated:YES];
......@@ -199,8 +198,7 @@
if (self.protocolDataSource.protocol == VLCServerProtocolUndefined) {
[VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"PROTOCOL_NOT_SELECTED", nil)
errorMessage:NSLocalizedString(@"PROTOCOL_NOT_SELECTED", nil)
viewController:self
buttonsAction:nil];
viewController:self];
[self.tableView deselectRowAtIndexPath:self.tableView.indexPathForSelectedRow animated:YES];
return NO;
}
......
......@@ -272,8 +272,7 @@
{
[VLCAlertViewController alertViewManagerWithTitle:title
errorMessage:message
viewController:[UIApplication sharedApplication].keyWindow.rootViewController
buttonsAction:nil];
viewController:[UIApplication sharedApplication].keyWindow.rootViewController];
}
- (void)calculateRemainingTime:(CGFloat)receivedDataSize expectedDownloadSize:(CGFloat)expectedDownloadSize
......
......@@ -248,8 +248,7 @@
} else {
[VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"DISK_FULL", nil)
errorMessage:[NSString stringWithFormat:NSLocalizedString(@"DISK_FULL_FORMAT", nil), _selectedFile.name, [[UIDevice currentDevice] model]]
viewController:self
buttonsAction:nil];
viewController:self];
}
}
......
......@@ -141,15 +141,13 @@ typedef NS_ENUM(NSUInteger, VLCDownloadScheme) {
if (![URLtoSave.lastPathComponent isSupportedFormat] && ![URLtoSave.lastPathComponent.pathExtension isEqualToString:@""]) {
[VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"FILE_NOT_SUPPORTED", nil)
errorMessage:[NSString stringWithFormat:NSLocalizedString(@"FILE_NOT_SUPPORTED_LONG", nil), URLtoSave.lastPathComponent]
viewController:self
buttonsAction:nil];
viewController:self];
return;
}
if (![URLtoSave.scheme isEqualToString:@"http"] & ![URLtoSave.scheme isEqualToString:@"https"] && ![URLtoSave.scheme isEqualToString:@"ftp"]) {
[VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"SCHEME_NOT_SUPPORTED", nil)
errorMessage:[NSString stringWithFormat:NSLocalizedString(@"SCHEME_NOT_SUPPORTED_LONG", nil), URLtoSave.scheme]
viewController:self
buttonsAction:nil];
viewController:self];
return;
}
......@@ -315,8 +313,7 @@ typedef NS_ENUM(NSUInteger, VLCDownloadScheme) {
{
[VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"SCHEME_NOT_SUPPORTED", nil)
errorMessage:description
viewController:self
buttonsAction:nil];
viewController:self];
}
- (void)progressUpdatedTo:(CGFloat)percentage receivedDataSize:(CGFloat)receivedDataSize expectedDownloadSize:(CGFloat)expectedDownloadSize
......@@ -391,8 +388,7 @@ typedef NS_ENUM(NSUInteger, VLCDownloadScheme) {
[self downloadEnded];
[VLCAlertViewController alertViewManagerWithTitle:[NSString stringWithFormat:NSLocalizedString(@"ERROR_NUMBER", nil), request.error.errorCode]
errorMessage:request.error.message
viewController:self
buttonsAction:nil];
viewController:self];
}
#pragma mark - table view data source
......
......@@ -328,8 +328,7 @@
#if TARGET_OS_IOS
[VLCAlertViewController alertViewManagerWithTitle:[NSString stringWithFormat:NSLocalizedString(@"ERROR_NUMBER", nil), error.code]
errorMessage:error.localizedDescription
viewController:[UIApplication sharedApplication].keyWindow.rootViewController
buttonsAction:nil];
viewController:[UIApplication sharedApplication].keyWindow.rootViewController];
#else
UIAlertController *alert = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:NSLocalizedString(@"ERROR_NUMBER", nil), error.code]
message:error.localizedDescription
......
......@@ -187,8 +187,7 @@
} else {
[VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"DISK_FULL", nil)
errorMessage:[NSString stringWithFormat:NSLocalizedString(@"DISK_FULL_FORMAT", nil), _selectedFile.name, [[UIDevice currentDevice] model]]
viewController:self
buttonsAction:nil];
viewController:self];
}
}
......
......@@ -131,8 +131,7 @@
{
[VLCAlertViewController alertViewManagerWithTitle:title
errorMessage:message
viewController:[UIApplication sharedApplication].keyWindow.rootViewController
buttonsAction:nil];
viewController:[UIApplication sharedApplication].keyWindow.rootViewController];
}
#pragma mark - file management
......
......@@ -145,8 +145,7 @@
} else {
[VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"DISK_FULL", nil)
errorMessage:[NSString stringWithFormat:NSLocalizedString(@"DISK_FULL_FORMAT", nil), _selectedFile.name, [[UIDevice currentDevice] model]]
viewController:self
buttonsAction:nil];
viewController:self];
}
}
#pragma mark - login dialog
......
......@@ -728,8 +728,7 @@
NSLocalizedString(@"DISK_FULL_FORMAT", nil),
filename,
[[UIDevice currentDevice] model]]
viewController:[UIApplication sharedApplication].keyWindow.rootViewController
buttonsAction:nil];
viewController:[UIApplication sharedApplication].keyWindow.rootViewController];
#else
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"DISK_FULL", nil)
message:[NSString stringWithFormat:
......
......@@ -114,8 +114,7 @@
if (_expectedDownloadSize > [[UIDevice currentDevice] VLCFreeDiskSpace].longLongValue) { //handle too big a download
[VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"DISK_FULL", nil)
errorMessage:[NSString stringWithFormat:NSLocalizedString(@"DISK_FULL_FORMAT", nil), _fileName, [[UIDevice currentDevice] model]]
viewController:self.delegate
buttonsAction:nil];
viewController:self.delegate];
[_sessionTask cancel];
[self _downloadEnded];
return;
......
......@@ -87,8 +87,7 @@
} else {
[VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"SHARING_ERROR_NO_FILES", nil)
errorMessage:nil
viewController:self.activityViewController
buttonsAction:nil];
viewController:self.activityViewController];
[self activityDidFinish:NO];
}
}
......@@ -127,8 +126,7 @@
if (!controllerWasPresentedSuccessfully) {
[VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"SHARING_ERROR_NO_APPLICATIONS", nil)
errorMessage:nil
viewController:self.activityViewController
buttonsAction:nil];
viewController:self.activityViewController];
[self activityDidFinish:NO];
}
};
......
......@@ -205,8 +205,7 @@
if ([self.urlField.text length] <= 0 || [NSURL URLWithString:self.urlField.text] == nil) {
[VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"URL_NOT_SUPPORTED", nil)
errorMessage:NSLocalizedString(@"PROTOCOL_NOT_SELECTED", nil)
viewController:self
buttonsAction:nil];
viewController:self];
return;
}
if (!self.privateToggleSwitch.on) {
......@@ -422,8 +421,7 @@ forRowAtIndexPath:(NSIndexPath *)indexPath
} else {
[VLCAlertViewController alertViewManagerWithTitle:NSLocalizedString(@"DISK_FULL", nil)
errorMessage:[NSString stringWithFormat:NSLocalizedString(@"DISK_FULL_FORMAT", nil), fileName, [[UIDevice currentDevice] model]]
viewController:self
buttonsAction:nil];
viewController:self];
}
return fileSubtitlePath;
......
......@@ -198,8 +198,7 @@ static NSString *const VLCPlayerDisplayControllerDisplayModeKey = @"VLCPlayerDis
default:
[VLCAlertViewController alertViewManagerWithTitle:failedString
errorMessage:nil
viewController:self
buttonsAction:nil];
viewController:self];
break;
}
#else
......
......@@ -25,8 +25,11 @@ typealias AlertAction = (UIAlertAction) -> Void
@objcMembers class VLCAlertViewController: UIAlertController {
class func alertViewManager(title: String, errorMessage: String? = nil, viewController: UIViewController,
buttonsAction: [VLCAlertButton]?) {
class func alertViewManager(title: String, errorMessage: String? = nil, viewController: UIViewController) {
VLCAlertViewController.alertViewManager(title: title, errorMessage: errorMessage, viewController: viewController, buttonsAction: nil)
}
class func alertViewManager(title: String, errorMessage: String? = nil, viewController: UIViewController, buttonsAction: [VLCAlertButton]?) {
let alert = UIAlertController(title: title, message: errorMessage, preferredStyle: .alert)
if let buttonsAction = buttonsAction {
for buttonAction in buttonsAction {
......@@ -41,10 +44,11 @@ typealias AlertAction = (UIAlertAction) -> Void
viewController.present(alert, animated: true, completion: nil)
}
class func alertManagerWithTextField(title: String, errorMessage: String? = nil, viewController: UIViewController,
buttonsAction: [VLCAlertButton],
textFieldText: String? = nil,
textFieldPlaceholder: String? = nil) {
class func alertManagerWithTextField(title: String, errorMessage: String? = nil,
viewController: UIViewController,
buttonsAction: [VLCAlertButton],
textFieldText: String? = nil,
textFieldPlaceholder: String? = nil) {
let alert = UIAlertController(title: title, message: errorMessage, preferredStyle: .alert)
alert.addTextField(configurationHandler: { textField in
textField.placeholder = textFieldPlaceholder
......
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