From 94112b4fc7169a24811d2a0241c45fd726cc7553 Mon Sep 17 00:00:00 2001 From: Daria Volvenkova Date: Tue, 14 Mar 2017 13:54:36 +0300 Subject: Added debug commands for changing map style. --- .../com/mapswithme/maps/search/SearchFragment.java | 25 ------------------- map/framework.cpp | 26 ++++++++++++++++++++ map/framework.hpp | 2 ++ qt/search_panel.cpp | 28 ---------------------- qt/search_panel.hpp | 1 - 5 files changed, 28 insertions(+), 54 deletions(-) diff --git a/android/src/com/mapswithme/maps/search/SearchFragment.java b/android/src/com/mapswithme/maps/search/SearchFragment.java index 65d37bfc3e..d3aefd7cce 100644 --- a/android/src/com/mapswithme/maps/search/SearchFragment.java +++ b/android/src/com/mapswithme/maps/search/SearchFragment.java @@ -94,10 +94,6 @@ public class SearchFragment extends BaseMwmFragment return; } - // TODO: This code only for demonstration purposes and will be removed soon - if (tryChangeMapStyle(query)) - return; - if (tryRecognizeLoggingCommand(query)) { mSearchAdapter.clear(); @@ -447,27 +443,6 @@ public class SearchFragment extends BaseMwmFragment Utils.navigateToParent(getActivity()); } - // FIXME: This code only for demonstration purposes and will be removed soon - private boolean tryChangeMapStyle(String str) - { - // Hook for shell command on change map style - final boolean isDark = str.equals("mapstyle:dark") || str.equals("?dark"); - final boolean isLight = isDark ? false : str.equals("mapstyle:light") || str.equals("?light"); - final boolean isOld = isDark || isLight ? false : str.equals("?oldstyle"); - - if (!isDark && !isLight && !isOld) - return false; - - hideSearch(); - - // change map style for the Map activity - final int mapStyle = isDark ? Framework.MAP_STYLE_DARK : Framework.MAP_STYLE_CLEAR; - Framework.nativeSetMapStyle(mapStyle); - - return true; - } - // FIXME END - private boolean tryRecognizeLoggingCommand(@NonNull String str) { if (str.equals("?enableLogging")) diff --git a/map/framework.cpp b/map/framework.cpp index 1b4961de69..6094a12a64 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -1394,6 +1394,9 @@ string Framework::GetCountryName(m2::PointD const & pt) const bool Framework::Search(search::SearchParams const & params) { + if (ParseDrapeDebugCommand(params.m_query)) + return false; + auto const mode = params.m_mode; auto & intent = m_searchIntents[static_cast(mode)]; @@ -2868,6 +2871,29 @@ uint32_t GetBestType(FeatureType const & ft) } } +bool Framework::ParseDrapeDebugCommand(std::string const & query) +{ + MapStyle desiredStyle = MapStyleCount; + if (query == "?dark" || query == "mapstyle:dark") + desiredStyle = MapStyleDark; + else if (query == "?light" || query == "mapstyle:light") + desiredStyle = MapStyleClear; + else if (query == "?vdark" || query == "mapstyle:vehicle_dark") + desiredStyle = MapStyleVehicleDark; + else if (query == "?vlight" || query == "mapstyle:vehicle_light") + desiredStyle = MapStyleVehicleClear; + else + return false; + +#if defined(OMIM_OS_ANDROID) + MarkMapStyle(desiredStyle); +#else + SetMapStyle(desiredStyle); +#endif + + return true; +} + bool Framework::ParseEditorDebugCommand(search::SearchParams const & params) { if (params.m_query == "?edits") diff --git a/map/framework.hpp b/map/framework.hpp index 264c40b69f..3c380674ae 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -620,6 +620,8 @@ private: //void GetLocality(m2::PointD const & pt, search::AddressInfo & info) const; /// @returns true if command was handled by editor. bool ParseEditorDebugCommand(search::SearchParams const & params); + /// @returns true if command was handled by drape. + bool ParseDrapeDebugCommand(std::string const & query); void FillFeatureInfo(FeatureID const & fid, place_page::Info & info) const; /// @param customTitle, if not empty, overrides any other calculated name. diff --git a/qt/search_panel.cpp b/qt/search_panel.cpp index 4a51b27538..254ef8bf10 100644 --- a/qt/search_panel.cpp +++ b/qt/search_panel.cpp @@ -151,32 +151,6 @@ void SearchPanel::OnSearchResult(ResultsT * results) } } -// TODO: This code only for demonstration purposes and will be removed soon -bool SearchPanel::TryChangeMapStyleCmd(QString const & str) -{ - // Hook for shell command on change map style - MapStyle desiredStyle = MapStyleCount; - if (str == "mapstyle:dark" || str == "?dark") - desiredStyle = MapStyleDark; - else if (str == "mapstyle:light" || str == "?light") - desiredStyle = MapStyleClear; - else if (str == "mapstyle:vehicle_dark" || str == "?vdark") - desiredStyle = MapStyleVehicleDark; - else if (str == "mapstyle:vehicle_light" || str == "?vlight") - desiredStyle = MapStyleVehicleClear; - else - return false; - - // close Search panel - m_pEditor->setText(""); - parentWidget()->hide(); - - // change color scheme for the Map activity - m_pDrawWidget->SetMapStyle(desiredStyle); - - return true; -} - // TODO: This code only for demonstration purposes and will be removed soon bool SearchPanel::TryChangeRouterCmd(QString const & str) { @@ -287,8 +261,6 @@ void SearchPanel::OnSearchTextChanged(QString const & str) QString const normalized = str.normalized(QString::NormalizationForm_KC); // TODO: This code only for demonstration purposes and will be removed soon - if (TryChangeMapStyleCmd(normalized)) - return; if (TryChangeRouterCmd(normalized)) return; if (Try3dModeCmd(normalized)) diff --git a/qt/search_panel.hpp b/qt/search_panel.hpp index d5cc2ef4c5..84ef17c3b4 100644 --- a/qt/search_panel.hpp +++ b/qt/search_panel.hpp @@ -63,7 +63,6 @@ private slots: void OnAnimationTimer(); void OnClearButton(); - bool TryChangeMapStyleCmd(QString const & str); bool TryChangeRouterCmd(QString const & str); bool Try3dModeCmd(QString const & str); bool TryMigrate(QString const & str); -- cgit v1.2.3