Remove unnecessary check "USE_MAP_MARKERS.get()" in some places
This commit is contained in:
parent
f13dacdc7c
commit
cfaf04e3b2
5 changed files with 36 additions and 60 deletions
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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<Object> o, boolean unknownLocation) {
|
||||
if (tileBox.getZoom() < 3 || !map.getMyApplication().getSettings().USE_MAP_MARKERS.get()) {
|
||||
if (tileBox.getZoom() < 3) {
|
||||
return;
|
||||
}
|
||||
amenities.clear();
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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<ContextMenuItem> 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<ContextMenuItem> 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) {
|
||||
|
|
Loading…
Reference in a new issue