| 373 | } |
| 374 | |
| 375 | void MyPositionController::NextMode(ScreenBase const & screen) |
| 376 | { |
| 377 | // When the app is awaiting location (indicator is active) and the user presses on the indicator, location updates |
| 378 | // will be stopped and goes into NotFollowNoPosition state. The next press on the indicator will start location |
| 379 | // updates again. |
| 380 | if (IsWaitingForLocation()) |
| 381 | { |
| 382 | m_desiredInitMode = location::Follow; |
| 383 | ChangeMode(location::NotFollowNoPosition); |
| 384 | return; |
| 385 | } |
| 386 | |
| 387 | // Start looking for location. |
| 388 | if (m_mode == location::NotFollowNoPosition) |
| 389 | { |
| 390 | ChangeMode(location::PendingPosition); |
| 391 | |
| 392 | if (!m_isPositionAssigned) |
| 393 | { |
| 394 | // This is the first user location request (button touch) after controller's initialization |
| 395 | // with some previous not Follow state. The new mode will be Follow to center on the position. |
| 396 | m_desiredInitMode = location::Follow; |
| 397 | } |
| 398 | return; |
| 399 | } |
| 400 | |
| 401 | // Calculate preferred zoom level. |
| 402 | int const currentZoom = GetZoomLevel(screen); |
| 403 | int preferredZoomLevel = kDoNotChangeZoom; |
| 404 | if (currentZoom < kZoomThreshold) |
| 405 | preferredZoomLevel = std::min(GetZoomLevel(screen, m_position, m_errorRadius), kMaxScaleZoomLevel); |
| 406 | |
| 407 | // In routing not-follow -> follow-and-rotate, otherwise not-follow -> follow. |
| 408 | if (m_mode == location::NotFollow) |
| 409 | { |
| 410 | if (IsRotationAvailable() && m_lastFollowMode == location::FollowAndRotate) |
| 411 | ChangeMode(location::FollowAndRotate, true); |
| 412 | else |
| 413 | ChangeMode(location::Follow, true); |
| 414 | |
| 415 | UpdateViewport(preferredZoomLevel); |
| 416 | return; |
| 417 | } |
| 418 | |
| 419 | // From follow mode we transit to follow-and-rotate if compass is available or |
| 420 | // routing is enabled. |
| 421 | if (m_mode == location::Follow) |
| 422 | { |
| 423 | if (IsRotationAvailable() || m_isInRouting) |
| 424 | { |
| 425 | ChangeMode(location::FollowAndRotate, true); |
| 426 | UpdateViewport(preferredZoomLevel); |
| 427 | } |
| 428 | return; |
| 429 | } |
| 430 | |
| 431 | // From follow-and-rotate mode we can transit to follow mode. |
| 432 | if (m_mode == location::FollowAndRotate) |
no test coverage detected