Add functionality for running exclusive action instead of opening context menu; rename setting

This commit is contained in:
Alexander Sytnyk 2017-11-20 14:16:41 +02:00
parent 348847c59e
commit 7d741dc89c
22 changed files with 114 additions and 9 deletions

View file

@ -716,7 +716,7 @@ public class OsmandSettings {
public final CommonPreference<Boolean> SHOW_LINES_TO_FIRST_MARKERS = new BooleanPreference("show_lines_to_first_markers", false).makeProfile();
public final CommonPreference<Boolean> SHOW_ARROWS_TO_FIRST_MARKERS = new BooleanPreference("show_arrows_to_first_markers", false).makeProfile();
public final CommonPreference<Boolean> ONE_TAP_MAKE_MARKER_FIRST = new BooleanPreference("one_tap_make_marker_first", false).makeProfile();
public final CommonPreference<Boolean> SELECT_MARKER_ON_SINGLE_TAP = new BooleanPreference("select_marker_on_single_tap", false).makeProfile();
public final CommonPreference<Boolean> USE_MAPILLARY_FILTER = new BooleanPreference("use_mapillary_filters", false).makeGlobal();
public final CommonPreference<String> MAPILLARY_FILTER_USER_KEY = new StringPreference("mapillary_filter_user_key", "").makeGlobal();

View file

@ -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<Object> objects) {
if (tileBox.getZoom() >= startZoom) {

View file

@ -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<Object> o) {
getMPointsFromPoint(tileBox, point, o);

View file

@ -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<? super MapillaryImage> images) {
Map<QuadPointDouble, Map> points = this.visiblePoints;
if (points != null) {

View file

@ -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);
}
});

View file

@ -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();

View file

@ -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<Object> res) {
if (tileBox.getZoom() >= startZoom) {

View file

@ -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<Object> o) {
if (tileBox.getZoom() >= startZoom) {

View file

@ -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<Object> o) {
getOsmoFromPoint(tileBox, point, o);

View file

@ -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<Object> o) {
getParkingFromPoint(tileBox, point, o);

View file

@ -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<Object> o) {

View file

@ -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<Object> o) {
getFromPoint(tileBox, point, o);

View file

@ -642,6 +642,13 @@ public class ContextMenuLayer extends OsmandMapLayer {
}
}
}
for (Map.Entry<Object, IContextMenuProvider> 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 {

View file

@ -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<? super DownloadMapObject> dataObjects) {
int zoom = tb.getZoom();
if (zoom >= ZOOM_TO_SHOW_SELECTION_ST && zoom < ZOOM_TO_SHOW_SELECTION

View file

@ -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<Object> res) {
if (this.settings.SHOW_FAVORITES.get() && tileBox.getZoom() >= startZoom) {

View file

@ -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<Object> res) {
if (tileBox.getZoom() >= startZoom) {

View file

@ -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<Object> o) {
if (tileBox.getZoom() >= startZoom) {

View file

@ -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<Object> o) {
if (tileBox.getZoom() < 3 || !map.getMyApplication().getSettings().USE_MAP_MARKERS.get()) {

View file

@ -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();

View file

@ -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) {

View file

@ -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<Object> o) {
if (tileBox.getZoom() >= 3) {

View file

@ -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<Object> res) {
if(tileBox.getZoom() >= startZoomRoute && route != null) {