commit
6cdf56dd17
3 changed files with 51 additions and 4 deletions
|
@ -9,6 +9,7 @@
|
||||||
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_emoticons_message">We changed your favorite point name to %1$s because it is not possible to save string with emoticons to file.</string>
|
||||||
<string name="print_route">Print route</string>
|
<string name="print_route">Print route</string>
|
||||||
<string name="test_native_render">Test native render</string>
|
<string name="test_native_render">Test native render</string>
|
||||||
<string name="test_native_render_msg">Starts activity with native render</string>
|
<string name="test_native_render_msg">Starts activity with native render</string>
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package net.osmand.plus;
|
package net.osmand.plus;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.lang.reflect.Array;
|
||||||
import java.text.Collator;
|
import java.text.Collator;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -9,6 +11,8 @@ import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.ActivityNotFoundException;
|
import android.content.ActivityNotFoundException;
|
||||||
|
@ -165,9 +169,15 @@ public class FavouritesDbHelper {
|
||||||
|
|
||||||
private void checkDublicates(FavouritePoint p){
|
private void checkDublicates(FavouritePoint p){
|
||||||
boolean fl = true;
|
boolean fl = true;
|
||||||
|
boolean emoticons = false;
|
||||||
String index = "";
|
String index = "";
|
||||||
int number = 0;
|
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){
|
while (fl){
|
||||||
fl = false;
|
fl = false;
|
||||||
for (FavouritePoint fp : cachedFavoritePoints){
|
for (FavouritePoint fp : cachedFavoritePoints){
|
||||||
|
@ -180,16 +190,51 @@ public class FavouritesDbHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (index.length() > 0){
|
if (index.length() > 0 || emoticons){
|
||||||
p.setName(name);
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(context.getMapActivity());
|
AlertDialog.Builder builder = new AlertDialog.Builder(context.getMapActivity());
|
||||||
builder.setTitle(R.string.fav_point_dublicate);
|
builder.setTitle(R.string.fav_point_dublicate);
|
||||||
|
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.setMessage(context.getString(R.string.fav_point_dublicate_message, name));
|
||||||
|
}
|
||||||
builder.setPositiveButton(R.string.default_buttons_ok, null);
|
builder.setPositiveButton(R.string.default_buttons_ok, null);
|
||||||
|
p.setName(name);
|
||||||
builder.show();
|
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) {
|
public boolean editFavouriteName(FavouritePoint p, String newName, String category) {
|
||||||
String oldCategory = p.getCategory();
|
String oldCategory = p.getCategory();
|
||||||
p.setName(newName);
|
p.setName(newName);
|
||||||
|
|
|
@ -12,6 +12,7 @@ import java.io.OutputStreamWriter;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
|
import java.net.URLEncoder;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.text.DecimalFormatSymbols;
|
import java.text.DecimalFormatSymbols;
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
|
|
Loading…
Reference in a new issue