[core, android] button "go" and core support for it

This commit is contained in:
ExMix 2014-10-03 21:52:11 +03:00 committed by Alex Zolotarev
parent 75b67819ba
commit 04bd479bd6
11 changed files with 88 additions and 31 deletions

View file

@ -1129,9 +1129,15 @@ extern "C"
}
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_Framework_nativeStartRoutingSession(JNIEnv * env, jclass thiz, jdouble lat, jdouble lon)
Java_com_mapswithme_maps_Framework_nativeBuildRoute(JNIEnv * env, jclass thiz, jdouble lat, jdouble lon)
{
g_framework->NativeFramework()->StartRoutingSession(MercatorBounds::FromLatLon(lat, lon));
g_framework->NativeFramework()->BuildRoute(MercatorBounds::FromLatLon(lat, lon));
}
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_Framework_nativeStartRoutingSession(JNIEnv * env, jclass thiz)
{
return g_framework->NativeFramework()->StartRoutingSession();
}
JNIEXPORT jobject JNICALL

View file

@ -131,7 +131,8 @@ public class Framework
public native static void nativeCancelRoutingSession();
public native static void nativeStartRoutingSession(double lat, double lon);
public native static void nativeBuildRoute(double lat, double lon);
public native static void nativeStartRoutingSession();
public native static LocationState.RoutingInfo nativeGetRouteFollowingInfo();
//@}

View file

