Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2016-04-19 16:14:42 +02:00
commit 733dfd3062
5 changed files with 33 additions and 13 deletions

View file

@ -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);

View file

@ -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());
}

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);
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);

View file

@ -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;
}

View file

@ -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<Boolean> 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<MapMarker> 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);