Commit 664d8f76 authored by Carola Nitz's avatar Carola Nitz

VLCOpenNetworkStreamViewController: add check if self.urlField.text can be converted to a url

if not we show the user an alert that the url is not supported
parent ddfd714f
......@@ -322,6 +322,8 @@
"BONJOUR_FILE_SERVERS" = "BONJOUR File Server";
"DSM_WORKGROUP" = "Workgroup";
"URL_NOT_SUPPORTED" = "The URL can't be opened";
// Insert %@ where play-pause-glyph should be placed
"DELETE_ITEM_HINT" = "Press %@ to Delete"; /* Insert %@ where play-pause-glyph should be placed */
......
......@@ -178,22 +178,33 @@
- (IBAction)openButtonAction:(id)sender
{
if ([self.urlField.text length] > 0) {
if (!self.privateToggleSwitch.on) {
NSString *urlString = self.urlField.text;
if ([_recentURLs indexOfObject:urlString] != NSNotFound)
[_recentURLs removeObject:urlString];
if (_recentURLs.count >= 100)
[_recentURLs removeLastObject];
[_recentURLs addObject:urlString];
[[NSUbiquitousKeyValueStore defaultStore] setArray:_recentURLs forKey:kVLCRecentURLs];
[self.historyTableView reloadData];
}
[self.urlField resignFirstResponder];
[self _openURLStringAndDismiss:self.urlField.text];
if ([self.urlField.text length] <= 0 || [NSURL URLWithString:self.urlField.text] == nil) {
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"URL_NOT_SUPPORTED", nil)
message:nil
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"BUTTON_OK", nil)
style:UIAlertActionStyleCancel
handler:nil];
[alertController addAction:okAction];
[self presentViewController:alertController animated:YES completion:nil];
return;
}
if (!self.privateToggleSwitch.on) {
NSString *urlString = self.urlField.text;
if ([_recentURLs indexOfObject:urlString] != NSNotFound)
[_recentURLs removeObject:urlString];
if (_recentURLs.count >= 100)
[_recentURLs removeLastObject];
[_recentURLs addObject:urlString];
[[NSUbiquitousKeyValueStore defaultStore] setArray:_recentURLs forKey:kVLCRecentURLs];
[self.historyTableView reloadData];
}
[self.urlField resignFirstResponder];
[self _openURLStringAndDismiss:self.urlField.text];
}
- (void)renameStreamFromCell:(UITableViewCell *)cell {
......
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