diff options
-rw-r--r-- | coding/transliteration.cpp | 13 | ||||
-rw-r--r-- | coding/transliteration.hpp | 6 | ||||
-rw-r--r-- | map/framework.cpp | 23 | ||||
-rw-r--r-- | map/framework.hpp | 4 |
4 files changed, 44 insertions, 2 deletions
diff --git a/coding/transliteration.cpp b/coding/transliteration.cpp index 717b90a4f7..c75839b3e9 100644 --- a/coding/transliteration.cpp +++ b/coding/transliteration.cpp @@ -12,7 +12,6 @@ #include "std/unique_ptr.hpp" -#include <atomic> #include <cstring> #include <mutex> @@ -27,6 +26,10 @@ struct Transliteration::TransliteratorInfo std::unique_ptr<Transliterator> m_transliterator; }; +Transliteration::Transliteration() + : m_enabled(true) +{} + Transliteration::~Transliteration() { // The use of u_cleanup() just before an application terminates is optional, @@ -59,8 +62,16 @@ void Transliteration::Init(std::string const & icuDataDir) } } +void Transliteration::SetEnabled(bool enable) +{ + m_enabled = enable; +} + bool Transliteration::Transliterate(std::string const & str, int8_t langCode, std::string & out) const { + if (!m_enabled) + return false; + if (str.empty() || strings::IsASCIIString(str)) return false; diff --git a/coding/transliteration.hpp b/coding/transliteration.hpp index 088f870b56..aa10126e88 100644 --- a/coding/transliteration.hpp +++ b/coding/transliteration.hpp @@ -1,5 +1,6 @@ #pragma once +#include <atomic> #include <map> #include <memory> #include <string> @@ -13,10 +14,13 @@ public: void Init(std::string const & icuDataDir); + void SetEnabled(bool enable); bool Transliterate(std::string const & str, int8_t langCode, std::string & out) const; private: - Transliteration() = default; + Transliteration(); + + std::atomic<bool> m_enabled; struct TransliteratorInfo; std::map<std::string, std::unique_ptr<TransliteratorInfo>> m_transliterators; diff --git a/map/framework.cpp b/map/framework.cpp index 054f04c689..c2db87eb03 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -134,6 +134,7 @@ char const kAllowAutoZoom[] = "AutoZoom"; char const kTrafficEnabledKey[] = "TrafficEnabled"; char const kTrafficSimplifiedColorsKey[] = "TrafficSimplifiedColors"; char const kLargeFontsSize[] = "LargeFontsSize"; +char const kAllowTranslit[] = "Transliteration"; #if defined(OMIM_OS_ANDROID) char const kICUDataFile[] = "icudt57l.dat"; @@ -1485,6 +1486,9 @@ void Framework::InitTransliteration() #else Transliteration::Instance().Init(GetPlatform().ResourcesDir()); #endif + + if (!LoadTransliteration()) + Transliteration::Instance().SetEnabled(false /* enable */); } storage::TCountryId Framework::GetCountryIndex(m2::PointD const & pt) const @@ -2911,6 +2915,25 @@ void Framework::SetRouteFinishPoint(m2::PointD const & pt, bool isValid) m_drapeEngine->SetRoutePoint(pt, false /* isStart */, isValid); } +void Framework::AllowTransliteration(bool allowTranslit) +{ + Transliteration::Instance().SetEnabled(allowTranslit); + InvalidateRect(GetCurrentViewport()); +} + +bool Framework::LoadTransliteration() +{ + bool isTranslitAllowed; + if (!settings::Get(kLargeFontsSize, isTranslitAllowed)) + isTranslitAllowed = true; + return isTranslitAllowed; +} + +void Framework::SaveTransliteration(bool allowTranslit) +{ + settings::Set(kAllowTranslit, allowTranslit); +} + void Framework::Allow3dMode(bool allow3d, bool allow3dBuildings) { CallDrapeFunction(bind(&df::DrapeEngine::Allow3dMode, _1, allow3d, allow3dBuildings)); diff --git a/map/framework.hpp b/map/framework.hpp index 6e61f9a794..77c1e7a748 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -814,6 +814,10 @@ public: void SetRouteStartPoint(m2::PointD const & pt, bool isValid); void SetRouteFinishPoint(m2::PointD const & pt, bool isValid); + void AllowTransliteration(bool allowTranslit); + bool LoadTransliteration(); + void SaveTransliteration(bool allowTranslit); + void Allow3dMode(bool allow3d, bool allow3dBuildings); void Save3dMode(bool allow3d, bool allow3dBuildings); void Load3dMode(bool & allow3d, bool & allow3dBuildings); |