Add descriptions to intermediate points (waypoints)
This commit is contained in:
parent
e80304a7f1
commit
981ddd553d
5 changed files with 86 additions and 11 deletions
|
@ -4,13 +4,19 @@
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent" android:orientation="vertical" >
|
android:layout_height="fill_parent" android:orientation="vertical" >
|
||||||
|
|
||||||
<TextView android:id="@+id/TextView" android:layout_width="fill_parent" android:textSize="18dp" android:layout_height="wrap_content" android:gravity="center" android:layout_marginTop="10dp" android:layout_marginBottom="10dp" android:text="@string/recalculate_route_to_your_location"></TextView>
|
<TextView android:layout_width="fill_parent" android:textSize="18dp" android:layout_height="wrap_content" android:gravity="center" android:layout_marginTop="10dp" android:layout_marginBottom="10dp" android:text="@string/recalculate_route_to_your_location"></TextView>
|
||||||
<LinearLayout android:id="@+id/LinearLayout" android:layout_width="fill_parent" android:gravity="center" android:layout_height="wrap_content" android:orientation="horizontal">
|
<LinearLayout android:id="@+id/LinearLayout" android:layout_width="fill_parent" android:gravity="center" android:layout_height="wrap_content" android:orientation="horizontal">
|
||||||
<ToggleButton android:contentDescription="@string/app_mode_car" android:textOn="" android:textOff="" android:id="@+id/CarButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/car_icon" android:layout_marginLeft="10dp" />
|
<ToggleButton android:contentDescription="@string/app_mode_car" android:textOn="" android:textOff="" android:id="@+id/CarButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/car_icon" android:layout_marginLeft="10dp" />
|
||||||
<ToggleButton android:contentDescription="@string/app_mode_bicycle" android:textOn="" android:textOff="" android:id="@+id/BicycleButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:background="@drawable/bicycle_icon"/>
|
<ToggleButton android:contentDescription="@string/app_mode_bicycle" android:textOn="" android:textOff="" android:id="@+id/BicycleButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:background="@drawable/bicycle_icon"/>
|
||||||
<ToggleButton android:contentDescription="@string/app_mode_pedestrian" android:textOn="" android:textOff="" android:id="@+id/PedestrianButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:background="@drawable/pedestrian_icon"/>
|
<ToggleButton android:contentDescription="@string/app_mode_pedestrian" android:textOn="" android:textOff="" android:id="@+id/PedestrianButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:background="@drawable/pedestrian_icon"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<ScrollView android:layout_height="wrap_content" android:layout_width="fill_parent"
|
||||||
|
android:layout_marginTop="5dp" android:layout_marginBottom="5dp" android:layout_marginLeft="10dp">
|
||||||
|
<TextView android:id="@+id/TextView" android:gravity="left" android:textSize="18dp"
|
||||||
|
android:layout_height="wrap_content" android:layout_width="fill_parent"
|
||||||
|
/>
|
||||||
|
</ScrollView>
|
||||||
<CheckBox android:id="@+id/OptimalCheckox" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/non_optimal_route_calculation"/>
|
<CheckBox android:id="@+id/OptimalCheckox" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/non_optimal_route_calculation"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,10 @@
|
||||||
1. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
1. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||||
-->
|
-->
|
||||||
|
<string name="route_descr_lat_lon">Lat %1$.3f lon %2$.3f</string>
|
||||||
|
<string name="route_descr_current_location">Current location</string>
|
||||||
|
<string name="route_descr_from_to">From %1$s\nTo %2$s</string>
|
||||||
|
<string name="route_descr_from_to_via">From : %1$s\nVia : %2$s\nTo : %3$s</string>
|
||||||
<string name="no_buildings_found">No buildings found.</string>
|
<string name="no_buildings_found">No buildings found.</string>
|
||||||
<string name="incremental_search_city">Search city incrementally.</string>
|
<string name="incremental_search_city">Search city incrementally.</string>
|
||||||
<string name="search_villages_and_postcodes">Search villages/postcode </string>
|
<string name="search_villages_and_postcodes">Search villages/postcode </string>
|
||||||
|
|
|
@ -1057,11 +1057,15 @@ public class OsmandSettings {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean insertIntermediatePoint(double latitude, double longitude, String historyDescription, int index) {
|
public boolean insertIntermediatePoint(double latitude, double longitude, String historyDescription, int index,
|
||||||
|
boolean navigate) {
|
||||||
List<LatLon> ps = getIntermediatePoints();
|
List<LatLon> ps = getIntermediatePoints();
|
||||||
List<String> ds = getIntermediatePointDescriptions(ps.size());
|
List<String> ds = getIntermediatePointDescriptions(ps.size());
|
||||||
ps.add(index, new LatLon(latitude, longitude));
|
ps.add(index, new LatLon(latitude, longitude));
|
||||||
ds.add(index, historyDescription);
|
ds.add(index, historyDescription);
|
||||||
|
if(navigate) {
|
||||||
|
globalPreferences.edit().putString(POINT_NAVIGATE_ROUTE, "true").commit();
|
||||||
|
}
|
||||||
if (historyDescription != null) {
|
if (historyDescription != null) {
|
||||||
SearchHistoryHelper.getInstance().addNewItemToHistory(latitude, longitude, historyDescription, ctx);
|
SearchHistoryHelper.getInstance().addNewItemToHistory(latitude, longitude, historyDescription, ctx);
|
||||||
}
|
}
|
||||||
|
@ -1106,7 +1110,7 @@ public class OsmandSettings {
|
||||||
|
|
||||||
public boolean setPointToNavigate(double latitude, double longitude, boolean navigate, String historyDescription) {
|
public boolean setPointToNavigate(double latitude, double longitude, boolean navigate, String historyDescription) {
|
||||||
boolean add = globalPreferences.edit().putFloat(POINT_NAVIGATE_LAT, (float) latitude).putFloat(POINT_NAVIGATE_LON, (float) longitude).commit();
|
boolean add = globalPreferences.edit().putFloat(POINT_NAVIGATE_LAT, (float) latitude).putFloat(POINT_NAVIGATE_LON, (float) longitude).commit();
|
||||||
globalPreferences.edit().putString(POINT_NAVIGATE_DESCRIPTION, historyDescription);
|
globalPreferences.edit().putString(POINT_NAVIGATE_DESCRIPTION, historyDescription).commit();
|
||||||
if(navigate) {
|
if(navigate) {
|
||||||
globalPreferences.edit().putString(POINT_NAVIGATE_ROUTE, "true").commit();
|
globalPreferences.edit().putString(POINT_NAVIGATE_ROUTE, "true").commit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1021,7 +1021,8 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
|
||||||
if(intermediate < 0) {
|
if(intermediate < 0) {
|
||||||
settings.setPointToNavigate(point.getLatitude(), point.getLongitude(), null);
|
settings.setPointToNavigate(point.getLatitude(), point.getLongitude(), null);
|
||||||
} else {
|
} else {
|
||||||
settings.insertIntermediatePoint(point.getLatitude(), point.getLongitude(), null, intermediate);
|
settings.insertIntermediatePoint(point.getLatitude(), point.getLongitude(), null,
|
||||||
|
intermediate, false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
settings.clearPointToNavigate();
|
settings.clearPointToNavigate();
|
||||||
|
@ -1054,6 +1055,7 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
|
||||||
return mapLayers.getNavigationLayer().getIntermediatePoints();
|
return mapLayers.getNavigationLayer().getIntermediatePoints();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public LatLon getFirstIntermediatePoint(){
|
public LatLon getFirstIntermediatePoint(){
|
||||||
List<LatLon> ip = mapLayers.getNavigationLayer().getIntermediatePoints();
|
List<LatLon> ip = mapLayers.getNavigationLayer().getIntermediatePoints();
|
||||||
if(ip.size() > 0) {
|
if(ip.size() > 0) {
|
||||||
|
|
|
@ -11,6 +11,7 @@ import java.util.List;
|
||||||
|
|
||||||
import net.londatiga.android.ActionItem;
|
import net.londatiga.android.ActionItem;
|
||||||
import net.londatiga.android.QuickAction;
|
import net.londatiga.android.QuickAction;
|
||||||
|
import net.osmand.Algoritms;
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.CallbackWithObject;
|
import net.osmand.CallbackWithObject;
|
||||||
import net.osmand.FavouritePoint;
|
import net.osmand.FavouritePoint;
|
||||||
|
@ -471,6 +472,48 @@ public class MapActivityActions implements DialogProvider {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getRoutePointDescription(double lat, double lon) {
|
||||||
|
return mapActivity.getString(R.string.route_descr_lat_lon, lat, lon);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRoutePointDescription(LatLon l, String d) {
|
||||||
|
if(d != null && d.length() > 0) {
|
||||||
|
return d.replace(':', ' ');
|
||||||
|
}
|
||||||
|
if(l != null) {
|
||||||
|
return mapActivity.getString(R.string.route_descr_lat_lon, l.getLatitude(), l.getLongitude());
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String generateRouteDescription(Location fromOrCurrent, LatLon to) {
|
||||||
|
String from = mapActivity.getString(R.string.route_descr_current_location);
|
||||||
|
if (fromOrCurrent != null && fromOrCurrent.getProvider().equals("map")) {
|
||||||
|
from = getRoutePointDescription(fromOrCurrent.getLatitude(),
|
||||||
|
fromOrCurrent.getLongitude());
|
||||||
|
}
|
||||||
|
|
||||||
|
String tos;
|
||||||
|
if(to == null) {
|
||||||
|
tos = getRoutePointDescription(mapActivity.getPointToNavigate(),
|
||||||
|
settings.getPointNavigateDescription());
|
||||||
|
} else {
|
||||||
|
tos = getRoutePointDescription(to, "");
|
||||||
|
}
|
||||||
|
int sz = mapActivity.getIntermediatePoints().size();
|
||||||
|
if(sz == 0) {
|
||||||
|
return mapActivity.getString(R.string.route_descr_from_to, from, tos);
|
||||||
|
} else {
|
||||||
|
String via = "";
|
||||||
|
List<String> names = settings.getIntermediatePointDescriptions(sz);
|
||||||
|
for (int i = 0; i < sz ; i++) {
|
||||||
|
via += "\n - " + getRoutePointDescription(mapActivity.getIntermediatePoints().get(i),
|
||||||
|
names.get(i));
|
||||||
|
}
|
||||||
|
return mapActivity.getString(R.string.route_descr_from_to_via, from, via, tos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void getDirections(final Location fromOrCurrent, final LatLon to, boolean gpxRouteEnabled) {
|
public void getDirections(final Location fromOrCurrent, final LatLon to, boolean gpxRouteEnabled) {
|
||||||
|
|
||||||
|
@ -484,6 +527,9 @@ public class MapActivityActions implements DialogProvider {
|
||||||
buttons[ApplicationMode.CAR.ordinal()] = (ToggleButton) view.findViewById(R.id.CarButton);
|
buttons[ApplicationMode.CAR.ordinal()] = (ToggleButton) view.findViewById(R.id.CarButton);
|
||||||
buttons[ApplicationMode.BICYCLE.ordinal()] = (ToggleButton) view.findViewById(R.id.BicycleButton);
|
buttons[ApplicationMode.BICYCLE.ordinal()] = (ToggleButton) view.findViewById(R.id.BicycleButton);
|
||||||
buttons[ApplicationMode.PEDESTRIAN.ordinal()] = (ToggleButton) view.findViewById(R.id.PedestrianButton);
|
buttons[ApplicationMode.PEDESTRIAN.ordinal()] = (ToggleButton) view.findViewById(R.id.PedestrianButton);
|
||||||
|
|
||||||
|
TextView tv = ((TextView) view.findViewById(R.id.TextView));
|
||||||
|
tv.setText(generateRouteDescription(fromOrCurrent, to));
|
||||||
ApplicationMode appMode = settings.getApplicationMode();
|
ApplicationMode appMode = settings.getApplicationMode();
|
||||||
if(appMode == ApplicationMode.DEFAULT) {
|
if(appMode == ApplicationMode.DEFAULT) {
|
||||||
appMode = ApplicationMode.CAR;
|
appMode = ApplicationMode.CAR;
|
||||||
|
@ -1125,17 +1171,29 @@ public class MapActivityActions implements DialogProvider {
|
||||||
public void openIntermediatePointsDialog(){
|
public void openIntermediatePointsDialog(){
|
||||||
Builder builder = new AlertDialog.Builder(mapActivity);
|
Builder builder = new AlertDialog.Builder(mapActivity);
|
||||||
final ArrayList<LatLon> intermediates = new ArrayList<LatLon>(mapActivity.getIntermediatePoints());
|
final ArrayList<LatLon> intermediates = new ArrayList<LatLon>(mapActivity.getIntermediatePoints());
|
||||||
|
final ArrayList<String> names = new ArrayList<String>(settings.getIntermediatePointDescriptions(
|
||||||
|
intermediates.size()));
|
||||||
final int targetPointInd = mapActivity.getPointToNavigate() == null ? -1 : intermediates.size();
|
final int targetPointInd = mapActivity.getPointToNavigate() == null ? -1 : intermediates.size();
|
||||||
if(mapActivity.getPointToNavigate() != null) {
|
if(mapActivity.getPointToNavigate() != null) {
|
||||||
intermediates.add(mapActivity.getPointToNavigate());
|
intermediates.add(mapActivity.getPointToNavigate());
|
||||||
|
if(settings.getPointNavigateDescription() != null) {
|
||||||
|
names.add(settings.getPointNavigateDescription());
|
||||||
|
} else {
|
||||||
|
names.add("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
final List<String> intermediateNames = new ArrayList<String>();
|
final List<String> intermediateNames = new ArrayList<String>();
|
||||||
double lat = mapActivity.getMapView().getLatitude();
|
double lat = mapActivity.getMapView().getLatitude();
|
||||||
double lon = mapActivity.getMapView().getLongitude();
|
double lon = mapActivity.getMapView().getLongitude();
|
||||||
for (int i = 0; i < intermediates.size(); i++) {
|
for (int i = 0; i < intermediates.size(); i++) {
|
||||||
double meters = MapUtils.getDistance(intermediates.get(i), lat, lon);
|
double meters = MapUtils.getDistance(intermediates.get(i), lat, lon);
|
||||||
intermediateNames.add((i+1)+". " +
|
String distString = OsmAndFormatter.getFormattedDistance((float) meters, mapActivity);
|
||||||
mapActivity.getString(R.string.target_point, OsmAndFormatter.getFormattedDistance((float) meters, mapActivity))+ "");
|
String nm = (i+1)+". " + mapActivity.getString(R.string.target_point, distString);
|
||||||
|
String descr = names.get(i);
|
||||||
|
if(names.get(i) != null && descr.trim().length() > 0) {
|
||||||
|
nm += "\n" + descr;
|
||||||
|
}
|
||||||
|
intermediateNames.add(nm);
|
||||||
}
|
}
|
||||||
final boolean[] checkedIntermediates = new boolean[intermediateNames.size()];
|
final boolean[] checkedIntermediates = new boolean[intermediateNames.size()];
|
||||||
ListAdapter listadapter = new ArrayAdapter<String>(mapActivity, R.layout.layers_list_activity_item, R.id.title,
|
ListAdapter listadapter = new ArrayAdapter<String>(mapActivity, R.layout.layers_list_activity_item, R.id.title,
|
||||||
|
@ -1328,12 +1386,13 @@ public class MapActivityActions implements DialogProvider {
|
||||||
app.getSettings().setPointToNavigate(lat, lon, true, name);
|
app.getSettings().setPointToNavigate(lat, lon, true, name);
|
||||||
} else if(which == 2) {
|
} else if(which == 2) {
|
||||||
int sz = app.getSettings().getIntermediatePoints().size();
|
int sz = app.getSettings().getIntermediatePoints().size();
|
||||||
app.getSettings().insertIntermediatePoint(lat, lon, name, sz);
|
// app.getSettings().insertIntermediatePoint(lat, lon, name, sz);
|
||||||
//LatLon pt = app.getSettings().getPointToNavigate();
|
LatLon pt = app.getSettings().getPointToNavigate();
|
||||||
// app.getSettings().insertIntermediatePoint(pt.getLatitude(), pt.getLongitude(), null, sz);
|
app.getSettings().insertIntermediatePoint(pt.getLatitude(), pt.getLongitude(),
|
||||||
//app.getSettings().setPointToNavigate(lat, lon, true, name);
|
app.getSettings().getPointNavigateDescription(), sz, true);
|
||||||
|
app.getSettings().setPointToNavigate(lat, lon, true, name);
|
||||||
} else {
|
} else {
|
||||||
app.getSettings().insertIntermediatePoint(lat, lon, name, 0);
|
app.getSettings().insertIntermediatePoint(lat, lon, name, 0, true);
|
||||||
}
|
}
|
||||||
MapActivity.launchMapActivityMoveToTop(activity);
|
MapActivity.launchMapActivityMoveToTop(activity);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue