diff --git a/android/src/com/mapswithme/maps/MwmActivity.java b/android/src/com/mapswithme/maps/MwmActivity.java index 2ba269e3ec..647be81d27 100644 --- a/android/src/com/mapswithme/maps/MwmActivity.java +++ b/android/src/com/mapswithme/maps/MwmActivity.java @@ -833,7 +833,14 @@ public class MwmActivity extends BaseMwmFragmentActivity PermissionsResult result = PermissionsUtils.computePermissionsResult(permissions, grantResults); if (result.isLocationGranted()) + { myPositionClick(); + } + else + { + Utils.showSnackbar(getActivity(), findViewById(R.id.coordinator), findViewById(R.id.menu_frame), + R.string.location_is_disabled_long_text); + } } @Override @@ -2041,12 +2048,7 @@ public class MwmActivity extends BaseMwmFragmentActivity if (!PermissionsUtils.isLocationGranted(getApplicationContext())) { PermissionsUtils.requestLocationPermission(MwmActivity.this, REQ_CODE_LOCATION_PERMISSION); - if (!PermissionsUtils.isLocationGranted(getApplicationContext())) - { - Utils.showSnackbar(getActivity(), findViewById(R.id.coordinator), findViewById(R.id.menu_frame), - R.string.enable_location_services); - return; - } + return; } myPositionClick(); diff --git a/android/src/com/mapswithme/maps/SplashActivity.java b/android/src/com/mapswithme/maps/SplashActivity.java index 89b7a211d6..46f2dddcf0 100644 --- a/android/src/com/mapswithme/maps/SplashActivity.java +++ b/android/src/com/mapswithme/maps/SplashActivity.java @@ -15,6 +15,7 @@ import androidx.appcompat.app.AppCompatActivity; import com.mapswithme.maps.base.BaseActivity; import com.mapswithme.maps.base.BaseActivityDelegate; import com.mapswithme.maps.location.LocationHelper; +import com.mapswithme.util.Config; import com.mapswithme.util.Counters; import com.mapswithme.util.PermissionsUtils; import com.mapswithme.util.ThemeUtils; @@ -89,7 +90,7 @@ public class SplashActivity extends AppCompatActivity implements BaseActivity mBaseDelegate.onResume(); if (mCanceled) return; - if (!PermissionsUtils.isLocationGranted(this)) + if (!Config.isLocationRequested() && !PermissionsUtils.isLocationGranted(this)) { PermissionsUtils.requestLocationPermission(SplashActivity.this, REQUEST_PERMISSIONS); return; @@ -146,11 +147,7 @@ public class SplashActivity extends AppCompatActivity implements BaseActivity if (requestCode != REQUEST_PERMISSIONS) throw new AssertionError("Unexpected requestCode"); super.onRequestPermissionsResult(requestCode, permissions, grantResults); - if (!PermissionsUtils.isLocationGranted(this)) - { - showFatalErrorDialog(R.string.enable_location_services, R.string.location_is_disabled_long_text); - return; - } + Config.setLocationRequested(); // No-op here - onResume() calls init(); } @@ -166,7 +163,7 @@ public class SplashActivity extends AppCompatActivity implements BaseActivity return; } - if (Counters.isFirstLaunch(this)) + if (Counters.isFirstLaunch(this) && PermissionsUtils.isLocationGranted(this)) { LocationHelper.INSTANCE.onEnteredIntoFirstRun(); if (!LocationHelper.INSTANCE.isActive()) diff --git a/android/src/com/mapswithme/maps/base/BaseMwmFragmentActivity.java b/android/src/com/mapswithme/maps/base/BaseMwmFragmentActivity.java index d51ae6e125..16ec066706 100644 --- a/android/src/com/mapswithme/maps/base/BaseMwmFragmentActivity.java +++ b/android/src/com/mapswithme/maps/base/BaseMwmFragmentActivity.java @@ -21,7 +21,6 @@ import com.mapswithme.maps.MwmApplication; import com.mapswithme.maps.R; import com.mapswithme.maps.SplashActivity; import com.mapswithme.util.Config; -import com.mapswithme.util.PermissionsUtils; import com.mapswithme.util.ThemeUtils; import com.mapswithme.util.UiUtils; import com.mapswithme.util.Utils; @@ -217,12 +216,6 @@ public abstract class BaseMwmFragmentActivity extends AppCompatActivity protected void onResume() { super.onResume(); - if (!PermissionsUtils.isLocationGranted(getApplicationContext())) - { - goToSplashScreen(null); - return; - } - mBaseDelegate.onResume(); } diff --git a/android/src/com/mapswithme/maps/location/LocationHelper.java b/android/src/com/mapswithme/maps/location/LocationHelper.java index ae4f95e1e4..fb3ed44706 100644 --- a/android/src/com/mapswithme/maps/location/LocationHelper.java +++ b/android/src/com/mapswithme/maps/location/LocationHelper.java @@ -146,7 +146,7 @@ public enum LocationHelper implements Initializable private final LocationState.LocationPendingTimeoutListener mLocationPendingTimeoutListener = () -> { stop(); - if (LocationUtils.areLocationServicesTurnedOn(mContext)) + if (PermissionsUtils.isLocationGranted(mContext) && LocationUtils.areLocationServicesTurnedOn(mContext)) notifyLocationNotFound(); }; diff --git a/android/src/com/mapswithme/util/Config.java b/android/src/com/mapswithme/util/Config.java index a7d5ebf991..426228635c 100644 --- a/android/src/com/mapswithme/util/Config.java +++ b/android/src/com/mapswithme/util/Config.java @@ -31,7 +31,7 @@ public final class Config private static final String KEY_PREF_USE_GS = "UseGoogleServices"; private static final String KEY_MISC_DISCLAIMER_ACCEPTED = "IsDisclaimerApproved"; - private static final String KEY_MISC_KITKAT_MIGRATED = "KitKatMigrationCompleted"; + private static final String KEY_MISC_LOCATION_REQUESTED = "LocationRequested"; private static final String KEY_MISC_UI_THEME = "UiTheme"; private static final String KEY_MISC_UI_THEME_SETTINGS = "UiThemeSettings"; private static final String KEY_MISC_USE_MOBILE_DATA = "UseMobileData"; @@ -198,14 +198,14 @@ public final class Config setBool(KEY_MISC_DISCLAIMER_ACCEPTED); } - public static boolean isKitKatMigrationComplete() + public static boolean isLocationRequested() { - return getBool(KEY_MISC_KITKAT_MIGRATED); + return getBool(KEY_MISC_LOCATION_REQUESTED); } - public static void setKitKatMigrationComplete() + public static void setLocationRequested() { - setBool(KEY_MISC_KITKAT_MIGRATED); + setBool(KEY_MISC_LOCATION_REQUESTED); } @NonNull