[android]: Fix "Ask every time" location option

Signed-off-by: Roman Tsisyk <roman@tsisyk.com>
This commit is contained in:
Roman Tsisyk 2021-03-27 18:00:03 +03:00
parent 9dbd990787
commit 2b3d594435
2 changed files with 6 additions and 12 deletions

View file

@ -2638,12 +2638,13 @@ public class MwmActivity extends BaseMwmFragmentActivity
{
if (!PermissionsUtils.isLocationGranted(getApplicationContext()))
{
if (PermissionsUtils.isLocationExplanationNeeded(MwmActivity.this))
PermissionsUtils.requestLocationPermission(MwmActivity.this, REQ_CODE_LOCATION_PERMISSION);
else
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;
R.string.enable_location_services);
return;
}
}
myPositionClick();

View file

@ -16,7 +16,6 @@ import java.util.Map;
import static android.Manifest.permission.ACCESS_COARSE_LOCATION;
import static android.Manifest.permission.ACCESS_FINE_LOCATION;
import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE;
import static androidx.core.app.ActivityCompat.shouldShowRequestPermissionRationale;
public final class PermissionsUtils
{
@ -53,12 +52,6 @@ public final class PermissionsUtils
return checkPermissions(context).isLocationGranted();
}
public static boolean isLocationExplanationNeeded(@NonNull Activity activity)
{
return shouldShowRequestPermissionRationale(activity, ACCESS_COARSE_LOCATION)
|| shouldShowRequestPermissionRationale(activity, ACCESS_FINE_LOCATION);
}
public static boolean isExternalStorageGranted(@NonNull Context context)
{
return checkPermissions(context).isExternalStorageGranted();