diff --git a/OsmAnd-java/src/net/osmand/util/Algorithms.java b/OsmAnd-java/src/net/osmand/util/Algorithms.java
index 5cc68b39d6..a866b4e91f 100644
--- a/OsmAnd-java/src/net/osmand/util/Algorithms.java
+++ b/OsmAnd-java/src/net/osmand/util/Algorithms.java
@@ -125,6 +125,7 @@ public class Algorithms {
throw new IllegalArgumentException("Unknown color " + colorString); //$NON-NLS-1$
}
+
public static int extractFirstIntegerNumber(String s) {
int i = 0;
for (int k = 0; k < s.length(); k++) {
@@ -137,6 +138,34 @@ public class Algorithms {
return i;
}
+ public static int extractIntegerNumber(String s) {
+ int i = 0;
+ int k = 0;
+ for (k = 0; k < s.length(); k++) {
+ if (Character.isDigit(s.charAt(k))) {
+ break;
+ }
+ }
+ for (; k < s.length(); k++) {
+ if (Character.isDigit(s.charAt(k))) {
+ i = i * 10 + (s.charAt(k) - '0');
+ } else {
+ break;
+ }
+ }
+ return i;
+ }
+
+ public static String extractIntegerPrefix(String s) {
+ int k = 0;
+ for (; k < s.length(); k++) {
+ if (Character.isDigit(s.charAt(k))) {
+ return s.substring(0, k);
+ }
+ }
+ return "";
+ }
+
public static String extractIntegerSuffix(String s) {
int k = 0;
for (; k < s.length(); k++) {
diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index e0f8bef47f..3d43bf5060 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -52,6 +52,7 @@
OSM changes added to local changeset
Mark to delete
Group name should be at least 3 characters long!
+ You are going to delete %1$d notes. Are you sure?
You are going to upload %1$d changes to OSM. Are you sure?
Do you want to clear the history?
Specify wait time to remain on the route planning screen
diff --git a/OsmAnd/src/net/osmand/data/FavouritePoint.java b/OsmAnd/src/net/osmand/data/FavouritePoint.java
index 2cd37511b7..69b33c5a4c 100644
--- a/OsmAnd/src/net/osmand/data/FavouritePoint.java
+++ b/OsmAnd/src/net/osmand/data/FavouritePoint.java
@@ -6,7 +6,7 @@ import android.content.Context;
public class FavouritePoint implements Serializable, LocationPoint {
private static final long serialVersionUID = 729654300829771466L;
- private String name;
+ private String name = "";
private String description;
private String category = "";
private double latitude;
@@ -21,6 +21,9 @@ public class FavouritePoint implements Serializable, LocationPoint {
this.latitude = latitude;
this.longitude = longitude;
this.category = category;
+ if(name == null) {
+ name = "";
+ }
this.name = name;
}
diff --git a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java
index 6a97df9d75..08c614aa5b 100644
--- a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java
+++ b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java
@@ -452,19 +452,36 @@ public class FavouritesDbHelper {
return collator.compare(lhs.name, rhs.name);
}
});
+ Comparator favoritesComparator = getComparator();
+ for (FavoriteGroup g : favoriteGroups) {
+ Collections.sort(g.points, favoritesComparator);
+ }
+ if (cachedFavoritePoints != null) {
+ Collections.sort(cachedFavoritePoints, favoritesComparator);
+ }
+ }
+
+ public static Comparator getComparator() {
+ final Collator collator = Collator.getInstance();
+ collator.setStrength(Collator.SECONDARY);
Comparator favoritesComparator = new Comparator() {
@Override
- public int compare(FavouritePoint object1, FavouritePoint object2) {
- return collator.compare(object1.getName(), object2.getName());
+ public int compare(FavouritePoint o1, FavouritePoint o2) {
+ String s1 = o1.getName();
+ String s2 = o2.getName();
+ int i1 = Algorithms.extractIntegerNumber(s1);
+ int i2 = Algorithms.extractIntegerNumber(s2);
+ if(i1 == i2) {
+ String ot1 = Algorithms.extractIntegerPrefix(s1);
+ String ot2 = Algorithms.extractIntegerPrefix(s2);
+ return collator.compare(ot1, ot2);
+ }
+
+ return i1 - i2;
}
};
- for(FavoriteGroup g : favoriteGroups) {
- Collections.sort(g.points, favoritesComparator);
- }
- if(cachedFavoritePoints != null) {
- Collections.sort(cachedFavoritePoints, favoritesComparator);
- }
+ return favoritesComparator;
}
diff --git a/OsmAnd/src/net/osmand/plus/audionotes/NotesFragment.java b/OsmAnd/src/net/osmand/plus/audionotes/NotesFragment.java
index 30f479fb02..e72dae42cc 100644
--- a/OsmAnd/src/net/osmand/plus/audionotes/NotesFragment.java
+++ b/OsmAnd/src/net/osmand/plus/audionotes/NotesFragment.java
@@ -1,6 +1,7 @@
package net.osmand.plus.audionotes;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import net.osmand.data.PointDescription;
@@ -15,8 +16,10 @@ import net.osmand.plus.audionotes.AudioVideoNotesPlugin.Recording;
import net.osmand.plus.dialogs.DirectionsDialogs;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.myplaces.FavoritesActivity;
+import net.osmand.plus.osmedit.OpenstreetmapPoint;
import net.osmand.plus.osmedit.OpenstreetmapRemoteUtil;
import net.osmand.plus.osmedit.OsmBugsRemoteUtil;
+import net.osmand.plus.osmedit.OsmNotesPoint;
import net.osmand.plus.osmedit.OsmPoint;
import net.osmand.plus.osmedit.OsmEditsFragment.BackupOpenstreetmapPointAsyncTask;
import android.app.AlertDialog;
@@ -87,10 +90,10 @@ public class NotesFragment extends OsmAndListFragment {
return view;
}
- private void selectAll(){
- for(int i =0 ;i < listAdapter.getCount(); i++){
+ private void selectAll() {
+ for (int i = 0; i < listAdapter.getCount(); i++) {
Recording point = listAdapter.getItem(i);
- if (!selected.contains(point)){
+ if (!selected.contains(point)) {
selected.add(point);
}
}
@@ -189,14 +192,39 @@ public class NotesFragment extends OsmAndListFragment {
selectAll.setChecked(true);
}
- private void deleteItems(ArrayList selected) {
- // TODO Auto-generated method stub
-
+ private void deleteItems(final ArrayList selected) {
+ AlertDialog.Builder b = new AlertDialog.Builder(getActivity());
+ b.setMessage(getString(R.string.local_recordings_delete_all_confirm, selected.size()));
+ b.setPositiveButton(R.string.shared_string_delete, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ Iterator it = selected.iterator();
+ while (it.hasNext()) {
+ Recording pnt = it.next();
+ plugin.deleteRecording(pnt);
+ it.remove();
+ listAdapter.delete(pnt);
+ }
+ listAdapter.notifyDataSetChanged();
+
+ }
+ });
+ b.setNegativeButton(R.string.shared_string_cancel, null);
+ b.show();
}
private void shareItems(ArrayList selected) {
- // TODO Auto-generated method stub
-
+ Intent intent = new Intent();
+ intent.setAction(Intent.ACTION_SEND_MULTIPLE);
+ intent.setType("image/*"); /* This example is sharing jpeg images. */
+
+ ArrayList files = new ArrayList();
+
+ for(Recording path : selected) {
+ files.add(Uri.fromFile(path.getFile()));
+ }
+ intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, files);
+ startActivity(Intent.createChooser(intent, getString(R.string.share_note)));
}
private void enterDeleteMode(final int type) {
@@ -205,7 +233,12 @@ public class NotesFragment extends OsmAndListFragment {
@Override
public boolean onCreateActionMode(final ActionMode mode, Menu menu) {
enableSelectionMode(true);
- MenuItem item = menu.add(R.string.shared_string_delete_all).setIcon(R.drawable.ic_action_delete_dark);
+ MenuItem item;
+ if(type == MODE_DELETE) {
+ item = menu.add(R.string.shared_string_delete_all).setIcon(R.drawable.ic_action_delete_dark);
+ } else {
+ item = menu.add(R.string.shared_string_share).setIcon(R.drawable.ic_action_export);
+ }
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
@@ -259,6 +292,11 @@ public class NotesFragment extends OsmAndListFragment {
super(getActivity(), R.layout.note, recordingList);
}
+ public void delete(Recording pnt) {
+ remove(pnt);
+
+ }
+
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = getActivity().getLayoutInflater();
diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java
index 021e5d56b9..235dcb5db4 100644
--- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java
+++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java
@@ -417,6 +417,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
if(visibleType == DashboardType.DASHBOARD) {
addOrUpdateDashboardFragments();
scrollView.setVisibility(View.VISIBLE);
+ scrollView.scrollTo(0, 0);
listViewLayout.setVisibility(View.GONE);
onScrollChanged(scrollView.getScrollY(), false, false);
} else {
diff --git a/OsmAnd/src/net/osmand/plus/myplaces/SelectedGPXFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/SelectedGPXFragment.java
index d32bd90aa6..adcc5167c5 100644
--- a/OsmAnd/src/net/osmand/plus/myplaces/SelectedGPXFragment.java
+++ b/OsmAnd/src/net/osmand/plus/myplaces/SelectedGPXFragment.java
@@ -227,11 +227,12 @@ public class SelectedGPXFragment extends OsmAndListFragment {
FavouritesDbHelper fdb = app.getFavorites();
for(GpxDisplayItem i : modifiableList) {
if (i.locationStart != null) {
- FavouritePoint fp = new FavouritePoint(i.locationStart.lat, i.locationStart.lon, i.locationStart.name,
+ FavouritePoint fp = new FavouritePoint(i.locationStart.lat, i.locationStart.lon, i.name,
category);
- fdb.addFavourite(fp);
+ fdb.addFavourite(fp, false);
}
}
+ fdb.saveCurrentPointsIntoFile();
}
@Override