From b95ebf1da3180651ed4567cd66fa689f89c4dd79 Mon Sep 17 00:00:00 2001 From: ExMix Date: Tue, 16 Sep 2014 13:00:28 +0300 Subject: [PATCH] [core] handle routing start in lite version --- .../jni/com/mapswithme/platform/Platform.cpp | 1 + map/framework.cpp | 8 +++--- map/location_state.cpp | 25 ++++++++----------- map/location_state.hpp | 2 +- platform/platform.hpp | 2 ++ platform/platform_ios.mm | 2 +- platform/platform_tizen.cpp | 1 + 7 files changed, 21 insertions(+), 20 deletions(-) diff --git a/android/jni/com/mapswithme/platform/Platform.cpp b/android/jni/com/mapswithme/platform/Platform.cpp index 2e2eafe1c9..3acd130d55 100644 --- a/android/jni/com/mapswithme/platform/Platform.cpp +++ b/android/jni/com/mapswithme/platform/Platform.cpp @@ -88,6 +88,7 @@ namespace android m_flags[PRO_URL] = isPro; m_flags[HAS_BOOKMARKS] = isPro || isYota; m_flags[HAS_ROTATION] = isPro; + m_flags[HAS_ROUTING] = isPro; string const obbPath = jni::ToNativeString(env, obbGooglePath); Platform::FilesList files; diff --git a/map/framework.cpp b/map/framework.cpp index 1c4dff6d9d..414986fd92 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -1942,13 +1942,13 @@ bool Framework::IsRountingActive() const bool Framework::StartRoutingSession(m2::PointD const & destination) { + shared_ptr state = GetLocationState(); + if (!GetPlatform().HasRouting() || !state->IsModeHasPosition()) + return false; + if (IsRountingActive()) CancelRoutingSession(); - shared_ptr state = GetLocationState(); - if (state->GetMode() < location::State::NotFollow) - return false; - m_routingSession.reset(new routing::RoutingSession(CreateRouter())); m_routingSession->BuildRoute(state->Position(), destination, [this, state](routing::Route const & route) diff --git a/map/location_state.cpp b/map/location_state.cpp index 44137bd3f9..59f0d502f9 100644 --- a/map/location_state.cpp +++ b/map/location_state.cpp @@ -115,7 +115,7 @@ void State::SwitchToNextMode() newMode = Follow; break; case Follow: - if (HasDirection()) + if (IsRotationActive()) newMode = RotateAndFollow; else newMode = UnknownPosition; @@ -126,15 +126,16 @@ void State::SwitchToNextMode() } } else - newMode = HasDirection() ? RotateAndFollow : Follow; + newMode = IsRotationActive() ? RotateAndFollow : Follow; SetModeInfo(ChangeMode(m_modeInfo, newMode)); } void State::StartRoutingMode() { + ASSERT(GetPlatform().HasRouting(), ()); ASSERT(IsModeHasPosition(), ()); - State::Mode newMode = HasDirection() ? RotateAndFollow : Follow; + State::Mode newMode = IsRotationActive() ? RotateAndFollow : Follow; SetModeInfo(ChangeMode(IncludeModeBit(m_modeInfo, RoutingSessionBit), newMode)); } @@ -270,7 +271,7 @@ void State::draw(graphics::OverlayRenderer * r, r->drawDisplayList(m_locationMarkDL.get(), drawM); // if we know look direction than we draw arrow - if (HasDirection()) + if (IsRotationActive()) { double rotateAngle = m_drawDirection + m_framework->GetNavigator().Screen().GetAngle(); @@ -358,9 +359,9 @@ void State::CacheLocationMark() cacheScreen->endFrame(); } -bool State::HasDirection() const +bool State::IsRotationActive() const { - return TestModeBit(m_modeInfo, KnownDirectionBit); + return m_framework->GetNavigator().DoSupportRotation() && TestModeBit(m_modeInfo, KnownDirectionBit); } bool State::IsInRouting() const @@ -370,17 +371,13 @@ bool State::IsInRouting() const void State::FollowCompass() { - if (!m_framework->GetNavigator().DoSupportRotation()) + if (!IsRotationActive() || GetMode() != RotateAndFollow) return; - if (TestModeBit(m_modeInfo, KnownDirectionBit) && GetMode() == RotateAndFollow) - { - anim::Controller::Guard guard(m_framework->GetAnimController()); + anim::Controller::Guard guard(m_framework->GetAnimController()); - m_framework->GetAnimator().RotateScreen( - m_framework->GetNavigator().Screen().GetAngle(), - -m_drawDirection); - } + m_framework->GetAnimator().RotateScreen(m_framework->GetNavigator().Screen().GetAngle(), + -m_drawDirection); } void State::SetModeInfo(uint16_t modeInfo) diff --git a/map/location_state.hpp b/map/location_state.hpp index cf5ffeaeee..493386e65e 100644 --- a/map/location_state.hpp +++ b/map/location_state.hpp @@ -112,7 +112,7 @@ namespace location void CachePositionArrow(); void CacheLocationMark(); - bool HasDirection() const; + bool IsRotationActive() const; bool IsInRouting() const; void FollowCompass(); diff --git a/platform/platform.hpp b/platform/platform.hpp index 6a3572fc21..ca246994ec 100644 --- a/platform/platform.hpp +++ b/platform/platform.hpp @@ -34,6 +34,7 @@ protected: PRO_URL, HAS_BOOKMARKS, HAS_ROTATION, + HAS_ROUTING, FLAGS_COUNT // should always be the last one }; @@ -138,6 +139,7 @@ public: inline bool IsPro() const { return m_flags[PRO_URL]; } inline bool HasBookmarks() const { return m_flags[HAS_BOOKMARKS]; } inline bool HasRotation() const { return m_flags[HAS_ROTATION]; } + inline bool HasRouting() const { return m_flags[HAS_ROUTING]; } /// @return url for clients to download maps //@{ diff --git a/platform/platform_ios.mm b/platform/platform_ios.mm index 3f20526c6c..0a4dd2943b 100644 --- a/platform/platform_ios.mm +++ b/platform/platform_ios.mm @@ -47,7 +47,7 @@ Platform::Platform() // .travelguide corresponds to the Lite version without search m_flags[PRO_URL] = ([appID rangeOfString:@"com.mapswithme.travelguide"].location == NSNotFound); - m_flags[HAS_BOOKMARKS] = m_flags[HAS_ROTATION] = m_flags[PRO_URL]; + m_flags[HAS_BOOKMARKS] = m_flags[HAS_ROTATION] = m_flags[HAS_ROUTING] = m_flags[PRO_URL]; UIDevice * device = [UIDevice currentDevice]; NSLog(@"Device: %@, SystemName: %@, SystemVersion: %@", device.model, device.systemName, device.systemVersion); diff --git a/platform/platform_tizen.cpp b/platform/platform_tizen.cpp index b0cb4db90d..f554700991 100644 --- a/platform/platform_tizen.cpp +++ b/platform/platform_tizen.cpp @@ -41,6 +41,7 @@ Platform::Platform() m_flags[HAS_BOOKMARKS] = true; m_flags[HAS_ROTATION] = true; + m_flags[HAS_ROUTING] = true; } int Platform::CpuCores() const