Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
5ee86235c6
17 changed files with 242 additions and 9 deletions
|
@ -135,6 +135,12 @@ public class RoutingConfiguration {
|
|||
return routers.get(applicationMode);
|
||||
|
||||
}
|
||||
|
||||
public void removeImpassableRoad(RouteDataObject obj) {
|
||||
impassableRoadIds.remove(obj.id);
|
||||
impassableRoads.remove(obj);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static int parseSilentInt(String t, int v) {
|
||||
|
|
BIN
OsmAnd/res/drawable-hdpi/ic_action_road_works_dark.png
Normal file
BIN
OsmAnd/res/drawable-hdpi/ic_action_road_works_dark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
BIN
OsmAnd/res/drawable-hdpi/ic_action_road_works_light.png
Normal file
BIN
OsmAnd/res/drawable-hdpi/ic_action_road_works_light.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2 KiB |
BIN
OsmAnd/res/drawable-xhdpi/ic_action_road_works_dark.png
Normal file
BIN
OsmAnd/res/drawable-xhdpi/ic_action_road_works_dark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
BIN
OsmAnd/res/drawable-xhdpi/ic_action_road_works_light.png
Normal file
BIN
OsmAnd/res/drawable-xhdpi/ic_action_road_works_light.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.4 KiB |
BIN
OsmAnd/res/drawable-xxhdpi/ic_action_road_works_dark.png
Normal file
BIN
OsmAnd/res/drawable-xxhdpi/ic_action_road_works_dark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.4 KiB |
BIN
OsmAnd/res/drawable-xxhdpi/ic_action_road_works_light.png
Normal file
BIN
OsmAnd/res/drawable-xxhdpi/ic_action_road_works_light.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.4 KiB |
|
@ -42,7 +42,7 @@
|
|||
|
||||
<ListView
|
||||
android:id="@+id/left_drawer"
|
||||
android:layout_width="320dp"
|
||||
android:layout_width="280dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start"
|
||||
android:choiceMode="singleChoice"
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
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="select_impassable_road">Select on map</string>
|
||||
<string name="impassable_road">Avoid roads…</string>
|
||||
<string name="rendering_attr_tramTrainRoutes_name">Tram and train</string>
|
||||
<string name="tip_recent_changes_1_9_t">Changes in 1.9:
|
||||
* Updated maps styles with road surface rendering, transport layers and hiking symbols
|
||||
|
@ -30,6 +32,7 @@
|
|||
<string name="rendering_attr_shareTaxiRoutes_name">Share taxi routes</string>
|
||||
<string name="rendering_attr_trolleybusRoutes_name">Trolleybus routes</string>
|
||||
<string name="rendering_attr_busRoutes_name">Bus routes</string>
|
||||
<string name="rendering_category_hide">Hide</string>
|
||||
<string name="rendering_category_routes">Routes</string>
|
||||
<string name="rendering_category_details">Details</string>
|
||||
<string name="rendering_category_transport">Transport</string>
|
||||
|
|
|
@ -42,7 +42,7 @@ public class CurrentPositionHelper {
|
|||
ctx = new RoutePlannerFrontEnd(false).buildRoutingContext(cfg, null, app.getResourceManager().getRoutingMapFiles());
|
||||
}
|
||||
|
||||
private RouteDataObject runUpdateInThread(Location loc) {
|
||||
public synchronized RouteDataObject runUpdateInThread(double lat , double lon) {
|
||||
RoutePlannerFrontEnd rp = new RoutePlannerFrontEnd(false);
|
||||
try {
|
||||
if(ctx == null || am != app.getSettings().getApplicationMode()) {
|
||||
|
@ -51,7 +51,7 @@ public class CurrentPositionHelper {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
RouteSegment sg = rp.findRouteSegment(loc.getLatitude(), loc.getLongitude(), ctx);
|
||||
RouteSegment sg = rp.findRouteSegment(lat, lon, ctx);
|
||||
if(sg == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -64,13 +64,13 @@ public class CurrentPositionHelper {
|
|||
|
||||
private void scheduleRouteSegmentFind(final Location loc){
|
||||
if(calculatingThread == Thread.currentThread()) {
|
||||
lastFound = runUpdateInThread(loc);
|
||||
lastFound = runUpdateInThread(loc.getLatitude(), loc.getLongitude());
|
||||
} else if(calculatingThread == null && loc != null) {
|
||||
Runnable run = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
lastFound = runUpdateInThread(loc);
|
||||
lastFound = runUpdateInThread(loc.getLatitude(), loc.getLongitude());
|
||||
if (lastAskedLocation != loc) {
|
||||
// refresh and run new task if needed
|
||||
getLastKnownRouteSegment(lastAskedLocation);
|
||||
|
|
|
@ -215,6 +215,10 @@ public class OsmAndLocationProvider implements SensorEventListener {
|
|||
locationSimulation = new OsmAndLocationSimulation(app, this);
|
||||
}
|
||||
|
||||
public RouteDataObject findRoute(double lat , double lon) {
|
||||
return currentPositionHelper.runUpdateInThread(lat, lon);
|
||||
}
|
||||
|
||||
public void resumeAllUpdates() {
|
||||
final LocationManager service = (LocationManager) app.getSystemService(Context.LOCATION_SERVICE);
|
||||
service.addGpsStatusListener(getGpsStatusListener(service));
|
||||
|
|
|
@ -25,6 +25,7 @@ import net.osmand.plus.activities.SettingsActivity;
|
|||
import net.osmand.plus.api.SQLiteAPI;
|
||||
import net.osmand.plus.api.SQLiteAPIImpl;
|
||||
import net.osmand.plus.download.DownloadActivity;
|
||||
import net.osmand.plus.helpers.AvoidSpecificRoads;
|
||||
import net.osmand.plus.helpers.WaypointHelper;
|
||||
import net.osmand.plus.monitoring.LiveMonitoringHelper;
|
||||
import net.osmand.plus.render.NativeOsmandLibrary;
|
||||
|
@ -109,6 +110,7 @@ public class OsmandApplication extends Application {
|
|||
private TargetPointsHelper targetPointsHelper;
|
||||
private RoutingConfiguration.Builder defaultRoutingConfig;
|
||||
private WaypointHelper waypointHelper;
|
||||
private AvoidSpecificRoads avoidSpecificRoads;
|
||||
|
||||
private boolean applicationInitializing = false;
|
||||
private Locale preferredLocale = null;
|
||||
|
@ -161,6 +163,7 @@ public class OsmandApplication extends Application {
|
|||
taskManager = new OsmAndTaskManager(this);
|
||||
resourceManager = new ResourceManager(this);
|
||||
daynightHelper = new DayNightHelper(this);
|
||||
avoidSpecificRoads = new AvoidSpecificRoads(this);
|
||||
locationProvider = new OsmAndLocationProvider(this);
|
||||
savingTrackHelper = new SavingTrackHelper(this);
|
||||
liveMonitoringHelper = new LiveMonitoringHelper(this);
|
||||
|
@ -218,6 +221,10 @@ public class OsmandApplication extends Application {
|
|||
return taskManager;
|
||||
}
|
||||
|
||||
public AvoidSpecificRoads getAvoidSpecificRoads() {
|
||||
return avoidSpecificRoads;
|
||||
}
|
||||
|
||||
|
||||
public OsmAndLocationProvider getLocationProvider() {
|
||||
return locationProvider;
|
||||
|
@ -227,6 +234,7 @@ public class OsmandApplication extends Application {
|
|||
return appCustomization;
|
||||
}
|
||||
|
||||
|
||||
public void setAppCustomization(OsmAndAppCustomization appCustomization) {
|
||||
this.appCustomization = appCustomization;
|
||||
this.appCustomization.setup(this);
|
||||
|
|
|
@ -758,6 +758,17 @@ public class MapActivityActions implements DialogProvider {
|
|||
}
|
||||
}).reg();
|
||||
}
|
||||
if(routingHelper.isRouteCalculated()) {
|
||||
optionsMenuHelper.item(R.string.impassable_road)
|
||||
.icons(R.drawable.ic_action_road_works_dark, R.drawable.ic_action_road_works_light)
|
||||
.listen(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
app.getAvoidSpecificRoads().showDialog(mapActivity);
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
}
|
||||
|
||||
// 5-9. Default actions (Layers, Configure Map screen, Settings, Search, Favorites)
|
||||
optionsMenuHelper.item(R.string.search_button)
|
||||
|
|
|
@ -24,7 +24,6 @@ import net.osmand.render.RenderingRulesStorage;
|
|||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
@ -261,12 +260,16 @@ public class ConfigureMapMenu {
|
|||
RenderingRulesStorage renderer = activity.getMyApplication().getRendererRegistry().getCurrentSelectedRenderer();
|
||||
if (renderer != null) {
|
||||
List<RenderingRuleProperty> customRules = new ArrayList<RenderingRuleProperty>(renderer.PROPS.getCustomRules());
|
||||
createProperties(customRules, R.string.rendering_category_details, "details",
|
||||
|
||||
createProperties(customRules, R.string.rendering_category_transport, "transport",
|
||||
adapter, activity);
|
||||
createProperties(customRules, R.string.rendering_category_routes, "routes",
|
||||
adapter, activity);
|
||||
createProperties(customRules, R.string.rendering_category_transport, "transport",
|
||||
createProperties(customRules, R.string.rendering_category_details, "details",
|
||||
adapter, activity);
|
||||
createProperties(customRules, R.string.rendering_category_hide, "hide",
|
||||
adapter, activity);
|
||||
|
||||
if(customRules.size() > 0) {
|
||||
adapter.item(R.string.rendering_category_others).setCategory(true).layout(R.layout.drawer_list_sub_header).reg();
|
||||
createCustomRenderingProperties(adapter, activity, customRules);
|
||||
|
|
181
OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java
Normal file
181
OsmAnd/src/net/osmand/plus/helpers/AvoidSpecificRoads.java
Normal file
|
@ -0,0 +1,181 @@
|
|||
package net.osmand.plus.helpers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.osmand.CallbackWithObject;
|
||||
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion;
|
||||
import net.osmand.binary.RouteDataObject;
|
||||
import net.osmand.data.LatLon;
|
||||
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.routing.RoutingHelper;
|
||||
import net.osmand.plus.views.AnimateDraggingMapThread;
|
||||
import net.osmand.plus.views.ContextMenuLayer;
|
||||
import net.osmand.router.RoutingConfiguration;
|
||||
import net.osmand.util.MapUtils;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.AsyncTask;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class AvoidSpecificRoads {
|
||||
private List<RouteDataObject> missingRoads;
|
||||
private OsmandApplication app;
|
||||
|
||||
public AvoidSpecificRoads(OsmandApplication app) {
|
||||
this.app = app;
|
||||
missingRoads = getBuilder().getImpassableRoads();
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected net.osmand.router.RoutingConfiguration.Builder getBuilder() {
|
||||
return RoutingConfiguration.getDefault();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ArrayAdapter<RouteDataObject> createAdapter(final MapActivity ctx) {
|
||||
final ArrayList<RouteDataObject> points = new ArrayList<RouteDataObject>();
|
||||
points.add(new RouteDataObject((RouteRegion) null));
|
||||
points.addAll(missingRoads);
|
||||
final LatLon mapLocation = ctx.getMapLocation();
|
||||
return new ArrayAdapter<RouteDataObject>(ctx,
|
||||
R.layout.waypoint_reached, R.id.title, points) {
|
||||
|
||||
@Override
|
||||
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||
// User super class to create the View
|
||||
View v = convertView;
|
||||
if (position == 0) {
|
||||
TextView tv = (TextView) ctx.getLayoutInflater().inflate(R.layout.list_textview, null);
|
||||
tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
|
||||
tv.setText(app.getString(R.string.select_impassable_road));
|
||||
v = tv;
|
||||
} else {
|
||||
if (v == null || v.findViewById(R.id.info_close) == null) {
|
||||
v = ctx.getLayoutInflater().inflate(R.layout.waypoint_reached, null);
|
||||
}
|
||||
final RouteDataObject obj = getItem(position);
|
||||
v.findViewById(R.id.all_points).setVisibility(View.GONE);
|
||||
((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);
|
||||
double dist = MapUtils.getDistance(mapLocation, MapUtils.get31LatitudeY(obj.getPoint31YTile(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_text)).setText(getText(obj));
|
||||
View remove = v.findViewById(R.id.info_close);
|
||||
remove.setVisibility(View.VISIBLE);
|
||||
remove.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
remove(obj);
|
||||
getBuilder().removeImpassableRoad(obj);
|
||||
notifyDataSetChanged();
|
||||
RoutingHelper rh = app.getRoutingHelper();
|
||||
if(rh.isRouteCalculated() || rh.isRouteBeingCalculated()) {
|
||||
rh.recalculateRouteDueToSettingsChange();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
protected String getText(RouteDataObject obj) {
|
||||
return RoutingHelper.formatStreetName(obj.getName(), obj.getRef(), obj.getDestinationName());
|
||||
}
|
||||
|
||||
public void showDialog(final MapActivity mapActivity) {
|
||||
Builder bld = new AlertDialog.Builder(mapActivity);
|
||||
bld.setTitle(R.string.impassable_road);
|
||||
final ArrayAdapter<?> listAdapter = createAdapter(mapActivity);
|
||||
bld.setAdapter(listAdapter, new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if(which == 0) {
|
||||
selectFromMap(mapActivity);
|
||||
} else {
|
||||
RouteDataObject obj = missingRoads.get(which - 1);
|
||||
double lat = MapUtils.get31LatitudeY(obj.getPoint31YTile(0));
|
||||
double lon = MapUtils.get31LongitudeX(obj.getPoint31XTile(0));
|
||||
showOnMap(app, mapActivity, lat, lon, getText(obj), dialog);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
bld.show();
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
private void findRoad(final MapActivity activity, final LatLon loc) {
|
||||
new AsyncTask<LatLon, Void, RouteDataObject>() {
|
||||
|
||||
@Override
|
||||
protected RouteDataObject doInBackground(LatLon... params) {
|
||||
return app.getLocationProvider().findRoute(loc.getLatitude(), loc.getLongitude());
|
||||
}
|
||||
|
||||
protected void onPostExecute(RouteDataObject result) {
|
||||
if(result != null) {
|
||||
getBuilder().addImpassableRoad(result);
|
||||
RoutingHelper rh = app.getRoutingHelper();
|
||||
if(rh.isRouteCalculated() || rh.isRouteBeingCalculated()) {
|
||||
rh.recalculateRouteDueToSettingsChange();
|
||||
}
|
||||
showDialog(activity);
|
||||
}
|
||||
};
|
||||
}.execute(loc);
|
||||
}
|
||||
|
||||
public static void showOnMap(OsmandApplication app, Activity a, double lat, double lon, String name,
|
||||
DialogInterface dialog) {
|
||||
if (!(a instanceof MapActivity)) {
|
||||
return;
|
||||
}
|
||||
MapActivity ctx = (MapActivity) a;
|
||||
AnimateDraggingMapThread thread = ctx.getMapView().getAnimatedDraggingThread();
|
||||
int fZoom = ctx.getMapView().getZoom() < 15 ? 15 : ctx.getMapView().getZoom();
|
||||
if (thread.isAnimating()) {
|
||||
ctx.getMapView().setIntZoom(fZoom);
|
||||
ctx.getMapView().setLatLon(lat, lon);
|
||||
} else {
|
||||
thread.startMoving(lat, lon, fZoom, true);
|
||||
}
|
||||
ctx.getMapLayers().getContextMenuLayer().setLocation(new LatLon(lat, lon), name);
|
||||
dialog.dismiss();
|
||||
}
|
||||
|
||||
}
|
|
@ -210,7 +210,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
|||
}
|
||||
};
|
||||
adapter.item(R.string.layer_map).icons(R.drawable.ic_action_globus_dark, R.drawable.ic_action_globus_light)
|
||||
.listen(listener).position(0).reg();
|
||||
.listen(listener).position(3).reg();
|
||||
adapter.item(R.string.layer_overlay).selected(overlayLayer.getMap() != null ? 1 : 0).
|
||||
icons(R.drawable.ic_action_up_dark, R.drawable.ic_action_up_light).listen(listener).position(14).reg();
|
||||
adapter.item(R.string.layer_underlay).selected(underlayLayer.getMap() != null ? 1 : 0)
|
||||
|
|
|
@ -7,11 +7,13 @@ import java.util.Map;
|
|||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import net.osmand.CallbackWithObject;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import alice.util.Sleep;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.content.DialogInterface;
|
||||
|
@ -70,6 +72,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
private Drawable boxLeg;
|
||||
private float scaleCoefficient = 1;
|
||||
private Rect textPadding;
|
||||
private CallbackWithObject<LatLon> selectOnMap = null;
|
||||
|
||||
public ContextMenuLayer(MapActivity activity){
|
||||
this.activity = activity;
|
||||
|
@ -170,6 +173,12 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public void setSelectOnMap(CallbackWithObject<LatLon> selectOnMap) {
|
||||
this.selectOnMap = selectOnMap;
|
||||
}
|
||||
|
||||
|
||||
private void layoutText() {
|
||||
Rect padding = new Rect();
|
||||
if (textView.getLineCount() > 0) {
|
||||
|
@ -333,6 +342,14 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
public boolean onSingleTap(PointF point, RotatedTileBox tileBox) {
|
||||
boolean nativeMode = (Build.VERSION.SDK_INT >= 14) || view.getSettings().SCROLL_MAP_BY_GESTURES.get();
|
||||
int val = pressedInTextView(tileBox, point.x, point.y);
|
||||
if(selectOnMap != null) {
|
||||
LatLon latlon = tileBox.getLatLonFromPixel(point.x, point.y);
|
||||
CallbackWithObject<LatLon> cb = selectOnMap;
|
||||
selectOnMap = null;
|
||||
cb.processResult(latlon);
|
||||
setLocation(latlon, null);
|
||||
return true;
|
||||
}
|
||||
if (val == 2) {
|
||||
setLocation(null, ""); //$NON-NLS-1$
|
||||
view.refreshMap();
|
||||
|
|
Loading…
Reference in a new issue