Fix parking issue. Show Home Work Parking icon on map. Disable ParkingPositionPlugin layer

This commit is contained in:
Dima-1 2020-01-21 15:46:30 +02:00
parent 7b64864eca
commit f55e4f7c00
3 changed files with 23 additions and 22 deletions

View file

@ -14,13 +14,11 @@ import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.res.ResourcesCompat; import android.support.v4.content.res.ResourcesCompat;
import net.osmand.GPXUtilities; import net.osmand.GPXUtilities;
import net.osmand.data.FavouritePoint; import net.osmand.data.FavouritePoint;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import java.util.TreeMap; import java.util.TreeMap;
@ -29,6 +27,7 @@ public class FavoriteImageDrawable extends Drawable {
private boolean withShadow; private boolean withShadow;
private boolean synced; private boolean synced;
private boolean history; private boolean history;
private boolean special;
private Bitmap favIcon; private Bitmap favIcon;
private Bitmap favBackground; private Bitmap favBackground;
private Bitmap syncedStroke; private Bitmap syncedStroke;
@ -42,7 +41,7 @@ public class FavoriteImageDrawable extends Drawable {
private Paint paintInnerCircle = new Paint(); private Paint paintInnerCircle = new Paint();
private ColorFilter colorFilter; private ColorFilter colorFilter;
private ColorFilter grayFilter; private ColorFilter grayFilter;
private Drawable personalPointBitmap; private ColorFilter specialPointColor;
private FavoriteImageDrawable(Context ctx, int color, boolean withShadow, boolean synced, FavouritePoint point) { private FavoriteImageDrawable(Context ctx, int color, boolean withShadow, boolean synced, FavouritePoint point) {
this.withShadow = withShadow; this.withShadow = withShadow;
@ -50,11 +49,12 @@ public class FavoriteImageDrawable extends Drawable {
Resources res = ctx.getResources(); Resources res = ctx.getResources();
int overlayIconId = point != null ? point.getOverlayIconId() : 0; int overlayIconId = point != null ? point.getOverlayIconId() : 0;
if (overlayIconId != 0) { if (overlayIconId != 0) {
personalPointBitmap = UiUtilities.tintDrawable(ResourcesCompat.getDrawable(res, overlayIconId, null), favIcon = BitmapFactory.decodeResource(res, overlayIconId);
ContextCompat.getColor(ctx, R.color.icon_color_default_light)); special = true;
} else {
favIcon = BitmapFactory.decodeResource(res, R.drawable.map_favorite);
} }
int col = color == 0 || color == Color.BLACK ? res.getColor(R.color.color_favorite) : color; int col = color == 0 || color == Color.BLACK ? res.getColor(R.color.color_favorite) : color;
favIcon = BitmapFactory.decodeResource(res, R.drawable.map_favorite);
favBackground = BitmapFactory.decodeResource(res, R.drawable.map_white_favorite_shield); favBackground = BitmapFactory.decodeResource(res, R.drawable.map_white_favorite_shield);
syncedStroke = BitmapFactory.decodeResource(res, R.drawable.map_shield_marker_point_stroke); syncedStroke = BitmapFactory.decodeResource(res, R.drawable.map_shield_marker_point_stroke);
syncedColor = BitmapFactory.decodeResource(res, R.drawable.map_shield_marker_point_color); syncedColor = BitmapFactory.decodeResource(res, R.drawable.map_shield_marker_point_color);
@ -65,6 +65,7 @@ public class FavoriteImageDrawable extends Drawable {
initSimplePaint(paintInnerCircle, col); initSimplePaint(paintInnerCircle, col);
colorFilter = new PorterDuffColorFilter(col, PorterDuff.Mode.MULTIPLY); colorFilter = new PorterDuffColorFilter(col, PorterDuff.Mode.MULTIPLY);
grayFilter = new PorterDuffColorFilter(res.getColor(R.color.color_favorite_gray), PorterDuff.Mode.MULTIPLY); grayFilter = new PorterDuffColorFilter(res.getColor(R.color.color_favorite_gray), PorterDuff.Mode.MULTIPLY);
specialPointColor = new PorterDuffColorFilter(res.getColor(R.color.icon_color_default_light), PorterDuff.Mode.MULTIPLY);
} }
private void initSimplePaint(Paint paint, int color) { private void initSimplePaint(Paint paint, int color) {
@ -81,20 +82,17 @@ public class FavoriteImageDrawable extends Drawable {
//bs.inset((int) (4 * density), (int) (4 * density)); //bs.inset((int) (4 * density), (int) (4 * density));
bs.inset(bs.width() / 4, bs.height() / 4); bs.inset(bs.width() / 4, bs.height() / 4);
listDrawable.setBounds(bs); listDrawable.setBounds(bs);
if (personalPointBitmap != null) {
personalPointBitmap.setBounds(bounds);
}
} }
} }
@Override @Override
public int getIntrinsicHeight() { public int getIntrinsicHeight() {
return synced ? syncedShadow.getHeight() : favBackground.getHeight(); return synced ? syncedShadow.getHeight() : special ? favIcon.getHeight() : favBackground.getHeight();
} }
@Override @Override
public int getIntrinsicWidth() { public int getIntrinsicWidth() {
return synced ? syncedShadow.getWidth() : favBackground.getWidth(); return synced ? syncedShadow.getWidth() : special ? favIcon.getWidth() : favBackground.getWidth();
} }
@Override @Override
@ -109,15 +107,18 @@ public class FavoriteImageDrawable extends Drawable {
} else if (withShadow) { } else if (withShadow) {
canvas.drawBitmap(favBackground, bs.exactCenterX() - favBackground.getWidth() / 2f, bs.exactCenterY() - favBackground.getHeight() / 2f, paintBackground); canvas.drawBitmap(favBackground, bs.exactCenterX() - favBackground.getWidth() / 2f, bs.exactCenterY() - favBackground.getHeight() / 2f, paintBackground);
canvas.drawBitmap(favIcon, bs.exactCenterX() - favIcon.getWidth() / 2f, bs.exactCenterY() - favIcon.getHeight() / 2f, paintIcon); canvas.drawBitmap(favIcon, bs.exactCenterX() - favIcon.getWidth() / 2f, bs.exactCenterY() - favIcon.getHeight() / 2f, paintIcon);
} else if (personalPointBitmap != null) {
personalPointBitmap.draw(canvas);
} else { } else {
int min = Math.min(bs.width(), bs.height()); if (special) {
int r = (min * 4 / 10); paintIcon.setColorFilter(specialPointColor);
int rs = (r - 1); canvas.drawBitmap(favIcon, bs.exactCenterX() - bs.width() / 2f, bs.exactCenterY() - bs.height() / 2f, paintIcon);
canvas.drawCircle(min / 2, min / 2, r, paintOuter); } else {
canvas.drawCircle(min / 2, min / 2, rs, paintInnerCircle); int min = Math.min(bs.width(), bs.height());
listDrawable.draw(canvas); int r = (min * 4 / 10);
int rs = (r - 1);
canvas.drawCircle(min / 2, min / 2, r, paintOuter);
canvas.drawCircle(min / 2, min / 2, rs, paintInnerCircle);
listDrawable.draw(canvas);
}
} }
} }

