From cfaf04e3b2dc730963f0dd9014faa618eeaf1a5b Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Sat, 17 Mar 2018 18:31:48 +0200 Subject: [PATCH] Remove unnecessary check "USE_MAP_MARKERS.get()" in some places --- .../activities/FavoritesTreeFragment.java | 23 +++-------- .../plus/mapcontextmenu/MapContextMenu.java | 27 ++++++------- .../osmand/plus/views/MapMarkersLayer.java | 4 +- .../mapwidgets/MapMarkersWidgetsFactory.java | 4 -- .../views/mapwidgets/MapWidgetRegistry.java | 38 +++++++++---------- 5 files changed, 36 insertions(+), 60 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java b/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java index d6b8e65380..81fe2c1bbb 100644 --- a/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java @@ -41,7 +41,6 @@ import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; -import net.osmand.plus.TargetPointsHelper; import net.osmand.plus.base.FavoriteImageDrawable; import net.osmand.plus.base.OsmandExpandableListFragment; import net.osmand.plus.helpers.AndroidUiHelper; @@ -58,7 +57,6 @@ import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.LinkedHashSet; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; @@ -347,13 +345,8 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment { R.drawable.ic_action_plus, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); createMenuItem(menu, SHARE_ID, R.string.shared_string_share, R.drawable.ic_action_gshare_dark, R.drawable.ic_action_gshare_dark, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); - if (getSettings().USE_MAP_MARKERS.get()) { - createMenuItem(menu, SELECT_MAP_MARKERS_ID, R.string.select_map_markers, R.drawable.ic_action_flag_dark, - R.drawable.ic_action_flag_dark, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); - } else { - createMenuItem(menu, SELECT_MAP_MARKERS_ID, R.string.select_destination_and_intermediate_points, R.drawable.ic_action_intermediate, - R.drawable.ic_action_intermediate, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); - } + createMenuItem(menu, SELECT_MAP_MARKERS_ID, R.string.select_map_markers, R.drawable.ic_action_flag_dark, + R.drawable.ic_action_flag_dark, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); createMenuItem(menu, DELETE_ID, R.string.shared_string_delete, R.drawable.ic_action_delete_dark, R.drawable.ic_action_delete_dark, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); // createMenuItem(menu, EXPORT_ID, R.string.shared_string_export, R.drawable.ic_action_gsave_light, @@ -383,15 +376,9 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment { @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { enableSelectionMode(true); - if (getSettings().USE_MAP_MARKERS.get()) { - createMenuItem(menu, SELECT_MAP_MARKERS_ACTION_MODE_ID, R.string.select_map_markers, - R.drawable.ic_action_flag_dark, R.drawable.ic_action_flag_dark, - MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); - } else { - createMenuItem(menu, SELECT_MAP_MARKERS_ACTION_MODE_ID, R.string.select_destination_and_intermediate_points, - R.drawable.ic_action_intermediate, R.drawable.ic_action_intermediate, - MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); - } + createMenuItem(menu, SELECT_MAP_MARKERS_ACTION_MODE_ID, R.string.select_map_markers, + R.drawable.ic_action_flag_dark, R.drawable.ic_action_flag_dark, + MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); favoritesSelected.clear(); groupsToDelete.clear(); favouritesAdapter.notifyDataSetInvalidated(); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java index a1788d050b..cb03d0aa3c 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java @@ -836,23 +836,18 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL if (marker != null) { RenameMarkerBottomSheetDialogFragment .showInstance(mapActivity.getSupportFragmentManager(), marker); - } else if (settings.USE_MAP_MARKERS.get()) { - if (pointDescription.isMapMarker()) { - hide(); - MapActivity.clearPrevActivityIntent(); - MapMarkersDialogFragment.showInstance(mapActivity); - } else { - String mapObjectName = null; - if (object instanceof Amenity) { - Amenity amenity = (Amenity) object; - mapObjectName = amenity.getName() + "_" + amenity.getType().getKeyName(); - } - mapActivity.getMapActions().addMapMarker(latLon.getLatitude(), latLon.getLongitude(), - getPointDescriptionForMarker(), mapObjectName); - } + } else if (pointDescription.isMapMarker()) { + hide(); + MapActivity.clearPrevActivityIntent(); + MapMarkersDialogFragment.showInstance(mapActivity); } else { - mapActivity.getMapActions().addAsTarget(latLon.getLatitude(), latLon.getLongitude(), - getPointDescriptionForTarget()); + String mapObjectName = null; + if (object instanceof Amenity) { + Amenity amenity = (Amenity) object; + mapObjectName = amenity.getName() + "_" + amenity.getType().getKeyName(); + } + mapActivity.getMapActions().addMapMarker(latLon.getLatitude(), latLon.getLongitude(), + getPointDescriptionForMarker(), mapObjectName); } close(); } diff --git a/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java b/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java index b9298bc8d9..155b034161 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java @@ -319,7 +319,7 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi widgetsFactory.updateInfo(useFingerLocation ? fingerLocation : null, tileBox.getZoom()); OsmandSettings settings = map.getMyApplication().getSettings(); - if (tileBox.getZoom() < 3 || !settings.USE_MAP_MARKERS.get()) { + if (tileBox.getZoom() < 3) { return; } @@ -514,7 +514,7 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi @Override public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List o, boolean unknownLocation) { - if (tileBox.getZoom() < 3 || !map.getMyApplication().getSettings().USE_MAP_MARKERS.get()) { + if (tileBox.getZoom() < 3) { return; } amenities.clear(); diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java index c14ab304cb..33c2120da7 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java @@ -185,10 +185,6 @@ public class MapMarkersWidgetsFactory { } public void updateInfo(LatLon customLocation, int zoom) { - if (!map.getMyApplication().getSettings().USE_MAP_MARKERS.get()) { - return; - } - if (customLocation != null) { loc = customLocation; } else { diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java index d3e66e0994..961a75d1dd 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapWidgetRegistry.java @@ -321,26 +321,24 @@ public class MapWidgetRegistry { if (mode != ApplicationMode.DEFAULT) { addControlId(map, cm, R.string.map_widget_top_text, settings.SHOW_STREET_NAME); } - if (settings.USE_MAP_MARKERS.get()) { - cm.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_markers, map) - .setDescription(settings.MAP_MARKERS_MODE.get().toHumanString(map)) - .setListener(new ContextMenuAdapter.ItemClickListener() { - @Override - public boolean onContextMenuClick(final ArrayAdapter adapter, int itemId, final int position, boolean isChecked, int[] viewCoordinates) { - DirectionIndicationDialogFragment fragment = new DirectionIndicationDialogFragment(); - fragment.setListener(new DirectionIndicationDialogFragment.DirectionIndicationFragmentListener() { - @Override - public void onMapMarkersModeChanged(boolean showDirectionEnabled) { - updateMapMarkersMode(map); - cm.getItem(position).setDescription(settings.MAP_MARKERS_MODE.get().toHumanString(map)); - adapter.notifyDataSetChanged(); - } - }); - fragment.show(map.getSupportFragmentManager(), DirectionIndicationDialogFragment.TAG); - return false; - } - }).setLayout(R.layout.list_item_text_button).createItem()); - } + cm.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_markers, map) + .setDescription(settings.MAP_MARKERS_MODE.get().toHumanString(map)) + .setListener(new ContextMenuAdapter.ItemClickListener() { + @Override + public boolean onContextMenuClick(final ArrayAdapter adapter, int itemId, final int position, boolean isChecked, int[] viewCoordinates) { + DirectionIndicationDialogFragment fragment = new DirectionIndicationDialogFragment(); + fragment.setListener(new DirectionIndicationDialogFragment.DirectionIndicationFragmentListener() { + @Override + public void onMapMarkersModeChanged(boolean showDirectionEnabled) { + updateMapMarkersMode(map); + cm.getItem(position).setDescription(settings.MAP_MARKERS_MODE.get().toHumanString(map)); + adapter.notifyDataSetChanged(); + } + }); + fragment.show(map.getSupportFragmentManager(), DirectionIndicationDialogFragment.TAG); + return false; + } + }).setLayout(R.layout.list_item_text_button).createItem()); } public void updateMapMarkersMode(MapActivity mapActivity) {