Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-06-08 22:53:55 +02:00
commit ba79a1e1f3
7 changed files with 110 additions and 20 deletions

View file

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

View file

@ -52,6 +52,7 @@
<string name="osm_changes_added_to_local_edits">OSM changes added to local changeset</string>
<string name="mark_to_delete">Mark to delete</string>
<string name="osmo_grop_name_length_alert">Group name should be at least 3 characters long!</string>
<string name="local_recordings_delete_all_confirm">You are going to delete %1$d notes. Are you sure?</string>
<string name="local_osm_changes_upload_all_confirm">You are going to upload %1$d changes to OSM. Are you sure?</string>
<string name="confirmation_to_clear_history">Do you want to clear the history?</string>
<string name="delay_to_start_navigation_descr">Specify wait time to remain on the route planning screen</string>

View file

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

View file

@ -452,19 +452,36 @@ public class FavouritesDbHelper {
return collator.compare(lhs.name, rhs.name);
}
});
Comparator<FavouritePoint> favoritesComparator = getComparator();
for (FavoriteGroup g : favoriteGroups) {
Collections.sort(g.points, favoritesComparator);
}
if (cachedFavoritePoints != null) {
Collections.sort(cachedFavoritePoints, favoritesComparator);
}
}
public static Comparator<FavouritePoint> getComparator() {
final Collator collator = Collator.getInstance();
collator.setStrength(Collator.SECONDARY);
Comparator<FavouritePoint> favoritesComparator = new Comparator<FavouritePoint>() {
@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;
}

View file

@ -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<Recording> selected) {
// TODO Auto-generated method stub
private void deleteItems(final ArrayList<Recording> 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<Recording> 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<Recording> 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<Uri> files = new ArrayList<Uri>();
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();

View file

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

View file

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