diff --git a/android/jni/com/mapswithme/maps/SearchEngine.cpp b/android/jni/com/mapswithme/maps/SearchEngine.cpp index 6bf05c88a2..d2ebf5d37b 100644 --- a/android/jni/com/mapswithme/maps/SearchEngine.cpp +++ b/android/jni/com/mapswithme/maps/SearchEngine.cpp @@ -343,6 +343,7 @@ jobject ToJavaResult(Result & result, search::ProductInfo const & productInfo, b jni::TScopedLocalRef address(env, jni::ToJavaString(env, result.GetAddress())); jni::TScopedLocalRef dist(env, jni::ToJavaString(env, distance)); jni::TScopedLocalRef cuisine(env, jni::ToJavaString(env, result.GetCuisine())); + jni::TScopedLocalRef brand(env, jni::ToJavaString(env, result.GetBrand())); jni::TScopedLocalRef airportIata(env, jni::ToJavaString(env, result.GetAirportIata())); jni::TScopedLocalRef pricing(env, jni::ToJavaString(env, result.GetHotelApproximatePricing())); @@ -354,7 +355,7 @@ jobject ToJavaResult(Result & result, search::ProductInfo const & productInfo, b jni::TScopedLocalRef desc(env, env->NewObject(g_descriptionClass, g_descriptionConstructor, featureId.get(), featureType.get(), address.get(), - dist.get(), cuisine.get(), airportIata.get(), + dist.get(), cuisine.get(), brand.get(), airportIata.get(), pricing.get(), rating, result.GetStarsCount(), static_cast(result.IsOpenNow()), @@ -648,7 +649,8 @@ extern "C" g_descriptionConstructor = jni::GetConstructorID(env, g_descriptionClass, "(Lcom/mapswithme/maps/bookmarks/data/FeatureId;" "Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;" - "Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;FIIZ)V"); + "Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;" + "Ljava/lang/String;FIIZ)V"); g_popularityClass = jni::GetGlobalClassRef(env, "com/mapswithme/maps/search/Popularity"); g_popularityConstructor = jni::GetConstructorID(env, g_popularityClass, "(I)V"); diff --git a/android/jni/com/mapswithme/platform/Localization.cpp b/android/jni/com/mapswithme/platform/Localization.cpp index d6dadf4873..e2b6c401e8 100644 --- a/android/jni/com/mapswithme/platform/Localization.cpp +++ b/android/jni/com/mapswithme/platform/Localization.cpp @@ -7,18 +7,31 @@ #include +namespace +{ +std::string GetLocalizedStringByUtil(std::string const & methodName, std::string const & str) +{ + JNIEnv * env = jni::GetEnv(); + static auto const getLocalizedString = jni::GetStaticMethodID( + env, g_utilsClazz, methodName.c_str(), "(Ljava/lang/String;)Ljava/lang/String;"); + + jni::TScopedLocalRef strRef(env, jni::ToJavaString(env, str)); + auto localizedString = + env->CallStaticObjectMethod(g_utilsClazz, getLocalizedString, strRef.get()); + + return jni::ToNativeString(env, static_cast(localizedString)); +} +} // namespace + namespace platform { std::string GetLocalizedTypeName(std::string const & type) { - JNIEnv * env = jni::GetEnv(); - static auto const getLocalizedFeatureType = jni::GetStaticMethodID( - env, g_utilsClazz, "getLocalizedFeatureType", "(Ljava/lang/String;)Ljava/lang/String;"); + return GetLocalizedStringByUtil("getLocalizedFeatureType", type); +} - jni::TScopedLocalRef typeRef(env, jni::ToJavaString(env, type)); - auto localizedFeatureType = - env->CallStaticObjectMethod(g_utilsClazz, getLocalizedFeatureType, typeRef.get()); - - return jni::ToNativeString(env, static_cast(localizedFeatureType)); +std::string GetLocalizedBrandName(std::string const & brand) +{ + return GetLocalizedStringByUtil("getLocalizedBrand", brand); } } // namespace platform diff --git a/android/src/com/mapswithme/maps/search/SearchAdapter.java b/android/src/com/mapswithme/maps/search/SearchAdapter.java index 716a92107c..74f9ed8f29 100644 --- a/android/src/com/mapswithme/maps/search/SearchAdapter.java +++ b/android/src/com/mapswithme/maps/search/SearchAdapter.java @@ -245,14 +245,21 @@ class SearchAdapter extends RecyclerView.Adapter 0) [self setInfoRating:starsCount]; - else if (cuisine.length > 0) - [self setInfoText:cuisine.capitalizedString]; else if (airportIata.length > 0) [self setInfoText:airportIata]; + else if (brand.length > 0 && cuisine.length > 0) + [self setInfoText:[NSString stringWithFormat:@"%@ • %@", brand, cuisine]]; + else if (brand.length > 0) + [self setInfoText:brand]; + else if (cuisine.length > 0) + [self setInfoText:cuisine]; else [self clearInfo]; diff --git a/platform/localization.hpp b/platform/localization.hpp index 22f20dbd0d..2ceea64655 100644 --- a/platform/localization.hpp +++ b/platform/localization.hpp @@ -5,4 +5,5 @@ namespace platform { extern std::string GetLocalizedTypeName(std::string const & type); +extern std::string GetLocalizedBrandName(std::string const & brand); } // namespace platform diff --git a/platform/localization.mm b/platform/localization.mm index c511228a66..06f779e207 100644 --- a/platform/localization.mm +++ b/platform/localization.mm @@ -13,4 +13,10 @@ std::string GetLocalizedTypeName(std::string const & type) return [NSLocalizedString(@(key.c_str()), @"") UTF8String]; } + +std::string GetLocalizedBrandName(std::string const & brand) +{ + auto const key = "brand." + brand; + return [NSLocalizedString(@(key.c_str()), @"") UTF8String]; +} } // namespace platform diff --git a/platform/localization_dummy.cpp b/platform/localization_dummy.cpp index efd714524d..9d40587cce 100644 --- a/platform/localization_dummy.cpp +++ b/platform/localization_dummy.cpp @@ -6,4 +6,6 @@ std::string GetLocalizedTypeName(std::string const & type) { return type; } + +std::string GetLocalizedBrandName(std::string const & brand) { return brand; } } // namespace platform diff --git a/search/intermediate_result.cpp b/search/intermediate_result.cpp index ae60c1d388..1458961de0 100644 --- a/search/intermediate_result.cpp +++ b/search/intermediate_result.cpp @@ -209,6 +209,7 @@ void ProcessMetadata(FeatureType & ft, Result::Metadata & meta) } meta.m_airportIata = src.Get(feature::Metadata::FMD_AIRPORT_IATA); + meta.m_brand = src.Get(feature::Metadata::FMD_BRAND); string const openHours = src.Get(feature::Metadata::FMD_OPEN_HOURS); if (!openHours.empty()) diff --git a/search/result.hpp b/search/result.hpp index b971b51e37..5100ab6b7b 100644 --- a/search/result.hpp +++ b/search/result.hpp @@ -48,6 +48,9 @@ public: // Valid only if not empty, used for airport iata codes. std::string m_airportIata; + // Valid only if not empty, used for brand name. + std::string m_brand; + // Following fields are used for hotels only. int m_hotelPricing = 0; std::string m_hotelApproximatePricing; @@ -84,6 +87,7 @@ public: std::string const & GetAddress() const { return m_address; } std::string const & GetCuisine() const { return m_metadata.m_cuisine; } std::string const & GetAirportIata() const { return m_metadata.m_airportIata; } + std::string const & GetBrand() const { return m_metadata.m_brand; } float GetHotelRating() const { return m_metadata.m_hotelRating; } std::string const & GetHotelApproximatePricing() const {