Fix poi creation dialog

This commit is contained in:
Victor Shcherb 2015-06-14 16:48:04 +02:00
parent 4b75d9274c
commit 308a777693
2 changed files with 8 additions and 7 deletions

View file

@ -133,7 +133,8 @@ public class MapPoiTypes {
if(pt.isReference()) { if(pt.isReference()) {
continue; continue;
} }
translation.put(pt.getTranslation(), pt); translation.put(pt.getKeyName().replace('_', ' ').toLowerCase(), pt);
translation.put(pt.getTranslation().toLowerCase(), pt);
} }
} }
return translation; return translation;
@ -415,7 +416,7 @@ public class MapPoiTypes {
public String getTranslation(AbstractPoiType abstractPoiType) { public String getTranslation(AbstractPoiType abstractPoiType) {
if(poiTranslator != null) { if(poiTranslator != null) {
String translation = poiTranslator.getTranslation(abstractPoiType); String translation = poiTranslator.getTranslation(abstractPoiType);
if(translation != null) { if(!Algorithms.isEmpty(translation)) {
return translation; return translation;
} }
} }

View file

@ -404,8 +404,8 @@ public class EditingPOIDialogProvider implements DialogProvider {
final String msg = n.getId() == -1 ? resources.getString(R.string.poi_action_add) : resources final String msg = n.getId() == -1 ? resources.getString(R.string.poi_action_add) : resources
.getString(R.string.poi_action_change); .getString(R.string.poi_action_change);
OsmPoint.Action action = n.getId() == -1 ? OsmPoint.Action.CREATE : OsmPoint.Action.MODIFY; OsmPoint.Action action = n.getId() == -1 ? OsmPoint.Action.CREATE : OsmPoint.Action.MODIFY;
String subType = typeText.getText().toString(); String subType = typeText.getText().toString().trim().toLowerCase();
if (allTranslatedSubTypes.get(subType.trim()) != null) { if (allTranslatedSubTypes.get(subType) != null) {
PoiType pt = allTranslatedSubTypes.get(subType); PoiType pt = allTranslatedSubTypes.get(subType);
n.putTag(pt.getOsmTag(), pt.getOsmValue()); n.putTag(pt.getOsmTag(), pt.getOsmValue());
if (pt.getOsmTag2() != null) { if (pt.getOsmTag2() != null) {
@ -478,9 +478,9 @@ public class EditingPOIDialogProvider implements DialogProvider {
} }
private void updateOsmTagValue(final Amenity a) { private void updateOsmTagValue(final Amenity a) {
String subType = typeText.getText().toString(); String subType = typeText.getText().toString().trim().toLowerCase();
String s = "OSM "; String s = "OSM ";
if (allTranslatedSubTypes.get(subType.trim()) != null) { if (allTranslatedSubTypes.get(subType) != null) {
PoiType pt = allTranslatedSubTypes.get(subType); PoiType pt = allTranslatedSubTypes.get(subType);
s = pt.getOsmTag() + "=" + pt.getOsmValue(); s = pt.getOsmTag() + "=" + pt.getOsmValue();
if (pt.getOsmTag2() != null) { if (pt.getOsmTag2() != null) {
@ -519,7 +519,7 @@ public class EditingPOIDialogProvider implements DialogProvider {
public void afterTextChanged(Editable s) { public void afterTextChanged(Editable s) {
String str = s.toString(); String str = s.toString();
a.setSubType(str); a.setSubType(str);
PoiType st = allTranslatedSubTypes.get(str); PoiType st = allTranslatedSubTypes.get(str.trim().toLowerCase());
if(st != null && a.getType() != st.getCategory() && st.getCategory() != null){ if(st != null && a.getType() != st.getCategory() && st.getCategory() != null){
a.setType(st.getCategory()); a.setType(st.getCategory());
typeButton.setText(st.getCategory().getTranslation()); typeButton.setText(st.getCategory().getTranslation());