summaryrefslogtreecommitdiff
path: root/altoslib/AltosMap.java
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2015-06-22 20:08:05 -0700
committerKeith Packard <keithp@keithp.com>2015-06-22 21:04:43 -0700
commit0f56903774d9e8bb033dfc0af6945e8ddc1d3065 (patch)
treeeac0d0900286d80253670738381e4de73481b4e0 /altoslib/AltosMap.java
parenta959c1926048d1b96a06aa291131afd7c8e771c7 (diff)
altosdroid: Select tracker by clicking on map
This lets you pick a tracker from the map, rather than having to use the menu. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altoslib/AltosMap.java')
-rw-r--r--altoslib/AltosMap.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/altoslib/AltosMap.java b/altoslib/AltosMap.java
index adf52ab9..8d12a180 100644
--- a/altoslib/AltosMap.java
+++ b/altoslib/AltosMap.java
@@ -391,6 +391,10 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener {
AltosPointInt drag_start;
+ boolean dragged;
+
+ static final double drag_far = 20;
+
private void drag(int x, int y) {
if (drag_start == null)
return;
@@ -398,6 +402,11 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener {
int dx = x - drag_start.x;
int dy = y - drag_start.y;
+ double distance = Math.hypot(dx, dy);
+
+ if (distance > drag_far)
+ dragged = true;
+
if (transform == null) {
debug("Transform not set in drag\n");
return;
@@ -410,6 +419,12 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener {
private void drag_start(int x, int y) {
drag_start = new AltosPointInt(x, y);
+ dragged = false;
+ }
+
+ private void drag_stop(int x, int y) {
+ if (!dragged)
+ map_interface.select_object (transform.screen_lat_lon(new AltosPointInt(x,y)));
}
private void line_start(int x, int y) {
@@ -442,6 +457,12 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener {
line(x, y);
}
+ public void touch_stop(int x, int y, boolean is_drag) {
+ notice_user_input();
+ if (is_drag)
+ drag_stop(x, y);
+ }
+
public AltosMap(AltosMapInterface map_interface) {
this.map_interface = map_interface;
cache = new AltosMapCache(map_interface);