Merge pull request #892 from Bars107/favorites
Added duplication check for favorite points
This commit is contained in:
commit
93f8feb2ea
2 changed files with 39 additions and 1 deletions
|
@ -9,6 +9,8 @@
|
||||||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
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
|
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||||
-->
|
-->
|
||||||
|
<string name="fav_point_dublicate">Favorite point name duplicate</string>
|
||||||
|
<string name="fav_point_dublicate_message">We changed your favorite point name to %1$s to avoid dublicated names.</string>
|
||||||
<string name="text_size_descr">Set the text size on the map.</string>
|
<string name="text_size_descr">Set the text size on the map.</string>
|
||||||
<string name="text_size">Text size</string>
|
<string name="text_size">Text size</string>
|
||||||
<string name="traffic_warning_speed_limit">Speed limit</string>
|
<string name="traffic_warning_speed_limit">Speed limit</string>
|
||||||
|
|
|
@ -10,6 +10,12 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.content.ActivityNotFoundException;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.widget.Toast;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.data.FavouritePoint;
|
import net.osmand.data.FavouritePoint;
|
||||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||||
|
@ -140,6 +146,10 @@ public class FavouritesDbHelper {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
FavoriteGroup group = getOrCreateGroup(p, 0);
|
FavoriteGroup group = getOrCreateGroup(p, 0);
|
||||||
|
|
||||||
|
//making sure that dublicated names will not occur in favorites
|
||||||
|
checkDublicates(p);
|
||||||
|
|
||||||
if (!p.getName().equals("")) {
|
if (!p.getName().equals("")) {
|
||||||
p.setVisible(group.visible);
|
p.setVisible(group.visible);
|
||||||
p.setColor(group.color);
|
p.setColor(group.color);
|
||||||
|
@ -149,10 +159,36 @@ public class FavouritesDbHelper {
|
||||||
if (saveImmediately) {
|
if (saveImmediately) {
|
||||||
saveCurrentPointsIntoFile();
|
saveCurrentPointsIntoFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkDublicates(FavouritePoint p){
|
||||||
|
boolean fl = true;
|
||||||
|
String index = "";
|
||||||
|
int number = 0;
|
||||||
|
String name = p.getName();
|
||||||
|
while (fl){
|
||||||
|
fl = false;
|
||||||
|
for (FavouritePoint fp : cachedFavoritePoints){
|
||||||
|
if (fp.getName().equals(name)){
|
||||||
|
number++;
|
||||||
|
index = " (" + number + ")";
|
||||||
|
name = p.getName() + index;
|
||||||
|
fl=true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (index.length() > 0){
|
||||||
|
p.setName(name);
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(context.getMapActivity());
|
||||||
|
builder.setTitle(R.string.fav_point_dublicate);
|
||||||
|
builder.setMessage(context.getString(R.string.fav_point_dublicate_message, name));
|
||||||
|
builder.setPositiveButton(R.string.default_buttons_ok, null);
|
||||||
|
builder.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean editFavouriteName(FavouritePoint p, String newName, String category) {
|
public boolean editFavouriteName(FavouritePoint p, String newName, String category) {
|
||||||
String oldCategory = p.getCategory();
|
String oldCategory = p.getCategory();
|
||||||
|
|
Loading…
Reference in a new issue