From a3c95a6209f014c4dc30f01a13c514d6cf00104f Mon Sep 17 00:00:00 2001 From: Alexander Marchuk Date: Mon, 16 May 2016 18:31:36 +0300 Subject: [PATCH] [android] fix: Do not show dialog about disabled GPS after "stop" pressed. --- android/src/com/mapswithme/maps/LocationState.java | 8 +++++++- android/src/com/mapswithme/maps/MwmActivity.java | 8 ++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/android/src/com/mapswithme/maps/LocationState.java b/android/src/com/mapswithme/maps/LocationState.java index 83852e9f0e..a11e93973f 100644 --- a/android/src/com/mapswithme/maps/LocationState.java +++ b/android/src/com/mapswithme/maps/LocationState.java @@ -28,12 +28,18 @@ public enum LocationState */ public static boolean isTurnedOn() { - return getMode() > NOT_FOLLOW_NO_POSITION; + return isTurnedOn(getMode()); + } + + public static boolean isTurnedOn(int mode) + { + return (mode > NOT_FOLLOW_NO_POSITION); } public static int getMode() { MwmApplication.get().initNativeCore(); return INSTANCE.nativeGetMode(); + } } diff --git a/android/src/com/mapswithme/maps/MwmActivity.java b/android/src/com/mapswithme/maps/MwmActivity.java index d8ffbe5148..78e83a9456 100644 --- a/android/src/com/mapswithme/maps/MwmActivity.java +++ b/android/src/com/mapswithme/maps/MwmActivity.java @@ -770,6 +770,9 @@ public class MwmActivity extends BaseMwmFragmentActivity { LocationHelper.nativeOnLocationError(errorCode); + if (sLocationStopped) + return; + if (errorCode == LocationHelper.ERROR_DENIED) { Intent intent = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS); @@ -841,7 +844,7 @@ public class MwmActivity extends BaseMwmFragmentActivity mLocationPredictor.myPositionModeChanged(newMode); mMainMenu.getMyPositionButton().update(newMode); - if (newMode != LocationState.NOT_FOLLOW_NO_POSITION) + if (LocationState.isTurnedOn(newMode)) sLocationStopped = false; switch (newMode) @@ -883,6 +886,7 @@ public class MwmActivity extends BaseMwmFragmentActivity @Override public void onClick(DialogInterface dialog, int which) { + sLocationStopped = false; LocationState.INSTANCE.nativeSwitchToNextMode(); } }).show(); @@ -976,7 +980,7 @@ public class MwmActivity extends BaseMwmFragmentActivity } }); } - if (!mFirstStart && !SinglePageNewsFragment.showOn(this)) + else if (!SinglePageNewsFragment.showOn(this)) { if (ViralFragment.shouldDisplay()) new ViralFragment().show(getSupportFragmentManager(), "");