Fix POI additionals in context menu

This commit is contained in:
Alexey Kulish 2018-02-06 14:57:25 +03:00
parent 3c7afb3139
commit 6482818892

View file

@ -97,7 +97,8 @@ public class AmenityMenuBuilder extends MenuBuilder {
ll.setOnLongClickListener(new View.OnLongClickListener() { ll.setOnLongClickListener(new View.OnLongClickListener() {
@Override @Override
public boolean onLongClick(View v) { public boolean onLongClick(View v) {
copyToClipboard(txt, view.getContext()); String textToCopy = !Algorithms.isEmpty(textPrefix) ? textPrefix + ": " + txt : txt;
copyToClipboard(textToCopy, view.getContext());
return true; return true;
} }
}); });
@ -429,8 +430,10 @@ public class AmenityMenuBuilder extends MenuBuilder {
for (String c : e.getValue().split(";")) { for (String c : e.getValue().split(";")) {
if (sb.length() > 0) { if (sb.length() > 0) {
sb.append(", "); sb.append(", ");
sb.append(poiTypes.getPoiTranslation("cuisine_" + c).toLowerCase());
} else {
sb.append(poiTypes.getPoiTranslation("cuisine_" + c));
} }
sb.append(poiTypes.getPoiTranslation("cuisine_" + c).toLowerCase());
} }
textPrefix = app.getString(R.string.poi_cuisine); textPrefix = app.getString(R.string.poi_cuisine);
vl = sb.toString(); vl = sb.toString();
@ -501,30 +504,33 @@ public class AmenityMenuBuilder extends MenuBuilder {
} }
} }
if (cuisineRow != null && poiAdditionalCategories.size() == 0) { if (cuisineRow != null) {
infoRows.add(cuisineRow); boolean hasCuisineOrDish = poiAdditionalCategories.get(Amenity.CUISINE) != null
|| poiAdditionalCategories.get(Amenity.DISH) != null;
if (!hasCuisineOrDish) {
infoRows.add(cuisineRow);
}
} }
for (List<PoiType> categoryTypes : poiAdditionalCategories.values()) { for (Map.Entry<String, List<PoiType>> e : poiAdditionalCategories.entrySet()) {
Drawable icon; String categoryName = e.getKey();
PoiType pType = categoryTypes.get(0); List<PoiType> categoryTypes = e.getValue();
String poiAdditionalCategoryName = pType.getPoiAdditionalCategory(); if (categoryTypes.size() > 0) {
String poiAddidionalIconName = poiTypes.getPoiAdditionalCategoryIconName(poiAdditionalCategoryName); Drawable icon;
icon = getRowIcon(view.getContext(), poiAddidionalIconName); PoiType pType = categoryTypes.get(0);
if (icon == null) { String poiAdditionalCategoryName = pType.getPoiAdditionalCategory();
icon = getRowIcon(view.getContext(), poiAdditionalCategoryName); String poiAddidionalIconName = poiTypes.getPoiAdditionalCategoryIconName(poiAdditionalCategoryName);
} icon = getRowIcon(view.getContext(), poiAddidionalIconName);
if (icon == null) { if (icon == null) {
icon = getRowIcon(view.getContext(), pType.getIconKeyName()); icon = getRowIcon(view.getContext(), poiAdditionalCategoryName);
} }
if (icon == null) { if (icon == null) {
icon = getRowIcon(R.drawable.ic_action_note_dark); icon = getRowIcon(view.getContext(), pType.getIconKeyName());
} }
if (categoryTypes.size() == 1) { if (icon == null) {
String vl = pType.getTranslation(); icon = getRowIcon(R.drawable.ic_action_note_dark);
infoRows.add(new AmenityInfoRow(poiAdditionalCategoryName, icon, pType.getPoiAdditionalCategoryTranslation(), vl, false, null, }
0, false, false, false, pType.getOrder(), pType.getKeyName(), false, false, false, 0));
} else {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (PoiType pt : categoryTypes) { for (PoiType pt : categoryTypes) {
if (sb.length() > 0) { if (sb.length() > 0) {
@ -532,7 +538,8 @@ public class AmenityMenuBuilder extends MenuBuilder {
} }
sb.append(pt.getTranslation()); sb.append(pt.getTranslation());
} }
CollapsableView collapsableView = getPoiAdditionalCollapsableView(view.getContext(), true, categoryTypes, cuisineRow); boolean cuisineOrDish = categoryName.equals(Amenity.CUISINE) || categoryName.equals(Amenity.DISH);
CollapsableView collapsableView = getPoiAdditionalCollapsableView(view.getContext(), true, categoryTypes, cuisineOrDish ? cuisineRow : null);
infoRows.add(new AmenityInfoRow(poiAdditionalCategoryName, icon, pType.getPoiAdditionalCategoryTranslation(), sb.toString(), true, collapsableView, infoRows.add(new AmenityInfoRow(poiAdditionalCategoryName, icon, pType.getPoiAdditionalCategoryTranslation(), sb.toString(), true, collapsableView,
0, false, false, false, pType.getOrder(), pType.getKeyName(), false, false, false, 1)); 0, false, false, false, pType.getOrder(), pType.getKeyName(), false, false, false, 1));
} }
@ -644,13 +651,11 @@ public class AmenityMenuBuilder extends MenuBuilder {
button.setOnClickListener(new View.OnClickListener() { button.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
AbstractPoiType parent = pt.getParentType(); if (amenity.getType() != null) {
if (parent != null) { PoiUIFilter filter = app.getPoiFilters().getFilterById(PoiUIFilter.STD_PREFIX + amenity.getType().getKeyName());
PoiUIFilter filter = app.getPoiFilters().getFilterById(PoiUIFilter.STD_PREFIX + parent.getKeyName());
//PoiUIFilter filter = app.getPoiFilters().getCustomPOIFilter();
if (filter != null) { if (filter != null) {
filter.clearFilter(); filter.clearFilter();
filter.setTypeToAccept(pt.getCategory(), true); filter.setTypeToAccept(amenity.getType(), true);
filter.updateTypesToAccept(pt); filter.updateTypesToAccept(pt);
filter.setFilterByName(pt.getKeyName().replace('_', ':').toLowerCase()); filter.setFilterByName(pt.getKeyName().replace('_', ':').toLowerCase());
getMapActivity().showQuickSearch(filter); getMapActivity().showQuickSearch(filter);
@ -667,7 +672,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
if (textCuisineRow != null) { if (textCuisineRow != null) {
TextViewEx button = buildButtonInCollapsableView(context, true, false, false); TextViewEx button = buildButtonInCollapsableView(context, true, false, false);
String name = textCuisineRow.textPrefix + ": " + textCuisineRow.text; String name = textCuisineRow.textPrefix + ": " + textCuisineRow.text.toLowerCase();
button.setText(name); button.setText(name);
view.addView(button); view.addView(button);
} }