[core] handle routing start in lite version

This commit is contained in:
ExMix 2014-09-16 13:00:28 +03:00 committed by Alex Zolotarev
parent 767e14ca68
commit b95ebf1da3
7 changed files with 21 additions and 20 deletions

View file

@ -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;

View file

@ -1942,13 +1942,13 @@ bool Framework::IsRountingActive() const
bool Framework::StartRoutingSession(m2::PointD const & destination)
{
shared_ptr<location::State> state = GetLocationState();
if (!GetPlatform().HasRouting() || !state->IsModeHasPosition())
return false;
if (IsRountingActive())
CancelRoutingSession();
shared_ptr<location::State> 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)

View file

@ -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)

View file

@ -112,7 +112,7 @@ namespace location
void CachePositionArrow();
void CacheLocationMark();
bool HasDirection() const;
bool IsRotationActive() const;
bool IsInRouting() const;
void FollowCompass();

View file

@ -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
//@{

View file

@ -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);

View file

@ -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