Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrachytski <siarhei.rachytski@gmail.com>2013-01-08 19:31:58 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:48:25 +0300
commite3bdd13df0ea887575f7819cae2496a2bf6e485e (patch)
tree48d2455259b89ec2c021e03184fc5bf0214762a1
parent72cfd1c8efaf51e5004b33de3501fb0899c0a080 (diff)
fixed "My Position" button processing logic.
-rw-r--r--android/jni/com/mapswithme/maps/LocationState.cpp14
-rw-r--r--android/src/com/mapswithme/maps/LocationState.java3
-rw-r--r--android/src/com/mapswithme/maps/MWMActivity.java29
-rw-r--r--iphone/Maps/Classes/MapViewController.mm53
-rw-r--r--map/location_state.cpp22
-rw-r--r--map/location_state.hpp1
6 files changed, 88 insertions, 34 deletions
diff --git a/android/jni/com/mapswithme/maps/LocationState.cpp b/android/jni/com/mapswithme/maps/LocationState.cpp
index 4efefa851a..c0ec5c7fb6 100644
--- a/android/jni/com/mapswithme/maps/LocationState.cpp
+++ b/android/jni/com/mapswithme/maps/LocationState.cpp
@@ -43,6 +43,20 @@ extern "C"
ls->StartCompassFollowing();
}
+ JNIEXPORT jboolean JNICALL
+ Java_com_mapswithme_maps_LocationState_isCentered(JNIEnv * env, jobject thiz)
+ {
+ shared_ptr<location::State> ls = g_framework->NativeFramework()->GetInformationDisplay().locationState();
+ return ls->IsCentered();
+ }
+
+ JNIEXPORT void JNICALL
+ Java_com_mapswithme_maps_LocationState_animateToPositionAndEnqueueLocationProcessMode(JNIEnv * env, jobject thiz, jint mode)
+ {
+ shared_ptr<location::State> ls = g_framework->NativeFramework()->GetInformationDisplay().locationState();
+ ls->AnimateToPositionAndEnqueueLocationProcessMode(static_cast<location::ELocationProcessMode>(mode));
+ }
+
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_LocationState_stopCompassFollowing(JNIEnv * env,
jobject thiz)
diff --git a/android/src/com/mapswithme/maps/LocationState.java b/android/src/com/mapswithme/maps/LocationState.java
index a830d8ca08..13735ea08d 100644
--- a/android/src/com/mapswithme/maps/LocationState.java
+++ b/android/src/com/mapswithme/maps/LocationState.java
@@ -32,6 +32,9 @@ public class LocationState
public native boolean hasCompass();
public native boolean isFirstPosition();
+ public native boolean isCentered();
+
+ public native void animateToPositionAndEnqueueLocationProcessMode(int mode);
public native void turnOff();
public native boolean isVisible();
diff --git a/android/src/com/mapswithme/maps/MWMActivity.java b/android/src/com/mapswithme/maps/MWMActivity.java
index f0e7301a42..4b7fc236f0 100644
--- a/android/src/com/mapswithme/maps/MWMActivity.java
+++ b/android/src/com/mapswithme/maps/MWMActivity.java
@@ -251,23 +251,30 @@ public class MWMActivity extends NvEventQueueActivity implements LocationService
}
else
{
- if (mApplication.isProVersion())
+ if (!state.isCentered())
{
- // Check if we need to start compass following.
- if (state.hasCompass())
+ state.animateToPositionAndEnqueueLocationProcessMode(LocationState.LOCATION_CENTER_ONLY);
+ v.setSelected(true);
+ return;
+ }
+ else
+ if (mApplication.isProVersion())
{
- if (state.getCompassProcessMode() != LocationState.COMPASS_FOLLOW)
+ // Check if we need to start compass following.
+ if (state.hasCompass())
{
- state.startCompassFollowing();
+ if (state.getCompassProcessMode() != LocationState.COMPASS_FOLLOW)
+ {
+ state.startCompassFollowing();
- v.setBackgroundResource(R.drawable.myposition_button_follow);
- v.setSelected(true);
- return;
+ v.setBackgroundResource(R.drawable.myposition_button_follow);
+ v.setSelected(true);
+ return;
+ }
+ else
+ state.stopCompassFollowing();
}
- else
- state.stopCompassFollowing();
}
- }
}
// Turn off location search:
diff --git a/iphone/Maps/Classes/MapViewController.mm b/iphone/Maps/Classes/MapViewController.mm
index 808c6b572e..4a1da152d2 100644
--- a/iphone/Maps/Classes/MapViewController.mm
+++ b/iphone/Maps/Classes/MapViewController.mm
@@ -130,38 +130,45 @@
}
else
{
- if (GetPlatform().IsPro())
+ if (!ls->IsCentered())
{
- if (ls->HasCompass())
+ ls->AnimateToPositionAndEnqueueLocationProcessMode(location::ELocationCenterOnly);
+ m_myPositionButton.selected = YES;
+ return;
+ }
+ else
+ if (GetPlatform().IsPro())
{
- if (ls->GetCompassProcessMode() != location::ECompassFollow)
+ if (ls->HasCompass())
{
- if (ls->IsCentered())
- ls->StartCompassFollowing();
+ if (ls->GetCompassProcessMode() != location::ECompassFollow)
+ {
+ if (ls->IsCentered())
+ ls->StartCompassFollowing();
+ else
+ ls->AnimateToPositionAndEnqueueFollowing();
+
+ m_myPositionButton.selected = YES;
+ [m_myPositionButton setImage:[UIImage imageNamed:@"location-follow.png"] forState:UIControlStateSelected];
+
+ return;
+ }
else
- ls->AnimateToPositionAndEnqueueFollowing();
-
- m_myPositionButton.selected = YES;
- [m_myPositionButton setImage:[UIImage imageNamed:@"location-follow.png"] forState:UIControlStateSelected];
-
- return;
- }
- else
- {
- anim::Controller *animController = f.GetAnimController();
- animController->Lock();
+ {
+ anim::Controller *animController = f.GetAnimController();
+ animController->Lock();
- f.GetInformationDisplay().locationState()->StopCompassFollowing();
+ f.GetInformationDisplay().locationState()->StopCompassFollowing();
- double startAngle = f.GetNavigator().Screen().GetAngle();
- double endAngle = 0;
+ double startAngle = f.GetNavigator().Screen().GetAngle();
+ double endAngle = 0;
- f.GetAnimator().RotateScreen(startAngle, endAngle);
+ f.GetAnimator().RotateScreen(startAngle, endAngle);
- animController->Unlock();
+ animController->Unlock();
- f.Invalidate();
- }
+ f.Invalidate();
+ }
}
}
}
diff --git a/map/location_state.cpp b/map/location_state.cpp
index 6b9ec8c699..d3a86ed2a0 100644
--- a/map/location_state.cpp
+++ b/map/location_state.cpp
@@ -567,6 +567,28 @@ namespace location
controller->Unlock();
}
+ void State::AnimateToPositionAndEnqueueLocationProcessMode(location::ELocationProcessMode mode)
+ {
+ anim::Controller * controller = m_framework->GetAnimController();
+
+ controller->Lock();
+
+ m2::PointD startPt = m_framework->GetNavigator().Screen().GetOrg();
+ m2::PointD endPt = Position();
+
+ ScreenBase const & s = m_framework->GetNavigator().Screen();
+ double speed = ComputeMoveSpeed(startPt, endPt, s);
+
+ shared_ptr<MoveScreenTask> const & t = m_framework->GetAnimator().MoveScreen(startPt, endPt, speed);
+
+ t->Lock();
+ t->AddCallback(anim::Task::EEnded, bind(&State::SetIsCentered, this, true));
+ t->AddCallback(anim::Task::EEnded, bind(&State::SetLocationProcessMode, this, mode));
+ t->Unlock();
+
+ controller->Unlock();
+ }
+
void State::StartCompassFollowing()
{
SetCompassProcessMode(ECompassFollow);
diff --git a/map/location_state.hpp b/map/location_state.hpp
index 6a73d66b58..969ec8ae7e 100644
--- a/map/location_state.hpp
+++ b/map/location_state.hpp
@@ -161,6 +161,7 @@ namespace location
void AnimateToPosition();
void AnimateToPositionAndEnqueueFollowing();
+ void AnimateToPositionAndEnqueueLocationProcessMode(location::ELocationProcessMode mode);
void CheckCompassRotation();
void CheckCompassFollowing();