diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index 2e9887054b..f1ac4b49c9 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -9,6 +9,7 @@
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
-->
+ We changed your favorite point name to %1$s because it is not possible to save string with emoticons to file.
Print route
Test native render
Starts activity with native render
diff --git a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java
index 3a07436805..d59e6d4ac0 100644
--- a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java
+++ b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java
@@ -1,6 +1,8 @@
package net.osmand.plus;
import java.io.File;
+import java.io.UnsupportedEncodingException;
+import java.lang.reflect.Array;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
@@ -9,6 +11,8 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
@@ -165,9 +169,15 @@ public class FavouritesDbHelper {
private void checkDublicates(FavouritePoint p){
boolean fl = true;
+ boolean emoticons = false;
String index = "";
int number = 0;
- String name = p.getName();
+ String name = checkEmoticons(p.getName());
+ String category = checkEmoticons(p.getCategory());
+ p.setCategory(category);
+ if (name.length() != p.getName().length()){
+ emoticons = true;
+ }
while (fl){
fl = false;
for (FavouritePoint fp : cachedFavoritePoints){
@@ -180,16 +190,51 @@ public class FavouritesDbHelper {
}
}
}
- if (index.length() > 0){
- p.setName(name);
+ if (index.length() > 0 || emoticons){
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));
+ if (emoticons){
+ builder.setMessage(context.getString(R.string.fav_point_emoticons_message, name));
+ } else {
+ builder.setMessage(context.getString(R.string.fav_point_dublicate_message, name));
+ }
builder.setPositiveButton(R.string.default_buttons_ok, null);
+ p.setName(name);
builder.show();
}
}
+ public String checkEmoticons(String name){
+ char[] chars = name.toCharArray();
+ int index;
+ char ch1;
+ char ch2;
+
+ index = 0;
+ StringBuilder builder = new StringBuilder();
+ while (index < chars.length) {
+ ch1 = chars[index];
+ if ((int)ch1 == 0xD83C) {
+ ch2 = chars[index+1];
+ if ((int)ch2 >= 0xDF00 && (int)ch2 <= 0xDFFF) {
+ index += 2;
+ continue;
+ }
+ }
+ else if ((int)ch1 == 0xD83D) {
+ ch2 = chars[index+1];
+ if ((int)ch2 >= 0xDC00 && (int)ch2 <= 0xDDFF) {
+ index += 2;
+ continue;
+ }
+ }
+ builder.append(ch1);
+ ++index;
+ }
+
+ return builder.toString();
+ }
+
public boolean editFavouriteName(FavouritePoint p, String newName, String category) {
String oldCategory = p.getCategory();
p.setName(newName);
diff --git a/OsmAnd/src/net/osmand/plus/GPXUtilities.java b/OsmAnd/src/net/osmand/plus/GPXUtilities.java
index 70eb6d8f5e..565a763192 100644
--- a/OsmAnd/src/net/osmand/plus/GPXUtilities.java
+++ b/OsmAnd/src/net/osmand/plus/GPXUtilities.java
@@ -12,6 +12,7 @@ import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.StringWriter;
import java.io.Writer;
+import java.net.URLEncoder;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.NumberFormat;