Update menu of Route (Route has 3 options : GPX, Follow and Show; If route calculated Route -> About Route and has 3 options : Save route, About route and close
This commit is contained in:
parent
83bd84aff3
commit
795356741e
8 changed files with 91 additions and 47 deletions
|
@ -12,11 +12,9 @@
|
|||
<item android:id="@+id/map_mute" android:title="@string/menu_mute_off" android:visible="false"></item>
|
||||
|
||||
<item android:id="@+id/map_get_directions" android:title="@string/get_directions" android:icon="@android:drawable/ic_menu_directions"></item>
|
||||
<item android:id="@+id/map_save_directions" android:title="@string/menu_save_directions" android:icon="@android:drawable/ic_menu_save" visible="false"></item>
|
||||
<item android:title="@string/context_menu_item_search" android:id="@+id/map_specify_point" android:icon="@android:drawable/ic_menu_search"></item>
|
||||
|
||||
<item android:title="@string/show_gps_status" android:id="@+id/map_show_gps_status" android:icon="@android:drawable/ic_menu_compass"></item>
|
||||
<item android:title="@string/map_route_by_gpx" android:id="@+id/map_gpx_routing"></item>
|
||||
<item android:id="@+id/map_show_point_options" android:title="@string/show_point_options"></item>
|
||||
</group>
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<resources>
|
||||
<string name="gpx_navigation">GPX route</string>
|
||||
<string name="poi_query_by_name_matches_categories">Some poi categories matching to the query were found :</string>
|
||||
<string name="data_to_search_poi_not_available">Local data to search POI is not present.</string>
|
||||
<string name="poi_filter_by_name">Search by name</string>
|
||||
|
|
|
@ -83,9 +83,9 @@ public class AsyncLoadingThread extends Thread {
|
|||
progress = BusyIndicator.STATUS_BLUE;
|
||||
} else if (!requests.isEmpty()) {
|
||||
progress = BusyIndicator.STATUS_BLACK;
|
||||
} else if(poiLoadRequest != null && !poiLoadRequest.isFinished()) {
|
||||
} else if(poiLoadRequest != null && poiLoadRequest.isRunning()) {
|
||||
progress = BusyIndicator.STATUS_BLACK;
|
||||
} else if(transportLoadRequest != null && !transportLoadRequest.isFinished()) {
|
||||
} else if(transportLoadRequest != null && transportLoadRequest.isRunning()) {
|
||||
progress = BusyIndicator.STATUS_BLACK;
|
||||
}
|
||||
return progress;
|
||||
|
@ -211,7 +211,7 @@ public class AsyncLoadingThread extends Thread {
|
|||
protected double leftLongitude;
|
||||
protected double rightLongitude;
|
||||
protected boolean cancelled = false;
|
||||
protected volatile boolean finished = false;
|
||||
protected volatile boolean running = false;
|
||||
|
||||
public boolean isContains(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude) {
|
||||
boolean inside = this.topLatitude >= topLatitude && this.leftLongitude <= leftLongitude
|
||||
|
@ -226,12 +226,16 @@ public class AsyncLoadingThread extends Thread {
|
|||
this.rightLongitude = rightLongitude;
|
||||
}
|
||||
|
||||
public boolean isFinished() {
|
||||
return finished;
|
||||
public boolean isRunning() {
|
||||
return running && !cancelled;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
running = true;
|
||||
}
|
||||
|
||||
public void finish() {
|
||||
finished = true;
|
||||
running = false;
|
||||
// use downloader callback
|
||||
for (IMapDownloaderCallback c : downloader.getDownloaderCallbacks()) {
|
||||
c.tileDownloaded(null);
|
||||
|
@ -271,11 +275,15 @@ public class AsyncLoadingThread extends Thread {
|
|||
return new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (AmenityIndexRepository repository : res) {
|
||||
repository.evaluateCachedAmenities(ntopLatitude, nleftLongitude, nbottomLatitude, nrightLongitude, zoom, filter,
|
||||
AmenityLoadRequest.this);
|
||||
start();
|
||||
try {
|
||||
for (AmenityIndexRepository repository : res) {
|
||||
repository.evaluateCachedAmenities(ntopLatitude, nleftLongitude, nbottomLatitude, nrightLongitude, zoom,
|
||||
filter, AmenityLoadRequest.this);
|
||||
}
|
||||
} finally {
|
||||
finish();
|
||||
}
|
||||
finish();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -308,11 +316,15 @@ public class AsyncLoadingThread extends Thread {
|
|||
return new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (TransportIndexRepository repository : repos) {
|
||||
repository.evaluateCachedTransportStops(ntopLatitude, nleftLongitude, nbottomLatitude, nrightLongitude, zoom,
|
||||
LIMIT_TRANSPORT, TransportLoadRequest.this);
|
||||
start();
|
||||
try {
|
||||
for (TransportIndexRepository repository : repos) {
|
||||
repository.evaluateCachedTransportStops(ntopLatitude, nleftLongitude, nbottomLatitude, nrightLongitude, zoom,
|
||||
LIMIT_TRANSPORT, TransportLoadRequest.this);
|
||||
}
|
||||
} finally {
|
||||
finish();
|
||||
}
|
||||
finish();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -121,10 +121,10 @@ public class TransportIndexRepositoryBinary implements TransportIndexRepository
|
|||
@Override
|
||||
public void evaluateCachedTransportStops(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude,
|
||||
int zoom, int limit, ResultMatcher<TransportStop> matcher) {
|
||||
cTopLatitude = topLatitude + (topLatitude - bottomLatitude);
|
||||
cBottomLatitude = bottomLatitude - (topLatitude - bottomLatitude);
|
||||
cLeftLongitude = leftLongitude - (rightLongitude - leftLongitude);
|
||||
cRightLongitude = rightLongitude + (rightLongitude - leftLongitude);
|
||||
cTopLatitude = topLatitude ;
|
||||
cBottomLatitude = bottomLatitude ;
|
||||
cLeftLongitude = leftLongitude ;
|
||||
cRightLongitude = rightLongitude ;
|
||||
cZoom = zoom;
|
||||
// first of all put all entities in temp list in order to not freeze other read threads
|
||||
ArrayList<TransportStop> tempList = new ArrayList<TransportStop>();
|
||||
|
|
|
@ -961,9 +961,11 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
|
|||
muteMenu.setVisible(false);
|
||||
}
|
||||
}
|
||||
MenuItem saveMenu = menu.findItem(R.id.map_save_directions);
|
||||
if(saveMenu != null){
|
||||
saveMenu.setVisible(routingHelper.isRouteCalculated());
|
||||
MenuItem directions = menu.findItem(R.id.map_get_directions);
|
||||
if(routingHelper.isRouteCalculated()){
|
||||
directions.setTitle(R.string.show_route);
|
||||
} else {
|
||||
directions.setTitle(R.string.get_directions);
|
||||
}
|
||||
|
||||
return val;
|
||||
|
@ -984,19 +986,20 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
|
|||
startGpsStatusIntent();
|
||||
return true;
|
||||
case R.id.map_get_directions:
|
||||
Location loc = getLastKnownLocation();
|
||||
if(loc != null){
|
||||
mapActions.getDirections(loc.getLatitude(), loc.getLongitude(), true);
|
||||
if(routingHelper.isRouteCalculated()){
|
||||
mapActions.aboutRoute();
|
||||
} else {
|
||||
mapActions.getDirections(mapView.getLatitude(), mapView.getLongitude(), true);
|
||||
Location loc = getLastKnownLocation();
|
||||
if (loc != null) {
|
||||
mapActions.getDirections(loc.getLatitude(), loc.getLongitude(), true);
|
||||
} else {
|
||||
mapActions.getDirections(mapView.getLatitude(), mapView.getLongitude(), true);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
case R.id.map_layers:
|
||||
mapLayers.openLayerSelectionDialog(mapView);
|
||||
return true;
|
||||
case R.id.map_save_directions :
|
||||
mapActions.saveDirections();
|
||||
return true;
|
||||
case R.id.map_specify_point:
|
||||
// next 2 lines replaced for Issue 493, replaced by new 3 lines
|
||||
// NavigatePointActivity dlg = new NavigatePointActivity(this);
|
||||
|
@ -1025,9 +1028,6 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
|
|||
}
|
||||
mapView.refreshMap();
|
||||
return true;
|
||||
case R.id.map_gpx_routing:
|
||||
mapActions.navigateUsingGPX();
|
||||
return true;
|
||||
case R.id.map_show_point_options:
|
||||
contextMenuPoint(mapView.getLatitude(), mapView.getLongitude());
|
||||
return true;
|
||||
|
@ -1140,7 +1140,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
|
|||
if(standardId == R.string.context_menu_item_navigate_point){
|
||||
navigateToPoint(new LatLon(latitude, longitude));
|
||||
} else if(standardId == R.string.context_menu_item_show_route){
|
||||
mapActions. getDirections(latitude, longitude, false);
|
||||
mapActions.getDirections(latitude, longitude, false);
|
||||
} else if(standardId == R.string.context_menu_item_search){
|
||||
Intent intent = new Intent(MapActivity.this, SearchActivity.class);
|
||||
intent.putExtra(SearchActivity.SEARCH_LAT, latitude);
|
||||
|
|
|
@ -303,6 +303,30 @@ public class MapActivityActions {
|
|||
}
|
||||
|
||||
|
||||
protected void aboutRoute() {
|
||||
DialogInterface.OnClickListener showRoute = new DialogInterface.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Intent intent = new Intent(mapActivity, ShowRouteInfoActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
mapActivity.startActivity(intent);
|
||||
}
|
||||
};
|
||||
DialogInterface.OnClickListener saveDirections = new DialogInterface.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
saveDirections();
|
||||
}
|
||||
};
|
||||
Builder builder = new AlertDialog.Builder(mapActivity);
|
||||
builder.setTitle(R.string.show_route);
|
||||
builder.setMessage(mapActivity.getRoutingHelper().getGeneralRouteInformation());
|
||||
builder.setPositiveButton(R.string.default_buttons_save, saveDirections);
|
||||
builder.setNeutralButton(R.string.route_about, showRoute);
|
||||
builder.setNegativeButton(R.string.close, null);
|
||||
builder.show();
|
||||
}
|
||||
|
||||
protected void getDirections(final double lat, final double lon, boolean followEnabled){
|
||||
MapActivityLayers mapLayers = mapActivity.getMapLayers();
|
||||
final OsmandSettings settings = OsmandSettings.getOsmandSettings(mapActivity);
|
||||
|
@ -393,12 +417,13 @@ public class MapActivityActions {
|
|||
getMyApplication().showDialogInitializingCommandPlayer(mapActivity);
|
||||
}
|
||||
};
|
||||
DialogInterface.OnClickListener showRoute = new DialogInterface.OnClickListener(){
|
||||
|
||||
|
||||
DialogInterface.OnClickListener useGpxNavigation = new DialogInterface.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Intent intent = new Intent(mapActivity, ShowRouteInfoActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
mapActivity.startActivity(intent);
|
||||
ApplicationMode mode = getAppMode(buttons, settings);
|
||||
navigateUsingGPX(mode);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -406,9 +431,7 @@ public class MapActivityActions {
|
|||
if (followEnabled) {
|
||||
builder.setTitle(R.string.follow_route);
|
||||
builder.setPositiveButton(R.string.follow, followCall);
|
||||
if (routingHelper.isRouterEnabled() && routingHelper.isRouteCalculated()) {
|
||||
builder.setNeutralButton(R.string.route_about, showRoute);
|
||||
}
|
||||
builder.setNeutralButton(R.string.gpx_navigation, useGpxNavigation);
|
||||
builder.setNegativeButton(R.string.only_show, onlyShowCall);
|
||||
} else {
|
||||
builder.setTitle(R.string.show_route);
|
||||
|
@ -433,7 +456,7 @@ public class MapActivityActions {
|
|||
return location;
|
||||
}
|
||||
|
||||
public void navigateUsingGPX() {
|
||||
public void navigateUsingGPX(final ApplicationMode appMode) {
|
||||
final LatLon endForRouting = mapActivity.getPointToNavigate();
|
||||
final MapActivityLayers mapLayers = mapActivity.getMapLayers();
|
||||
final OsmandSettings settings = OsmandSettings.getOsmandSettings(mapActivity);
|
||||
|
@ -481,6 +504,11 @@ public class MapActivityActions {
|
|||
mapLayers.getNavigationLayer().setPointToNavigate(point);
|
||||
}
|
||||
}
|
||||
// change global settings
|
||||
boolean changed = settings.APPLICATION_MODE.set(appMode);
|
||||
if (changed) {
|
||||
mapActivity.updateApplicationModeSettings();
|
||||
}
|
||||
mapActivity.getMapView().refreshMap();
|
||||
if(endPoint != null){
|
||||
settings.FOLLOW_THE_ROUTE.set(true);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.osmand.plus.activities;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
@ -370,6 +371,14 @@ public class RoutingHelper {
|
|||
return 0;
|
||||
}
|
||||
|
||||
public String getGeneralRouteInformation(){
|
||||
int dist = getLeftDistance();
|
||||
int hours = getLeftTime() / (60 * 60);
|
||||
int minutes = (getLeftTime() / 60) % 60;
|
||||
return MessageFormat.format(context.getString(R.string.route_general_information), OsmAndFormatter.getFormattedDistance(dist, context),
|
||||
hours, minutes);
|
||||
}
|
||||
|
||||
public Location getLocationFromRouteDirection(RouteDirectionInfo i){
|
||||
if(i.routePointOffset < routeNodes.size()){
|
||||
return routeNodes.get(i.routePointOffset);
|
||||
|
|
|
@ -60,11 +60,7 @@ public class ShowRouteInfoActivity extends ListActivity {
|
|||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
int dist = helper.getLeftDistance();
|
||||
int hours = helper.getLeftTime() / (60 * 60);
|
||||
int minutes = (helper.getLeftTime() / 60) % 60;
|
||||
header.setText(MessageFormat.format(getString(R.string.route_general_information), OsmAndFormatter.getFormattedDistance(dist, this),
|
||||
hours, minutes));
|
||||
header.setText(helper.getGeneralRouteInformation());
|
||||
float f = Math.min(dm.widthPixels/(dm.density*160),dm.heightPixels/(dm.density*160));
|
||||
if (f >= 3) {
|
||||
// large screen
|
||||
|
|
Loading…
Reference in a new issue