From b89515089fa3e536984d9997d4ad4189e11928ad Mon Sep 17 00:00:00 2001 From: Diego Waxemberg Date: Thu, 8 Jan 2015 19:37:51 -0500 Subject: [PATCH] fixed long clicking host on iPads and made applist appear immediately after the apps are known --- Limelight/UIComputerView.h | 2 +- Limelight/UIComputerView.m | 2 +- .../ViewControllers/MainFrameViewController.m | 20 +++++++++++++------ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Limelight/UIComputerView.h b/Limelight/UIComputerView.h index 54bf95f..dc13f41 100644 --- a/Limelight/UIComputerView.h +++ b/Limelight/UIComputerView.h @@ -12,7 +12,7 @@ @protocol HostCallback - (void) hostClicked:(Host*)host; -- (void) hostLongClicked:(Host*)host; +- (void) hostLongClicked:(Host*)host view:(UIView*)view; - (void) addHostClicked; @end diff --git a/Limelight/UIComputerView.m b/Limelight/UIComputerView.m index 73a0933..72c27fa 100644 --- a/Limelight/UIComputerView.m +++ b/Limelight/UIComputerView.m @@ -134,7 +134,7 @@ static const int LABEL_DY = 20; - (void) hostLongClicked { - [_callback hostLongClicked:_host]; + [_callback hostLongClicked:_host view:self]; } - (void) hostClicked { diff --git a/Limelight/ViewControllers/MainFrameViewController.m b/Limelight/ViewControllers/MainFrameViewController.m index a78e924..11f641f 100644 --- a/Limelight/ViewControllers/MainFrameViewController.m +++ b/Limelight/ViewControllers/MainFrameViewController.m @@ -67,14 +67,15 @@ static StreamConfiguration* streamConfig; - (void)alreadyPaired { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ dispatch_async(dispatch_get_main_queue(), ^{ - [self updateApps]; - NSLog(@"Setting _computerNameButton.title: %@", _selectedHost.name); _computerNameButton.title = _selectedHost.name; }); HttpManager* hMan = [[HttpManager alloc] initWithHost:_selectedHost.address uniqueId:_uniqueId deviceName:deviceName cert:_cert]; NSData* appListResp = [hMan executeRequestSynchronously:[hMan newAppListRequest]]; appList = [HttpManager getAppListFromXML:appListResp]; + dispatch_async(dispatch_get_main_queue(), ^{ + [self updateApps]; + }); [AppManager retrieveAppAssets:appList withManager:hMan andCallback:self]; }); } @@ -117,7 +118,7 @@ static StreamConfiguration* streamConfig; }); } -- (void)hostLongClicked:(Host *)host { +- (void)hostLongClicked:(Host *)host view:(UIView *)view { NSLog(@"Long clicked host: %@", host.name); UIAlertController* longClickAlert = [UIAlertController alertControllerWithTitle:host.name message:@"" preferredStyle:UIAlertControllerStyleActionSheet]; if (host.online) { @@ -145,14 +146,21 @@ static StreamConfiguration* streamConfig; }]]; } [longClickAlert addAction:[UIAlertAction actionWithTitle:@"Remove Host" style:UIAlertActionStyleDestructive handler:^(UIAlertAction* action) { - @synchronized(hostList) { - [hostList removeObject:host]; - } [_discMan removeHostFromDiscovery:host]; DataManager* dataMan = [[DataManager alloc] init]; [dataMan removeHost:host]; + @synchronized(hostList) { + [hostList removeObject:host]; + } + [self updateAllHosts:[hostList allObjects]]; + }]]; [longClickAlert addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]]; + + // these two lines are required for iPad support of UIAlertSheet + longClickAlert.popoverPresentationController.sourceView = view; + + longClickAlert.popoverPresentationController.sourceRect = CGRectMake(view.bounds.size.width / 2.0, view.bounds.size.height / 2.0, 1.0, 1.0); // center of the view [self presentViewController:longClickAlert animated:YES completion:^{ [self updateHosts]; }];