Merge pull request #9039 from osmandapp/Text_scale_map_icon37

Text scale map icon fix
This commit is contained in:
max-klaus 2020-05-21 16:41:07 +03:00 committed by GitHub
commit 13875cf3be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 31 additions and 18 deletions

View file

@ -128,5 +128,6 @@
<dimen name="side_of_the_world_button_size">54dp</dimen>
<dimen name="toolbar_height">64dp</dimen>
<dimen name="poi_icon_size">24dp</dimen>
</resources>

View file

@ -90,6 +90,7 @@
<dimen name="dialog_content_bottom_margin">16dp</dimen>
<dimen name="local_size_height">34dp</dimen>
<dimen name="standard_icon_size">24dp</dimen>
<dimen name="poi_icon_size">16dp</dimen>
<dimen name="gpx_small_icon_margin">3dp</dimen>
<dimen name="gpx_small_text_margin">14dp</dimen>
<dimen name="gpx_text_top_margin">6dp</dimen>

View file

@ -203,7 +203,7 @@ public class AudioNotesLayer extends OsmandMapLayer implements
public void getRecordingsFromPoint(PointF point, RotatedTileBox tileBox, List<? super Recording> am) {
int ex = (int) point.x;
int ey = (int) point.y;
int compare = getRadiusPoi(tileBox);
int compare = getScaledTouchRadius(activity.getMyApplication(), getRadiusPoi(tileBox));
int radius = compare * 3 / 2;
for (Recording n : plugin.getAllRecordings()) {
int x = (int) tileBox.getPixXFromLatLon(n.getLatitude(), n.getLongitude());

View file

@ -21,7 +21,6 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresPermission;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.core.content.ContextCompat;
import net.osmand.AndroidUtils;
import net.osmand.CallbackWithObject;
@ -223,15 +222,21 @@ public class ContextMenuLayer extends OsmandMapLayer {
}
}
}
float scale = 1f;
if (!pressedLatLonSmall.isEmpty() || !pressedLatLonFull.isEmpty()) {
scale = activity.getMyApplication().getSettings().TEXT_SCALE.get();
}
for (LatLon latLon : pressedLatLonSmall) {
int x = (int) box.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
int y = (int) box.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
canvas.drawBitmap(pressedBitmapSmall, x - pressedBitmapSmall.getWidth() / 2, y - pressedBitmapSmall.getHeight() / 2, paint);
Rect destRect = getIconDestinationRect(x, y, pressedBitmapSmall.getWidth(), pressedBitmapSmall.getHeight(), scale);
canvas.drawBitmap(pressedBitmapSmall, null, destRect, paint);
}
for (LatLon latLon : pressedLatLonFull) {
int x = (int) box.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
int y = (int) box.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
canvas.drawBitmap(pressedBitmap, x - pressedBitmap.getWidth() / 2, y - pressedBitmap.getHeight() / 2, paint);
Rect destRect = getIconDestinationRect(x, y, pressedBitmap.getWidth(), pressedBitmap.getHeight(), scale);
canvas.drawBitmap(pressedBitmap, null, destRect, paint);
}
if (mapQuickActionLayer != null && mapQuickActionLayer.isInMovingMarkerMode())

View file

@ -216,7 +216,7 @@ public class FavouritesLayer extends OsmandMapLayer implements ContextMenuLayer.
}
private void getFavoriteFromPoint(RotatedTileBox tb, PointF point, List<? super FavouritePoint> res) {
int r = getDefaultRadiusPoi(tb);
int r = getScaledTouchRadius(view.getApplication(), getDefaultRadiusPoi(tb));
int ex = (int) point.x;
int ey = (int) point.y;
for (FavouritePoint n : favorites.getFavouritePoints()) {

View file

@ -580,7 +580,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
}
public void getWptFromPoint(RotatedTileBox tb, PointF point, List<? super WptPt> res) {
int r = getDefaultRadiusPoi(tb);
int r = getScaledTouchRadius(view.getApplication(), getDefaultRadiusPoi(tb));
int ex = (int) point.x;
int ey = (int) point.y;
List<SelectedGpxFile> selectedGpxFiles = new ArrayList<>(selectedGpxHelper.getSelectedGPXFiles());

View file

@ -637,6 +637,14 @@ public abstract class OsmandMapLayer {
return rect;
}
public int getScaledTouchRadius(OsmandApplication app, int radiusPoi) {
float textScale = app.getSettings().TEXT_SCALE.get();
if (textScale < 1.0f) {
textScale = 1.0f;
}
return (int) textScale * radiusPoi;
}
public abstract class MapLayerData<T> {
public int ZOOM_THRESHOLD = 1;
public RotatedTileBox queriedBox;

View file

@ -153,9 +153,8 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
if (objects != null) {
int ex = (int) point.x;
int ey = (int) point.y;
final int rp = getRadiusPoi(tb);
int compare = rp;
int radius = rp * 3 / 2;
int compare = getScaledTouchRadius(view.getApplication(), getRadiusPoi(tb));
int radius = compare * 3 / 2;
try {
for (int i = 0; i < objects.size(); i++) {
Amenity n = objects.get(i);
@ -176,8 +175,7 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
@Override
public void initLayer(OsmandMapTileView view) {
this.view = view;
poiSize = dpToPx(view.getContext(), 16f);
poiSize = app.getResources().getDimensionPixelSize(R.dimen.poi_icon_size);
poiColorFilter = new PorterDuffColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN);
paintIconBackground = new Paint();
poiBackground = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_white_orange_poi_shield);

View file

@ -144,7 +144,7 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa
List<TransportStop> objects) {
int ex = (int) point.x;
int ey = (int) point.y;
final int rp = getRadiusPoi(tb);
final int rp = getScaledTouchRadius(mapActivity.getMyApplication(), getRadiusPoi(tb));
int radius = rp * 3 / 2;
try {
TreeSet<String> ms = new TreeSet<>();