Update favorite icon
This commit is contained in:
parent
ff12924f63
commit
a2ac25cdda
2 changed files with 13 additions and 34 deletions
|
@ -38,7 +38,6 @@
|
|||
<!-- string name="delete_confirmation_title">About to delete</string -->
|
||||
<string name="delete_confirmation_msg">Delete %1$s?</string>
|
||||
<string name="city_type_suburb">Suburb</string>
|
||||
<string name="city_type_suburb">Suburb</string>
|
||||
<string name="city_type_hamlet">Hamlet</string>
|
||||
<string name="city_type_village">Village</string>
|
||||
<string name="city_type_town">Town</string>
|
||||
|
|
|
@ -8,6 +8,8 @@ import net.osmand.plus.FavouritesDbHelper;
|
|||
import net.osmand.plus.R;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Paint;
|
||||
|
@ -26,13 +28,10 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.I
|
|||
private static final int radius = 15;
|
||||
|
||||
private OsmandMapTileView view;
|
||||
private Path path;
|
||||
private Path pathDst;
|
||||
private Paint paint;
|
||||
private Matrix matrix;
|
||||
private Paint paintBlack;
|
||||
private DisplayMetrics dm;
|
||||
private FavouritesDbHelper favorites;
|
||||
private Bitmap favoriteIcon;
|
||||
|
||||
|
||||
public FavoritesLayer(){
|
||||
|
@ -45,33 +44,16 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.I
|
|||
dm = new DisplayMetrics();
|
||||
WindowManager wmgr = (WindowManager) view.getContext().getSystemService(Context.WINDOW_SERVICE);
|
||||
wmgr.getDefaultDisplay().getMetrics(dm);
|
||||
path = new Path();
|
||||
pathDst = new Path();
|
||||
int coef1 = (int) (radius * dm.density);
|
||||
int coef2 = (int) (radius * dm.density/2);
|
||||
float a = (float) (Math.PI/ 5);
|
||||
path.moveTo(FloatMath.sin(0)*coef1, -FloatMath.cos(0)*coef1);
|
||||
for (int j = 1; j < 10; j++) {
|
||||
if (j % 2 == 1) {
|
||||
path.lineTo(FloatMath.sin(j * a) * coef2, -FloatMath.cos(j * a) * coef2);
|
||||
} else {
|
||||
path.lineTo(FloatMath.sin(j * a) * coef1, -FloatMath.cos(j * a) * coef1);
|
||||
}
|
||||
}
|
||||
matrix = new Matrix();
|
||||
path.close();
|
||||
|
||||
paint = new Paint();
|
||||
paint.setStyle(Style.FILL);
|
||||
paint.setARGB(200, 255, 150, 0);
|
||||
paintBlack = new Paint();
|
||||
paintBlack.setStyle(Style.STROKE);
|
||||
paintBlack.setARGB(255, 0, 0, 0);
|
||||
paintBlack.setAntiAlias(true);
|
||||
paintBlack.setStrokeWidth(2);
|
||||
paint.setAntiAlias(true);
|
||||
paint.setFilterBitmap(true);
|
||||
paint.setDither(true);
|
||||
|
||||
favorites = view.getApplication().getFavorites();
|
||||
|
||||
favoriteIcon = BitmapFactory.decodeResource(view.getResources(), R.drawable.poi_favourite);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -82,7 +64,7 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.I
|
|||
|
||||
@Override
|
||||
public boolean drawInScreenPixels() {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -93,12 +75,10 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.I
|
|||
for (FavouritePoint o : favorites.getFavouritePoints()) {
|
||||
if (o.getLatitude() >= latLonBounds.bottom && o.getLatitude() <= latLonBounds.top && o.getLongitude() >= latLonBounds.left
|
||||
&& o.getLongitude() <= latLonBounds.right ) {
|
||||
int x = view.getMapXForPoint(o.getLongitude());
|
||||
int y = view.getMapYForPoint(o.getLatitude());
|
||||
matrix.setTranslate(x, y);
|
||||
path.transform(matrix, pathDst);
|
||||
canvas.drawPath(pathDst, paint);
|
||||
canvas.drawPath(pathDst, paintBlack);
|
||||
int x = view.getRotatedMapXForPoint(o.getLatitude(), o.getLongitude());
|
||||
int y = view.getRotatedMapYForPoint(o.getLatitude(), o.getLongitude());
|
||||
canvas.drawBitmap(favoriteIcon, x - favoriteIcon.getWidth() / 2,
|
||||
y - favoriteIcon.getHeight() / 2, paint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue