Fix remarks
This commit is contained in:
parent
6cd53e5510
commit
da8b4602cb
6 changed files with 23 additions and 35 deletions
|
@ -1,5 +1,6 @@
|
|||
package net.osmand.plus;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Build.VERSION;
|
||||
import android.os.Build.VERSION_CODES;
|
||||
import java.util.ArrayList;
|
||||
|
@ -17,7 +18,6 @@ import net.osmand.binary.GeocodingUtilities.GeocodingResult;
|
|||
import net.osmand.binary.RouteDataObject;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.QuadPoint;
|
||||
import net.osmand.plus.OsmandSettings.OsmandPreference;
|
||||
import net.osmand.plus.TargetPointsHelper.TargetPoint;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.router.RouteSegmentResult;
|
||||
|
@ -975,4 +975,12 @@ public class OsmAndLocationProvider implements SensorEventListener {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void requestFineLocationPermissionIfNeeded(Activity activity) {
|
||||
if (!OsmAndLocationProvider.isLocationPermissionAvailable(activity)) {
|
||||
ActivityCompat.requestPermissions(activity,
|
||||
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
|
||||
OsmAndLocationProvider.REQUEST_LOCATION_PERMISSION);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2009,7 +2009,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
}
|
||||
|
||||
if (requestCode == DataStorageFragment.PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE
|
||||
&& grantResults.length > 0 && permissions.length > 0
|
||||
&& permissions.length > 0
|
||||
&& Manifest.permission.WRITE_EXTERNAL_STORAGE.equals(permissions[0])) {
|
||||
if (grantResults[0] != PackageManager.PERMISSION_GRANTED) {
|
||||
Toast.makeText(this,
|
||||
|
@ -2017,12 +2017,12 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
} else if (requestCode == DownloadActivity.PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE
|
||||
&& grantResults.length > 0 && permissions.length > 0
|
||||
&& permissions.length > 0
|
||||
&& Manifest.permission.WRITE_EXTERNAL_STORAGE.equals(permissions[0])) {
|
||||
permissionAsked = true;
|
||||
permissionGranted = grantResults[0] == PackageManager.PERMISSION_GRANTED;
|
||||
} else if (requestCode == FirstUsageWizardFragment.FIRST_USAGE_REQUEST_WRITE_EXTERNAL_STORAGE_PERMISSION
|
||||
&& grantResults.length > 0 && permissions.length > 0
|
||||
&& permissions.length > 0
|
||||
&& Manifest.permission.WRITE_EXTERNAL_STORAGE.equals(permissions[0])) {
|
||||
|
||||
new Timer().schedule(new TimerTask() {
|
||||
|
@ -2045,7 +2045,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
}
|
||||
}, 1);
|
||||
} else if (requestCode == MapActivityActions.REQUEST_LOCATION_FOR_DIRECTIONS_NAVIGATION_PERMISSION
|
||||
&& grantResults.length > 0 && permissions.length > 0
|
||||
&& permissions.length > 0
|
||||
&& Manifest.permission.ACCESS_FINE_LOCATION.equals(permissions[0])) {
|
||||
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
LatLon latLon = getContextMenu().getLatLon();
|
||||
|
|
|
@ -158,14 +158,9 @@ public class FavouritesBottomSheetMenuFragment extends MenuBottomSheetDialogFrag
|
|||
targetPointsHelper.setStartPoint(ll, true, point.getPointDescription(app));
|
||||
break;
|
||||
case TARGET:
|
||||
if (OsmAndLocationProvider.isLocationPermissionAvailable(getContext())) {
|
||||
if (getActivity() != null) {
|
||||
targetPointsHelper.navigateToPoint(ll, true, -1, point.getPointDescription(app));
|
||||
} else {
|
||||
if (getActivity() != null) {
|
||||
ActivityCompat.requestPermissions(getActivity(),
|
||||
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
|
||||
OsmAndLocationProvider.REQUEST_LOCATION_PERMISSION);
|
||||
}
|
||||
OsmAndLocationProvider.requestFineLocationPermissionIfNeeded(getActivity());
|
||||
}
|
||||
break;
|
||||
case INTERMEDIATE:
|
||||
|
|
|
@ -445,13 +445,8 @@ public class AddPointBottomSheetDialog extends MenuBottomSheetDialogFragment {
|
|||
targetPointsHelper.setStartPoint(ll, true, name);
|
||||
break;
|
||||
case TARGET:
|
||||
if (OsmAndLocationProvider.isLocationPermissionAvailable(getContext())) {
|
||||
targetPointsHelper.navigateToPoint(ll, true, -1, name);
|
||||
} else {
|
||||
ActivityCompat.requestPermissions(mapActivity,
|
||||
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
|
||||
OsmAndLocationProvider.REQUEST_LOCATION_PERMISSION);
|
||||
}
|
||||
targetPointsHelper.navigateToPoint(ll, true, -1, name);
|
||||
OsmAndLocationProvider.requestFineLocationPermissionIfNeeded(mapActivity);
|
||||
break;
|
||||
case INTERMEDIATE:
|
||||
targetPointsHelper.navigateToPoint(ll, true, targetPointsHelper.getIntermediatePoints().size(), name);
|
||||
|
|
|
@ -284,13 +284,8 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
|
|||
targetPointsHelper.setStartPoint(latLon, true, pd);
|
||||
break;
|
||||
case TARGET:
|
||||
if (OsmAndLocationProvider.isLocationPermissionAvailable(app)) {
|
||||
targetPointsHelper.navigateToPoint(latLon, true, -1, pd);
|
||||
} else {
|
||||
ActivityCompat.requestPermissions(mapActivity,
|
||||
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
|
||||
OsmAndLocationProvider.REQUEST_LOCATION_PERMISSION);
|
||||
}
|
||||
targetPointsHelper.navigateToPoint(latLon, true, -1, pd);
|
||||
OsmAndLocationProvider.requestFineLocationPermissionIfNeeded(mapActivity);
|
||||
break;
|
||||
case INTERMEDIATE:
|
||||
targetPointsHelper.navigateToPoint(latLon, true, targetPointsHelper.getIntermediatePoints().size(), pd);
|
||||
|
|
|
@ -64,15 +64,10 @@ public class HomeWorkCard extends BaseCard {
|
|||
if (point == null) {
|
||||
AddPointBottomSheetDialog.showInstance(mapActivity, pointType);
|
||||
} else {
|
||||
if (OsmAndLocationProvider.isLocationPermissionAvailable(app)) {
|
||||
mapActivity.getMyApplication().getTargetPointsHelper()
|
||||
.navigateToPoint(new LatLon(point.getLatitude(), point.getLongitude()),
|
||||
true, -1, point.getPointDescription(mapActivity));
|
||||
} else {
|
||||
ActivityCompat.requestPermissions(mapActivity,
|
||||
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
|
||||
OsmAndLocationProvider.REQUEST_LOCATION_PERMISSION);
|
||||
}
|
||||
mapActivity.getMyApplication().getTargetPointsHelper().navigateToPoint(
|
||||
new LatLon(point.getLatitude(), point.getLongitude()),
|
||||
true, -1, point.getPointDescription(app));
|
||||
OsmAndLocationProvider.requestFineLocationPermissionIfNeeded(mapActivity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue