From 17e85379f898191f94d49f0a2cbe162770a29dd8 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Tue, 4 Apr 2023 18:42:03 -0700 Subject: [PATCH] Tap the map background to deselect trkpt. --- .../java/net/voussoir/trkpt/TrackFragment.kt | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/app/src/main/java/net/voussoir/trkpt/TrackFragment.kt b/app/src/main/java/net/voussoir/trkpt/TrackFragment.kt index adb68a2..63e6eb0 100644 --- a/app/src/main/java/net/voussoir/trkpt/TrackFragment.kt +++ b/app/src/main/java/net/voussoir/trkpt/TrackFragment.kt @@ -46,12 +46,14 @@ import com.google.android.material.textview.MaterialTextView import net.voussoir.trkpt.helpers.* import org.osmdroid.api.IGeoPoint import org.osmdroid.api.IMapController +import org.osmdroid.events.MapEventsReceiver import org.osmdroid.events.MapListener import org.osmdroid.events.ScrollEvent import org.osmdroid.events.ZoomEvent import org.osmdroid.tileprovider.tilesource.TileSourceFactory import org.osmdroid.util.GeoPoint import org.osmdroid.views.MapView +import org.osmdroid.views.overlay.MapEventsOverlay import org.osmdroid.views.overlay.Polyline import org.osmdroid.views.overlay.TilesOverlay import org.osmdroid.views.overlay.simplefastpoint.SimpleFastPointOverlay @@ -402,6 +404,25 @@ class TrackFragment : Fragment(), MapListener, YesNoDialog.YesNoDialogListener selected_trkpt_info.text = "" } + fun create_event_receiver_overlay() + { + val receiver: MapEventsReceiver = object: MapEventsReceiver + { + override fun singleTapConfirmedHelper(p: GeoPoint?): Boolean + { + Log.i("VOUSSOIR", "MapEventsReceiver.singletap") + deselect_trkpt() + return true + } + + override fun longPressHelper(point: GeoPoint): Boolean + { + return false + } + } + mapView.overlays.add(MapEventsOverlay(receiver)) + } + fun render_track() { Log.i("VOUSSOIR", "TrackFragment.render_track") @@ -416,6 +437,9 @@ class TrackFragment : Fragment(), MapListener, YesNoDialog.YesNoDialogListener { return } + + create_event_receiver_overlay() + Log.i("VOUSSOIR", "MapOverlayHelper.createTrackOverlay") track_geopoints = mutableListOf() for (trkpt in track.trkpts)