This commit is contained in:
Alexey Kulish 2017-03-27 16:26:27 +03:00
parent 07a5b6994e
commit c0d362d424
2 changed files with 33 additions and 15 deletions

View file

@ -119,6 +119,8 @@ public class ApplicationMode {
public ApplicationModeBuilder carLocation() { public ApplicationModeBuilder carLocation() {
applicationMode.bearingIconDay = R.drawable.map_car_bearing; applicationMode.bearingIconDay = R.drawable.map_car_bearing;
applicationMode.bearingIconNight = R.drawable.map_car_bearing_night; applicationMode.bearingIconNight = R.drawable.map_car_bearing_night;
applicationMode.headingIconDay = R.drawable.map_car_location_view_angle;
applicationMode.headingIconNight = R.drawable.map_car_location_view_angle_night;
applicationMode.locationIconDay = R.drawable.map_car_location; applicationMode.locationIconDay = R.drawable.map_car_location;
applicationMode.locationIconNight = R.drawable.map_car_location_night; applicationMode.locationIconNight = R.drawable.map_car_location_night;
return this; return this;
@ -132,6 +134,8 @@ public class ApplicationMode {
public ApplicationModeBuilder bicycleLocation() { public ApplicationModeBuilder bicycleLocation() {
applicationMode.bearingIconDay = R.drawable.map_bicycle_bearing; applicationMode.bearingIconDay = R.drawable.map_bicycle_bearing;
applicationMode.bearingIconNight = R.drawable.map_bicycle_bearing_night; applicationMode.bearingIconNight = R.drawable.map_bicycle_bearing_night;
applicationMode.headingIconDay = R.drawable.map_bicycle_location_view_angle;
applicationMode.headingIconNight = R.drawable.map_bicycle_location_view_angle_night;
applicationMode.locationIconDay = R.drawable.map_bicycle_location; applicationMode.locationIconDay = R.drawable.map_bicycle_location;
applicationMode.locationIconNight = R.drawable.map_bicycle_location_night; applicationMode.locationIconNight = R.drawable.map_bicycle_location_night;
return this; return this;
@ -140,6 +144,8 @@ public class ApplicationMode {
public ApplicationModeBuilder defLocation() { public ApplicationModeBuilder defLocation() {
applicationMode.bearingIconDay = R.drawable.map_pedestrian_bearing; applicationMode.bearingIconDay = R.drawable.map_pedestrian_bearing;
applicationMode.bearingIconNight = R.drawable.map_pedestrian_bearing_night; applicationMode.bearingIconNight = R.drawable.map_pedestrian_bearing_night;
applicationMode.headingIconDay = R.drawable.map_default_location_view_angle;
applicationMode.headingIconNight = R.drawable.map_default_location_view_angle_night;
applicationMode.locationIconDay = R.drawable.map_pedestrian_location; applicationMode.locationIconDay = R.drawable.map_pedestrian_location;
applicationMode.locationIconNight = R.drawable.map_pedestrian_location_night; applicationMode.locationIconNight = R.drawable.map_pedestrian_location_night;
return this; return this;
@ -281,6 +287,14 @@ public class ApplicationMode {
return bearingIconNight; return bearingIconNight;
} }
public int getResourceHeadingDay() {
return headingIconDay;
}
public int getResourceHeadingNight() {
return headingIconNight;
}
public int getResourceLocationDay() { public int getResourceLocationDay() {
return locationIconDay; return locationIconDay;
} }
@ -339,13 +353,15 @@ public class ApplicationMode {
private final String stringKey; private final String stringKey;
private ApplicationMode parent; private ApplicationMode parent;
private int mapIconId = R.drawable.ic_browse_map; private int mapIconId = R.drawable.map_world_globe_dark;
private int smallIconDark = R.drawable.ic_world_globe_dark; private int smallIconDark = R.drawable.ic_world_globe_dark;
private float defaultSpeed = 10f; private float defaultSpeed = 10f;
private int minDistanceForTurn = 50; private int minDistanceForTurn = 50;
private int arrivalDistance = 90; private int arrivalDistance = 90;
private int bearingIconDay = R.drawable.map_pedestrian_bearing; private int bearingIconDay = R.drawable.map_pedestrian_bearing;
private int bearingIconNight = R.drawable.map_pedestrian_bearing_night; private int bearingIconNight = R.drawable.map_pedestrian_bearing_night;
private int headingIconDay = R.drawable.map_pedestrian_location_view_angle;
private int headingIconNight = R.drawable.map_pedestrian_location_view_angle_night;
private int locationIconDay = R.drawable.map_pedestrian_location; private int locationIconDay = R.drawable.map_pedestrian_location;
private int locationIconNight = R.drawable.map_pedestrian_location_night; private int locationIconNight = R.drawable.map_pedestrian_location_night;
private static StateChangedListener<String> listener; private static StateChangedListener<String> listener;

View file

@ -26,17 +26,16 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay
private static final Log LOG = PlatformUtil.getLog(PointLocationLayer.class); private static final Log LOG = PlatformUtil.getLog(PointLocationLayer.class);
protected final static int RADIUS = 7; protected final static int RADIUS = 7;
protected final static float HEADING_ANGLE = 60;
private Paint locationPaint; private Paint locationPaint;
private Paint area; private Paint area;
private Paint aroundArea; private Paint aroundArea;
private Paint headingPaint;
private OsmandMapTileView view; private OsmandMapTileView view;
private ApplicationMode appMode; private ApplicationMode appMode;
private Bitmap bearingIcon; private Bitmap bearingIcon;
private Bitmap headingIcon;
private Bitmap locationIcon; private Bitmap locationIcon;
private OsmAndLocationProvider locationProvider; private OsmAndLocationProvider locationProvider;
private MapViewTrackingUtilities mapViewTrackingUtilities; private MapViewTrackingUtilities mapViewTrackingUtilities;
@ -52,7 +51,6 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay
locationPaint.setFilterBitmap(true); locationPaint.setFilterBitmap(true);
locationPaint.setDither(true); locationPaint.setDither(true);
area = new Paint(); area = new Paint();
area.setColor(view.getResources().getColor(R.color.pos_area)); area.setColor(view.getResources().getColor(R.color.pos_area));
@ -62,11 +60,6 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay
aroundArea.setStrokeWidth(1); aroundArea.setStrokeWidth(1);
aroundArea.setAntiAlias(true); aroundArea.setAntiAlias(true);
headingPaint = new Paint();
headingPaint.setColor(view.getResources().getColor(R.color.pos_heading));
headingPaint.setAntiAlias(true);
headingPaint.setStyle(Style.FILL);
updateIcons(view.getSettings().getApplicationMode(), false); updateIcons(view.getSettings().getApplicationMode(), false);
locationProvider = view.getApplication().getLocationProvider(); locationProvider = view.getApplication().getLocationProvider();
} }
@ -113,8 +106,13 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay
Float heading = locationProvider.getHeading(); Float heading = locationProvider.getHeading();
if (heading != null && mapViewTrackingUtilities.isShowViewAngle()) { if (heading != null && mapViewTrackingUtilities.isShowViewAngle()) {
canvas.drawArc(getHeadingRect(locationX, locationY), heading - HEADING_ANGLE / 2 - 90, HEADING_ANGLE,
true, headingPaint); canvas.save();
canvas.rotate(heading - 180, locationX, locationY);
canvas.drawBitmap(headingIcon, locationX - headingIcon.getWidth() / 2,
locationY - headingIcon.getHeight() / 2, locationPaint);
canvas.restore();
} }
if (isBearing) { if (isBearing) {
float bearing = lastKnownLocation.getBearing(); float bearing = lastKnownLocation.getBearing();
@ -147,12 +145,16 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay
final int resourceBearing = nighMode ? resourceBearingNight : resourceBearingDay; final int resourceBearing = nighMode ? resourceBearingNight : resourceBearingDay;
bearingIcon = BitmapFactory.decodeResource(view.getResources(), resourceBearing); bearingIcon = BitmapFactory.decodeResource(view.getResources(), resourceBearing);
final int resourceHeadingDay = appMode.getResourceHeadingDay();
final int resourceHeadingNight = appMode.getResourceHeadingNight();
final int resourceHeading = nighMode ? resourceHeadingNight : resourceHeadingDay;
headingIcon = BitmapFactory.decodeResource(view.getResources(), resourceHeading);
final int resourceLocationDay = appMode.getResourceLocationDay(); final int resourceLocationDay = appMode.getResourceLocationDay();
final int resourceLocationNight = appMode.getResourceLocationNight(); final int resourceLocationNight = appMode.getResourceLocationNight();
final int resourceLocation = nighMode ? resourceLocationNight : resourceLocationDay; final int resourceLocation = nighMode ? resourceLocationNight : resourceLocationDay;
locationIcon = BitmapFactory.decodeResource(view.getResources(), resourceLocation); locationIcon = BitmapFactory.decodeResource(view.getResources(), resourceLocation);
area.setColor(view.getResources().getColor(!nm ? R.color.pos_area : R.color.pos_area_night)); area.setColor(view.getResources().getColor(!nm ? R.color.pos_area : R.color.pos_area_night));
headingPaint.setColor(view.getResources().getColor(!nm ? R.color.pos_heading : R.color.pos_heading_night));
} }
} }