Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArsentiy Milchakov <milcars@mapswithme.com>2018-09-25 11:55:50 +0300
committerAleksey Belousov <beloal@users.noreply.github.com>2018-09-25 11:56:55 +0300
commit86e0c657b930d03a3bc79980ceab8c4bc601be8b (patch)
tree5c2895e25b8117b4ac513b2547bb350a1be2880a
parent3cc4b54ad9ffa17d14dd3a5d0b0e7f11644ca578 (diff)
[strings_types][ios] review fixes
-rw-r--r--iphone/Maps/UI/Editor/MWMObjectsCategorySelectorController.mm16
-rw-r--r--iphone/Maps/UI/Search/TableView/MWMSearchCell.h4
-rw-r--r--iphone/Maps/UI/Search/TableView/MWMSearchCell.mm22
-rw-r--r--iphone/Maps/UI/Search/TableView/MWMSearchCommonCell.h3
-rw-r--r--iphone/Maps/UI/Search/TableView/MWMSearchCommonCell.mm5
-rw-r--r--iphone/Maps/UI/Search/TableView/MWMSearchTableViewController.mm23
-rw-r--r--search/result.cpp4
-rwxr-xr-xtools/python/find_untranslated_strings.py2
8 files changed, 42 insertions, 37 deletions
diff --git a/iphone/Maps/UI/Editor/MWMObjectsCategorySelectorController.mm b/iphone/Maps/UI/Editor/MWMObjectsCategorySelectorController.mm
index c784252fb3..50fd8bb862 100644
--- a/iphone/Maps/UI/Editor/MWMObjectsCategorySelectorController.mm
+++ b/iphone/Maps/UI/Editor/MWMObjectsCategorySelectorController.mm
@@ -26,7 +26,6 @@ NSString * const kToEditorSegue = @"CategorySelectorToEditorSegue";
@property(weak, nonatomic) IBOutlet UITableView * tableView;
@property(weak, nonatomic) IBOutlet UISearchBar * searchBar;
@property(nonatomic) NSString * selectedType;
-@property(nonatomic) NSIndexPath * selectedIndexPath;
@property(nonatomic) BOOL isSearch;
@property(nonatomic) MWMObjectsCategorySelectorDataSource * dataSource;
@@ -49,11 +48,6 @@ NSString * const kToEditorSegue = @"CategorySelectorToEditorSegue";
[self configSearchBar];
[MWMKeyboard addObserver:self];
self.dataSource = [[MWMObjectsCategorySelectorDataSource alloc] init];
- if (self.selectedType)
- {
- self.selectedIndexPath =
- [NSIndexPath indexPathForRow:([self.dataSource getTypeIndex:self.selectedType])inSection:0];
- }
}
- (void)configTable
@@ -87,7 +81,7 @@ NSString * const kToEditorSegue = @"CategorySelectorToEditorSegue";
- (void)onDone
{
- if (!self.selectedIndexPath)
+ if (!self.selectedType)
return;
[self performSegueWithIdentifier:kToEditorSegue sender:nil];
}
@@ -129,10 +123,9 @@ NSString * const kToEditorSegue = @"CategorySelectorToEditorSegue";
- (EditableMapObject)createdObject
{
- auto const & typeName = [self.dataSource getType:self.selectedIndexPath.row].UTF8String;
EditableMapObject emo;
auto & f = GetFramework();
- auto const type = classif().GetTypeByReadableObjectName(typeName);
+ auto const type = classif().GetTypeByReadableObjectName(self.selectedType.UTF8String);
if (!f.CreateMapObject(f.GetViewportCenter(), type, emo))
NSAssert(false, @"This call should never fail, because IsPointCoveredByDownloadedMaps is "
@"always called before!");
@@ -147,7 +140,8 @@ NSString * const kToEditorSegue = @"CategorySelectorToEditorSegue";
auto cell =
[tableView dequeueReusableCellWithCellClass:[UITableViewCell class] indexPath:indexPath];
cell.textLabel.text = [self.dataSource getTranslation:indexPath.row];
- if ([indexPath isEqual:self.selectedIndexPath])
+ auto const type = [self.dataSource getType:indexPath.row];
+ if ([type isEqualToString:self.selectedType])
cell.accessoryType = UITableViewCellAccessoryCheckmark;
else
cell.accessoryType = UITableViewCellAccessoryNone;
@@ -156,7 +150,7 @@ NSString * const kToEditorSegue = @"CategorySelectorToEditorSegue";
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
- self.selectedIndexPath = indexPath;
+ self.selectedType = [self.dataSource getType:indexPath.row];
id<MWMObjectsCategorySelectorDelegate> delegate = self.delegate;
if (delegate)
diff --git a/iphone/Maps/UI/Search/TableView/MWMSearchCell.h b/iphone/Maps/UI/Search/TableView/MWMSearchCell.h
index b118a4cfff..e62c845491 100644
--- a/iphone/Maps/UI/Search/TableView/MWMSearchCell.h
+++ b/iphone/Maps/UI/Search/TableView/MWMSearchCell.h
@@ -4,6 +4,6 @@
@interface MWMSearchCell : MWMTableViewCell
-- (void)config:(search::Result const &)result;
-+ (NSString *)getLocalizedTypeName:(search::Result const &)result;
+- (void)config:(search::Result const &)result
+ localizedTypeName:(NSString *)localizedTypeName;
@end
diff --git a/iphone/Maps/UI/Search/TableView/MWMSearchCell.mm b/iphone/Maps/UI/Search/TableView/MWMSearchCell.mm
index 66291094a4..a42185f2f7 100644
--- a/iphone/Maps/UI/Search/TableView/MWMSearchCell.mm
+++ b/iphone/Maps/UI/Search/TableView/MWMSearchCell.mm
@@ -4,10 +4,6 @@
#include "Framework.h"
-#include "indexer/classificator.hpp"
-
-#include "platform/localization.hpp"
-
#include "base/logging.hpp"
#include <string>
@@ -21,12 +17,16 @@
@implementation MWMSearchCell
- (void)config:(search::Result const &)result
+ localizedTypeName:(NSString *)localizedTypeName
{
- NSString * title = @(result.GetString().c_str());
+ NSString * title = result.GetString().empty() ? localizedTypeName : @(result.GetString().c_str());
+
if (title.length == 0)
{
- title = [self.class getLocalizedTypeName:result];
+ self.titleLabel.text = @"";
+ return;
}
+
NSDictionary * selectedTitleAttributes = [self selectedTitleAttributes];
NSDictionary * unselectedTitleAttributes = [self unselectedTitleAttributes];
if (!selectedTitleAttributes || !unselectedTitleAttributes)
@@ -60,16 +60,6 @@
self.backgroundColor = [UIColor white];
}
-+ (NSString *)getLocalizedTypeName:(search::Result const &)result
-{
- if (result.GetResultType() != search::Result::Type::Feature)
- return @"";
-
- auto const readableType = classif().GetReadableObjectName(result.GetFeatureType());
-
- return @(platform::GetLocalizedTypeName(readableType).c_str());
-}
-
- (NSDictionary *)selectedTitleAttributes
{
return nil;
diff --git a/iphone/Maps/UI/Search/TableView/MWMSearchCommonCell.h b/iphone/Maps/UI/Search/TableView/MWMSearchCommonCell.h
index a696041f19..e0b2c51253 100644
--- a/iphone/Maps/UI/Search/TableView/MWMSearchCommonCell.h
+++ b/iphone/Maps/UI/Search/TableView/MWMSearchCommonCell.h
@@ -9,6 +9,7 @@
- (void)config:(search::Result const &)result
isAvailable:(BOOL)isAvailable
isHotOffer:(BOOL)isHotOffer
- productInfo:(search::ProductInfo const &)productInfo;
+ productInfo:(search::ProductInfo const &)productInfo
+ localizedTypeName:(NSString *)localizedTypeName;
@end
diff --git a/iphone/Maps/UI/Search/TableView/MWMSearchCommonCell.mm b/iphone/Maps/UI/Search/TableView/MWMSearchCommonCell.mm
index a142c9477e..5892e1255d 100644
--- a/iphone/Maps/UI/Search/TableView/MWMSearchCommonCell.mm
+++ b/iphone/Maps/UI/Search/TableView/MWMSearchCommonCell.mm
@@ -47,10 +47,11 @@ bool PopularityHasHigherPriority(bool hasPosition, double distanceInMeters)
isAvailable:(BOOL)isAvailable
isHotOffer:(BOOL)isHotOffer
productInfo:(search::ProductInfo const &)productInfo
+ localizedTypeName:(NSString *)localizedTypeName
{
- [super config:result];
+ [super config:result localizedTypeName:localizedTypeName];
- self.typeLabel.text = [self.class getLocalizedTypeName:result];
+ self.typeLabel.text = localizedTypeName;
auto const hotelRating = result.GetHotelRating();
auto const ugcRating = productInfo.m_ugcRating;
diff --git a/iphone/Maps/UI/Search/TableView/MWMSearchTableViewController.mm b/iphone/Maps/UI/Search/TableView/MWMSearchTableViewController.mm
index 253474d3c1..8f8e4642fa 100644
--- a/iphone/Maps/UI/Search/TableView/MWMSearchTableViewController.mm
+++ b/iphone/Maps/UI/Search/TableView/MWMSearchTableViewController.mm
@@ -5,6 +5,23 @@
#import "Statistics.h"
#import "SwiftBridge.h"
+#include "indexer/classificator.hpp"
+
+#include "platform/localization.hpp"
+
+namespace
+{
+NSString * GetLocalizedTypeName(search::Result const & result)
+{
+ if (result.GetResultType() != search::Result::Type::Feature)
+ return @"";
+
+ auto const readableType = classif().GetReadableObjectName(result.GetFeatureType());
+
+ return @(platform::GetLocalizedTypeName(readableType).c_str());
+}
+}
+
@interface MWMSearchTableViewController ()<UITableViewDataSource, UITableViewDelegate, MWMGoogleFallbackBannerDynamicSizeDelegate>
@property(weak, nonatomic) IBOutlet UITableView * tableView;
@@ -90,7 +107,9 @@
auto const isBookingAvailable = [MWMSearch isBookingAvailableWithContainerIndex:containerIndex];
auto const isDealAvailable = [MWMSearch isDealAvailableWithContainerIndex:containerIndex];
auto const & productInfo = [MWMSearch productInfoWithContainerIndex:containerIndex];
- [cell config:result isAvailable:isBookingAvailable isHotOffer:isDealAvailable productInfo:productInfo];
+ auto const typeName = GetLocalizedTypeName(result);
+ [cell config:result isAvailable:isBookingAvailable isHotOffer:isDealAvailable productInfo:productInfo
+ localizedTypeName:typeName];
return cell;
}
case MWMSearchItemTypeMopub:
@@ -114,7 +133,7 @@
dequeueReusableCellWithCellClass:[MWMSearchSuggestionCell class]
indexPath:indexPath]);
auto const & suggestion = [MWMSearch resultWithContainerIndex:containerIndex];
- [cell config:suggestion];
+ [cell config:suggestion localizedTypeName:@""];
cell.isLastCell = row == [MWMSearch suggestionsCount] - 1;
return cell;
}
diff --git a/search/result.cpp b/search/result.cpp
index 0e1064285d..6f3fca91aa 100644
--- a/search/result.cpp
+++ b/search/result.cpp
@@ -81,13 +81,13 @@ bool Result::HasPoint() const
FeatureID const & Result::GetFeatureID() const
{
- ASSERT(m_resultType == Type::Feature, (m_resultType));
+ ASSERT_EQUAL(m_resultType, Type::Feature, (m_resultType));
return m_id;
}
uint32_t Result::GetFeatureType() const
{
- ASSERT(m_resultType == Type::Feature, (m_resultType));
+ ASSERT_EQUAL(m_resultType, Type::Feature, (m_resultType));
return m_featureType;
}
diff --git a/tools/python/find_untranslated_strings.py b/tools/python/find_untranslated_strings.py
index 402d09b315..daf9abd0f2 100755
--- a/tools/python/find_untranslated_strings.py
+++ b/tools/python/find_untranslated_strings.py
@@ -23,7 +23,7 @@ class StringsTxt:
def __init__(self, strings_path=None):
if not strings_path:
- self.strings_path = join(dirname(argv[0]), "..", "..", "data","strings", "strings.txt")
+ self.strings_path = join(dirname(argv[0]), "..", "..", "data", "strings", "strings.txt")
else:
self.strings_path = strings_path