View file

@ -184,7 +184,8 @@ public abstract class MenuController extends BaseMenuController implements Colla
if (object instanceof Amenity) { if (object instanceof Amenity) {
menuController = new AmenityMenuController(mapActivity, pointDescription, (Amenity) object); menuController = new AmenityMenuController(mapActivity, pointDescription, (Amenity) object);
} else if (object instanceof FavouritePoint) { } else if (object instanceof FavouritePoint) {
if (pointDescription.isParking()) { if (pointDescription.isParking()
|| (FavouritePoint.SpecialPointType.PARKING.equals(((FavouritePoint) object).getSpecialPointType()))) {
menuController = new ParkingPositionMenuController(mapActivity, pointDescription); menuController = new ParkingPositionMenuController(mapActivity, pointDescription);
} else { } else {
menuController = new FavouritePointMenuController(mapActivity, pointDescription, (FavouritePoint) object); menuController = new FavouritePointMenuController(mapActivity, pointDescription, (FavouritePoint) object);

View file

@ -31,7 +31,6 @@ import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dashboard.tools.DashFragmentData; import net.osmand.plus.dashboard.tools.DashFragmentData;
import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.settings.BaseSettingsFragment;
import net.osmand.plus.views.AnimateDraggingMapThread; import net.osmand.plus.views.AnimateDraggingMapThread;
import net.osmand.plus.views.MapInfoLayer; import net.osmand.plus.views.MapInfoLayer;
import net.osmand.plus.views.OsmandMapLayer.DrawSettings; import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
@ -193,7 +192,7 @@ public class ParkingPositionPlugin extends OsmandPlugin {
activity.getMapView().removeLayer(parkingLayer); activity.getMapView().removeLayer(parkingLayer);
} }
parkingLayer = new ParkingPositionLayer(activity, this); parkingLayer = new ParkingPositionLayer(activity, this);
activity.getMapView().addLayer(parkingLayer, 5.5f); // activity.getMapView().addLayer(parkingLayer, 5.5f);
registerWidget(activity); registerWidget(activity);
} }