Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2016-03-05 10:40:34 +01:00
commit 90841ca1ec
8 changed files with 60 additions and 24 deletions

View file

@ -9,6 +9,7 @@
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
-->
<string name="avoid_road">Avoid road</string>
<string name="storage_directory_readonly_desc">Currently selected Data storage folder is readonly. The storage folder was temporarily switched to Internal memory. Please choose valid storage directory.</string>
<string name="storage_directory_shared">Shared memory</string>
<string name="shared_string_topbar">Topbar</string>

View file

@ -635,8 +635,8 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
}
@Override
public void populateObjectContextMenu(Object o, ContextMenuAdapter adapter) {
if(o instanceof WptPt) {
public void populateObjectContextMenu(LatLon latLon, Object o, ContextMenuAdapter adapter) {
if (o != null && o instanceof WptPt) {
final WptPt p = (WptPt) o;
boolean containsPoint = false;
for (int i = 0; i < measurementPoints.size(); i++) {

View file

@ -20,6 +20,7 @@ import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.views.AnimateDraggingMapThread;
import net.osmand.plus.views.ContextMenuLayer;
@ -134,16 +135,17 @@ public class AvoidSpecificRoads {
protected void selectFromMap(final MapActivity mapActivity) {
ContextMenuLayer cm = mapActivity.getMapLayers().getContextMenuLayer();
cm.setSelectOnMap(new CallbackWithObject<LatLon>() {
@Override
public boolean processResult(LatLon result) {
findRoad(mapActivity, result);
addImpassableRoad(mapActivity, result, true);
return true;
}
});
}
private void findRoad(final MapActivity activity, final LatLon loc) {
public void addImpassableRoad(final MapActivity activity, final LatLon loc, final boolean showDialog) {
final Location ll = new Location("");
ll.setLatitude(loc.getLatitude());
ll.setLongitude(loc.getLongitude());
@ -159,7 +161,13 @@ public class AvoidSpecificRoads {
if(rh.isRouteCalculated() || rh.isRouteBeingCalculated()) {
rh.recalculateRouteDueToSettingsChange();
}
showDialog(activity);
if (showDialog) {
showDialog(activity);
}
MapContextMenu menu = activity.getContextMenu();
if (menu.isActive() && menu.getLatLon().equals(loc)) {
menu.close();
}
}
return true;
}

View file

@ -554,10 +554,8 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
public void buttonMorePressed() {
final ContextMenuAdapter menuAdapter = new ContextMenuAdapter(mapActivity);
if (object != null) {
for (OsmandMapLayer layer : mapActivity.getMapView().getLayers()) {
layer.populateObjectContextMenu(object, menuAdapter);
}
for (OsmandMapLayer layer : mapActivity.getMapView().getLayers()) {
layer.populateObjectContextMenu(latLon, object, menuAdapter);
}
mapActivity.getMapActions().contextMenuPoint(latLon.getLatitude(), latLon.getLongitude(), menuAdapter, object);

View file

@ -81,8 +81,8 @@ public class RoutePointsLayer extends OsmandMapLayer implements ContextMenuLaye
}
@Override
public void populateObjectContextMenu(Object o, ContextMenuAdapter adapter) {
if (o instanceof GPXUtilities.WptPt && plugin.getCurrentRoute() != null){
public void populateObjectContextMenu(LatLon latLon, Object o, ContextMenuAdapter adapter) {
if (o != null && o instanceof GPXUtilities.WptPt && plugin.getCurrentRoute() != null){
final GPXUtilities.WptPt point = (GPXUtilities.WptPt) o;
ContextMenuAdapter.OnContextMenuClick listener = new ContextMenuAdapter.OnContextMenuClick() {
@Override

View file

@ -102,7 +102,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
}
@Override
public void populateObjectContextMenu(Object o, ContextMenuAdapter adapter) {
public void populateObjectContextMenu(LatLon latLon, Object o, ContextMenuAdapter adapter) {
if (menu.hasHiddenBottomInfo()) {
ContextMenuAdapter.OnContextMenuClick listener = new ContextMenuAdapter.OnContextMenuClick() {
@Override

View file

@ -5,14 +5,18 @@ import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PointF;
import android.widget.ArrayAdapter;
import net.osmand.Location;
import net.osmand.binary.RouteDataObject;
import net.osmand.data.LatLon;
import net.osmand.data.LocationPoint;
import net.osmand.data.PointDescription;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.routing.RoutingHelper;
import java.util.List;
import java.util.Map;
@ -26,6 +30,7 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements ContextMenuL
private Paint paint;
private Map<Long, Location> missingRoadLocations;
private List<RouteDataObject> missingRoads;
private RoutingHelper routingHelper;
public ImpassableRoadsLayer(MapActivity activity) {
this.activity = activity;
@ -36,6 +41,7 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements ContextMenuL
this.view = view;
roadWorkIcon = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_pin_avoid_road);
paint = new Paint();
routingHelper = activity.getRoutingHelper();
}
@Override
@ -58,14 +64,14 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements ContextMenuL
}
public Map<Long, Location> getMissingRoadLocations() {
if(missingRoadLocations == null) {
if (missingRoadLocations == null) {
missingRoadLocations = activity.getMyApplication().getDefaultRoutingConfig().getImpassableRoadLocations();
}
return missingRoadLocations;
}
public List<RouteDataObject> getMissingRoads() {
if(missingRoads == null) {
if (missingRoads == null) {
missingRoads = activity.getMyApplication().getDefaultRoutingConfig().getImpassableRoads();
}
return missingRoads;
@ -81,9 +87,9 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements ContextMenuL
return true;
}
public int getRadiusPoi(RotatedTileBox tb){
public int getRadiusPoi(RotatedTileBox tb) {
int r = 0;
if(tb.getZoom() < startZoom){
if (tb.getZoom() < startZoom) {
r = 0;
} else {
r = 15;
@ -92,7 +98,7 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements ContextMenuL
}
private boolean calculateBelongs(int ex, int ey, int objx, int objy, int radius) {
return Math.abs(objx - ex) <= radius && (ey - objy) <= radius / 2 && (objy - ey) <= 3 * radius ;
return Math.abs(objx - ex) <= radius && (ey - objy) <= radius / 2 && (objy - ey) <= 3 * radius;
}
@Override
@ -125,8 +131,8 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements ContextMenuL
@Override
public LatLon getObjectLocation(Object o) {
if(o instanceof RouteDataObject) {
RouteDataObject route = (RouteDataObject) o;
if (o instanceof RouteDataObject) {
RouteDataObject route = (RouteDataObject) o;
Location location = missingRoadLocations.get(route.getId());
return new LatLon(location.getLatitude(), location.getLongitude());
}
@ -140,11 +146,32 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements ContextMenuL
@Override
public PointDescription getObjectName(Object o) {
if(o instanceof RouteDataObject) {
RouteDataObject route = (RouteDataObject) o;
if (o instanceof RouteDataObject) {
RouteDataObject route = (RouteDataObject) o;
return new PointDescription(PointDescription.POINT_TYPE_BLOCKED_ROAD, route.getName());
}
return null;
}
@Override
public void populateObjectContextMenu(final LatLon latLon, final Object o, ContextMenuAdapter adapter) {
if (latLon != null && o == null
&& (routingHelper.isRoutePlanningMode() || routingHelper.isFollowingMode())) {
ContextMenuAdapter.OnContextMenuClick listener = new ContextMenuAdapter.OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
if (itemId == R.string.avoid_road) {
activity.getMyApplication().getAvoidSpecificRoads().addImpassableRoad(
activity, latLon, false);
}
activity.refreshMap();
return true;
}
};
adapter.item(R.string.avoid_road).iconColor(
R.drawable.ic_action_road_works_dark).listen(listener).reg();
}
}
}

View file

@ -6,6 +6,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import net.osmand.data.LatLon;
import net.osmand.data.QuadRect;
import net.osmand.data.QuadTree;
import net.osmand.data.RotatedTileBox;
@ -16,6 +17,7 @@ import android.graphics.Path;
import android.graphics.PointF;
import android.os.AsyncTask;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.MotionEvent;
public abstract class OsmandMapLayer {
@ -31,8 +33,8 @@ public abstract class OsmandMapLayer {
public abstract void destroyLayer();
public void onRetainNonConfigurationInstance(Map<String, Object> map) {}
public void populateObjectContextMenu(Object o, ContextMenuAdapter adapter) {}
public void populateObjectContextMenu(LatLon latLon, Object o, ContextMenuAdapter adapter) {}
public boolean onSingleTap(PointF point, RotatedTileBox tileBox) {
return false;