From 13287f5b056bd1ee5cccc9298c46aaa563c1f7e1 Mon Sep 17 00:00:00 2001 From: "Daniele Verducci (Slimpenguin)" Date: Fri, 23 Feb 2024 08:31:23 +0100 Subject: [PATCH] Implemented geofav creation on long press --- .../fragments/GeofavoriteMapFragment.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/it/danieleverducci/nextcloudmaps/fragments/GeofavoriteMapFragment.java b/app/src/main/java/it/danieleverducci/nextcloudmaps/fragments/GeofavoriteMapFragment.java index 0a02f2f..8d88e5e 100644 --- a/app/src/main/java/it/danieleverducci/nextcloudmaps/fragments/GeofavoriteMapFragment.java +++ b/app/src/main/java/it/danieleverducci/nextcloudmaps/fragments/GeofavoriteMapFragment.java @@ -1,8 +1,10 @@ package it.danieleverducci.nextcloudmaps.fragments; import android.Manifest; +import android.content.Intent; import android.content.pm.PackageManager; import android.graphics.drawable.Drawable; +import android.net.Uri; import android.os.Bundle; import android.util.Log; import android.view.LayoutInflater; @@ -33,7 +35,9 @@ import java.util.Set; import it.danieleverducci.nextcloudmaps.R; import it.danieleverducci.nextcloudmaps.activity.detail.GeofavoriteDetailActivity; import it.danieleverducci.nextcloudmaps.activity.main.MainActivity; +import it.danieleverducci.nextcloudmaps.activity.mappicker.MapPickerActivity; import it.danieleverducci.nextcloudmaps.model.Geofavorite; +import it.danieleverducci.nextcloudmaps.utils.GeoUriParser; import it.danieleverducci.nextcloudmaps.utils.MapUtils; import it.danieleverducci.nextcloudmaps.utils.SettingsManager; import it.danieleverducci.nextcloudmaps.views.GeofavMarkerInfoWindow; @@ -63,7 +67,7 @@ public class GeofavoriteMapFragment extends GeofavoritesFragment implements Main map.getZoomController().setVisibility(CustomZoomButtonsController.Visibility.NEVER); map.setMultiTouchControls(true); MapUtils.setTheme(map); - MapEventsOverlay meo = new MapEventsOverlay(requireContext(), new MapEventsReceiver() { + MapEventsOverlay meo = new MapEventsOverlay(new MapEventsReceiver() { @Override public boolean singleTapConfirmedHelper(GeoPoint p) { InfoWindow.closeAllInfoWindowsOn(map); @@ -71,7 +75,14 @@ public class GeofavoriteMapFragment extends GeofavoritesFragment implements Main } @Override - public boolean longPressHelper(GeoPoint p) {return false;} + public boolean longPressHelper(GeoPoint p) { + // Create new geofavorite (go to geofav creation activity) + Uri geoUri = GeoUriParser.createGeoUri(p.getLatitude(), p.getLongitude(), null); + Intent i = new Intent(requireActivity(), GeofavoriteDetailActivity.class); + i.setData(geoUri); + startActivity(i); + return true; + } }); map.getOverlays().add(0, meo); showUserPosition();