From 55b4389716ec4ae9090b526d9f1607ea701ce7c1 Mon Sep 17 00:00:00 2001 From: Kirill Zhdanovich Date: Tue, 26 Mar 2013 11:43:28 +0300 Subject: [PATCH] Search Screen. Check if location is valid in "near me" screen, if not tell about it to user. Search Screen. Check if location is valid in "near me" screen, if not tell about it to user. --- iphone/Maps/Classes/SearchVC.mm | 16 +++++++++++----- iphone/Maps/Platform/LocationManager.h | 2 ++ iphone/Maps/Platform/LocationManager.mm | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/iphone/Maps/Classes/SearchVC.mm b/iphone/Maps/Classes/SearchVC.mm index 8523c30527..35b43aaed1 100644 --- a/iphone/Maps/Classes/SearchVC.mm +++ b/iphone/Maps/Classes/SearchVC.mm @@ -363,7 +363,7 @@ static void OnSearchResultCallback(search::Results const & res) static NSString *CellIdentifier = @"categoryCell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; - if (cell == nil) + if (!cell) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } @@ -377,12 +377,18 @@ static void OnSearchResultCallback(search::Results const & res) if ([m_searchBar.text length] != 0 && ![[_searchResults objectAtIndex:scopeSection] getCount] && numberOfRowsInEmptySearch) { UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"NoResultsCell"]; - if (cell == nil) + if (!cell) { - cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"NoResultsCell"] autorelease]; - [cell setSelectionStyle:UITableViewCellSelectionStyleNone]; - cell.textLabel.text = NSLocalizedString(@"no_search_results_found", nil); + cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"NoResultsCell"] autorelease]; + cell.selectionStyle = UITableViewCellSelectionStyleNone; } + cell.textLabel.text = NSLocalizedString(@"no_search_results_found", nil); + + // check if we have no position in "near me" screen + if (![m_locationManager lastLocationIsValid] && scopeSection == 0) + cell.detailTextLabel.text = NSLocalizedString(@"unknown_current_position", nil); + else + cell.detailTextLabel.text = @""; return cell; } diff --git a/iphone/Maps/Platform/LocationManager.h b/iphone/Maps/Platform/LocationManager.h index fc8494e067..d761ecc7be 100644 --- a/iphone/Maps/Platform/LocationManager.h +++ b/iphone/Maps/Platform/LocationManager.h @@ -35,4 +35,6 @@ - (bool)getNorthRad:(double &)rad; + (NSString *)formatDistance:(double)meters; + +- (bool)lastLocationIsValid; @end diff --git a/iphone/Maps/Platform/LocationManager.mm b/iphone/Maps/Platform/LocationManager.mm index ab91f21803..46ad3388b2 100644 --- a/iphone/Maps/Platform/LocationManager.mm +++ b/iphone/Maps/Platform/LocationManager.mm @@ -245,7 +245,7 @@ return [NSString stringWithUTF8String:s.c_str()]; } --(bool)lastLocationIsValid +- (bool)lastLocationIsValid { return (([self lastLocation] != nil) && ([m_lastLocationTime timeIntervalSinceNow] > -300.0)); }