From 348847c59e5a4f6a5e4735bb1a420a0aa7ceb351 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Mon, 20 Nov 2017 12:41:41 +0200 Subject: [PATCH 1/4] Add UI and setting for "markers - One tap active" --- .../fragment_direction_indication_dialog.xml | 60 ++++++++++++++++++- .../fragment_direction_indication_dialog.xml | 59 ++++++++++++++++++ OsmAnd/res/values/strings.xml | 2 + .../src/net/osmand/plus/OsmandSettings.java | 2 + .../DirectionIndicationDialogFragment.java | 9 +++ 5 files changed, 131 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/layout-land/fragment_direction_indication_dialog.xml b/OsmAnd/res/layout-land/fragment_direction_indication_dialog.xml index f5424bf6a1..d76253eb22 100644 --- a/OsmAnd/res/layout-land/fragment_direction_indication_dialog.xml +++ b/OsmAnd/res/layout-land/fragment_direction_indication_dialog.xml @@ -348,7 +348,6 @@ @@ -404,6 +403,65 @@ + + + + + + + + + + + + + + + diff --git a/OsmAnd/res/layout/fragment_direction_indication_dialog.xml b/OsmAnd/res/layout/fragment_direction_indication_dialog.xml index cd7759273e..c66311cb24 100644 --- a/OsmAnd/res/layout/fragment_direction_indication_dialog.xml +++ b/OsmAnd/res/layout/fragment_direction_indication_dialog.xml @@ -398,6 +398,65 @@ + + + + + + + + + + + + + + + + + diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 143cd7e007..1a678afc6d 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,6 +9,8 @@ 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy --> + Tap on marker on the map, move it to the first place in active markers, without opening context menu. + One tap active Looking for tracks with waypoints More Appearance on the map diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index b79ae13a91..0dcefc83ca 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -716,6 +716,8 @@ public class OsmandSettings { public final CommonPreference SHOW_LINES_TO_FIRST_MARKERS = new BooleanPreference("show_lines_to_first_markers", false).makeProfile(); public final CommonPreference SHOW_ARROWS_TO_FIRST_MARKERS = new BooleanPreference("show_arrows_to_first_markers", false).makeProfile(); + public final CommonPreference ONE_TAP_MAKE_MARKER_FIRST = new BooleanPreference("one_tap_make_marker_first", false).makeProfile(); + public final CommonPreference USE_MAPILLARY_FILTER = new BooleanPreference("use_mapillary_filters", false).makeGlobal(); public final CommonPreference MAPILLARY_FILTER_USER_KEY = new StringPreference("mapillary_filter_user_key", "").makeGlobal(); public final CommonPreference MAPILLARY_FILTER_USERNAME = new StringPreference("mapillary_filter_username", "").makeGlobal(); diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/DirectionIndicationDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/DirectionIndicationDialogFragment.java index c46d56625b..ab6bd60d01 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/DirectionIndicationDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/DirectionIndicationDialogFragment.java @@ -182,6 +182,15 @@ public class DirectionIndicationDialogFragment extends BaseOsmAndDialogFragment } }); + final CompoundButton oneTapActiveToggle = (CompoundButton) mainView.findViewById(R.id.one_tap_active_switch); + oneTapActiveToggle.setChecked(settings.ONE_TAP_MAKE_MARKER_FIRST.get()); + mainView.findViewById(R.id.one_tap_active_row).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + updateChecked(settings.ONE_TAP_MAKE_MARKER_FIRST, oneTapActiveToggle); + } + }); + return mainView; } From 7d741dc89cabbb24a8c17b7c240736d025bbfbee Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Mon, 20 Nov 2017 14:16:41 +0200 Subject: [PATCH 2/4] Add functionality for running exclusive action instead of opening context menu; rename setting --- OsmAnd/src/net/osmand/plus/OsmandSettings.java | 2 +- .../net/osmand/plus/audionotes/AudioNotesLayer.java | 5 +++++ .../distancecalculator/DistanceCalculatorPlugin.java | 5 +++++ .../osmand/plus/mapillary/MapillaryVectorLayer.java | 5 +++++ .../mapmarkers/DirectionIndicationDialogFragment.java | 4 ++-- .../plus/measurementtool/MeasurementToolLayer.java | 5 +++++ OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java | 5 +++++ OsmAnd/src/net/osmand/plus/osmedit/OsmEditsLayer.java | 5 +++++ OsmAnd/src/net/osmand/plus/osmo/OsMoPositionLayer.java | 7 ++++++- .../osmand/plus/parkingpoint/ParkingPositionLayer.java | 5 +++++ .../plus/routepointsnavigation/RoutePointsLayer.java | 5 +++++ OsmAnd/src/net/osmand/plus/views/AidlMapLayer.java | 5 +++++ OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java | 8 ++++++++ .../net/osmand/plus/views/DownloadedRegionsLayer.java | 7 ++++++- OsmAnd/src/net/osmand/plus/views/FavouritesLayer.java | 5 +++++ OsmAnd/src/net/osmand/plus/views/GPXLayer.java | 5 +++++ .../net/osmand/plus/views/ImpassableRoadsLayer.java | 5 +++++ OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java | 10 ++++++++++ OsmAnd/src/net/osmand/plus/views/POIMapLayer.java | 8 ++++++-- .../src/net/osmand/plus/views/PointLocationLayer.java | 5 +++++ .../net/osmand/plus/views/PointNavigationLayer.java | 7 +++++-- .../src/net/osmand/plus/views/TransportStopsLayer.java | 5 +++++ 22 files changed, 114 insertions(+), 9 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index 0dcefc83ca..e4c2cfbc91 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -716,7 +716,7 @@ public class OsmandSettings { public final CommonPreference SHOW_LINES_TO_FIRST_MARKERS = new BooleanPreference("show_lines_to_first_markers", false).makeProfile(); public final CommonPreference SHOW_ARROWS_TO_FIRST_MARKERS = new BooleanPreference("show_arrows_to_first_markers", false).makeProfile(); - public final CommonPreference ONE_TAP_MAKE_MARKER_FIRST = new BooleanPreference("one_tap_make_marker_first", false).makeProfile(); + public final CommonPreference SELECT_MARKER_ON_SINGLE_TAP = new BooleanPreference("select_marker_on_single_tap", false).makeProfile(); public final CommonPreference USE_MAPILLARY_FILTER = new BooleanPreference("use_mapillary_filters", false).makeGlobal(); public final CommonPreference MAPILLARY_FILTER_USER_KEY = new StringPreference("mapillary_filter_user_key", "").makeGlobal(); diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioNotesLayer.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioNotesLayer.java index e8f0d287bb..046fc39059 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/AudioNotesLayer.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioNotesLayer.java @@ -182,6 +182,11 @@ public class AudioNotesLayer extends OsmandMapLayer implements return o instanceof Recording; } + @Override + public boolean runExclusiveAction(Object o, boolean unknownLocation) { + return false; + } + @Override public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List objects) { if (tileBox.getZoom() >= startZoom) { diff --git a/OsmAnd/src/net/osmand/plus/distancecalculator/DistanceCalculatorPlugin.java b/OsmAnd/src/net/osmand/plus/distancecalculator/DistanceCalculatorPlugin.java index 487e2a22ac..f346b95d0c 100644 --- a/OsmAnd/src/net/osmand/plus/distancecalculator/DistanceCalculatorPlugin.java +++ b/OsmAnd/src/net/osmand/plus/distancecalculator/DistanceCalculatorPlugin.java @@ -589,6 +589,11 @@ public class DistanceCalculatorPlugin extends OsmandPlugin { return false; } + @Override + public boolean runExclusiveAction(Object o, boolean unknownLocation) { + return false; + } + @Override public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List o) { getMPointsFromPoint(tileBox, point, o); diff --git a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryVectorLayer.java b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryVectorLayer.java index 4f802340b3..69ff11e771 100644 --- a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryVectorLayer.java +++ b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryVectorLayer.java @@ -333,6 +333,11 @@ class MapillaryVectorLayer extends MapTileLayer implements MapillaryLayer, ICont return o instanceof MapillaryImage; } + @Override + public boolean runExclusiveAction(Object o, boolean unknownLocation) { + return false; + } + private void getImagesFromPoint(RotatedTileBox tb, PointF point, List images) { Map points = this.visiblePoints; if (points != null) { diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/DirectionIndicationDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/DirectionIndicationDialogFragment.java index ab6bd60d01..1b24b4a1dd 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/DirectionIndicationDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/DirectionIndicationDialogFragment.java @@ -183,11 +183,11 @@ public class DirectionIndicationDialogFragment extends BaseOsmAndDialogFragment }); final CompoundButton oneTapActiveToggle = (CompoundButton) mainView.findViewById(R.id.one_tap_active_switch); - oneTapActiveToggle.setChecked(settings.ONE_TAP_MAKE_MARKER_FIRST.get()); + oneTapActiveToggle.setChecked(settings.SELECT_MARKER_ON_SINGLE_TAP.get()); mainView.findViewById(R.id.one_tap_active_row).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - updateChecked(settings.ONE_TAP_MAKE_MARKER_FIRST, oneTapActiveToggle); + updateChecked(settings.SELECT_MARKER_ON_SINGLE_TAP, oneTapActiveToggle); } }); diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java index b56959ea9d..1cea9008ba 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolLayer.java @@ -409,6 +409,11 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL return !isInMeasurementMode(); } + @Override + public boolean runExclusiveAction(Object o, boolean unknownLocation) { + return false; + } + interface OnSingleTapListener { void onAddPoint(); diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java index 7452609509..5ed95ab18b 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmBugsLayer.java @@ -512,6 +512,11 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider return o instanceof OpenStreetNote; } + @Override + public boolean runExclusiveAction(Object o, boolean unknownLocation) { + return false; + } + @Override public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List res) { if (tileBox.getZoom() >= startZoom) { diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsLayer.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsLayer.java index 1f86adec92..0699f9367a 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsLayer.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditsLayer.java @@ -160,6 +160,11 @@ public class OsmEditsLayer extends OsmandMapLayer implements ContextMenuLayer.IC return o instanceof OsmPoint; } + @Override + public boolean runExclusiveAction(Object o, boolean unknownLocation) { + return false; + } + @Override public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List o) { if (tileBox.getZoom() >= startZoom) { diff --git a/OsmAnd/src/net/osmand/plus/osmo/OsMoPositionLayer.java b/OsmAnd/src/net/osmand/plus/osmo/OsMoPositionLayer.java index 6e6209ce11..35e1368055 100644 --- a/OsmAnd/src/net/osmand/plus/osmo/OsMoPositionLayer.java +++ b/OsmAnd/src/net/osmand/plus/osmo/OsMoPositionLayer.java @@ -13,11 +13,11 @@ import android.graphics.PointF; import android.os.Handler; import android.util.DisplayMetrics; import android.view.WindowManager; + import net.osmand.Location; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.data.RotatedTileBox; -import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.R; import net.osmand.plus.TargetPointsHelper; import net.osmand.plus.TargetPointsHelper.TargetPoint; @@ -212,6 +212,11 @@ public class OsMoPositionLayer extends OsmandMapLayer implements ContextMenuLaye return o instanceof OsMoDevice; } + @Override + public boolean runExclusiveAction(Object o, boolean unknownLocation) { + return false; + } + @Override public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List o) { getOsmoFromPoint(tileBox, point, o); diff --git a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionLayer.java b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionLayer.java index 56823979bc..d768f4181d 100644 --- a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionLayer.java +++ b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionLayer.java @@ -135,6 +135,11 @@ public class ParkingPositionLayer extends OsmandMapLayer implements return o == getParkingPoint(); } + @Override + public boolean runExclusiveAction(Object o, boolean unknownLocation) { + return false; + } + @Override public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List o) { getParkingFromPoint(tileBox, point, o); diff --git a/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsLayer.java b/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsLayer.java index f171815e89..c8ac99da18 100644 --- a/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsLayer.java +++ b/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsLayer.java @@ -42,6 +42,11 @@ public class RoutePointsLayer extends OsmandMapLayer implements ContextMenuLaye return false; } + @Override + public boolean runExclusiveAction(Object o, boolean unknownLocation) { + return false; + } + @Override public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List o) { diff --git a/OsmAnd/src/net/osmand/plus/views/AidlMapLayer.java b/OsmAnd/src/net/osmand/plus/views/AidlMapLayer.java index e6a7a562e0..b11e902931 100644 --- a/OsmAnd/src/net/osmand/plus/views/AidlMapLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/AidlMapLayer.java @@ -128,6 +128,11 @@ public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider return o instanceof AMapPoint; } + @Override + public boolean runExclusiveAction(Object o, boolean unknownLocation) { + return false; + } + @Override public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List o) { getFromPoint(tileBox, point, o); diff --git a/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java b/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java index 84ddef5780..08c0e05efe 100644 --- a/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java @@ -642,6 +642,13 @@ public class ContextMenuLayer extends OsmandMapLayer { } } } + for (Map.Entry entry : selectedObjects.entrySet()) { + Object o = entry.getKey(); + IContextMenuProvider provider = entry.getValue(); + if (o != null && provider != null && provider.runExclusiveAction(o, showUnknownLocation)) { + return true; + } + } if (selectedObjects.size() == 1) { Object selectedObj = selectedObjects.keySet().iterator().next(); LatLon latLon = objectLatLon; @@ -924,6 +931,7 @@ public class ContextMenuLayer extends OsmandMapLayer { boolean isObjectClickable(Object o); + boolean runExclusiveAction(Object o, boolean unknownLocation); } public interface IMoveObjectProvider { diff --git a/OsmAnd/src/net/osmand/plus/views/DownloadedRegionsLayer.java b/OsmAnd/src/net/osmand/plus/views/DownloadedRegionsLayer.java index 402ddd540e..abbafcdb8e 100644 --- a/OsmAnd/src/net/osmand/plus/views/DownloadedRegionsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/DownloadedRegionsLayer.java @@ -11,9 +11,9 @@ import android.graphics.PointF; import android.text.TextPaint; import android.util.DisplayMetrics; import android.view.WindowManager; + import net.osmand.IndexConstants; import net.osmand.binary.BinaryMapDataObject; -import net.osmand.binary.BinaryMapIndexReader; import net.osmand.binary.BinaryMapIndexReader.TagValuePair; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; @@ -458,6 +458,11 @@ public class DownloadedRegionsLayer extends OsmandMapLayer implements IContextMe return false; } + @Override + public boolean runExclusiveAction(Object o, boolean unknownLocation) { + return false; + } + private void getWorldRegionFromPoint(RotatedTileBox tb, PointF point, List dataObjects) { int zoom = tb.getZoom(); if (zoom >= ZOOM_TO_SHOW_SELECTION_ST && zoom < ZOOM_TO_SHOW_SELECTION diff --git a/OsmAnd/src/net/osmand/plus/views/FavouritesLayer.java b/OsmAnd/src/net/osmand/plus/views/FavouritesLayer.java index d820578ecf..9efc9f1054 100644 --- a/OsmAnd/src/net/osmand/plus/views/FavouritesLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/FavouritesLayer.java @@ -209,6 +209,11 @@ public class FavouritesLayer extends OsmandMapLayer implements ContextMenuLayer. return o instanceof FavouritePoint && o != contextMenuLayer.getMoveableObject(); } + @Override + public boolean runExclusiveAction(Object o, boolean unknownLocation) { + return false; + } + @Override public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List res) { if (this.settings.SHOW_FAVORITES.get() && tileBox.getZoom() >= startZoom) { diff --git a/OsmAnd/src/net/osmand/plus/views/GPXLayer.java b/OsmAnd/src/net/osmand/plus/views/GPXLayer.java index e5f4b73fc9..be7921a76d 100644 --- a/OsmAnd/src/net/osmand/plus/views/GPXLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/GPXLayer.java @@ -564,6 +564,11 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex return o instanceof WptPt; } + @Override + public boolean runExclusiveAction(Object o, boolean unknownLocation) { + return false; + } + @Override public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List res) { if (tileBox.getZoom() >= startZoom) { diff --git a/OsmAnd/src/net/osmand/plus/views/ImpassableRoadsLayer.java b/OsmAnd/src/net/osmand/plus/views/ImpassableRoadsLayer.java index 27136462c4..9fd7c62e70 100644 --- a/OsmAnd/src/net/osmand/plus/views/ImpassableRoadsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/ImpassableRoadsLayer.java @@ -161,6 +161,11 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements return false; } + @Override + public boolean runExclusiveAction(Object o, boolean unknownLocation) { + return false; + } + @Override public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List o) { if (tileBox.getZoom() >= startZoom) { diff --git a/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java b/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java index 65e2b40e11..3de4f99215 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java @@ -481,6 +481,16 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi return false; } + @Override + public boolean runExclusiveAction(Object o, boolean unknownLocation) { + if (unknownLocation || !(o instanceof MapMarker) + || !map.getMyApplication().getSettings().SELECT_MARKER_ON_SINGLE_TAP.get()) { + return false; + } + map.getMyApplication().getMapMarkersHelper().moveMarkerToTop((MapMarker) o); + return true; + } + @Override public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List o) { if (tileBox.getZoom() < 3 || !map.getMyApplication().getSettings().USE_MAP_MARKERS.get()) { diff --git a/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java b/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java index 04b7287646..8d619e05f8 100644 --- a/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/POIMapLayer.java @@ -1,7 +1,6 @@ package net.osmand.plus.views; import android.app.Dialog; -import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.res.Resources; @@ -15,7 +14,6 @@ import android.graphics.PorterDuff; import android.graphics.PorterDuffColorFilter; import android.graphics.drawable.Drawable; import android.net.Uri; -import android.provider.Settings; import android.support.v4.content.ContextCompat; import android.support.v4.view.MenuItemCompat; import android.support.v7.widget.PopupMenu; @@ -35,6 +33,7 @@ import android.widget.LinearLayout; import android.widget.LinearLayout.LayoutParams; import android.widget.ScrollView; import android.widget.TextView; + import net.osmand.AndroidUtils; import net.osmand.PlatformUtil; import net.osmand.ResultMatcher; @@ -564,6 +563,11 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon return o instanceof Amenity; } + @Override + public boolean runExclusiveAction(Object o, boolean unknownLocation) { + return false; + } + @Override public LatLon getTextLocation(Amenity o) { return o.getLocation(); diff --git a/OsmAnd/src/net/osmand/plus/views/PointLocationLayer.java b/OsmAnd/src/net/osmand/plus/views/PointLocationLayer.java index 67f527ca10..64a0098002 100644 --- a/OsmAnd/src/net/osmand/plus/views/PointLocationLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/PointLocationLayer.java @@ -215,6 +215,11 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay return false; } + @Override + public boolean runExclusiveAction(Object o, boolean unknownLocation) { + return false; + } + private LatLon getMyLocation() { Location location = locationProvider.getLastKnownLocation(); if (location != null) { diff --git a/OsmAnd/src/net/osmand/plus/views/PointNavigationLayer.java b/OsmAnd/src/net/osmand/plus/views/PointNavigationLayer.java index 65910cccc5..9d70ae0c7f 100644 --- a/OsmAnd/src/net/osmand/plus/views/PointNavigationLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/PointNavigationLayer.java @@ -14,7 +14,6 @@ import android.support.v4.content.ContextCompat; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; -import net.osmand.data.QuadPoint; import net.osmand.data.RotatedTileBox; import net.osmand.plus.R; import net.osmand.plus.TargetPointsHelper; @@ -22,7 +21,6 @@ import net.osmand.plus.TargetPointsHelper.TargetPoint; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.views.ContextMenuLayer.IContextMenuProvider; -import java.util.Iterator; import java.util.List; public class PointNavigationLayer extends OsmandMapLayer implements @@ -180,6 +178,11 @@ public class PointNavigationLayer extends OsmandMapLayer implements return false; } + @Override + public boolean runExclusiveAction(Object o, boolean unknownLocation) { + return false; + } + @Override public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List o) { if (tileBox.getZoom() >= 3) { diff --git a/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java b/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java index 9715308027..b43cfae364 100644 --- a/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java @@ -279,6 +279,11 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa return false; } + @Override + public boolean runExclusiveAction(Object o, boolean unknownLocation) { + return false; + } + @Override public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List res) { if(tileBox.getZoom() >= startZoomRoute && route != null) { From 5e21aaf8b432b55bf732c20dda70cae9a1a075b4 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Mon, 20 Nov 2017 14:21:21 +0200 Subject: [PATCH 3/4] Handle null in runExclusiveAction --- OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java | 5 ++--- OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java b/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java index 08c0e05efe..ac4aae0893 100644 --- a/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/ContextMenuLayer.java @@ -643,9 +643,8 @@ public class ContextMenuLayer extends OsmandMapLayer { } } for (Map.Entry entry : selectedObjects.entrySet()) { - Object o = entry.getKey(); IContextMenuProvider provider = entry.getValue(); - if (o != null && provider != null && provider.runExclusiveAction(o, showUnknownLocation)) { + if (provider != null && provider.runExclusiveAction(entry.getKey(), showUnknownLocation)) { return true; } } @@ -931,7 +930,7 @@ public class ContextMenuLayer extends OsmandMapLayer { boolean isObjectClickable(Object o); - boolean runExclusiveAction(Object o, boolean unknownLocation); + boolean runExclusiveAction(@Nullable Object o, boolean unknownLocation); } public interface IMoveObjectProvider { diff --git a/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java b/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java index 3de4f99215..93f80d5a35 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java @@ -483,7 +483,7 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi @Override public boolean runExclusiveAction(Object o, boolean unknownLocation) { - if (unknownLocation || !(o instanceof MapMarker) + if (unknownLocation || o == null || !(o instanceof MapMarker) || !map.getMyApplication().getSettings().SELECT_MARKER_ON_SINGLE_TAP.get()) { return false; } From 1856bc24c1c2133cee3ddb88e11a5def1213412e Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Mon, 20 Nov 2017 16:19:13 +0200 Subject: [PATCH 4/4] Add snackbar --- OsmAnd/res/values/strings.xml | 1 + .../net/osmand/plus/views/MapMarkersLayer.java | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 1a678afc6d..fb99df2849 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,6 +9,7 @@ 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy --> + Marker %s activated. Tap on marker on the map, move it to the first place in active markers, without opening context menu. One tap active Looking for tracks with waypoints diff --git a/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java b/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java index 93f80d5a35..44194aff2a 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java @@ -14,9 +14,11 @@ import android.os.Handler; import android.os.Message; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.design.widget.Snackbar; import android.support.v4.content.ContextCompat; import android.view.GestureDetector; import android.view.MotionEvent; +import android.view.View; import net.osmand.Location; import net.osmand.data.LatLon; @@ -487,7 +489,18 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi || !map.getMyApplication().getSettings().SELECT_MARKER_ON_SINGLE_TAP.get()) { return false; } - map.getMyApplication().getMapMarkersHelper().moveMarkerToTop((MapMarker) o); + final MapMarkersHelper helper = map.getMyApplication().getMapMarkersHelper(); + final MapMarker old = helper.getMapMarkers().get(0); + helper.moveMarkerToTop((MapMarker) o); + String title = map.getString(R.string.marker_activated, helper.getMapMarkers().get(0).getName(map)); + Snackbar.make(map.findViewById(R.id.bottomFragmentContainer), title, Snackbar.LENGTH_LONG) + .setAction(R.string.shared_string_cancel, new View.OnClickListener() { + @Override + public void onClick(View v) { + helper.moveMarkerToTop(old); + } + }) + .show(); return true; }