@ -1376,13 +1376,13 @@ public class MWMActivity extends NvEventQueueActivity
startActivity(new Intent(this, MoreAppsActivity.class));
break;
case R.id.iv__start_routing:
startRouting();
buildRoute();
break;
case R.id.iv__routing_close:
stopRouting();
break;
case R.id.btn__routing_go:
// TODO call some native magic
startRouting();
break;
default:
break;
@ -1390,6 +1390,11 @@ public class MWMActivity extends NvEventQueueActivity
}
private void startRouting()
{
Framework.nativeStartRoutingSession();
}
private void buildRoute()
{
if (LocationState.INSTANCE.getLocationStateMode() < LocationState.NOT_FOLLOW)
{
@ -1407,7 +1412,7 @@ public class MWMActivity extends NvEventQueueActivity
mInfoView.setState(State.HIDDEN);
Framework.nativeStartRoutingSession(mInfoView.getMapObject().getLat(), mInfoView.getMapObject().getLon());
Framework.nativeBuildRoute(mInfoView.getMapObject().getLat(), mInfoView.getMapObject().getLon());
if (mIsLocationLocked)
{
final LocationState.RoutingInfo info = Framework.nativeGetRouteFollowingInfo();

View file

@ -764,7 +764,7 @@
{
if ([MapsAppDelegate theApp].m_locationManager.lastLocation)
{
GetFramework().StartRoutingSession([placePage pinPoint]);
GetFramework().BuildRoute([placePage pinPoint]);
[placePage setState:PlacePageStateHidden animated:YES withCallback:YES];
[self performAfterDelay:0.3 block:^{
[self.routeView setVisible:YES animated:YES];

View file

@ -1847,7 +1847,7 @@ bool Framework::IsRoutingActive() const
return m_routingSession.IsActive();
}
bool Framework::StartRoutingSession(m2::PointD const & destination)
bool Framework::BuildRoute(m2::PointD const & destination)
{
shared_ptr<State> const & state = GetLocationState();
if (!GetPlatform().HasRouting() || !state->IsModeHasPosition())
@ -1859,12 +1859,26 @@ bool Framework::StartRoutingSession(m2::PointD const & destination)
m_routingSession.BuildRoute(state->Position(), destination, [&] (Route const & route)
{
InsertRoute(route);
state->StartRoutingMode();
state->RouteBuilded();
m2::PolylineD const & poly = route.GetPoly();
m2::AnyRectD srcRect = GetNavigator().Screen().GlobalRect();
m2::RectD rect = srcRect.GetGlobalRect();
for (auto it = poly.Begin(); it != poly.End(); ++it)
rect.Add(*it);
ShowRectExVisibleScale(rect);
});
return true;
}
void Framework::StartRoutingSession()
{
GetLocationState()->StartRouteFollow();
}
BookmarkCategory * Framework::FindCategory(string const & name)
{
for (size_t i = 0; i < m_bmManager.GetBmCategoriesCount(); ++i)

View file

@ -483,7 +483,8 @@ public:
/// @name Routing mode
//@{
bool IsRoutingActive() const;
bool StartRoutingSession(m2::PointD const & destination);
bool BuildRoute(m2::PointD const & destination);
void StartRoutingSession();
void CancelRoutingSession();
void GetRouteFollowingInfo(location::FollowingInfo & info) const;

View file

@ -278,12 +278,24 @@ void State::SwitchToNextMode()
SetModeInfo(ChangeMode(m_modeInfo, newMode));
}
void State::StartRoutingMode()
void State::RouteBuilded()
{
ASSERT(GetPlatform().HasRouting(), ());
ASSERT(IsModeHasPosition(), ());
State::Mode newMode = IsRotationActive() ? RotateAndFollow : Follow;
SetModeInfo(ChangeMode(IncludeModeBit(m_modeInfo, RoutingSessionBit), newMode));
StopAllAnimations();
SetModeInfo(ChangeMode(IncludeModeBit(m_modeInfo, RoutingSessionBit), NotFollow));
}
void State::StartRouteFollow()
{
ASSERT(TestModeBit(m_modeInfo, RoutingSessionBit), ());
ASSERT(GetPlatform().HasRouting(), ());
ASSERT(IsModeHasPosition(), ());
m2::PointD const size(m_errorRadius, m_errorRadius);
m_framework->ShowRectExVisibleScale(m2::RectD(m_position - size, m_position + size),
scales::GetUpperComfortScale());
SetModeInfo(ChangeMode(m_modeInfo, IsRotationActive() ? RotateAndFollow : Follow));
}
void State::StopRoutingMode()

View file

@ -60,7 +60,8 @@ namespace location
bool IsModeHasPosition() const;
void SwitchToNextMode();
void StartRoutingMode();
void RouteBuilded();
void StartRouteFollow();
void StopRoutingMode();
int AddStateModeListener(TStateModeListener const & l);

View file

@ -445,14 +445,16 @@ namespace
m2::PointD const &, m2::PointD const &)> TScaleImplFn;
ZoomAnim(m2::PointD const & startPt, m2::PointD const & endPt,
m2::PointD const & target, TScaleImplFn const & fn, double deltaTime)
: m_targetPt(target)
, m_startPt(startPt)
, m_endPt(endPt)
, m_prevPt(startPt)
, m_fn(fn)
: m_fn(fn)
, m_startTime(0.0)
, m_deltaTime(deltaTime)
{
m_finger1Start = target + (startPt - target);
m_prevPt1 = m_finger1Start;
m_finger1End = m_finger1Start + (endPt - startPt);
m_finger2Start = target - (startPt - target);
m_prevPt2 = m_finger2Start;
m_finger2End = m_finger2Start - (endPt - startPt);
}
virtual bool IsVisual() const { return true; }
@ -471,22 +473,28 @@ namespace
double t = elapsed / m_deltaTime;
if (t > 1.0 || my::AlmostEqual(t, 1.0))
{
m_fn(m_targetPt, m_endPt, m_targetPt, m_prevPt);
m_fn(m_finger1End, m_finger2End, m_prevPt1, m_prevPt2);
End();
return;
}
m2::PointD delta = (m_endPt - m_startPt) * t;
m2::PointD current = m_startPt + delta;
m_fn(m_targetPt, current, m_targetPt, m_prevPt);
m_prevPt = current;
m2::PointD delta1 = ((m_finger1End - m_finger1Start) * t);
m2::PointD delta2 = ((m_finger2End - m_finger2Start) * t);
m2::PointD current1 = m_finger1Start + delta1;
m2::PointD current2 = m_finger2Start + delta2;
m_fn(current1, current2, m_prevPt1, m_prevPt2);
m_prevPt1 = current1;
m_prevPt2 = current2;
}
private:
m2::PointD m_targetPt;
m2::PointD m_startPt;
m2::PointD m_endPt;
m2::PointD m_prevPt;
m2::PointD m_prevPt1;
m2::PointD m_prevPt2;
m2::PointD m_finger1Start;
m2::PointD m_finger1End;
m2::PointD m_finger2Start;
m2::PointD m_finger2End;
TScaleImplFn m_fn;
double m_startTime;
@ -636,7 +644,7 @@ void Navigator::Scale(double scale)
shared_ptr<anim::Task> Navigator::ScaleAnim(double scale)
{
return ScaleToPointAnim(m_Screen.PixelRect().Center(), scale, 0.3);
return ScaleToPointAnim(m_Screen.PixelRect().Center() + m2::PointD(0.0, 300.0), scale, 0.3);
}
void Navigator::Rotate(double angle)

View file

@ -394,9 +394,17 @@ namespace qt
else if (e->modifiers() & Qt::ShiftModifier)
{
if (m_framework->IsRoutingActive())
m_framework->CancelRoutingSession();
{
static int counter = 0;
if (counter % 2 == 0)
m_framework->StartRoutingSession();
else
m_framework->CancelRoutingSession();
counter++;
}
else
m_framework->StartRoutingSession(m_framework->PtoG(pt));
m_framework->BuildRoute(m_framework->PtoG(pt));
}
if (e->modifiers() & Qt::AltModifier)
{

View file

@ -126,6 +126,7 @@ MainWindow::MainWindow() : m_locationService(CreateDesktopLocationService(*this)
#endif // NO_DOWNLOADER
m_pDrawWidget->UpdateAfterSettingsChanged();
locState->InvalidatePosition();
}
#if defined(Q_WS_WIN)