Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-10-14 21:28:35 +02:00
commit 2c524bfdce
9 changed files with 46 additions and 24 deletions

View file

@ -41,6 +41,7 @@ public class OsmandRegions {
private BinaryMapIndexReader reader; private BinaryMapIndexReader reader;
Map<String, LinkedList<BinaryMapDataObject>> countriesByDownloadName = new HashMap<String, LinkedList<BinaryMapDataObject>>(); Map<String, LinkedList<BinaryMapDataObject>> countriesByDownloadName = new HashMap<String, LinkedList<BinaryMapDataObject>>();
Map<String, String> fullNamesToLocaleNames = new HashMap<String, String>(); Map<String, String> fullNamesToLocaleNames = new HashMap<String, String>();
Map<String, String> fullNamesNoParentToLocaleNames = new HashMap<String, String>();
Map<String, String> fullMapNamesToDownloadNames = new HashMap<String, String>(); Map<String, String> fullMapNamesToDownloadNames = new HashMap<String, String>();
Map<String, String> downloadNamesToFullNames = new HashMap<String, String>(); Map<String, String> downloadNamesToFullNames = new HashMap<String, String>();
Map<String, String> fullNamesToLowercaseIndex = new HashMap<String, String>(); Map<String, String> fullNamesToLowercaseIndex = new HashMap<String, String>();
@ -81,22 +82,36 @@ public class OsmandRegions {
return nameEnType; return nameEnType;
} }
public String getLocaleName(String downloadName) { public String getLocaleName(String downloadName, boolean includingParent) {
final String lc = downloadName.toLowerCase(); final String lc = downloadName.toLowerCase();
if (downloadNamesToFullNames.containsKey(lc)) { if (downloadNamesToFullNames.containsKey(lc)) {
String fullName = downloadNamesToFullNames.get(lc); String fullName = downloadNamesToFullNames.get(lc);
if (fullNamesToLocaleNames.containsKey(fullName)) { if (includingParent) {
return fullNamesToLocaleNames.get(fullName); if (fullNamesToLocaleNames.containsKey(fullName)) {
return fullNamesToLocaleNames.get(fullName);
}
} else {
if (fullNamesNoParentToLocaleNames.containsKey(fullName)) {
return fullNamesNoParentToLocaleNames.get(fullName);
}
} }
} }
return downloadName.replace('_', ' '); return downloadName.replace('_', ' ');
} }
public String getLocaleNameByFullName(String fullName) { public String getLocaleNameByFullName(String fullName, boolean includingParent) {
if (fullNamesToLocaleNames.containsKey(fullName)) { if (includingParent) {
return fullNamesToLocaleNames.get(fullName); if (fullNamesToLocaleNames.containsKey(fullName)) {
return fullNamesToLocaleNames.get(fullName);
} else {
return fullName.replace('_', ' ');
}
} else { } else {
return fullName.replace('_', ' '); if (fullNamesNoParentToLocaleNames.containsKey(fullName)) {
return fullNamesNoParentToLocaleNames.get(fullName);
} else {
return fullName.replace('_', ' ');
}
} }
} }
@ -350,6 +365,7 @@ public class OsmandRegions {
String locName = getLocaleName(object); String locName = getLocaleName(object);
if(!Algorithms.isEmpty(locName)){ if(!Algorithms.isEmpty(locName)){
fullNamesToLocaleNames.put(fullName, locName); fullNamesToLocaleNames.put(fullName, locName);
fullNamesNoParentToLocaleNames.put(fullName, locName);
} }
MapIndex mi = object.getMapIndex(); MapIndex mi = object.getMapIndex();
TIntObjectIterator<String> it = object.getObjectNames().iterator(); TIntObjectIterator<String> it = object.getObjectNames().iterator();
@ -358,8 +374,9 @@ public class OsmandRegions {
it.advance(); it.advance();
TagValuePair tp = mi.decodeType(it.key()); TagValuePair tp = mi.decodeType(it.key());
if (tp.tag.equals("key_name") && Algorithms.isEmpty(locName)) { if (tp.tag.equals("key_name") && Algorithms.isEmpty(locName)) {
fullNamesToLocaleNames.put(fullName, String str = Algorithms.capitalizeFirstLetterAndLowercase(it.value().replace('_', '-'));
Algorithms.capitalizeFirstLetterAndLowercase(it.value().replace('_', '-'))); fullNamesToLocaleNames.put(fullName, str);
fullNamesNoParentToLocaleNames.put(fullName, str);
} }
if(tp.tag.startsWith("name") || tp.tag.equals("key_name")) { if(tp.tag.startsWith("name") || tp.tag.equals("key_name")) {
final String vl = it.value().toLowerCase(); final String vl = it.value().toLowerCase();
@ -403,7 +420,8 @@ public class OsmandRegions {
if(locPrefix == null || locName == null) { if(locPrefix == null || locName == null) {
throw new IllegalStateException("There is no prefix registered for " + fullName + " (" + parentFullName + ") "); throw new IllegalStateException("There is no prefix registered for " + fullName + " (" + parentFullName + ") ");
} }
fullNamesToLocaleNames.put(fullName, /*locPrefix + " " +*/ locName); fullNamesToLocaleNames.put(fullName, locPrefix + " " + locName);
fullNamesNoParentToLocaleNames.put(fullName, locName);
String index = fullNamesToLowercaseIndex.get(fullName); String index = fullNamesToLowercaseIndex.get(fullName);
String prindex = fullNamesToLowercaseIndex.get(parentFullName); String prindex = fullNamesToLowercaseIndex.get(parentFullName);
fullNamesToLowercaseIndex.put(fullName, index + " " + prindex); fullNamesToLowercaseIndex.put(fullName, index + " " + prindex);

View file

@ -141,7 +141,7 @@ public class WorldRegion {
if (name != null) { if (name != null) {
this.name = name; this.name = name;
} else { } else {
this.name = osmandRegions.getLocaleNameByFullName(regionId); this.name = osmandRegions.getLocaleNameByFullName(regionId, false);
if (this.name == null) { if (this.name == null) {
this.name = capitalize(regionId.replace('_', ' ')); this.name = capitalize(regionId.replace('_', ' '));
} }
@ -157,7 +157,7 @@ public class WorldRegion {
} else { } else {
this.downloadsIdPrefix = regionId.toLowerCase() + "."; this.downloadsIdPrefix = regionId.toLowerCase() + ".";
} }
this.name = osmandRegions.getLocaleNameByFullName(regionId); this.name = osmandRegions.getLocaleNameByFullName(regionId, false);
if (this.name == null) { if (this.name == null) {
this.name = capitalize(regionId.replace('_', ' ')); this.name = capitalize(regionId.replace('_', ' '));
} }

View file

@ -259,7 +259,7 @@ public class DownloadActivityType implements Parcelable {
return ""; return "";
} }
public String getVisibleName(IndexItem indexItem, Context ctx, OsmandRegions osmandRegions) { public String getVisibleName(IndexItem indexItem, Context ctx, OsmandRegions osmandRegions, boolean includingParent) {
if (this == VOICE_FILE) { if (this == VOICE_FILE) {
String fileName = indexItem.fileName; String fileName = indexItem.fileName;
if (fileName.endsWith(IndexConstants.VOICE_INDEX_EXT_ZIP)) { if (fileName.endsWith(IndexConstants.VOICE_INDEX_EXT_ZIP)) {
@ -284,11 +284,11 @@ public class DownloadActivityType implements Parcelable {
if (bn.contains("addresses-nationwide")) { if (bn.contains("addresses-nationwide")) {
final int ind = bn.indexOf("addresses-nationwide"); final int ind = bn.indexOf("addresses-nationwide");
String downloadName = bn.substring(0, ind - 1) + bn.substring(ind + "addresses-nationwide".length()); String downloadName = bn.substring(0, ind - 1) + bn.substring(ind + "addresses-nationwide".length());
return osmandRegions.getLocaleName(downloadName) + return osmandRegions.getLocaleName(downloadName, includingParent) +
" "+ ctx.getString(R.string.index_item_nation_addresses); " "+ ctx.getString(R.string.index_item_nation_addresses);
} }
return osmandRegions.getLocaleName(bn); return osmandRegions.getLocaleName(bn, includingParent);
} }
public String getTargetFileName(IndexItem item) { public String getTargetFileName(IndexItem item) {

View file

@ -137,7 +137,11 @@ public class IndexItem implements Comparable<IndexItem>, HasName, Parcelable {
} }
public String getVisibleName(Context ctx, OsmandRegions osmandRegions) { public String getVisibleName(Context ctx, OsmandRegions osmandRegions) {
return type.getVisibleName(this, ctx, osmandRegions); return type.getVisibleName(this, ctx, osmandRegions, true);
}
public String getVisibleName(Context ctx, OsmandRegions osmandRegions, boolean includingParent) {
return type.getVisibleName(this, ctx, osmandRegions, includingParent);
} }
public String getVisibleDescription(OsmandApplication clctx) { public String getVisibleDescription(OsmandApplication clctx) {

View file

@ -96,7 +96,7 @@ public class ItemViewHolder {
if (indexItem.getType() == DownloadActivityType.VOICE_FILE) { if (indexItem.getType() == DownloadActivityType.VOICE_FILE) {
nameTextView.setText(indexItem.getVisibleName(context, nameTextView.setText(indexItem.getVisibleName(context,
context.getMyApplication().getRegions())); context.getMyApplication().getRegions(), false));
} else { } else {
if (indexItem.getSimplifiedFileName().equals(ItemsListBuilder.WORLD_SEAMARKS_KEY) && nauticalPluginDisabled) { if (indexItem.getSimplifiedFileName().equals(ItemsListBuilder.WORLD_SEAMARKS_KEY) && nauticalPluginDisabled) {
rightButtonAction = RightButtonAction.ASK_FOR_SEAMARKS_PLUGIN; rightButtonAction = RightButtonAction.ASK_FOR_SEAMARKS_PLUGIN;
@ -119,7 +119,7 @@ public class ItemViewHolder {
if (showTypeInTitle) { if (showTypeInTitle) {
nameTextView.setText(indexItem.getType().getString(context)); nameTextView.setText(indexItem.getType().getString(context));
} else { } else {
nameTextView.setText(indexItem.getVisibleName(context, context.getMyApplication().getRegions())); nameTextView.setText(indexItem.getVisibleName(context, context.getMyApplication().getRegions(), false));
} }
} }

View file

@ -231,7 +231,7 @@ public class ItemsListBuilder {
for (IndexItem indexItem : regionResources.values()) { for (IndexItem indexItem : regionResources.values()) {
String name = indexItem.getVisibleName(context, osmandRegions); String name = indexItem.getVisibleName(context, osmandRegions, false);
if (Algorithms.isEmpty(name)) { if (Algorithms.isEmpty(name)) {
continue; continue;
} }

View file

@ -322,13 +322,13 @@ public class SearchItemsFragment extends Fragment {
if (obj1 instanceof WorldRegion) { if (obj1 instanceof WorldRegion) {
str1 = ((WorldRegion) obj1).getName(); str1 = ((WorldRegion) obj1).getName();
} else { } else {
str1 = ((IndexItem) obj1).getVisibleName(getMyApplication(), osmandRegions); str1 = ((IndexItem) obj1).getVisibleName(getMyApplication(), osmandRegions, false);
} }
if (obj2 instanceof WorldRegion) { if (obj2 instanceof WorldRegion) {
str2 = ((WorldRegion) obj2).getName(); str2 = ((WorldRegion) obj2).getName();
} else { } else {
str2 = ((IndexItem) obj2).getVisibleName(getMyApplication(), osmandRegions); str2 = ((IndexItem) obj2).getVisibleName(getMyApplication(), osmandRegions, false);
} }
return collator.compare(str1, str2); return collator.compare(str1, str2);

View file

@ -48,7 +48,7 @@ public class FileNameTranslationHelper {
} }
if (regions != null) { if (regions != null) {
return regions.getLocaleName(basename); return regions.getLocaleName(basename, true);
} }
return null; return null;
@ -56,7 +56,7 @@ public class FileNameTranslationHelper {
public static String getHillShadeName(Context ctx, OsmandRegions regions, String basename) { public static String getHillShadeName(Context ctx, OsmandRegions regions, String basename) {
String hillsh = ctx.getString(R.string.download_hillshade_item) + " "; String hillsh = ctx.getString(R.string.download_hillshade_item) + " ";
String locName = regions.getLocaleName(basename.trim()); String locName = regions.getLocaleName(basename.trim(), true);
return hillsh + locName; return hillsh + locName;
} }

View file

@ -250,7 +250,7 @@ public class DownloadedRegionsLayer extends OsmandMapLayer {
String fullName = osmandRegions.getFullName(o); String fullName = osmandRegions.getFullName(o);
String downloadName = osmandRegions.getMapDownloadType(fullName); String downloadName = osmandRegions.getMapDownloadType(fullName);
if (!Algorithms.isEmpty(downloadName)) { if (!Algorithms.isEmpty(downloadName)) {
String name = osmandRegions.getLocaleName(downloadName); // Algorithms.capitalizeFirstLetterAndLowercase(o.getName()); String name = osmandRegions.getLocaleName(downloadName, true); // Algorithms.capitalizeFirstLetterAndLowercase(o.getName());
if (checkIfObjectDownloaded(downloadName)) { if (checkIfObjectDownloaded(downloadName)) {
return null; return null;
} }