diff --git a/indexer/map_style_reader.cpp b/indexer/map_style_reader.cpp index f0e0051087..0d3fc7fe13 100644 --- a/indexer/map_style_reader.cpp +++ b/indexer/map_style_reader.cpp @@ -5,15 +5,12 @@ #include "coding/file_name_utils.hpp" #include "platform/platform.hpp" -#include "platform/settings.hpp" #include "std/string.hpp" namespace { -char const * const kMapStyleKey = "MapStyleKeyV1"; - const char * const kSuffixLegacyLight = ""; const char * const kSuffixLegacyDark = "_dark"; const char * const kSuffixModernClear = "_clear"; @@ -38,22 +35,19 @@ string GetStyleSuffix(MapStyle mapStyle) } // namespace +StyleReader::StyleReader() + : m_mapStyle(MapStyleLight) +{ +} + void StyleReader::SetCurrentStyle(MapStyle mapStyle) { - Settings::Set(kMapStyleKey, static_cast(mapStyle)); + m_mapStyle = mapStyle; } MapStyle StyleReader::GetCurrentStyle() { - int mapStyle = MapStyleLight; -// @TODO(shalnev) It's a hotfix to fix tests generator_tests and map_tests. -// Tests should work with any styles. -#if defined(OMIM_OS_ANDROID) || defined(OMIM_OS_IPHONE) - if (!Settings::Get(kMapStyleKey, mapStyle)) - mapStyle = MapStyleClear; -#endif - - return static_cast(mapStyle); + return m_mapStyle; } ReaderPtr StyleReader::GetDrawingRulesReader() diff --git a/indexer/map_style_reader.hpp b/indexer/map_style_reader.hpp index 485558bb35..63ff46a47a 100644 --- a/indexer/map_style_reader.hpp +++ b/indexer/map_style_reader.hpp @@ -7,12 +7,17 @@ class StyleReader { public: + StyleReader(); + void SetCurrentStyle(MapStyle mapStyle); MapStyle GetCurrentStyle(); ReaderPtr GetDrawingRulesReader(); ReaderPtr GetResourceReader(string const & file, string const & density); + +private: + MapStyle m_mapStyle; }; extern StyleReader & GetStyleReader(); diff --git a/map/framework.cpp b/map/framework.cpp index 31871d80d1..530cbcc67f 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -102,6 +102,7 @@ namespace static const int BM_TOUCH_PIXEL_INCREASE = 20; static const int kKeepPedestrianDistanceMeters = 10000; char const kRouterTypeKey[] = "router"; + char const kMapStyleKey[] = "MapStyleKeyV1"; } pair Framework::RegisterMap( @@ -204,6 +205,12 @@ Framework::Framework() m_fixedSearchResults(0), m_locationChangedSlotID(-1) { + // Restore map style before classificator loading + int mapStyle = MapStyleLight; + if (!Settings::Get(kMapStyleKey, mapStyle)) + mapStyle = MapStyleClear; + GetStyleReader().SetCurrentStyle(static_cast(mapStyle)); + // Checking whether we should enable benchmark. bool isBenchmarkingEnabled = false; (void)Settings::Get("IsBenchmarking", isBenchmarkingEnabled); @@ -1618,7 +1625,10 @@ void Framework::CreateDrapeEngine(dp::RefPointer contextF void Framework::SetMapStyle(MapStyle mapStyle) { + // Store current map style before classificator reloading + Settings::Set(kMapStyleKey, static_cast(mapStyle)); GetStyleReader().SetCurrentStyle(mapStyle); + classificator::Load(); alohalytics::TStringMap details {{"mapStyle", strings::to_string(static_cast(mapStyle))}};