Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
32e193a508
2 changed files with 81 additions and 60 deletions
|
@ -1,7 +1,5 @@
|
|||
package net.osmand.plus.audionotes;
|
||||
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
|
@ -9,16 +7,13 @@ import android.graphics.Color;
|
|||
import android.graphics.Paint;
|
||||
import android.graphics.Paint.Style;
|
||||
import android.graphics.PointF;
|
||||
import android.widget.ArrayAdapter;
|
||||
|
||||
import net.osmand.access.AccessibleAlertBuilder;
|
||||
import net.osmand.data.DataTileManager;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.data.QuadTree;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.audionotes.AudioVideoNotesPlugin.Recording;
|
||||
|
@ -26,6 +21,7 @@ import net.osmand.plus.views.ContextMenuLayer.IContextMenuProvider;
|
|||
import net.osmand.plus.views.OsmandMapLayer;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AudioNotesLayer extends OsmandMapLayer implements IContextMenuProvider {
|
||||
|
@ -40,6 +36,7 @@ public class AudioNotesLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
private Bitmap audio;
|
||||
private Bitmap video;
|
||||
private Bitmap photo;
|
||||
private Bitmap pointSmall;
|
||||
|
||||
public AudioNotesLayer(MapActivity activity, AudioVideoNotesPlugin plugin) {
|
||||
this.activity = activity;
|
||||
|
@ -58,6 +55,8 @@ public class AudioNotesLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
video = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_note_video);
|
||||
photo = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_note_photo);
|
||||
|
||||
pointSmall = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_note_small);
|
||||
|
||||
paintIcon = new Paint();
|
||||
|
||||
point = new Paint();
|
||||
|
@ -76,6 +75,16 @@ public class AudioNotesLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
return (int) (r * tb.getDensity());
|
||||
}
|
||||
|
||||
private QuadRect calculateRect(float x, float y, float width, float height) {
|
||||
QuadRect rf;
|
||||
double left = x - width / 2.0d;
|
||||
double top = y - height / 2.0d;
|
||||
double right = left + width;
|
||||
double bottom = top + height;
|
||||
rf = new QuadRect(left, top, right, bottom);
|
||||
return rf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
|
||||
}
|
||||
|
@ -83,12 +92,41 @@ public class AudioNotesLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
@Override
|
||||
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
|
||||
if (tileBox.getZoom() >= startZoom) {
|
||||
float iconSize = audio.getWidth() * 3 / 2.5f;
|
||||
QuadRect bounds = new QuadRect(0, 0, tileBox.getPixWidth(), tileBox.getPixHeight());
|
||||
bounds.inset(-bounds.width()/4, -bounds.height()/4);
|
||||
QuadTree<QuadRect> boundIntersections = new QuadTree<>(bounds, 4, 0.6f);
|
||||
List<QuadRect> result = new ArrayList<>();
|
||||
|
||||
DataTileManager<Recording> recs = plugin.getRecordings();
|
||||
final QuadRect latlon = tileBox.getLatLonBounds();
|
||||
List<Recording> objects = recs.getObjects(latlon. top, latlon.left, latlon.bottom, latlon.right);
|
||||
List<Recording> objects = recs.getObjects(latlon.top, latlon.left, latlon.bottom, latlon.right);
|
||||
List<Recording> fullObjects = new ArrayList<>();
|
||||
for (Recording o : objects) {
|
||||
int x = (int) tileBox.getPixXFromLatLon(o.getLatitude(), o.getLongitude());
|
||||
int y = (int) tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
|
||||
float x = tileBox.getPixXFromLatLon(o.getLatitude(), o.getLongitude());
|
||||
float y = tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
|
||||
|
||||
boolean intersects = false;
|
||||
QuadRect visibleRect = calculateRect(x, y, iconSize, iconSize);
|
||||
boundIntersections.queryInBox(new QuadRect(visibleRect.left, visibleRect.top, visibleRect.right, visibleRect.bottom), result);
|
||||
for (QuadRect r : result) {
|
||||
if (QuadRect.intersects(r, visibleRect)) {
|
||||
intersects = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (intersects) {
|
||||
canvas.drawBitmap(pointSmall, x - pointSmall.getWidth() / 2, y - pointSmall.getHeight() / 2, paintIcon);
|
||||
} else {
|
||||
boundIntersections.insert(visibleRect,
|
||||
new QuadRect(visibleRect.left, visibleRect.top, visibleRect.right, visibleRect.bottom));
|
||||
fullObjects.add(o);
|
||||
}
|
||||
}
|
||||
for (Recording o : fullObjects) {
|
||||
float x = tileBox.getPixXFromLatLon(o.getLatitude(), o.getLongitude());
|
||||
float y = tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
|
||||
Bitmap b;
|
||||
if (o.isPhoto()) {
|
||||
b = photo;
|
||||
|
@ -96,7 +134,6 @@ public class AudioNotesLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
b = audio;
|
||||
} else {
|
||||
b = video;
|
||||
|
||||
}
|
||||
canvas.drawBitmap(b, x - b.getWidth() / 2, y - b.getHeight() / 2, paintIcon);
|
||||
}
|
||||
|
|
|
@ -1,39 +1,5 @@
|
|||
package net.osmand.plus.views;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.ResultMatcher;
|
||||
import net.osmand.ValueHolder;
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.data.QuadTree;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.osm.PoiType;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.helpers.FileNameTranslationHelper;
|
||||
import net.osmand.plus.poi.PoiFiltersHelper;
|
||||
import net.osmand.plus.poi.PoiUIFilter;
|
||||
import net.osmand.plus.render.RenderingIcons;
|
||||
import net.osmand.plus.resources.ResourceManager;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener;
|
||||
import net.osmand.plus.views.MapTextLayer.MapTextProvider;
|
||||
import net.osmand.util.Algorithms;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.app.Dialog;
|
||||
|
@ -44,7 +10,6 @@ import android.graphics.BitmapFactory;
|
|||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Paint.Style;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
|
@ -64,13 +29,43 @@ import android.view.MotionEvent;
|
|||
import android.view.View;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.LinearLayout.LayoutParams;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.ResultMatcher;
|
||||
import net.osmand.ValueHolder;
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.data.QuadTree;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.osm.PoiType;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.helpers.FileNameTranslationHelper;
|
||||
import net.osmand.plus.poi.PoiFiltersHelper;
|
||||
import net.osmand.plus.poi.PoiUIFilter;
|
||||
import net.osmand.plus.render.RenderingIcons;
|
||||
import net.osmand.plus.resources.ResourceManager;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener;
|
||||
import net.osmand.plus.views.MapTextLayer.MapTextProvider;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.IContextMenuProvider,
|
||||
MapTextProvider<Amenity>, IRouteInformationListener {
|
||||
|
@ -222,16 +217,6 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
|
|||
return (int) (r * tb.getDensity());
|
||||
}
|
||||
|
||||
private QuadRect calculateRect(int x, int y, int width, int height) {
|
||||
QuadRect rf;
|
||||
double left = x - width / 2;
|
||||
double top = y - height / 2;
|
||||
double right = left + width;
|
||||
double bottom = top + height;
|
||||
rf = new QuadRect(left, top, right, bottom);
|
||||
return rf;
|
||||
}
|
||||
|
||||
private QuadRect calculateRect(float x, float y, float width, float height) {
|
||||
QuadRect rf;
|
||||
double left = x - width / 2.0d;
|
||||
|
@ -273,10 +258,9 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
|
|||
.getLongitude());
|
||||
float y = tileBox.getPixYFromLatLon(o.getLocation().getLatitude(), o.getLocation()
|
||||
.getLongitude());
|
||||
boolean intersects =false;
|
||||
QuadRect visibleRect = calculateRect(x, y, iconSize, iconSize);
|
||||
//canvas.drawRect(visibleRect, paintIcon);
|
||||
|
||||
boolean intersects = false;
|
||||
QuadRect visibleRect = calculateRect(x, y, iconSize, iconSize);
|
||||
boundIntersections.queryInBox(new QuadRect(visibleRect.left, visibleRect.top, visibleRect.right, visibleRect.bottom), result);
|
||||
for (QuadRect r : result) {
|
||||
if (QuadRect.intersects(r, visibleRect)) {
|
||||
|
|
Loading…
Reference in a new issue