commit
60b62b6c7d
4 changed files with 53 additions and 21 deletions
|
@ -11,6 +11,7 @@
|
||||||
Thx - Hardy
|
Thx - Hardy
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
<string name="ask_for_location_permission">Please give OsmAnd permission for location to continue.</string>
|
||||||
<string name="thank_you_for_feedback">Thank you for feedback</string>
|
<string name="thank_you_for_feedback">Thank you for feedback</string>
|
||||||
<string name="poi_cannot_be_found">Node or way cannot be found.</string>
|
<string name="poi_cannot_be_found">Node or way cannot be found.</string>
|
||||||
<string name="search_no_results_feedback">No search results?\nGive us feedback</string>
|
<string name="search_no_results_feedback">No search results?\nGive us feedback</string>
|
||||||
|
|
|
@ -1703,6 +1703,17 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 1);
|
}, 1);
|
||||||
|
} else if (requestCode == MapActivityActions.REQUEST_LOCATION_FOR_DIRECTIONS_NAVIGATION_PERMISSION
|
||||||
|
&& grantResults.length > 0 && permissions.length > 0
|
||||||
|
&& Manifest.permission.ACCESS_FINE_LOCATION.equals(permissions[0])) {
|
||||||
|
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||||
|
LatLon latLon = getContextMenu().getLatLon();
|
||||||
|
if (latLon != null) {
|
||||||
|
mapActions.enterDirectionsFromPoint(latLon.getLatitude(), latLon.getLongitude());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
app.showToastMessage(R.string.ask_for_location_permission);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package net.osmand.plus.activities;
|
package net.osmand.plus.activities;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
@ -7,6 +8,7 @@ import android.content.Intent;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.v4.app.ActivityCompat;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -83,6 +85,8 @@ public class MapActivityActions implements DialogProvider {
|
||||||
public static final String KEY_NAME = "name";
|
public static final String KEY_NAME = "name";
|
||||||
|
|
||||||
public static final String KEY_ZOOM = "zoom";
|
public static final String KEY_ZOOM = "zoom";
|
||||||
|
|
||||||
|
public static final int REQUEST_LOCATION_FOR_DIRECTIONS_NAVIGATION_PERMISSION = 203;
|
||||||
|
|
||||||
// Constants for determining the order of items in the additional actions context menu
|
// Constants for determining the order of items in the additional actions context menu
|
||||||
public static final int DIRECTIONS_FROM_ITEM_ORDER = 1000;
|
public static final int DIRECTIONS_FROM_ITEM_ORDER = 1000;
|
||||||
|
@ -351,16 +355,12 @@ public class MapActivityActions implements DialogProvider {
|
||||||
} else if (standardId == R.string.context_menu_item_search) {
|
} else if (standardId == R.string.context_menu_item_search) {
|
||||||
mapActivity.showQuickSearch(latitude, longitude);
|
mapActivity.showQuickSearch(latitude, longitude);
|
||||||
} else if (standardId == R.string.context_menu_item_directions_from) {
|
} else if (standardId == R.string.context_menu_item_directions_from) {
|
||||||
mapActivity.getContextMenu().hide();
|
if (OsmAndLocationProvider.isLocationPermissionAvailable(mapActivity)) {
|
||||||
if (getMyApplication().getTargetPointsHelper().getPointToNavigate() == null) {
|
enterDirectionsFromPoint(latitude, longitude);
|
||||||
setFirstMapMarkerAsTarget();
|
} else if (!ActivityCompat.shouldShowRequestPermissionRationale(mapActivity, Manifest.permission.ACCESS_FINE_LOCATION)) {
|
||||||
}
|
mapActivity.getMyApplication().showToastMessage(R.string.ask_for_location_permission);
|
||||||
if (!mapActivity.getRoutingHelper().isFollowingMode() && !mapActivity.getRoutingHelper().isRoutePlanningMode()) {
|
|
||||||
enterRoutePlanningMode(new LatLon(latitude, longitude),
|
|
||||||
mapActivity.getContextMenu().getPointDescription());
|
|
||||||
} else {
|
} else {
|
||||||
getMyApplication().getTargetPointsHelper().setStartPoint(new LatLon(latitude, longitude),
|
ActivityCompat.requestPermissions(mapActivity, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_LOCATION_FOR_DIRECTIONS_NAVIGATION_PERMISSION);
|
||||||
true, mapActivity.getContextMenu().getPointDescription());
|
|
||||||
}
|
}
|
||||||
} else if (standardId == R.string.measurement_tool) {
|
} else if (standardId == R.string.measurement_tool) {
|
||||||
mapActivity.getContextMenu().close();
|
mapActivity.getContextMenu().close();
|
||||||
|
@ -371,6 +371,20 @@ public class MapActivityActions implements DialogProvider {
|
||||||
actionsBottomSheetDialogFragment.show(mapActivity.getSupportFragmentManager(), AdditionalActionsBottomSheetDialogFragment.TAG);
|
actionsBottomSheetDialogFragment.show(mapActivity.getSupportFragmentManager(), AdditionalActionsBottomSheetDialogFragment.TAG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void enterDirectionsFromPoint(final double latitude, final double longitude) {
|
||||||
|
mapActivity.getContextMenu().hide();
|
||||||
|
if (getMyApplication().getTargetPointsHelper().getPointToNavigate() == null) {
|
||||||
|
setFirstMapMarkerAsTarget();
|
||||||
|
}
|
||||||
|
if (!mapActivity.getRoutingHelper().isFollowingMode() && !mapActivity.getRoutingHelper().isRoutePlanningMode()) {
|
||||||
|
enterRoutePlanningMode(new LatLon(latitude, longitude),
|
||||||
|
mapActivity.getContextMenu().getPointDescription());
|
||||||
|
} else {
|
||||||
|
getMyApplication().getTargetPointsHelper().setStartPoint(new LatLon(latitude, longitude),
|
||||||
|
true, mapActivity.getContextMenu().getPointDescription());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setGPXRouteParams(GPXFile result) {
|
public void setGPXRouteParams(GPXFile result) {
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
mapActivity.getRoutingHelper().setGpxParams(null);
|
mapActivity.getRoutingHelper().setGpxParams(null);
|
||||||
|
|
|
@ -442,6 +442,8 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
this.hasTargets = hasTargets;
|
this.hasTargets = hasTargets;
|
||||||
if (OsmAndLocationProvider.isLocationPermissionAvailable(mapActivity)) {
|
if (OsmAndLocationProvider.isLocationPermissionAvailable(mapActivity)) {
|
||||||
onNavigationClick();
|
onNavigationClick();
|
||||||
|
} else if (!ActivityCompat.shouldShowRequestPermissionRationale(mapActivity, Manifest.permission.ACCESS_FINE_LOCATION)) {
|
||||||
|
app.showToastMessage(R.string.ask_for_location_permission);
|
||||||
} else {
|
} else {
|
||||||
ActivityCompat.requestPermissions(mapActivity,
|
ActivityCompat.requestPermissions(mapActivity,
|
||||||
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
|
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
|
||||||
|
@ -1310,18 +1312,22 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
||||||
if (requestCode == REQUEST_LOCATION_FOR_NAVIGATION_PERMISSION
|
if (grantResults.length > 0) {
|
||||||
&& grantResults.length > 0
|
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||||
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
switch (requestCode) {
|
||||||
onNavigationClick();
|
case REQUEST_LOCATION_FOR_NAVIGATION_PERMISSION:
|
||||||
} else if (requestCode == REQUEST_LOCATION_FOR_NAVIGATION_FAB_PERMISSION
|
onNavigationClick();
|
||||||
&& grantResults.length > 0
|
break;
|
||||||
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
case REQUEST_LOCATION_FOR_NAVIGATION_FAB_PERMISSION:
|
||||||
navigateButton();
|
navigateButton();
|
||||||
} else if (requestCode == REQUEST_LOCATION_FOR_ADD_DESTINATION_PERMISSION
|
break;
|
||||||
&& grantResults.length > 0
|
case REQUEST_LOCATION_FOR_ADD_DESTINATION_PERMISSION:
|
||||||
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
addDestination(requestedLatLon);
|
||||||
addDestination(requestedLatLon);
|
break;
|
||||||
|
}
|
||||||
|
} else if (grantResults[0] == PackageManager.PERMISSION_DENIED) {
|
||||||
|
app.showToastMessage(R.string.ask_for_location_permission);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue