diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index 7772ad0352..fe06c1c1a0 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
-->
+ Do you want to add all points to Map Markers?
+ Add to Map Markers
Select Map Markers
Reverse order
Map Markers
diff --git a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java
index 7d2873efd0..61ce247f20 100644
--- a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java
+++ b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java
@@ -21,6 +21,7 @@ public class MapMarkersHelper {
public interface MapMarkerChangedListener {
void onMapMarkerChanged(MapMarker mapMarker);
+
void onMapMarkersChanged();
}
@@ -199,25 +200,50 @@ public class MapMarkersHelper {
}
public void addMapMarker(LatLon point, PointDescription historyName) {
- if (point != null) {
- final PointDescription pointDescription;
- if (historyName == null) {
- pointDescription = new PointDescription(PointDescription.POINT_TYPE_LOCATION, "");
- } else {
- pointDescription = historyName;
- }
- if (pointDescription.isLocation() && Algorithms.isEmpty(pointDescription.getName())) {
- pointDescription.setName(PointDescription.getSearchAddressStr(ctx));
- }
- int colorIndex;
- if (mapMarkers.size() > 0) {
- colorIndex = (mapMarkers.get(0).colorIndex + 1) % MAP_MARKERS_COLORS_COUNT;
- } else {
- colorIndex = 0;
- }
- settings.insertMapMarker(point.getLatitude(), point.getLongitude(),
- pointDescription, colorIndex, 0);
+ List points = new ArrayList<>(1);
+ List historyNames = new ArrayList<>(1);
+ points.add(point);
+ historyNames.add(historyName);
+ addMapMarkers(points, historyNames);
+ }
+ public void addMapMarkers(List points, List historyNames) {
+ if (points.size() > 0) {
+ int colorIndex = -1;
+ double[] latitudes = new double[points.size()];
+ double[] longitudes = new double[points.size()];
+ List pointDescriptions = new ArrayList<>();
+ int[] colorIndexes = new int[points.size()];
+ int[] indexes = new int[points.size()];
+ for (int i = 0; i < points.size(); i++) {
+ LatLon point = points.get(i);
+ PointDescription historyName = historyNames.get(i);
+ final PointDescription pointDescription;
+ if (historyName == null) {
+ pointDescription = new PointDescription(PointDescription.POINT_TYPE_LOCATION, "");
+ } else {
+ pointDescription = historyName;
+ }
+ if (pointDescription.isLocation() && Algorithms.isEmpty(pointDescription.getName())) {
+ pointDescription.setName(PointDescription.getSearchAddressStr(ctx));
+ }
+ if (colorIndex == -1) {
+ if (mapMarkers.size() > 0) {
+ colorIndex = (mapMarkers.get(0).colorIndex + 1) % MAP_MARKERS_COLORS_COUNT;
+ } else {
+ colorIndex = 0;
+ }
+ } else {
+ colorIndex = (colorIndex + 1) % MAP_MARKERS_COLORS_COUNT;
+ }
+
+ latitudes[i] = point.getLatitude();
+ longitudes[i] = point.getLongitude();
+ pointDescriptions.add(pointDescription);
+ colorIndexes[i] = colorIndex;
+ indexes[i] = 0;
+ }
+ settings.insertMapMarkers(latitudes, longitudes, pointDescriptions, colorIndexes, indexes);
readFromSettings();
refresh();
}
diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java
index 54d56184fb..8cd9e38e12 100644
--- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java
+++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java
@@ -1614,6 +1614,27 @@ public class OsmandSettings {
return savePoints(ps, ds, cs);
}
+ public boolean insertPoints(double[] latitudes, double[] longitudes,
+ List historyDescriptions, int[] colorIndexes, int[] indexes) {
+ List ps = getPoints();
+ List ds = getPointDescriptions(ps.size());
+ List cs = getColors(ps.size());
+ for (int i = 0; i < latitudes.length; i++) {
+ double latitude = latitudes[i];
+ double longitude = longitudes[i];
+ PointDescription historyDescription = historyDescriptions.get(i);
+ int colorIndex = colorIndexes[i];
+ int index = indexes[i];
+ ps.add(index, new LatLon(latitude, longitude));
+ ds.add(index, PointDescription.serializeToString(historyDescription));
+ cs.add(index, colorIndex);
+ if (historyDescription != null && !historyDescription.isSearchingAddress(ctx)) {
+ SearchHistoryHelper.getInstance(ctx).addNewItemToHistory(latitude, longitude, historyDescription);
+ }
+ }
+ return savePoints(ps, ds, cs);
+ }
+
public boolean updatePoint(double latitude, double longitude,
PointDescription historyDescription, int colorIndex) {
List ps = getPoints();
@@ -1827,6 +1848,11 @@ public class OsmandSettings {
return mapMarkersStorage.insertPoint(latitude, longitude, historyDescription, colorIndex, index);
}
+ public boolean insertMapMarkers(double[] latitudes, double[] longitudes,
+ List historyDescriptions, int[] colorIndexes, int[] indexes) {
+ return mapMarkersStorage.insertPoints(latitudes, longitudes, historyDescriptions, colorIndexes, indexes);
+ }
+
public boolean updateMapMarker(double latitude, double longitude,
PointDescription historyDescription, int colorIndex) {
return mapMarkersStorage.updatePoint(latitude, longitude, historyDescription, colorIndex);
diff --git a/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java b/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java
index 576f2a1d09..795b275109 100644
--- a/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java
+++ b/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java
@@ -421,10 +421,13 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
if(!favoritesSelected.isEmpty()) {
if (getSettings().USE_MAP_MARKERS.get()) {
MapMarkersHelper markersHelper = getMyApplication().getMapMarkersHelper();
+ List points = new ArrayList<>(favoritesSelected.size());
+ List names = new ArrayList<>(favoritesSelected.size());
for (FavouritePoint fp : favoritesSelected) {
- markersHelper.addMapMarker(new LatLon(fp.getLatitude(), fp.getLongitude()),
- new PointDescription(PointDescription.POINT_TYPE_MAP_MARKER, fp.getName()));
+ points.add(new LatLon(fp.getLatitude(), fp.getLongitude()));
+ names.add(new PointDescription(PointDescription.POINT_TYPE_MAP_MARKER, fp.getName()));
}
+ markersHelper.addMapMarkers(points, names);
MapActivity.launchMapActivityMoveToTop(getActivity());
} else {
final TargetPointsHelper targetPointsHelper = getMyApplication().getTargetPointsHelper();
diff --git a/OsmAnd/src/net/osmand/plus/myplaces/SelectedGPXFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/SelectedGPXFragment.java
index 4bac9e1ada..f587adbd63 100644
--- a/OsmAnd/src/net/osmand/plus/myplaces/SelectedGPXFragment.java
+++ b/OsmAnd/src/net/osmand/plus/myplaces/SelectedGPXFragment.java
@@ -38,6 +38,7 @@ import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
+import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
@@ -222,7 +223,24 @@ public class SelectedGPXFragment extends OsmAndListFragment {
@Override
public void onClick(DialogInterface dialog, int which) {
saveFavoritesImpl(flatten(gs), editText.getText().toString());
+ }
+ });
+ b.setNegativeButton(R.string.shared_string_cancel, null);
+ b.show();
+ }
+ protected void saveAsMapMarkers(final GpxDisplayItemType gpxDisplayItemType) {
+ AlertDialog.Builder b = new AlertDialog.Builder(getMyActivity());
+ final List gs = filterGroups(gpxDisplayItemType, getMyActivity(), getArguments());
+ if (gs.size() == 0) {
+ return;
+ }
+ b.setMessage(R.string.add_points_to_map_markers_q);
+ b.setPositiveButton(R.string.shared_string_add, new DialogInterface.OnClickListener() {
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ saveMapMarkersImpl(flatten(gs));
}
});
b.setNegativeButton(R.string.shared_string_cancel, null);
@@ -241,6 +259,19 @@ public class SelectedGPXFragment extends OsmAndListFragment {
fdb.saveCurrentPointsIntoFile();
}
+ protected void saveMapMarkersImpl(List modifiableList) {
+ MapMarkersHelper markersHelper = app.getMapMarkersHelper();
+ List points = new ArrayList<>();
+ List names = new ArrayList<>();
+ for(GpxDisplayItem i : modifiableList) {
+ if (i.locationStart != null) {
+ points.add(new LatLon(i.locationStart.lat, i.locationStart.lon));
+ names.add(new PointDescription(PointDescription.POINT_TYPE_MAP_MARKER, i.name));
+ }
+ }
+ markersHelper.addMapMarkers(points, names);
+ }
+
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
menu.clear();
diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java
index 69a8b245c3..9521633721 100644
--- a/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java
+++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java
@@ -30,5 +30,17 @@ public class TrackPointFragment extends SelectedGPXFragment {
}
});
MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
+
+ if (app.getSettings().USE_MAP_MARKERS.get()) {
+ item = menu.add(R.string.shared_string_add_to_map_markers).setIcon(R.drawable.ic_action_flag_dark)
+ .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
+ @Override
+ public boolean onMenuItemClick(MenuItem item) {
+ saveAsMapMarkers(GpxSelectionHelper.GpxDisplayItemType.TRACK_POINTS);
+ return true;
+ }
+ });
+ MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
+ }
}
}
diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackRoutePointFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackRoutePointFragment.java
index a60f61f828..842de5e018 100644
--- a/OsmAnd/src/net/osmand/plus/myplaces/TrackRoutePointFragment.java
+++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackRoutePointFragment.java
@@ -33,5 +33,17 @@ public class TrackRoutePointFragment extends SelectedGPXFragment {
}
});
MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
+
+ if (app.getSettings().USE_MAP_MARKERS.get()) {
+ item = menu.add(R.string.shared_string_add_to_map_markers).setIcon(R.drawable.ic_action_flag_dark)
+ .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
+ @Override
+ public boolean onMenuItemClick(MenuItem item) {
+ saveAsMapMarkers(GpxSelectionHelper.GpxDisplayItemType.TRACK_ROUTE_POINTS);
+ return true;
+ }
+ });
+ MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
+ }
}
}
diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidget.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidget.java
index 9a24c83a2e..95ec963512 100644
--- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidget.java
+++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidget.java
@@ -83,7 +83,7 @@ public class MapMarkersWidget {
});
IconsCache iconsCache = map.getMyApplication().getIconsCache();
- if (isLandscapeLayout()) {
+ if (isLandscapeLayout() && helper.getActiveMapMarkers().size() > 1) {
moreButton.setVisibility(View.GONE);
} else {
moreButton.setImageDrawable(iconsCache.getIcon(R.drawable.ic_overflow_menu_white, R.color.marker_top_2nd_line_color));