Fix issue 1327, show relative names for poi subcategories
This commit is contained in:
parent
78a4c7be94
commit
4c59d9d1b4
4 changed files with 30 additions and 11 deletions
|
@ -12,6 +12,7 @@ import java.util.LinkedHashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.parsers.SAXParser;
|
||||
|
@ -218,7 +219,7 @@ public class MapRenderingTypes {
|
|||
for(MapRulType type : types.values()){
|
||||
if(type.poiCategory != null && type.targetTagValue == null) {
|
||||
if(!amenityTypeNameToTagVal.containsKey(type.poiCategory)) {
|
||||
amenityTypeNameToTagVal.put(type.poiCategory, new LinkedHashMap<String, String>());
|
||||
amenityTypeNameToTagVal.put(type.poiCategory, new TreeMap<String, String>());
|
||||
}
|
||||
String name = type.value;
|
||||
if (name != null) {
|
||||
|
|
|
@ -201,10 +201,6 @@ public class OsmAndFormatter {
|
|||
public static String getPoiStringWithoutType(Amenity amenity, boolean en) {
|
||||
String type = SpecialPhrases.getSpecialPhrase(amenity.getSubType());
|
||||
String n = amenity.getName(en);
|
||||
|
||||
if (type == null) {
|
||||
type = amenity.getSubType();
|
||||
}
|
||||
if (n.indexOf(type) != -1) {
|
||||
// type is contained in name e.g.
|
||||
// n = "Bakery the Corner"
|
||||
|
|
|
@ -26,18 +26,22 @@ public class SpecialPhrases {
|
|||
*
|
||||
* If the language isn't set yet, a nullpointer exception will be thrown
|
||||
*
|
||||
* @param key the subtype to query
|
||||
* @param value the subtype to query
|
||||
* @return the special phrase according to the asked key, or "null" if the key isn't found
|
||||
*/
|
||||
public static String getSpecialPhrase(String key) {
|
||||
public static String getSpecialPhrase(String value) {
|
||||
if (m == null) {
|
||||
// do not throw exception because OsmAndApplication is not always initiliazed before
|
||||
// this call
|
||||
log.warn("The language has not been set for special phrases");
|
||||
return null;
|
||||
return value;
|
||||
|
||||
}
|
||||
return m.get(key);
|
||||
String specialValue = m.get(value);
|
||||
if(Algoritms.isEmpty(specialValue)) {
|
||||
return value;
|
||||
}
|
||||
return specialValue;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,7 +3,10 @@
|
|||
*/
|
||||
package net.osmand.plus.activities;
|
||||
|
||||
import java.text.Collator;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -16,6 +19,7 @@ import net.osmand.plus.OsmandApplication;
|
|||
import net.osmand.plus.PoiFilter;
|
||||
import net.osmand.plus.PoiFiltersHelper;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.SpecialPhrases;
|
||||
import net.osmand.plus.activities.search.SearchActivity;
|
||||
import net.osmand.plus.activities.search.SearchPOIActivity;
|
||||
import android.app.AlertDialog;
|
||||
|
@ -197,8 +201,22 @@ public class EditPOIFilterActivity extends OsmandListActivity {
|
|||
}
|
||||
|
||||
final String[] array = subCategories.toArray(new String[0]);
|
||||
final Collator cl = Collator.getInstance();
|
||||
cl.setStrength(Collator.SECONDARY);
|
||||
Arrays.sort(array, 0, array.length, new Comparator<String>() {
|
||||
|
||||
@Override
|
||||
public int compare(String object1, String object2) {
|
||||
String v1 = SpecialPhrases.getSpecialPhrase(object1).replace('_', ' ');
|
||||
String v2 = SpecialPhrases.getSpecialPhrase(object2).replace('_', ' ');
|
||||
return cl.compare(v1, v2);
|
||||
}
|
||||
});
|
||||
final String[] visibleNames = new String[array.length];
|
||||
final boolean[] selected = new boolean[array.length];
|
||||
for (int i = 0; i < selected.length; i++) {
|
||||
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
visibleNames[i] = SpecialPhrases.getSpecialPhrase(array[i]).replace('_', ' ');
|
||||
if (acceptedCategories == null) {
|
||||
selected[i] = true;
|
||||
} else {
|
||||
|
@ -239,7 +257,7 @@ public class EditPOIFilterActivity extends OsmandListActivity {
|
|||
}
|
||||
});
|
||||
|
||||
builder.setMultiChoiceItems(array, selected, new DialogInterface.OnMultiChoiceClickListener() {
|
||||
builder.setMultiChoiceItems(visibleNames, selected, new DialogInterface.OnMultiChoiceClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int item, boolean isChecked) {
|
||||
|
|
Loading…
Reference in a new issue