Fix favorite icon
This commit is contained in:
parent
11bee7bf40
commit
cb243a0012
11 changed files with 16 additions and 17 deletions
|
@ -228,7 +228,7 @@ public class FavoritesListFragment extends OsmAndListFragment implements SearchA
|
|||
}
|
||||
((TextView) row.findViewById(R.id.group_name)).setText(favorite.getCategory());
|
||||
|
||||
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(activity, favorite.getColor(), 0));
|
||||
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(activity, favorite.getColor(), false));
|
||||
DashLocationFragment.updateLocationView(!searchAroundLocation, location, heading, direction, distanceText,
|
||||
favorite.getLatitude(), favorite.getLongitude(), screenOrientation, app, activity);
|
||||
|
||||
|
|
|
@ -807,7 +807,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
|
|||
}
|
||||
});
|
||||
}
|
||||
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(getActivity(), model.getColor(), 0));
|
||||
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(getActivity(), model.getColor(), false));
|
||||
LatLon lastKnownMapLocation = getMyApplication().getSettings().getLastKnownMapLocation();
|
||||
int dist = (int) (MapUtils.getDistance(model.getLatitude(), model.getLongitude(),
|
||||
lastKnownMapLocation.getLatitude(), lastKnownMapLocation.getLongitude()));
|
||||
|
|
|
@ -26,7 +26,7 @@ public class FavoriteImageDrawable extends Drawable {
|
|||
private Bitmap favBackground;
|
||||
private Resources resources;
|
||||
|
||||
public FavoriteImageDrawable(Context ctx, int color) {
|
||||
public FavoriteImageDrawable(Context ctx, int color, boolean withShadow) {
|
||||
this.resources = ctx.getResources();
|
||||
this.color = color;
|
||||
paintIcon = new Paint();
|
||||
|
@ -95,12 +95,12 @@ public class FavoriteImageDrawable extends Drawable {
|
|||
|
||||
private static TreeMap<Integer, FavoriteImageDrawable> cache = new TreeMap<>();
|
||||
|
||||
public static FavoriteImageDrawable getOrCreate(Context a, int color, float density) {
|
||||
public static FavoriteImageDrawable getOrCreate(Context a, int color, boolean withShadow) {
|
||||
color = color | 0xff000000;
|
||||
int hash = (color << 2) + (int) (density * 6);
|
||||
int hash = (color << 2) + (withShadow ? 1 : 0);
|
||||
FavoriteImageDrawable drawable = cache.get(hash);
|
||||
if (drawable == null) {
|
||||
drawable = new FavoriteImageDrawable(a, color);
|
||||
drawable = new FavoriteImageDrawable(a, color, withShadow);
|
||||
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
|
||||
cache.put(hash, drawable);
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ public class DashFavoritesFragment extends DashLocationFragment {
|
|||
}
|
||||
|
||||
((ImageView) view.findViewById(R.id.favourite_icon)).setImageDrawable(FavoriteImageDrawable.getOrCreate(
|
||||
getActivity(), point.getColor(), 0));
|
||||
getActivity(), point.getColor(), false));
|
||||
DashLocationView dv = new DashLocationView(direction, label, new LatLon(point.getLatitude(),
|
||||
point.getLongitude()));
|
||||
distances.add(dv);
|
||||
|
|
|
@ -683,7 +683,7 @@ public class WaypointHelper {
|
|||
R.drawable.list_intermediate;
|
||||
return uiCtx.getResources().getDrawable(i);
|
||||
} else if(type == FAVORITES || type == WAYPOINTS) {
|
||||
return FavoriteImageDrawable.getOrCreate(uiCtx, point.getColor(), 0);
|
||||
return FavoriteImageDrawable.getOrCreate(uiCtx, point.getColor(), false);
|
||||
} else if(type == ALARMS) {
|
||||
//assign alarm list icons manually for now
|
||||
if(((AlarmInfo) point).getType().toString() == "SPEED_CAMERA") {
|
||||
|
|
|
@ -49,7 +49,7 @@ public class FavouritePointMenuController extends MenuController {
|
|||
|
||||
@Override
|
||||
public Drawable getLeftIcon() {
|
||||
return FavoriteImageDrawable.getOrCreate(getMapActivity().getMyApplication(), fav.getColor(), 0);
|
||||
return FavoriteImageDrawable.getOrCreate(getMapActivity().getMyApplication(), fav.getColor(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -50,7 +50,7 @@ public class WptPtMenuController extends MenuController {
|
|||
|
||||
@Override
|
||||
public Drawable getLeftIcon() {
|
||||
return FavoriteImageDrawable.getOrCreate(getMapActivity().getMyApplication(), wpt.getColor(), 0);
|
||||
return FavoriteImageDrawable.getOrCreate(getMapActivity().getMyApplication(), wpt.getColor(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -210,7 +210,7 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
|
|||
if (group != null) {
|
||||
color = group.color;
|
||||
}
|
||||
return FavoriteImageDrawable.getOrCreate(getMapActivity(), color, getMapActivity().getMapView().getCurrentRotatedTileBox().getDensity());
|
||||
return FavoriteImageDrawable.getOrCreate(getMapActivity(), color, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -459,7 +459,7 @@ public class SelectedGPXFragment extends OsmAndListFragment {
|
|||
if(groupColor == 0) {
|
||||
groupColor = getMyActivity().getResources().getColor(R.color.gpx_track);
|
||||
}
|
||||
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(getMyActivity(), groupColor, 0));
|
||||
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(getMyActivity(), groupColor, false));
|
||||
}
|
||||
}
|
||||
row.setTag(child);
|
||||
|
|
|
@ -90,7 +90,7 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
|||
if (this.settings.SHOW_FAVORITES.get()) {
|
||||
if (tileBox.getZoom() >= startZoom) {
|
||||
float iconSize = FavoriteImageDrawable.getOrCreate(view.getContext(), 0,
|
||||
tileBox.getDensity()).getIntrinsicWidth() * 3 / 2.5f;
|
||||
true).getIntrinsicWidth() * 3 / 2.5f;
|
||||
QuadTree<QuadRect> boundIntersections = initBoundIntersections(tileBox);
|
||||
|
||||
// request to load
|
||||
|
@ -124,7 +124,7 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
|||
cache.add(o);
|
||||
int x = (int) tileBox.getPixXFromLatLon(o.getLatitude(), o.getLongitude());
|
||||
int y = (int) tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
|
||||
FavoriteImageDrawable fid = FavoriteImageDrawable.getOrCreate(view.getContext(), o.getColor(), tileBox.getDensity());
|
||||
FavoriteImageDrawable fid = FavoriteImageDrawable.getOrCreate(view.getContext(), o.getColor(), true);
|
||||
fid.drawBitmapInCenter(canvas, x, y);
|
||||
// canvas.drawBitmap(favoriteIcon, x - favoriteIcon.getWidth() / 2,
|
||||
// y - favoriteIcon.getHeight(), paint);
|
||||
|
|
|
@ -277,7 +277,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
int visitedColor = view.getContext().getResources().getColor(R.color.color_ok);
|
||||
if (tileBox.getZoom() >= startZoom) {
|
||||
float iconSize = FavoriteImageDrawable.getOrCreate(view.getContext(), 0,
|
||||
tileBox.getDensity()).getIntrinsicWidth() * 3 / 2.5f;
|
||||
true).getIntrinsicWidth() * 3 / 2.5f;
|
||||
QuadTree<QuadRect> boundIntersections = initBoundIntersections(tileBox);
|
||||
|
||||
// request to load
|
||||
|
@ -305,8 +305,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
float y = tileBox.getPixYFromLatLon(o.lat, o.lon);
|
||||
boolean visit = isPointVisited(o);
|
||||
int pointColor = visit ? visitedColor : o.getColor(fcolor);
|
||||
FavoriteImageDrawable fid = FavoriteImageDrawable.getOrCreate(view.getContext(), pointColor,
|
||||
tileBox.getDensity());
|
||||
FavoriteImageDrawable fid = FavoriteImageDrawable.getOrCreate(view.getContext(), pointColor, true);
|
||||
fid.drawBitmapInCenter(canvas, x, y);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue