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