From 8da756687aac96d6d5a6ba6804067de46956b7a7 Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Tue, 19 Apr 2016 17:14:19 +0300 Subject: [PATCH] Fix lane arrow shadow density. Fix bearing - magnetic/icon/point on marker --- .../src/net/osmand/plus/ApplicationMode.java | 1 - .../src/net/osmand/plus/MapMarkersHelper.java | 2 +- .../net/osmand/plus/views/MapInfoLayer.java | 8 ++--- .../views/mapwidgets/MapWidgetRegistry.java | 1 - .../mapwidgets/RouteInfoWidgetsFactory.java | 34 +++++++++++++++---- 5 files changed, 33 insertions(+), 13 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/ApplicationMode.java b/OsmAnd/src/net/osmand/plus/ApplicationMode.java index 1b1d1fd510..9f11d54050 100644 --- a/OsmAnd/src/net/osmand/plus/ApplicationMode.java +++ b/OsmAnd/src/net/osmand/plus/ApplicationMode.java @@ -67,7 +67,6 @@ public class ApplicationMode { // right regWidget("intermediate_distance", exceptDefault); regWidget("distance", exceptDefault); - regWidget("bearing", none); regWidget("time", exceptDefault); regWidget("speed", exceptPedestrianAndDefault); regWidget("max_speed", CAR); diff --git a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java index a5a158c2f3..46309ea281 100644 --- a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java +++ b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java @@ -50,7 +50,7 @@ public class MapMarkersHelper { } public PointDescription getPointDescription(Context ctx) { - return new PointDescription(PointDescription.POINT_TYPE_MAP_MARKER, ctx.getString(R.string.map_marker, ""), + return new PointDescription(PointDescription.POINT_TYPE_MAP_MARKER, ctx.getString(R.string.map_marker), getOnlyName()); } diff --git a/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java b/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java index 722558111f..05f81bca06 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java @@ -119,16 +119,16 @@ public class MapInfoLayer extends OsmandMapLayer { registerSideWidget(intermediateDist, R.drawable.ic_action_intermediate, R.string.map_widget_intermediate_distance, "intermediate_distance", false, 3); TextInfoWidget dist = ric.createDistanceControl(map); registerSideWidget(dist, R.drawable.ic_action_target, R.string.map_widget_distance, "distance", false, 5); - TextInfoWidget bearing = ric.createBearingControl(map); - registerSideWidget(bearing, R.drawable.ic_action_bearing, R.string.map_widget_bearing, "bearing", false, 7); TextInfoWidget time = ric.createTimeControl(map); registerSideWidget(time, R.drawable.ic_action_time, R.string.map_widget_time, "time", false, 10); + TextInfoWidget bearing = ric.createBearingControl(map); + registerSideWidget(bearing, R.drawable.ic_action_bearing, R.string.map_widget_bearing, "bearing", false, 11); if (settings.USE_MAP_MARKERS.get()) { TextInfoWidget marker = mwf.createMapMarkerControl(map, true); - registerSideWidget(marker, R.drawable.ic_action_flag_dark, R.string.map_marker_1st, "map_marker_1st", false, 11); + registerSideWidget(marker, R.drawable.ic_action_flag_dark, R.string.map_marker_1st, "map_marker_1st", false, 12); TextInfoWidget marker2nd = mwf.createMapMarkerControl(map, false); - registerSideWidget(marker2nd, R.drawable.ic_action_flag_dark, R.string.map_marker_2nd, "map_marker_2nd", false, 12); + registerSideWidget(marker2nd, R.drawable.ic_action_flag_dark, R.string.map_marker_2nd, "map_marker_2nd", false, 13); } TextInfoWidget speed = ric.createSpeedControl(map); diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java index 938e3e07ef..c24d99d7fa 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java @@ -360,7 +360,6 @@ public class MapWidgetRegistry { if (mode == ApplicationMode.DEFAULT) { if ("intermediate_distance".equals(r.key) || "distance".equals(r.key) - || "bearing".equals(r.key) || "time".equals(r.key)) { continue; } diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java index f0f0d8a1c3..c0e098574f 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java @@ -16,6 +16,7 @@ import android.graphics.Path; import android.graphics.PorterDuff; import android.graphics.PorterDuffColorFilter; import android.graphics.drawable.Drawable; +import android.hardware.GeomagneticField; import android.text.format.DateFormat; import android.view.View; import android.view.ViewGroup; @@ -26,6 +27,8 @@ import net.osmand.Location; import net.osmand.binary.RouteDataObject; import net.osmand.data.LatLon; import net.osmand.data.RotatedTileBox; +import net.osmand.plus.MapMarkersHelper; +import net.osmand.plus.MapMarkersHelper.MapMarker; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndLocationProvider; import net.osmand.plus.OsmandApplication; @@ -508,8 +511,8 @@ public class RouteInfoWidgetsFactory { public TextInfoWidget createBearingControl(final MapActivity map) { final int bearingResId = R.drawable.widget_bearing_day; final int bearingNightResId = R.drawable.widget_bearing_night; - final int relativeBearingResId = R.drawable.widget_bearing_day; - final int relativeBearingNightResId = R.drawable.widget_bearing_night; + final int relativeBearingResId = R.drawable.widget_relative_bearing_day; + final int relativeBearingNightResId = R.drawable.widget_relative_bearing_night; final OsmandApplication ctx = map.getMyApplication(); final OsmandPreference showRelativeBearing = ctx.getSettings().SHOW_RELATIVE_BEARING_OTHERWISE_REGULAR_BEARING; @@ -540,15 +543,33 @@ public class RouteInfoWidgetsFactory { int d = -1000; Location myLocation = getOsmandApplication().getLocationProvider().getLastKnownLocation(); LatLon l = getPointToNavigate(); + if (l == null) { + List markers = getOsmandApplication().getMapMarkersHelper().getSortedMapMarkers(); + if (markers.size() > 0) { + l = markers.get(0).point; + } + } if (myLocation != null && l != null) { Location dest = new Location(""); dest.setLatitude(l.getLatitude()); dest.setLongitude(l.getLongitude()); dest.setBearing(myLocation.bearingTo(dest)); - float bearingToDest = dest.getBearing(); + GeomagneticField destGf = new GeomagneticField((float) dest.getLatitude(), (float) dest.getLongitude(), (float) dest.getAltitude(), + System.currentTimeMillis()); + float bearingToDest = dest.getBearing() + destGf.getDeclination(); if (relative) { - if (myLocation.hasBearing()) { - bearingToDest -= myLocation.getBearing(); + float b = -1000; + Float heading = getOsmandApplication().getLocationProvider().getHeading(); + if (((myLocation.hasSpeed() && myLocation.getSpeed() < 11) || !myLocation.hasBearing()) + && heading != null) { + b = heading; + } else if (myLocation.hasBearing()) { + GeomagneticField myLocGf = new GeomagneticField((float) myLocation.getLatitude(), (float) myLocation.getLongitude(), (float) myLocation.getAltitude(), + System.currentTimeMillis()); + b = (myLocation.getBearing() + myLocGf.getDeclination()); + } + if (b > -1000) { + bearingToDest -= b; if (bearingToDest > 180f) { bearingToDest -= 360f; } else if (bearingToDest < -180f) { @@ -829,7 +850,8 @@ public class RouteInfoWidgetsFactory { // create a blur paint for capturing alpha Paint ptBlur = new Paint(); - ptBlur.setMaskFilter(new BlurMaskFilter(5, Blur.OUTER)); + float density = ctx.getResources().getDisplayMetrics().density; + ptBlur.setMaskFilter(new BlurMaskFilter(1.66f * density, Blur.OUTER)); int[] offsetXY = new int[2]; // capture alpha into a bitmap Bitmap bmAlpha = src.extractAlpha(ptBlur, offsetXY);