This commit is contained in:
Victor Shcherb 2015-11-08 12:23:17 +01:00
parent 4de026b56a
commit 6ed714c93d
4 changed files with 37 additions and 9 deletions

View file

@ -12,6 +12,8 @@ public abstract class AbstractPoiType {
protected final MapPoiTypes registry;
private List<PoiType> poiAdditionals = null;
private boolean topVisible;
private String lang;
private AbstractPoiType baseLangType;
public AbstractPoiType(String keyName, MapPoiTypes registry) {
@ -19,6 +21,22 @@ public abstract class AbstractPoiType {
this.registry = registry;
}
public void setBaseLangType(AbstractPoiType baseLangType) {
this.baseLangType = baseLangType;
}
public AbstractPoiType getBaseLangType() {
return baseLangType;
}
public void setLang(String lang) {
this.lang = lang;
}
public String getLang() {
return lang;
}
public String getKeyName() {
return keyName;
}

View file

@ -286,23 +286,25 @@ public class MapPoiTypes {
if(lastCategory == null) {
lastCategory = getOtherMapCategory();
}
PoiType baseType = parsePoiAdditional(parser, lastCategory, lastFilter, lastType, null, null);
if("true".equals(parser.getAttributeValue("", "lang"))) {
for(String lng : MapRenderingTypes.langs) {
parsePoiAdditional(parser, lastCategory, lastFilter, lastType, lng);
parsePoiAdditional(parser, lastCategory, lastFilter, lastType, lng, baseType);
}
parsePoiAdditional(parser, lastCategory, lastFilter, lastType, "en");
parsePoiAdditional(parser, lastCategory, lastFilter, lastType, "en", baseType);
}
parsePoiAdditional(parser, lastCategory, lastFilter, lastType, null);
} else if (name.equals("poi_type")) {
if(lastCategory == null) {
lastCategory = getOtherMapCategory();
}
lastType = parsePoiType(allTypes, parser, lastCategory, lastFilter, null, null);
if("true".equals(parser.getAttributeValue("", "lang"))) {
for(String lng : MapRenderingTypes.langs) {
parsePoiType(allTypes, parser, lastCategory, lastFilter, lng);
parsePoiType(allTypes, parser, lastCategory, lastFilter, lng, lastType);
}
}
lastType = parsePoiType(allTypes, parser, lastCategory, lastFilter, null);
}
} else if (tok == XmlPullParser.END_TAG) {
String name = parser.getName();
@ -343,8 +345,8 @@ public class MapPoiTypes {
}
private void parsePoiAdditional(XmlPullParser parser, PoiCategory lastCategory, PoiFilter lastFilter,
PoiType lastType, String lang) {
private PoiType parsePoiAdditional(XmlPullParser parser, PoiCategory lastCategory, PoiFilter lastFilter,
PoiType lastType, String lang, PoiType langBaseType) {
String oname = parser.getAttributeValue("", "name");
if(lang != null) {
oname += ":" + lang;
@ -354,6 +356,8 @@ public class MapPoiTypes {
otag += ":" + lang;
}
PoiType tp = new PoiType(this, lastCategory, oname);
tp.setBaseLangType(langBaseType);
tp.setLang(lang);
tp.setAdditional(lastType != null ? lastType :
(lastFilter != null ? lastFilter : lastCategory));
tp.setTopVisible(Boolean.parseBoolean(parser.getAttributeValue("", "top")));
@ -369,11 +373,12 @@ public class MapPoiTypes {
} else if (lastCategory != null) {
lastCategory.addPoiAdditional(tp);
}
return tp;
}
private PoiType parsePoiType(final Map<String, PoiType> allTypes, XmlPullParser parser, PoiCategory lastCategory,
PoiFilter lastFilter, String lang) {
PoiFilter lastFilter, String lang, PoiType langBaseType) {
String oname = parser.getAttributeValue("", "name");
if(lang != null) {
oname += ":" + lang;
@ -383,6 +388,8 @@ public class MapPoiTypes {
if(lang != null) {
otag += ":" + lang;
}
tp.setBaseLangType(langBaseType);
tp.setLang(lang);
tp.setOsmTag(otag);
tp.setOsmValue(parser.getAttributeValue("", "value"));
tp.setOsmTag2(parser.getAttributeValue("", "tag2"));

View file

@ -268,6 +268,9 @@ public class AppInitializer implements IProgress {
@Override
public String getTranslation(AbstractPoiType type) {
if(type.getBaseLangType() != null) {
return getTranslation(type.getBaseLangType()) + "(" + type.getLang() +")";
}
try {
Field f = R.string.class.getField("poi_" + type.getIconKeyName());
if (f != null) {

View file

@ -272,7 +272,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
svlss[i++] = o.toString();
}
basePref = createListPreference(settings.getCustomRoutingProperty(p.getId(),
p.getType() == RoutingParameterType.NUMERIC ? "0" : "-"),
p.getType() == RoutingParameterType.NUMERIC ? "0.0" : "-"),
p.getPossibleValueDescriptions(), svlss,
SettingsBaseActivity.getRoutingStringPropertyName(this, p.getId(), p.getName()),
SettingsBaseActivity.getRoutingStringPropertyDescription(this, p.getId(), p.getDescription()));