From f8b92e7ec9b9ec81db4ad9e31f6b4ae2a340c1e3 Mon Sep 17 00:00:00 2001 From: Alexander Marchuk Date: Tue, 26 Apr 2016 14:25:56 +0300 Subject: [PATCH] [location][android] fix: MyPosition button restored. --- .../src/com/mapswithme/maps/LocationState.java | 1 + android/src/com/mapswithme/maps/MwmActivity.java | 12 ++++-------- .../maps/routing/ResultCodesHelper.java | 15 ++++++++++++--- .../maps/widget/menu/MyPositionButton.java | 1 + drape_frontend/my_position_controller.cpp | 7 +++++-- 5 files changed, 23 insertions(+), 13 deletions(-) diff --git a/android/src/com/mapswithme/maps/LocationState.java b/android/src/com/mapswithme/maps/LocationState.java index 0a3885a639..092ad52234 100644 --- a/android/src/com/mapswithme/maps/LocationState.java +++ b/android/src/com/mapswithme/maps/LocationState.java @@ -7,6 +7,7 @@ public enum LocationState /// These values should correspond to values of /// location::EMyPositionMode defined in platform/location.hpp public static final int PENDING_POSITION = 0; + public static final int NOT_FOLLOW_NO_POSITION = 1; public static final int NOT_FOLLOW = 2; public static final int FOLLOW = 3; public static final int FOLLOW_AND_ROTATE = 4; diff --git a/android/src/com/mapswithme/maps/MwmActivity.java b/android/src/com/mapswithme/maps/MwmActivity.java index 724c03d872..944467b706 100644 --- a/android/src/com/mapswithme/maps/MwmActivity.java +++ b/android/src/com/mapswithme/maps/MwmActivity.java @@ -844,6 +844,7 @@ public class MwmActivity extends BaseMwmFragmentActivity super.onResume(); LocationState.INSTANCE.setMyPositionModeListener(this); + refreshLocationState(); mSearchController.refreshToolbar(); @@ -983,18 +984,13 @@ public class MwmActivity extends BaseMwmFragmentActivity mLocationPredictor.pause(); } - private void refreshLocationState(int newMode) + private void refreshLocationState() { + int newMode = LocationState.INSTANCE.getLocationStateMode(); mMainMenu.getMyPositionButton().update(newMode); - switch (newMode) - { - case LocationState.PENDING_POSITION: + if (newMode != LocationState.NOT_FOLLOW_NO_POSITION) resumeLocation(); - break; - default: - break; - } } @Override diff --git a/android/src/com/mapswithme/maps/routing/ResultCodesHelper.java b/android/src/com/mapswithme/maps/routing/ResultCodesHelper.java index ecc77e345f..b5a3d67876 100644 --- a/android/src/com/mapswithme/maps/routing/ResultCodesHelper.java +++ b/android/src/com/mapswithme/maps/routing/ResultCodesHelper.java @@ -6,6 +6,7 @@ import android.util.Pair; import java.util.ArrayList; import java.util.List; +import com.mapswithme.maps.LocationState; import com.mapswithme.maps.MwmApplication; import com.mapswithme.maps.R; @@ -33,9 +34,17 @@ class ResultCodesHelper switch (errorCode) { case NO_POSITION: - titleRes = R.string.dialog_routing_check_gps; - messages.add(resources.getString(R.string.dialog_routing_error_location_not_found)); - messages.add(resources.getString(R.string.dialog_routing_location_turn_wifi)); + if (LocationState.INSTANCE.getLocationStateMode() == LocationState.NOT_FOLLOW_NO_POSITION) + { + titleRes = R.string.dialog_routing_location_turn_on; + messages.add(resources.getString(R.string.dialog_routing_location_unknown_turn_on)); + } + else + { + titleRes = R.string.dialog_routing_check_gps; + messages.add(resources.getString(R.string.dialog_routing_error_location_not_found)); + messages.add(resources.getString(R.string.dialog_routing_location_turn_wifi)); + } break; case INCONSISTENT_MWM_ROUTE: case ROUTING_FILE_NOT_EXIST: diff --git a/android/src/com/mapswithme/maps/widget/menu/MyPositionButton.java b/android/src/com/mapswithme/maps/widget/menu/MyPositionButton.java index 9be78e5115..c0ad951343 100644 --- a/android/src/com/mapswithme/maps/widget/menu/MyPositionButton.java +++ b/android/src/com/mapswithme/maps/widget/menu/MyPositionButton.java @@ -41,6 +41,7 @@ public class MyPositionButton image = mButton.getResources().getDrawable(ThemeUtils.getResource(mButton.getContext(), R.attr.myPositionButtonAnimation)); break; + case LocationState.NOT_FOLLOW_NO_POSITION: case LocationState.NOT_FOLLOW: image = Graphics.tint(mButton.getContext(), R.drawable.ic_not_follow); break; diff --git a/drape_frontend/my_position_controller.cpp b/drape_frontend/my_position_controller.cpp index 27992cf31c..ebeeb08fc5 100644 --- a/drape_frontend/my_position_controller.cpp +++ b/drape_frontend/my_position_controller.cpp @@ -330,8 +330,11 @@ void MyPositionController::OnLocationUpdate(location::GpsInfo const & info, bool void MyPositionController::LoseLocation() { - ChangeMode(location::NotFollowNoPosition); - SetIsVisible(false); + if (m_mode != location::NotFollowNoPosition) + { + ChangeMode(location::NotFollowNoPosition); + SetIsVisible(false); + } } void MyPositionController::OnCompassUpdate(location::CompassInfo const & info, ScreenBase const & screen)