Updated avoid roads dialog
This commit is contained in:
parent
10535946c1
commit
b39fce5cc1
2 changed files with 44 additions and 45 deletions
|
@ -9,6 +9,7 @@
|
||||||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
3. 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="avoid_roads_msg">You can change route by selecting roads to avoid</string>
|
||||||
<string name="rendering_value__name">Default</string>
|
<string name="rendering_value__name">Default</string>
|
||||||
<string name="speak_pedestrian">Announce pedestrian crosswalks</string>
|
<string name="speak_pedestrian">Announce pedestrian crosswalks</string>
|
||||||
<string name="rendering_attr_roadStyle_name">Road style</string>
|
<string name="rendering_attr_roadStyle_name">Road style</string>
|
||||||
|
|
|
@ -48,7 +48,6 @@ public class AvoidSpecificRoads {
|
||||||
|
|
||||||
public ArrayAdapter<RouteDataObject> createAdapter(final MapActivity ctx) {
|
public ArrayAdapter<RouteDataObject> createAdapter(final MapActivity ctx) {
|
||||||
final ArrayList<RouteDataObject> points = new ArrayList<RouteDataObject>();
|
final ArrayList<RouteDataObject> points = new ArrayList<RouteDataObject>();
|
||||||
points.add(new RouteDataObject((RouteRegion) null));
|
|
||||||
points.addAll(missingRoads);
|
points.addAll(missingRoads);
|
||||||
final LatLon mapLocation = ctx.getMapLocation();
|
final LatLon mapLocation = ctx.getMapLocation();
|
||||||
return new ArrayAdapter<RouteDataObject>(ctx,
|
return new ArrayAdapter<RouteDataObject>(ctx,
|
||||||
|
@ -58,26 +57,21 @@ public class AvoidSpecificRoads {
|
||||||
public View getView(final int position, View convertView, ViewGroup parent) {
|
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||||
// User super class to create the View
|
// User super class to create the View
|
||||||
View v = convertView;
|
View v = convertView;
|
||||||
if (position == 0) {
|
|
||||||
v= ctx.getLayoutInflater().inflate(R.layout.list_bigtextview, null);
|
|
||||||
TextView tv = (TextView) v.findViewById(R.id.Text);
|
|
||||||
tv.setText(app.getString(R.string.select_impassable_road));
|
|
||||||
} else {
|
|
||||||
if (v == null || v.findViewById(R.id.info_close) == null) {
|
if (v == null || v.findViewById(R.id.info_close) == null) {
|
||||||
v = ctx.getLayoutInflater().inflate(R.layout.waypoint_reached, null);
|
v = ctx.getLayoutInflater().inflate(R.layout.waypoint_reached, null);
|
||||||
}
|
}
|
||||||
final RouteDataObject obj = getItem(position);
|
final RouteDataObject obj = getItem(position);
|
||||||
v.findViewById(R.id.all_points).setVisibility(View.GONE);
|
v.findViewById(R.id.all_points).setVisibility(View.GONE);
|
||||||
((ImageView) v.findViewById(R.id.waypoint_icon)).setImageResource(app.getSettings().isLightContentMenu()?
|
((ImageView) v.findViewById(R.id.waypoint_icon)).setImageResource(app.getSettings().isLightContentMenu() ?
|
||||||
R.drawable.ic_action_road_works_light : R.drawable.ic_action_road_works_dark);
|
R.drawable.ic_action_road_works_light : R.drawable.ic_action_road_works_dark);
|
||||||
double dist = MapUtils.getDistance(mapLocation, MapUtils.get31LatitudeY(obj.getPoint31YTile(0)) ,
|
double dist = MapUtils.getDistance(mapLocation, MapUtils.get31LatitudeY(obj.getPoint31YTile(0)),
|
||||||
MapUtils.get31LongitudeX(obj.getPoint31XTile(0)));
|
MapUtils.get31LongitudeX(obj.getPoint31XTile(0)));
|
||||||
((TextView)v.findViewById(R.id.waypoint_dist)).setText(OsmAndFormatter.getFormattedDistance((float) dist, app));
|
((TextView) v.findViewById(R.id.waypoint_dist)).setText(OsmAndFormatter.getFormattedDistance((float) dist, app));
|
||||||
|
|
||||||
((TextView)v.findViewById(R.id.waypoint_text)).setText(getText(obj));
|
((TextView) v.findViewById(R.id.waypoint_text)).setText(getText(obj));
|
||||||
ImageButton remove = (ImageButton) v.findViewById(R.id.info_close);
|
ImageButton remove = (ImageButton) v.findViewById(R.id.info_close);
|
||||||
remove.setVisibility(View.VISIBLE);
|
remove.setVisibility(View.VISIBLE);
|
||||||
remove.setImageResource(app.getSettings().isLightContentMenu()?
|
remove.setImageResource(app.getSettings().isLightContentMenu() ?
|
||||||
R.drawable.ic_action_gremove_light : R.drawable.ic_action_gremove_dark);
|
R.drawable.ic_action_gremove_light : R.drawable.ic_action_gremove_dark);
|
||||||
remove.setOnClickListener(new View.OnClickListener() {
|
remove.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
||||||
|
@ -87,13 +81,11 @@ public class AvoidSpecificRoads {
|
||||||
getBuilder().removeImpassableRoad(obj);
|
getBuilder().removeImpassableRoad(obj);
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
RoutingHelper rh = app.getRoutingHelper();
|
RoutingHelper rh = app.getRoutingHelper();
|
||||||
if(rh.isRouteCalculated() || rh.isRouteBeingCalculated()) {
|
if (rh.isRouteCalculated() || rh.isRouteBeingCalculated()) {
|
||||||
rh.recalculateRouteDueToSettingsChange();
|
rh.recalculateRouteDueToSettingsChange();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,22 +102,28 @@ public class AvoidSpecificRoads {
|
||||||
Builder bld = new AlertDialog.Builder(mapActivity);
|
Builder bld = new AlertDialog.Builder(mapActivity);
|
||||||
bld.setTitle(R.string.impassable_road);
|
bld.setTitle(R.string.impassable_road);
|
||||||
final ArrayAdapter<?> listAdapter = createAdapter(mapActivity);
|
final ArrayAdapter<?> listAdapter = createAdapter(mapActivity);
|
||||||
|
if (missingRoads.size() == 0){
|
||||||
|
bld.setMessage(R.string.avoid_roads_msg);
|
||||||
|
} else {
|
||||||
bld.setAdapter(listAdapter, new DialogInterface.OnClickListener() {
|
bld.setAdapter(listAdapter, new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
if(which == 0) {
|
|
||||||
selectFromMap(mapActivity);
|
|
||||||
} else {
|
|
||||||
RouteDataObject obj = missingRoads.get(which - 1);
|
RouteDataObject obj = missingRoads.get(which - 1);
|
||||||
double lat = MapUtils.get31LatitudeY(obj.getPoint31YTile(0));
|
double lat = MapUtils.get31LatitudeY(obj.getPoint31YTile(0));
|
||||||
double lon = MapUtils.get31LongitudeX(obj.getPoint31XTile(0));
|
double lon = MapUtils.get31LongitudeX(obj.getPoint31XTile(0));
|
||||||
showOnMap(app, mapActivity, lat, lon, getText(obj), dialog);
|
showOnMap(app, mapActivity, lat, lon, getText(obj), dialog);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
bld.setPositiveButton(R.string.close, null);
|
}
|
||||||
|
|
||||||
|
bld.setPositiveButton(R.string.select_impassable_road, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialogInterface, int i) {
|
||||||
|
selectFromMap(mapActivity);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
bld.setNegativeButton(R.string.default_buttons_cancel, null);
|
||||||
bld.show();
|
bld.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue