From cec2f6fb09621917bda22be0384f1f6c5cec99fe Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Tue, 2 Oct 2018 13:59:53 +0300 Subject: [PATCH] Fix titles of custom poi filters for search history --- OsmAnd/res/layout/search_list_item.xml | 2 ++ .../src/net/osmand/plus/poi/PoiUIFilter.java | 22 +++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/OsmAnd/res/layout/search_list_item.xml b/OsmAnd/res/layout/search_list_item.xml index 62b079fa2f..5f9443007d 100644 --- a/OsmAnd/res/layout/search_list_item.xml +++ b/OsmAnd/res/layout/search_list_item.xml @@ -51,6 +51,8 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" + android:ellipsize="end" + android:maxLines="2" android:paddingRight="16dp" android:textColor="?android:textColorPrimary" android:textSize="@dimen/default_list_text_size" diff --git a/OsmAnd/src/net/osmand/plus/poi/PoiUIFilter.java b/OsmAnd/src/net/osmand/plus/poi/PoiUIFilter.java index 8564184ff8..930c181388 100644 --- a/OsmAnd/src/net/osmand/plus/poi/PoiUIFilter.java +++ b/OsmAnd/src/net/osmand/plus/poi/PoiUIFilter.java @@ -509,15 +509,29 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable public String getTypesName() { StringBuilder sb = new StringBuilder(); - for (PoiCategory p : acceptedTypes.keySet()) { - if (sb.length() > 0) { - sb.append(", "); + for (Map.Entry> entry : acceptedTypes.entrySet()) { + LinkedHashSet set = entry.getValue(); + if (set != null && !set.isEmpty()) { + for (String key : set) { + PoiType pt = poiTypes.getPoiTypeByKey(key); + if (pt != null) { + appendWithSeparator(sb, pt.getTranslation()); + } + } + } else { + appendWithSeparator(sb, entry.getKey().getTranslation()); } - sb.append(p.getTranslation()); } return sb.toString(); } + private void appendWithSeparator(StringBuilder sb, String s) { + if (sb.length() > 0) { + sb.append(", "); + } + sb.append(s); + } + /** * @param type * @return null if all subtypes are accepted/ empty list if type is not accepted at all