[Quick search] added icon for filter categories
This commit is contained in:
parent
9b2c75f045
commit
a3b167c6bf
4 changed files with 28 additions and 6 deletions
|
@ -39,7 +39,8 @@ public class MapPoiTypes {
|
||||||
private boolean init;
|
private boolean init;
|
||||||
Map<String, PoiType> poiTypesByTag = new LinkedHashMap<String, PoiType>();
|
Map<String, PoiType> poiTypesByTag = new LinkedHashMap<String, PoiType>();
|
||||||
Map<String, String> deprecatedTags = new LinkedHashMap<String, String>();
|
Map<String, String> deprecatedTags = new LinkedHashMap<String, String>();
|
||||||
|
Map<String, String> poiAdditionalCategoryIcons = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
|
|
||||||
public MapPoiTypes(String fileName) {
|
public MapPoiTypes(String fileName) {
|
||||||
this.resourceName = fileName;
|
this.resourceName = fileName;
|
||||||
|
@ -88,6 +89,10 @@ public class MapPoiTypes {
|
||||||
return otherMapCategory;
|
return otherMapCategory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPoiAdditionalCategoryIcon(String category) {
|
||||||
|
return poiAdditionalCategoryIcons.get(category);
|
||||||
|
}
|
||||||
|
|
||||||
public List<PoiFilter> getTopVisibleFilters() {
|
public List<PoiFilter> getTopVisibleFilters() {
|
||||||
List<PoiFilter> lf = new ArrayList<PoiFilter>();
|
List<PoiFilter> lf = new ArrayList<PoiFilter>();
|
||||||
for (PoiCategory pc : categories) {
|
for (PoiCategory pc : categories) {
|
||||||
|
@ -315,6 +320,10 @@ public class MapPoiTypes {
|
||||||
} else if (name.equals("poi_additional_category")) {
|
} else if (name.equals("poi_additional_category")) {
|
||||||
if (lastPoiAdditionalCategory == null) {
|
if (lastPoiAdditionalCategory == null) {
|
||||||
lastPoiAdditionalCategory = parser.getAttributeValue("", "name");
|
lastPoiAdditionalCategory = parser.getAttributeValue("", "name");
|
||||||
|
String icon = parser.getAttributeValue("", "icon");
|
||||||
|
if (!Algorithms.isEmpty(icon)) {
|
||||||
|
poiAdditionalCategoryIcons.put(lastPoiAdditionalCategory, icon);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (name.equals("poi_type")) {
|
} else if (name.equals("poi_type")) {
|
||||||
|
|
|
@ -186,7 +186,7 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:contentDescription="@string/poi_filter_custom_filter"
|
android:contentDescription="@string/poi_filter_custom_filter"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:src="@drawable/ic_action_filter_dark"/>
|
android:src="@drawable/ic_action_filter"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
|
@ -212,7 +212,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
buttonToolbarImage = (ImageView) view.findViewById(R.id.buttonToolbarImage);
|
buttonToolbarImage = (ImageView) view.findViewById(R.id.buttonToolbarImage);
|
||||||
buttonToolbarImage.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_marker_dark));
|
buttonToolbarImage.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_marker_dark));
|
||||||
buttonToolbarFilter = (ImageButton) view.findViewById(R.id.filterButton);
|
buttonToolbarFilter = (ImageButton) view.findViewById(R.id.filterButton);
|
||||||
buttonToolbarFilter.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_filter_dark));
|
buttonToolbarFilter.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_filter));
|
||||||
buttonToolbarFilter.setOnClickListener(new OnClickListener() {
|
buttonToolbarFilter.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
|
|
@ -29,6 +29,7 @@ import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
|
import net.osmand.osm.MapPoiTypes;
|
||||||
import net.osmand.osm.PoiType;
|
import net.osmand.osm.PoiType;
|
||||||
import net.osmand.plus.IconsCache;
|
import net.osmand.plus.IconsCache;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
@ -405,6 +406,7 @@ public class QuickSearchPoiFilterFragment extends DialogFragment {
|
||||||
|
|
||||||
private List<PoiFilterListItem> getListItems() {
|
private List<PoiFilterListItem> getListItems() {
|
||||||
OsmandApplication app = getMyApplication();
|
OsmandApplication app = getMyApplication();
|
||||||
|
MapPoiTypes poiTypes = app.getPoiTypes();
|
||||||
int groupId = 0;
|
int groupId = 0;
|
||||||
List<PoiFilterListItem> items = new ArrayList<>();
|
List<PoiFilterListItem> items = new ArrayList<>();
|
||||||
items.add(new PoiFilterListItem(PoiFilterListItemType.DIVIDER, 0, null, -1, false, false, false, null, null));
|
items.add(new PoiFilterListItem(PoiFilterListItemType.DIVIDER, 0, null, -1, false, false, false, null, null));
|
||||||
|
@ -418,7 +420,7 @@ public class QuickSearchPoiFilterFragment extends DialogFragment {
|
||||||
selectedPoiAdditionals.contains(keyNameOpen24), null, keyNameOpen24));
|
selectedPoiAdditionals.contains(keyNameOpen24), null, keyNameOpen24));
|
||||||
|
|
||||||
Map<String, PoiType> poiAdditionals = filter.getPoiAdditionals();
|
Map<String, PoiType> poiAdditionals = filter.getPoiAdditionals();
|
||||||
List<PoiType> otherAdditionalCategories = app.getPoiTypes().getOtherMapCategory().getPoiAdditionalsCategorized();
|
List<PoiType> otherAdditionalCategories = poiTypes.getOtherMapCategory().getPoiAdditionalsCategorized();
|
||||||
if (poiAdditionals != null) {
|
if (poiAdditionals != null) {
|
||||||
Map<String, Set<String>> additionalsMap = new TreeMap<>();
|
Map<String, Set<String>> additionalsMap = new TreeMap<>();
|
||||||
extractPoiAdditionals(poiAdditionals.values(), additionalsMap, false);
|
extractPoiAdditionals(poiAdditionals.values(), additionalsMap, false);
|
||||||
|
@ -427,11 +429,22 @@ public class QuickSearchPoiFilterFragment extends DialogFragment {
|
||||||
if (additionalsMap.size() > 0) {
|
if (additionalsMap.size() > 0) {
|
||||||
for (Entry<String, Set<String>> entry : additionalsMap.entrySet()) {
|
for (Entry<String, Set<String>> entry : additionalsMap.entrySet()) {
|
||||||
String category = entry.getKey();
|
String category = entry.getKey();
|
||||||
|
String categoryLocalizedName = poiTypes.getPoiTranslation(category);
|
||||||
boolean expanded = !collapsedCategories.contains(category);
|
boolean expanded = !collapsedCategories.contains(category);
|
||||||
boolean showAll = showAllCategories.contains(category);
|
boolean showAll = showAllCategories.contains(category);
|
||||||
items.add(new PoiFilterListItem(PoiFilterListItemType.DIVIDER, 0, null, -1, false, false, false, null, null));
|
items.add(new PoiFilterListItem(PoiFilterListItemType.DIVIDER, 0, null, -1, false, false, false, null, null));
|
||||||
|
|
||||||
|
String categoryIconStr = poiTypes.getPoiAdditionalCategoryIcon(category);
|
||||||
|
int categoryIconId = 0;
|
||||||
|
if (!Algorithms.isEmpty(categoryIconStr)) {
|
||||||
|
categoryIconId = getResources().getIdentifier(categoryIconStr, "drawable", app.getPackageName());
|
||||||
|
}
|
||||||
|
if (categoryIconId == 0) {
|
||||||
|
categoryIconId = R.drawable.ic_action_folder_stroke;
|
||||||
|
}
|
||||||
|
|
||||||
items.add(new PoiFilterListItem(PoiFilterListItemType.GROUP_HEADER,
|
items.add(new PoiFilterListItem(PoiFilterListItemType.GROUP_HEADER,
|
||||||
R.drawable.ic_action_folder_stroke, category, ++groupId, true, expanded, false, category, null));
|
categoryIconId, categoryLocalizedName, ++groupId, true, expanded, false, category, null));
|
||||||
List<String> poiTypeNames = new ArrayList<>(entry.getValue());
|
List<String> poiTypeNames = new ArrayList<>(entry.getValue());
|
||||||
Collections.sort(poiTypeNames);
|
Collections.sort(poiTypeNames);
|
||||||
for (String poiTypeName : poiTypeNames) {
|
for (String poiTypeName : poiTypeNames) {
|
||||||
|
@ -451,7 +464,7 @@ public class QuickSearchPoiFilterFragment extends DialogFragment {
|
||||||
|
|
||||||
private void extractPoiAdditionals(Collection<PoiType> poiAdditionals, Map<String, Set<String>> additionalsMap, boolean extractAll) {
|
private void extractPoiAdditionals(Collection<PoiType> poiAdditionals, Map<String, Set<String>> additionalsMap, boolean extractAll) {
|
||||||
for (PoiType poiType : poiAdditionals) {
|
for (PoiType poiType : poiAdditionals) {
|
||||||
String category = poiType.getPoiAdditionalCategoryTranslation();
|
String category = poiType.getPoiAdditionalCategory();
|
||||||
if (category == null) {
|
if (category == null) {
|
||||||
category = "";
|
category = "";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue