Revert fav/wpt icon. Fix fav's visibility on small zooms
This commit is contained in:
parent
b14e285e76
commit
e64db571e3
3 changed files with 79 additions and 73 deletions
|
@ -13,7 +13,7 @@ import android.graphics.PorterDuff;
|
|||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.DisplayMetrics;
|
||||
|
||||
import net.osmand.plus.R;
|
||||
|
||||
import java.util.TreeMap;
|
||||
|
@ -35,30 +35,22 @@ public class FavoriteImageDrawable extends Drawable {
|
|||
this.withShadow = withShadow;
|
||||
this.resources = ctx.getResources();
|
||||
this.color = color;
|
||||
paintIcon = new Paint();
|
||||
int col = color == 0 || color == Color.BLACK ? getResources().getColor(R.color.color_favorite) : color;
|
||||
paintIcon.setColorFilter(new PorterDuffColorFilter(col, PorterDuff.Mode.SRC_IN));
|
||||
paintBackground = new Paint();
|
||||
int col = color == 0 || color == Color.BLACK ? getResources().getColor(R.color.color_favorite) : color;
|
||||
paintBackground.setColorFilter(new PorterDuffColorFilter(col, PorterDuff.Mode.MULTIPLY));
|
||||
paintIcon = new Paint();
|
||||
favIcon = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.map_favorite);
|
||||
favBackground = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.map_white_favorite_shield);
|
||||
|
||||
|
||||
listDrawable = getResources().getDrawable(R.drawable.ic_action_fav_dark).mutate();
|
||||
listDrawable.setColorFilter(new PorterDuffColorFilter(col, PorterDuff.Mode.SRC_IN));
|
||||
DisplayMetrics metrics = getResources().getDisplayMetrics();
|
||||
|
||||
paintOuter = new Paint();
|
||||
paintOuter.setAntiAlias(true);
|
||||
paintOuter.setStyle(Style.FILL_AND_STROKE);
|
||||
paintInnerCircle = new Paint();
|
||||
paintInnerCircle.setStyle(Style.FILL_AND_STROKE);
|
||||
if(metrics != null && metrics.density > 0) {
|
||||
paintOuter.setStrokeWidth(metrics.density * 1);
|
||||
} else {
|
||||
paintOuter.setStrokeWidth(1);
|
||||
}
|
||||
// paintOuter.setColor(color == 0 || color == Color.BLACK ? 0x88555555 : color);
|
||||
paintOuter.setColor(0xffbbbbbb);
|
||||
paintInnerCircle.setColor(Color.WHITE);
|
||||
paintOuter.setColor(color == 0 || color == Color.BLACK ? 0x88555555 : color);
|
||||
paintInnerCircle.setColor(color == 0 || color == Color.BLACK ? getResources().getColor(R.color.color_favorite)
|
||||
: color);
|
||||
paintInnerCircle.setAntiAlias(true);
|
||||
}
|
||||
|
||||
|
@ -69,7 +61,7 @@ public class FavoriteImageDrawable extends Drawable {
|
|||
if (!withShadow) {
|
||||
Rect bs = new Rect(bounds);
|
||||
//bs.inset((int) (4 * density), (int) (4 * density));
|
||||
bs.inset(bs.width() / 4, (int) bs.height() / 4);
|
||||
bs.inset(bs.width() / 4, bs.height() / 4);
|
||||
listDrawable.setBounds(bs);
|
||||
}
|
||||
}
|
||||
|
@ -100,8 +92,8 @@ public class FavoriteImageDrawable extends Drawable {
|
|||
canvas.drawBitmap(favIcon, bs.exactCenterX() - favIcon.getWidth() / 2f, bs.exactCenterY() - favIcon.getHeight() / 2f, paintIcon);
|
||||
} else {
|
||||
int min = Math.min(bs.width(), bs.height());
|
||||
int r = (int) (min * 4 / 10);
|
||||
int rs = (int) (r - 1);
|
||||
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);
|
||||
|
|
|
@ -3,8 +3,11 @@ package net.osmand.plus.views;
|
|||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
|
@ -33,6 +36,7 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
|||
private MapTextLayer textLayer;
|
||||
private Paint paintIcon;
|
||||
private Bitmap pointSmall;
|
||||
private int defaultColor;
|
||||
|
||||
private OsmandSettings settings;
|
||||
|
||||
|
@ -60,6 +64,7 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
|||
textLayer = view.getLayerByClass(MapTextLayer.class);
|
||||
paintIcon = new Paint();
|
||||
pointSmall = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_white_shield_small);
|
||||
defaultColor = view.getResources().getColor(R.color.color_favorite);
|
||||
}
|
||||
|
||||
private boolean calculateBelongs(int ex, int ey, int objx, int objy, int radius) {
|
||||
|
@ -97,10 +102,15 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
|||
final QuadRect latLonBounds = tileBox.getLatLonBounds();
|
||||
List<LocationPoint> fullObjects = new ArrayList<>();
|
||||
for (LocationPoint o : getPoints()) {
|
||||
if (!o.isVisible()) {
|
||||
continue;
|
||||
}
|
||||
float x = tileBox.getPixXFromLatLon(o.getLatitude(), o.getLongitude());
|
||||
float y = tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
|
||||
|
||||
if (intersects(boundIntersections, x, y, iconSize, iconSize)) {
|
||||
int col = o.getColor() == 0 || o.getColor() == Color.BLACK ? defaultColor : o.getColor();
|
||||
paintIcon.setColorFilter(new PorterDuffColorFilter(col, PorterDuff.Mode.MULTIPLY));
|
||||
canvas.drawBitmap(pointSmall, x - pointSmall.getWidth() / 2, y - pointSmall.getHeight() / 2, paintIcon);
|
||||
} else {
|
||||
fullObjects.add(o);
|
||||
|
|
|
@ -10,6 +10,7 @@ import android.graphics.Paint.Align;
|
|||
import android.graphics.Paint.Style;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuff.Mode;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.support.annotation.NonNull;
|
||||
|
@ -294,6 +295,9 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
float y = tileBox.getPixYFromLatLon(o.lat, o.lon);
|
||||
|
||||
if (intersects(boundIntersections, x, y, iconSize, iconSize)) {
|
||||
boolean visit = isPointVisited(o);
|
||||
int col = visit ? visitedColor : o.getColor(fcolor);
|
||||
paintIcon.setColorFilter(new PorterDuffColorFilter(col, PorterDuff.Mode.MULTIPLY));
|
||||
canvas.drawBitmap(pointSmall, x - pointSmall.getWidth() / 2, y - pointSmall.getHeight() / 2, paintIcon);
|
||||
} else {
|
||||
fullObjects.add(o);
|
||||
|
|
Loading…
Reference in a new issue