diff --git a/map/framework.cpp b/map/framework.cpp index e7b88ac3a1..360c22ba68 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -2258,6 +2258,12 @@ void Framework::RemoveRoute() m_bmManager.ResetRouteTrack(); } +bool Framework::DisableFollowMode() +{ + GetLocationState()->SetRoutingNotFollow(); + return m_routingSession.DisableFollowMode(); +} + void Framework::FollowRoute() { int const scale = (m_currentRouterType == RouterType::Pedestrian) ? diff --git a/map/framework.hpp b/map/framework.hpp index e8a2e17b1b..d60396d143 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -593,7 +593,7 @@ public: void BuildRoute(m2::PointD const & start, m2::PointD const & finish, uint32_t timeoutSec); // FollowRoute has a bug where the router follows the route even if the method hads't been called. // This method was added because we do not want to break the behaviour that is familiar to our users. - bool DisableFollowMode() { return m_routingSession.DisableFollowMode(); } + bool DisableFollowMode(); void SetRouteBuildingListener(TRouteBuildingCallback const & buildingCallback) { m_routingCallback = buildingCallback; } void SetRouteProgressListener(TRouteProgressCallback const & progressCallback) { m_progressCallback = progressCallback; } void FollowRoute(); diff --git a/map/location_state.cpp b/map/location_state.cpp index 94f53ddbab..00f7e333d3 100644 --- a/map/location_state.cpp +++ b/map/location_state.cpp @@ -311,7 +311,7 @@ void State::SwitchToNextMode() Mode currentMode = GetMode(); Mode newMode = currentMode; - if (!IsInRouting()) + if (!IsInRouting() || IsRoutingFollowingDisabled()) { switch (currentMode) { @@ -360,10 +360,7 @@ void State::RouteBuilded() if (mode > NotFollow) SetModeInfo(ChangeMode(m_modeInfo, NotFollow)); else if (mode == UnknownPosition) - { m_afterPendingMode = NotFollow; - SetModeInfo(ChangeMode(m_modeInfo, PendingPosition)); - } } void State::StartRouteFollow(int scale) @@ -382,7 +379,11 @@ void State::StopRoutingMode() { if (IsInRouting()) { - SetModeInfo(ChangeMode(ExcludeModeBit(m_modeInfo, RoutingSessionBit), GetMode() == RotateAndFollow ? Follow : NotFollow)); + bool const isNotFollow = IsRoutingFollowingDisabled(); + m_modeInfo = ExcludeModeBit(m_modeInfo, RoutingNotFollowBit | RoutingSessionBit); + if (isNotFollow) + return; + SetModeInfo(ChangeMode(m_modeInfo, GetMode() == RotateAndFollow ? Follow : NotFollow)); RotateOnNorth(); AnimateFollow(); } @@ -662,6 +663,11 @@ bool State::IsInRouting() const return TestModeBit(m_modeInfo, RoutingSessionBit); } +bool State::IsRoutingFollowingDisabled() const +{ + return TestModeBit(m_modeInfo, RoutingNotFollowBit); +} + m2::PointD const State::GetModeDefaultPixelBinding(State::Mode mode) const { switch (mode) @@ -773,6 +779,11 @@ void State::SetFixedZoom() SetModeInfo(IncludeModeBit(m_modeInfo, FixedZoomBit)); } +void State::SetRoutingNotFollow() +{ + SetModeInfo(IncludeModeBit(m_modeInfo, RoutingNotFollowBit)); +} + void State::DragStarted() { m_dragModeInfo = m_modeInfo; diff --git a/map/location_state.hpp b/map/location_state.hpp index 3f88095b91..631acbf7b1 100644 --- a/map/location_state.hpp +++ b/map/location_state.hpp @@ -83,6 +83,7 @@ namespace location void StopCompassFollowing(); void StopLocationFollow(bool callListeners = true); void SetFixedZoom(); + void SetRoutingNotFollow(); /// @name User input notification block //@{ @@ -142,6 +143,7 @@ namespace location bool IsRotationActive() const; bool IsInRouting() const; + bool IsRoutingFollowingDisabled() const; m2::PointD const GetModeDefaultPixelBinding(Mode mode) const; m2::PointD const GetRaFModeDefaultPxBind() const; @@ -158,12 +160,14 @@ namespace location const m2::PointD GetPositionForDraw() const; private: - // Mode bits - // { - static uint16_t const FixedZoomBit = 0x20; - static uint16_t const RoutingSessionBit = 0x40; - static uint16_t const KnownDirectionBit = 0x80; - // } + + enum ExternalMode + { + RoutingNotFollowBit = 0x10, + FixedZoomBit = 0x20, + RoutingSessionBit = 0x40, + KnownDirectionBit = 0x80 + }; static uint16_t const s_cacheRadius = 500.0f; uint16_t m_modeInfo; // combination of Mode enum and "Mode bits"