[iOS][api] open app if parameter was set on balloon click

This commit is contained in:
Kirill Zhdanovich 2013-08-16 22:05:34 +03:00 committed by Alex Zolotarev
parent 4d29fac905
commit 8c48de5ae2
2 changed files with 9 additions and 21 deletions

View file

@ -6,6 +6,7 @@
#import "PlacePageVC.h"
#import "GetActiveConnectionType.h"
#import "PlacePreviewViewController.h"
#import "MWMApi.h"
#import "../Settings/SettingsManager.h"
@ -739,6 +740,11 @@ NSInteger compareAddress(id l, id r, void * context)
-(void)apiBalloonClicked:(url_scheme::ApiPoint const &) apiPoint
{
if (GetFramework().GoBackOnBalloonClick() && [MWMApi canOpenApiUrl:apiPoint])
{
[MWMApi openAppWithPoint:apiPoint];
return;
}
PlacePreviewViewController * apiPreview = [[PlacePreviewViewController alloc] initWithApiPoint:apiPoint];
m_popoverPos = CGPointMake(MercatorBounds::LonToX(apiPoint.m_lon), MercatorBounds::LatToY(apiPoint.m_lat));
[self pushViewController:apiPreview];

View file

@ -16,6 +16,7 @@
#import "CompassView.h"
#import "MapsAppDelegate.h"
#import "MapViewController.h"
#import "MWMApi.h"
#include "../../../search/result.hpp"
#include "../../../platform/platform.hpp"
@ -98,7 +99,7 @@ typedef enum {APIPOINT, POI, MYPOSITION} Type;
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return (m_previewType == APIPOINT && [self canOpenApiUrl]) ? 3 : 2;
return (m_previewType == APIPOINT && [MWMApi canOpenApiUrl:m_apiPoint]) ? 3 : 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
@ -156,16 +157,7 @@ typedef enum {APIPOINT, POI, MYPOSITION} Type;
{
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
if (m_previewType == APIPOINT && indexPath.section == 2)
{
NSString * z = [NSString stringWithUTF8String:m_apiPoint.m_id.c_str()];
NSURL * url = [NSURL URLWithString:z];
if ([[UIApplication sharedApplication] canOpenURL:url])
[[UIApplication sharedApplication] openURL:url];
else
[[UIApplication sharedApplication] openURL:[self getBackUrl]];
[[MapsAppDelegate theApp] showMap];
[[MapsAppDelegate theApp].m_mapViewController clearApiMode];
}
[MWMApi openAppWithPoint:m_apiPoint];
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
@ -271,16 +263,6 @@ typedef enum {APIPOINT, POI, MYPOSITION} Type;
}
}
-(BOOL)canOpenApiUrl
{
NSString * z = [NSString stringWithUTF8String:m_apiPoint.m_id.c_str()];
if ([[UIApplication sharedApplication]canOpenURL:[NSURL URLWithString:z]])
return YES;
if ([[UIApplication sharedApplication]canOpenURL:[self getBackUrl]])
return YES;
return NO;
}
-(NSURL *)getBackUrl
{
string const str = GetFramework().GenerateApiBackUrl(m_apiPoint);