Commit 265466c5 authored by Felix Paul Kühne's avatar Felix Paul Kühne

iOS Dialog Provider: runtime fixes and added base l10n

parent 749fb1c5
...@@ -111,7 +111,6 @@ struct intf_sys_t ...@@ -111,7 +111,6 @@ struct intf_sys_t
*****************************************************************************/ *****************************************************************************/
vlc_module_begin() vlc_module_begin()
/* Minimal interface. see intf.m */
set_shortname("iOS Dialogs") set_shortname("iOS Dialogs")
add_shortcut("ios_dialog_provider", "miosx") add_shortcut("ios_dialog_provider", "miosx")
set_description("iOS Dialog Provider") set_description("iOS Dialog Provider")
...@@ -321,22 +320,20 @@ bool checkProgressPanel (void *priv) ...@@ -321,22 +320,20 @@ bool checkProgressPanel (void *priv)
message:dialog[@"message"] message:dialog[@"message"]
preferredStyle:UIAlertControllerStyleAlert]; preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *action = [UIAlertAction actionWithTitle:@"OK" UIAlertAction *action = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil)
style:UIAlertActionStyleDestructive style:UIAlertActionStyleDestructive
handler:^(UIAlertAction * _Nonnull action) { handler:^(UIAlertAction * _Nonnull action) {
[action release];
[alertController release];
[dialog release]; [dialog release];
}]; }];
[alertController addAction:action]; [alertController addAction:action];
[alertController setPreferredAction:action]; [alertController setPreferredAction:action];
[[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:alertController animated:YES completion:nil]; [[[[UIApplication sharedApplication].delegate.window rootViewController] presentedViewController] presentViewController:alertController animated:YES completion:nil];
#else #else
VLCBlockingAlertView *alert = [[VLCBlockingAlertView alloc] initWithTitle:dialog[@"title"] VLCBlockingAlertView *alert = [[VLCBlockingAlertView alloc] initWithTitle:dialog[@"title"]
message:dialog[@"message"] message:dialog[@"message"]
delegate:nil delegate:nil
cancelButtonTitle:@"OK" cancelButtonTitle:NSLocalizedString(@"OK", nil)
otherButtonTitles:nil]; otherButtonTitles:nil];
alert.completion = ^(BOOL cancelled, NSInteger buttonIndex) { alert.completion = ^(BOOL cancelled, NSInteger buttonIndex) {
[alert release]; [alert release];
...@@ -355,22 +352,20 @@ bool checkProgressPanel (void *priv) ...@@ -355,22 +352,20 @@ bool checkProgressPanel (void *priv)
message:dialog[@"message"] message:dialog[@"message"]
preferredStyle:UIAlertControllerStyleAlert]; preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *action = [UIAlertAction actionWithTitle:@"OK" UIAlertAction *action = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil)
style:UIAlertActionStyleDestructive style:UIAlertActionStyleDestructive
handler:^(UIAlertAction * _Nonnull action) { handler:^(UIAlertAction * _Nonnull action) {
[action release];
[alertController release];
[dialog release]; [dialog release];
}]; }];
[alertController addAction:action]; [alertController addAction:action];
[alertController setPreferredAction:action]; [alertController setPreferredAction:action];
[[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:alertController animated:YES completion:nil]; [[[[UIApplication sharedApplication].delegate.window rootViewController] presentedViewController] presentViewController:alertController animated:YES completion:nil];
#else #else
VLCBlockingAlertView *alert = [[VLCBlockingAlertView alloc] initWithTitle:dialog[@"title"] VLCBlockingAlertView *alert = [[VLCBlockingAlertView alloc] initWithTitle:dialog[@"title"]
message:dialog[@"message"] message:dialog[@"message"]
delegate:nil delegate:nil
cancelButtonTitle:@"OK" cancelButtonTitle:NSLocalizedString(@"OK", nil)
otherButtonTitles:nil]; otherButtonTitles:nil];
alert.completion = ^(BOOL cancelled, NSInteger buttonIndex) { alert.completion = ^(BOOL cancelled, NSInteger buttonIndex) {
[alert release]; [alert release];
...@@ -384,27 +379,22 @@ bool checkProgressPanel (void *priv) ...@@ -384,27 +379,22 @@ bool checkProgressPanel (void *priv)
{ {
#if TARGET_OS_TV #if TARGET_OS_TV
__block int ret = 0; __block int ret = 0;
__block UIAlertController *alertController;
__block UIAlertAction *yesAction;
__block UIAlertAction *noAction;
__block UIAlertAction *cancelAction;
dispatch_semaphore_t sema = dispatch_semaphore_create(0); dispatch_semaphore_t sema = dispatch_semaphore_create(0);
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
alertController = [UIAlertController alertControllerWithTitle:dialog[@"title"] UIAlertController *alertController = [UIAlertController alertControllerWithTitle:dialog[@"title"]
message:dialog[@"message"] message:dialog[@"message"]
preferredStyle:UIAlertControllerStyleAlert]; preferredStyle:UIAlertControllerStyleAlert];
cancelAction = [UIAlertAction actionWithTitle:dialog[@"cancel"] [alertController addAction:[UIAlertAction actionWithTitle:dialog[@"cancel"]
style:UIAlertActionStyleDestructive style:UIAlertActionStyleDestructive
handler:^(UIAlertAction * _Nonnull action) { handler:^(UIAlertAction * _Nonnull action) {
ret = 3; ret = 3;
dispatch_semaphore_signal(sema); dispatch_semaphore_signal(sema);
}]; }]];
[alertController addAction:cancelAction];
yesAction = [UIAlertAction actionWithTitle:dialog[@"yes"] UIAlertAction *yesAction = [UIAlertAction actionWithTitle:dialog[@"yes"]
style:UIAlertActionStyleDestructive style:UIAlertActionStyleDestructive
handler:^(UIAlertAction * _Nonnull action) { handler:^(UIAlertAction * _Nonnull action) {
ret = 0; ret = 0;
...@@ -413,23 +403,18 @@ bool checkProgressPanel (void *priv) ...@@ -413,23 +403,18 @@ bool checkProgressPanel (void *priv)
[alertController addAction:yesAction]; [alertController addAction:yesAction];
[alertController setPreferredAction:yesAction]; [alertController setPreferredAction:yesAction];
noAction = [UIAlertAction actionWithTitle:dialog[@"yes"] [alertController addAction:[UIAlertAction actionWithTitle:dialog[@"yes"]
style:UIAlertActionStyleDestructive style:UIAlertActionStyleDestructive
handler:^(UIAlertAction * _Nonnull action) { handler:^(UIAlertAction * _Nonnull action) {
ret = 1; ret = 1;
dispatch_semaphore_signal(sema); dispatch_semaphore_signal(sema);
}]; }]];
[alertController addAction:noAction];
[[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:alertController animated:YES completion:nil]; [[[[UIApplication sharedApplication].delegate.window rootViewController] presentedViewController] presentViewController:alertController animated:YES completion:nil];
}); });
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER); dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
[cancelAction release];
[yesAction release];
[noAction release];
[alertController release];
[dialog release]; [dialog release];
return @(ret); return @(ret);
...@@ -468,11 +453,10 @@ bool checkProgressPanel (void *priv) ...@@ -468,11 +453,10 @@ bool checkProgressPanel (void *priv)
{ {
#if TARGET_OS_TV #if TARGET_OS_TV
dispatch_semaphore_t sema = dispatch_semaphore_create(0); dispatch_semaphore_t sema = dispatch_semaphore_create(0);
__block UIAlertController *alertController; __block NSMutableDictionary *dict = [NSMutableDictionary dictionary];
__block NSDictionary *dict;
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
alertController = [UIAlertController alertControllerWithTitle:dialog[@"title"] UIAlertController *alertController = [UIAlertController alertControllerWithTitle:dialog[@"title"]
message:dialog[@"message"] message:dialog[@"message"]
preferredStyle:UIAlertControllerStyleAlert]; preferredStyle:UIAlertControllerStyleAlert];
...@@ -480,37 +464,36 @@ bool checkProgressPanel (void *priv) ...@@ -480,37 +464,36 @@ bool checkProgressPanel (void *priv)
__block UITextField *passwordField = nil; __block UITextField *passwordField = nil;
[alertController addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) { [alertController addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
usernameField = textField; usernameField = textField;
textField.placeholder = NSLocalizedString(@"User", nil);
}]; }];
[alertController addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) { [alertController addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
textField.secureTextEntry = YES; textField.secureTextEntry = YES;
textField.placeholder = NSLocalizedString(@"Password", nil);
passwordField = textField; passwordField = textField;
}]; }];
[alertController addAction:[[UIAlertAction actionWithTitle:@"Login"
[alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Login", nil)
style:UIAlertActionStyleDefault style:UIAlertActionStyleDefault
handler:^(UIAlertAction * _Nonnull action) { handler:^(UIAlertAction * _Nonnull action) {
NSString *user = usernameField.text; NSString *user = usernameField.text;
NSString *pass = passwordField.text; NSString *pass = passwordField.text;
dict = [[NSDictionary dictionaryWithObjectsAndKeys: [dict setObject:user ? user : @"" forKey:@"username"];
user ? user : @"", @"username", [dict setObject:pass ? pass : @"" forKey:@"password"];
pass ? pass : @"", @"password",
nil] retain];
dispatch_semaphore_signal(sema); dispatch_semaphore_signal(sema);
}] autorelease]]; }]];
[alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil)
[alertController addAction:[[UIAlertAction actionWithTitle:@"Cancel"
style:UIAlertActionStyleCancel style:UIAlertActionStyleCancel
handler:^(UIAlertAction * _Nonnull action) { handler:^(UIAlertAction * _Nonnull action) {
dispatch_semaphore_signal(sema); dispatch_semaphore_signal(sema);
}] autorelease]]; }]];
[[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:alertController animated:YES completion:nil]; [[[[UIApplication sharedApplication].delegate.window rootViewController] presentedViewController] presentViewController:alertController animated:YES completion:nil];
}); });
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER); dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
[alertController release];
[dialog release]; [dialog release];
return dict; return [dict copy];
#else #else
__block NSDictionary *dict; __block NSDictionary *dict;
__block VLCBlockingAlertView *alert; __block VLCBlockingAlertView *alert;
...@@ -521,8 +504,8 @@ bool checkProgressPanel (void *priv) ...@@ -521,8 +504,8 @@ bool checkProgressPanel (void *priv)
alert = [[VLCBlockingAlertView alloc] initWithTitle:dialog[@"title"] alert = [[VLCBlockingAlertView alloc] initWithTitle:dialog[@"title"]
message:dialog[@"message"] message:dialog[@"message"]
delegate:nil delegate:nil
cancelButtonTitle:@"Cancel" cancelButtonTitle:NSLocalizedString(@"Cancel", nil)
otherButtonTitles:@"Login", nil]; otherButtonTitles:NSLocalizedString(@"Login", nil), nil];
alert.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput; alert.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput;
alert.completion = ^(BOOL cancelled, NSInteger buttonIndex) { alert.completion = ^(BOOL cancelled, NSInteger buttonIndex) {
if (!cancelled) { if (!cancelled) {
......
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