fixed "My Position" button processing logic.

This commit is contained in:
rachytski 2013-01-08 18:31:58 +03:00 committed by Alex Zolotarev
parent 72cfd1c8ef
commit e3bdd13df0
6 changed files with 92 additions and 38 deletions

View file

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

View file

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

View file

@ -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())
{
if (state.getCompassProcessMode() != LocationState.COMPASS_FOLLOW)
{
state.startCompassFollowing();
v.setBackgroundResource(R.drawable.myposition_button_follow);
v.setSelected(true);
return;
}
else
state.stopCompassFollowing();
}
state.animateToPositionAndEnqueueLocationProcessMode(LocationState.LOCATION_CENTER_ONLY);
v.setSelected(true);
return;
}
else
if (mApplication.isProVersion())
{
// Check if we need to start compass following.
if (state.hasCompass())
{
if (state.getCompassProcessMode() != LocationState.COMPASS_FOLLOW)
{
state.startCompassFollowing();
v.setBackgroundResource(R.drawable.myposition_button_follow);
v.setSelected(true);
return;
}
else
state.stopCompassFollowing();
}
}
}
// Turn off location search:

View file

@ -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();
{
anim::Controller *animController = f.GetAnimController();
animController->Lock();
m_myPositionButton.selected = YES;
[m_myPositionButton setImage:[UIImage imageNamed:@"location-follow.png"] forState:UIControlStateSelected];
return;
}
else
{
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();
}
}
}
}

View file

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

View file

@ -161,6 +161,7 @@ namespace location
void AnimateToPosition();
void AnimateToPositionAndEnqueueFollowing();
void AnimateToPositionAndEnqueueLocationProcessMode(location::ELocationProcessMode mode);
void CheckCompassRotation();
void CheckCompassFollowing();