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

View file

@ -184,7 +184,8 @@ public abstract class MenuController extends BaseMenuController implements Colla
if (object instanceof Amenity) {
menuController = new AmenityMenuController(mapActivity, pointDescription, (Amenity) object);
} else if (object instanceof FavouritePoint) {
if (pointDescription.isParking()) {
if (pointDescription.isParking()
|| (FavouritePoint.SpecialPointType.PARKING.equals(((FavouritePoint) object).getSpecialPointType()))) {
menuController = new ParkingPositionMenuController(mapActivity, pointDescription);
} else {
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.dashboard.tools.DashFragmentData;
import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.settings.BaseSettingsFragment;
import net.osmand.plus.views.AnimateDraggingMapThread;
import net.osmand.plus.views.MapInfoLayer;
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
@ -193,7 +192,7 @@ public class ParkingPositionPlugin extends OsmandPlugin {
activity.getMapView().removeLayer(parkingLayer);
}
parkingLayer = new ParkingPositionLayer(activity, this);
activity.getMapView().addLayer(parkingLayer, 5.5f);
// activity.getMapView().addLayer(parkingLayer, 5.5f);
registerWidget(activity);
}