Fix lane arrow shadow density. Fix bearing - magnetic/icon/point on marker

This commit is contained in:
Alexey Kulish 2016-04-19 17:14:19 +03:00
parent 9c8eae57e5
commit 8da756687a
5 changed files with 33 additions and 13 deletions

View file

@ -67,7 +67,6 @@ public class ApplicationMode {
// right // right
regWidget("intermediate_distance", exceptDefault); regWidget("intermediate_distance", exceptDefault);
regWidget("distance", exceptDefault); regWidget("distance", exceptDefault);
regWidget("bearing", none);
regWidget("time", exceptDefault); regWidget("time", exceptDefault);
regWidget("speed", exceptPedestrianAndDefault); regWidget("speed", exceptPedestrianAndDefault);
regWidget("max_speed", CAR); regWidget("max_speed", CAR);

View file

@ -50,7 +50,7 @@ public class MapMarkersHelper {
} }
public PointDescription getPointDescription(Context ctx) { 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()); getOnlyName());
} }

View file

@ -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); registerSideWidget(intermediateDist, R.drawable.ic_action_intermediate, R.string.map_widget_intermediate_distance, "intermediate_distance", false, 3);
TextInfoWidget dist = ric.createDistanceControl(map); TextInfoWidget dist = ric.createDistanceControl(map);
registerSideWidget(dist, R.drawable.ic_action_target, R.string.map_widget_distance, "distance", false, 5); 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); TextInfoWidget time = ric.createTimeControl(map);
registerSideWidget(time, R.drawable.ic_action_time, R.string.map_widget_time, "time", false, 10); 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()) { if (settings.USE_MAP_MARKERS.get()) {
TextInfoWidget marker = mwf.createMapMarkerControl(map, true); 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); 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); TextInfoWidget speed = ric.createSpeedControl(map);

View file

@ -360,7 +360,6 @@ public class MapWidgetRegistry {
if (mode == ApplicationMode.DEFAULT) { if (mode == ApplicationMode.DEFAULT) {
if ("intermediate_distance".equals(r.key) if ("intermediate_distance".equals(r.key)
|| "distance".equals(r.key) || "distance".equals(r.key)
|| "bearing".equals(r.key)
|| "time".equals(r.key)) { || "time".equals(r.key)) {
continue; continue;
} }

View file

@ -16,6 +16,7 @@ import android.graphics.Path;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter; import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.hardware.GeomagneticField;
import android.text.format.DateFormat; import android.text.format.DateFormat;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -26,6 +27,8 @@ import net.osmand.Location;
import net.osmand.binary.RouteDataObject; import net.osmand.binary.RouteDataObject;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.RotatedTileBox; 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.OsmAndFormatter;
import net.osmand.plus.OsmAndLocationProvider; import net.osmand.plus.OsmAndLocationProvider;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
@ -508,8 +511,8 @@ public class RouteInfoWidgetsFactory {
public TextInfoWidget createBearingControl(final MapActivity map) { public TextInfoWidget createBearingControl(final MapActivity map) {
final int bearingResId = R.drawable.widget_bearing_day; final int bearingResId = R.drawable.widget_bearing_day;
final int bearingNightResId = R.drawable.widget_bearing_night; final int bearingNightResId = R.drawable.widget_bearing_night;
final int relativeBearingResId = R.drawable.widget_bearing_day; final int relativeBearingResId = R.drawable.widget_relative_bearing_day;
final int relativeBearingNightResId = R.drawable.widget_bearing_night; final int relativeBearingNightResId = R.drawable.widget_relative_bearing_night;
final OsmandApplication ctx = map.getMyApplication(); final OsmandApplication ctx = map.getMyApplication();
final OsmandPreference<Boolean> showRelativeBearing = ctx.getSettings().SHOW_RELATIVE_BEARING_OTHERWISE_REGULAR_BEARING; final OsmandPreference<Boolean> showRelativeBearing = ctx.getSettings().SHOW_RELATIVE_BEARING_OTHERWISE_REGULAR_BEARING;
@ -540,15 +543,33 @@ public class RouteInfoWidgetsFactory {
int d = -1000; int d = -1000;
Location myLocation = getOsmandApplication().getLocationProvider().getLastKnownLocation(); Location myLocation = getOsmandApplication().getLocationProvider().getLastKnownLocation();
LatLon l = getPointToNavigate(); LatLon l = getPointToNavigate();
if (l == null) {
List<MapMarker> markers = getOsmandApplication().getMapMarkersHelper().getSortedMapMarkers();
if (markers.size() > 0) {
l = markers.get(0).point;
}
}
if (myLocation != null && l != null) { if (myLocation != null && l != null) {
Location dest = new Location(""); Location dest = new Location("");
dest.setLatitude(l.getLatitude()); dest.setLatitude(l.getLatitude());
dest.setLongitude(l.getLongitude()); dest.setLongitude(l.getLongitude());
dest.setBearing(myLocation.bearingTo(dest)); 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 (relative) {
if (myLocation.hasBearing()) { float b = -1000;
bearingToDest -= myLocation.getBearing(); 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) { if (bearingToDest > 180f) {
bearingToDest -= 360f; bearingToDest -= 360f;
} else if (bearingToDest < -180f) { } else if (bearingToDest < -180f) {
@ -829,7 +850,8 @@ public class RouteInfoWidgetsFactory {
// create a blur paint for capturing alpha // create a blur paint for capturing alpha
Paint ptBlur = new Paint(); 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]; int[] offsetXY = new int[2];
// capture alpha into a bitmap // capture alpha into a bitmap
Bitmap bmAlpha = src.extractAlpha(ptBlur, offsetXY); Bitmap bmAlpha = src.extractAlpha(ptBlur, offsetXY);