diff --git a/android/jni/com/mapswithme/maps/LocationState.cpp b/android/jni/com/mapswithme/maps/LocationState.cpp index b76929accb..60d94841bb 100644 --- a/android/jni/com/mapswithme/maps/LocationState.cpp +++ b/android/jni/com/mapswithme/maps/LocationState.cpp @@ -101,4 +101,18 @@ extern "C" shared_ptr ls = g_framework->NativeFramework()->GetInformationDisplay().locationState(); return ls->isVisible(); } + + JNIEXPORT void JNICALL + Java_com_mapswithme_maps_LocationState_onStartLocation(JNIEnv * env, jobject thiz) + { + shared_ptr ls = g_framework->NativeFramework()->GetInformationDisplay().locationState(); + ls->OnStartLocation(); + } + + JNIEXPORT void JNICALL + Java_com_mapswithme_maps_LocationState_onStopLocation(JNIEnv * env, jobject thiz) + { + shared_ptr ls = g_framework->NativeFramework()->GetInformationDisplay().locationState(); + ls->OnStopLocation(); + } } diff --git a/android/src/com/mapswithme/maps/LocationState.java b/android/src/com/mapswithme/maps/LocationState.java index c5f3af4acc..280d12682b 100644 --- a/android/src/com/mapswithme/maps/LocationState.java +++ b/android/src/com/mapswithme/maps/LocationState.java @@ -25,6 +25,9 @@ public class LocationState public native int addCompassStatusListener(Object l); public native void removeCompassStatusListener(int slotID); + public native void onStartLocation(); + public native void onStopLocation(); + public native boolean hasPosition(); public native boolean hasCompass(); diff --git a/map/framework.cpp b/map/framework.cpp index 5a9f755ef1..ee76a48597 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -78,6 +78,16 @@ void Framework::RemoveMap(string const & datFile) m_model.RemoveMap(datFile); } +void Framework::StartLocation() +{ + m_informationDisplay.locationState()->OnStartLocation(); +} + +void Framework::StopLocation() +{ + m_informationDisplay.locationState()->OnStopLocation(); +} + void Framework::OnLocationError(location::TLocationError error) {} diff --git a/map/framework.hpp b/map/framework.hpp index cf0c6d2520..265caf58f3 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -206,6 +206,10 @@ public: /// @name GPS location updates routine. //@{ + + void StartLocation(); + void StopLocation(); + void OnLocationError(location::TLocationError error); void OnLocationUpdate(location::GpsInfo const & info); void OnCompassUpdate(location::CompassInfo const & info); diff --git a/map/location_state.cpp b/map/location_state.cpp index afc378e4bd..4dd10d1d98 100644 --- a/map/location_state.cpp +++ b/map/location_state.cpp @@ -78,6 +78,11 @@ namespace location return m_hasCompass; } + bool State::IsFirstPosition() const + { + return m_isFirstPosition; + } + void State::TurnOff() { m_hasPosition = false; @@ -112,6 +117,8 @@ namespace location void State::OnLocationUpdate(location::GpsInfo const & info) { + m_isFirstPosition = false; + m2::RectD rect = MercatorBounds::MetresToXY(info.m_longitude, info.m_latitude, info.m_horizontalAccuracy); @@ -564,6 +571,21 @@ namespace location return slotID; } + void State::OnStartLocation() + { + SetCompassProcessMode(location::ECompassDoNothing); + SetLocationProcessMode(location::ELocationCenterAndScale); + m_isFirstPosition = true; + } + + void State::OnStopLocation() + { + SetLocationProcessMode(location::ELocationDoNothing); + SetCompassProcessMode(location::ECompassDoNothing); + m_isFirstPosition = false; + TurnOff(); + } + void State::RemoveCompassStatusListener(int slotID) { m_compassStatusListeners.erase(slotID); diff --git a/map/location_state.hpp b/map/location_state.hpp index 38977e7fe6..8d3eacd6ea 100644 --- a/map/location_state.hpp +++ b/map/location_state.hpp @@ -64,6 +64,7 @@ namespace location bool m_hasPosition; bool m_hasCompass; bool m_isCentered; + bool m_isFirstPosition; ELocationProcessMode m_locationProcessMode; ECompassProcessMode m_compassProcessMode; @@ -132,6 +133,7 @@ namespace location bool HasPosition() const; bool HasCompass() const; + bool IsFirstPosition() const; ELocationProcessMode LocationProcessMode() const; void SetLocationProcessMode(ELocationProcessMode mode); @@ -144,6 +146,9 @@ namespace location void StartCompassFollowing(); void StopCompassFollowing(); + void OnStartLocation(); + void OnStopLocation(); + int AddCompassStatusListener(TCompassStatusListener const & l); void RemoveCompassStatusListener(int slotID);