Add directions context menu
This commit is contained in:
parent
c187934ff0
commit
e288f954bc
3 changed files with 32 additions and 35 deletions
|
@ -8,6 +8,9 @@
|
|||
If you are making/correcting english translations make sure :
|
||||
1. All your modified/created strings are in the top of the file (to make easier find what's translated).
|
||||
-->
|
||||
<string name="unknown_from_location">Start location is not determined yet</string>
|
||||
<string name="unknown_location">Location is not found yet</string>
|
||||
<string name="context_menu_item_directions">Directions to here</string>
|
||||
<string name="modify_transparency">Modify transparency (0 - transparent, 255 - opaque)</string>
|
||||
<string name="confirm_interrupt_download">Do you want to interrupt file downloading?</string>
|
||||
<string name="first_time_msg">To use the major features of this application, you need some regional offline data, which you can download (use Settings, Offline Data). Afterwards, you will be able to search by address, look up POIs and find public transportation.</string>
|
||||
|
@ -628,7 +631,6 @@
|
|||
<string name="download_type_to_filter">type to filter</string>
|
||||
<string name="use_high_res_maps">High resolution display</string>
|
||||
<string name="use_high_res_maps_descr">Do not stretch (and blur) map tiles on high density displays</string>
|
||||
<string name="unknown_location">Position unknown yet</string>
|
||||
<string name="download_files">Download</string>
|
||||
<string name="context_menu_item_search_transport">Search transport</string>
|
||||
<string name="transport_searching_transport">Transport results (no target):</string>
|
||||
|
|
|
@ -247,6 +247,10 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
|
|||
// can't return from this method we are not sure if activity will be recreated or not
|
||||
}
|
||||
mapLayers.getNavigationLayer().setPointToNavigate(settings.getPointToNavigate());
|
||||
Location loc = getLastKnownLocation();
|
||||
if (loc != null && (System.currentTimeMillis() - loc.getTime()) > 30 * 1000) {
|
||||
setLocation(null);
|
||||
}
|
||||
|
||||
currentScreenOrientation = getWindow().getWindowManager().getDefaultDisplay().getOrientation();
|
||||
|
||||
|
@ -702,12 +706,13 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
|
|||
}
|
||||
}
|
||||
|
||||
// location not null!
|
||||
private void updateSpeedBearing(Location location) {
|
||||
// For network/gps it's bad way (not accurate). It's widely used for testing purposes
|
||||
// possibly keep using only for emulator case
|
||||
PointLocationLayer locationLayer = mapLayers.getLocationLayer();
|
||||
if (isRunningOnEmulator()
|
||||
&& locationLayer.getLastKnownLocation() != null && location != null) {
|
||||
&& locationLayer.getLastKnownLocation() != null) {
|
||||
if (locationLayer.getLastKnownLocation().distanceTo(location) > 3) {
|
||||
float d = location.distanceTo(locationLayer.getLastKnownLocation());
|
||||
long time = location.getTime() - locationLayer.getLastKnownLocation().getTime();
|
||||
|
@ -724,7 +729,7 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
|
|||
location.setSpeed(speed);
|
||||
}
|
||||
}
|
||||
if(locationLayer.getLastKnownLocation() != null && location != null && location.hasBearing()){
|
||||
if(locationLayer.getLastKnownLocation() != null && location.hasBearing()){
|
||||
if(locationLayer.getLastKnownLocation().distanceTo(location) > 10 && !isRunningOnEmulator()){
|
||||
location.setBearing(locationLayer.getLastKnownLocation().bearingTo(location));
|
||||
}
|
||||
|
@ -754,11 +759,13 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
|
|||
liveMonitoringHelper.insertData(location.getLatitude(), location.getLongitude(), location.getAltitude(),
|
||||
location.getSpeed(), location.getAccuracy(), location.getTime(), settings);
|
||||
}
|
||||
|
||||
updateSpeedBearing(location);
|
||||
}
|
||||
|
||||
|
||||
registerUnregisterSensor(location);
|
||||
updateSpeedBearing(location);
|
||||
|
||||
mapLayers.getLocationLayer().setLastKnownLocation(location);
|
||||
navigationInfo.setLocation(location);
|
||||
if(routingHelper.isFollowingMode()){
|
||||
|
@ -1171,8 +1178,7 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
|
|||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
final int itemId = item.getItemId();
|
||||
if (itemId == R.id.map_show_settings) {
|
||||
final Intent intentSettings = new Intent(MapActivity.this,
|
||||
SettingsActivity.class);
|
||||
final Intent intentSettings = new Intent(MapActivity.this, SettingsActivity.class);
|
||||
startActivity(intentSettings);
|
||||
return true;
|
||||
} else if (itemId == R.id.map_where_am_i) {
|
||||
|
@ -1191,44 +1197,22 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
|
|||
} else {
|
||||
Location loc = getLastKnownLocation();
|
||||
if (loc != null) {
|
||||
mapActions.getDirections(loc.getLatitude(),
|
||||
loc.getLongitude(), true);
|
||||
mapActions.getDirections(loc.getLatitude(), loc.getLongitude(), true);
|
||||
} else {
|
||||
mapActions.getDirections(mapView.getLatitude(),
|
||||
mapView.getLongitude(), true);
|
||||
mapActions.getDirections(mapView.getLatitude(), mapView.getLongitude(), true);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else if (itemId == R.id.map_layers) {
|
||||
mapLayers.openLayerSelectionDialog(mapView);
|
||||
return true;
|
||||
} else if (itemId == R.id.map_specify_point) {
|
||||
// next 2 lines replaced for Issue 493, replaced by new 3 lines
|
||||
// NavigatePointActivity dlg = new NavigatePointActivity(this);
|
||||
// dlg.showDialog();
|
||||
Intent newIntent = new Intent(MapActivity.this,
|
||||
SearchActivity.class);
|
||||
// causes wrong position caching:
|
||||
// newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
LatLon mapLoc = getMapLocation();
|
||||
newIntent.putExtra(SearchActivity.SEARCH_LAT, mapLoc.getLatitude());
|
||||
newIntent
|
||||
.putExtra(SearchActivity.SEARCH_LON, mapLoc.getLongitude());
|
||||
newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(newIntent);
|
||||
return true;
|
||||
} else if (itemId == R.id.map_mute) {
|
||||
routingHelper.getVoiceRouter().setMute(
|
||||
!routingHelper.getVoiceRouter().isMute());
|
||||
routingHelper.getVoiceRouter().setMute(!routingHelper.getVoiceRouter().isMute());
|
||||
return true;
|
||||
} else if (itemId == R.id.map_navigate_to_point) {
|
||||
if (mapLayers.getNavigationLayer().getPointToNavigate() != null) {
|
||||
if (routingHelper.isRouteCalculated()
|
||||
|| routingHelper.isFollowingMode()
|
||||
|| routingHelper.isRouteBeingCalculated()) {
|
||||
routingHelper.setFinalAndCurrentLocation(null,
|
||||
routingHelper.getCurrentLocation(),
|
||||
routingHelper.getCurrentGPXRoute());
|
||||
if (routingHelper.isRouteCalculated() || routingHelper.isFollowingMode() || routingHelper.isRouteBeingCalculated()) {
|
||||
routingHelper.setFinalAndCurrentLocation(null, routingHelper.getCurrentLocation(), routingHelper.getCurrentGPXRoute());
|
||||
} else {
|
||||
navigateToPoint(null);
|
||||
}
|
||||
|
|
|
@ -677,8 +677,9 @@ public class MapActivityActions implements DialogProvider {
|
|||
final OsmandMapTileView mapView = mapActivity.getMapView();
|
||||
|
||||
adapter.registerItem(R.string.context_menu_item_navigate_point);
|
||||
adapter.registerItem(R.string.context_menu_item_show_route);
|
||||
adapter.registerItem(R.string.context_menu_item_search);
|
||||
adapter.registerItem(R.string.context_menu_item_directions);
|
||||
adapter.registerItem(R.string.context_menu_item_show_route);
|
||||
adapter.registerItem(R.string.context_menu_item_add_favorite);
|
||||
adapter.registerItem(R.string.context_menu_item_share_location);
|
||||
|
||||
|
@ -695,7 +696,17 @@ public class MapActivityActions implements DialogProvider {
|
|||
} else if (standardId == R.string.context_menu_item_navigate_point) {
|
||||
mapActivity.navigateToPoint(new LatLon(latitude, longitude));
|
||||
} else if (standardId == R.string.context_menu_item_show_route) {
|
||||
getDirections(latitude, longitude, false);
|
||||
if(checkPointToNavigate()) {
|
||||
getDirections(latitude, longitude, false);
|
||||
}
|
||||
} else if (standardId == R.string.context_menu_item_directions) {
|
||||
Location loc = mapActivity.getLastKnownLocation();
|
||||
if (loc != null) {
|
||||
mapActivity.navigateToPoint(new LatLon(latitude, longitude));
|
||||
getDirections(loc.getLatitude(), loc.getLongitude(), true);
|
||||
} else {
|
||||
AccessibleToast.makeText(mapActivity, R.string.unknown_from_location, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
} else if (standardId == R.string.context_menu_item_search) {
|
||||
Intent intent = new Intent(mapActivity, SearchActivity.class);
|
||||
intent.putExtra(SearchActivity.SEARCH_LAT, latitude);
|
||||
|
|
Loading…
Reference in a new issue