proper icon for custom filter
This commit is contained in:
parent
daa446daf8
commit
76549c03f8
2 changed files with 28 additions and 17 deletions
|
@ -34,6 +34,7 @@ import com.google.android.material.snackbar.Snackbar;
|
|||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.plus.search.listitems.QuickSearchListItem;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
|
@ -583,7 +584,8 @@ public class RearrangePoiFiltersFragment extends DialogFragment implements Selec
|
|||
final PoiUIFilterDataObject poiInfo = (PoiUIFilterDataObject) item.value;
|
||||
int osmandOrangeColorResId = nightMode ? R.color.osmand_orange_dark : R.color.osmand_orange;
|
||||
h.title.setText(poiInfo.name);
|
||||
h.icon.setImageDrawable(uiUtilities.getIcon(poiInfo.iconRes, osmandOrangeColorResId));
|
||||
int iconRes = QuickSearchListItem.getCustomFilterIconRes(poiHelper.getFilterById(poiInfo.filterId));
|
||||
h.icon.setImageDrawable(uiUtilities.getIcon(iconRes, osmandOrangeColorResId));
|
||||
h.moveIcon.setVisibility(poiInfo.isActive ? View.VISIBLE : View.GONE);
|
||||
h.actionIcon.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.content.Context;
|
|||
import android.graphics.drawable.Drawable;
|
||||
import android.text.Spannable;
|
||||
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
|
@ -334,23 +335,8 @@ public class QuickSearchListItem {
|
|||
} else if (searchResult.object instanceof CustomSearchPoiFilter) {
|
||||
CustomSearchPoiFilter searchPoiFilter = (CustomSearchPoiFilter) searchResult.object;
|
||||
PoiUIFilter filter = app.getPoiFilters().getFilterById(searchPoiFilter.getFilterId());
|
||||
iconId = R.drawable.mx_special_custom_category;
|
||||
if (filter != null) {
|
||||
Map<PoiCategory, LinkedHashSet<String>> acceptedTypes = filter.getAcceptedTypes();
|
||||
List<PoiCategory> categories = new ArrayList<>(acceptedTypes.keySet());
|
||||
if (categories.size() == 1) {
|
||||
String res = "";
|
||||
PoiCategory category = categories.get(0);
|
||||
LinkedHashSet<String> filters = acceptedTypes.get(category);
|
||||
if (filters == null || filters.size() > 1) {
|
||||
res = category.getIconKeyName();
|
||||
} else {
|
||||
res = getPoiTypeIconName(category.getPoiTypeByKeyName(filters.iterator().next()));
|
||||
}
|
||||
if (res != null && RenderingIcons.containsBigIcon(res)) {
|
||||
iconId = RenderingIcons.getBigIconResourceId(res);
|
||||
}
|
||||
}
|
||||
iconId = getCustomFilterIconRes(filter);
|
||||
}
|
||||
}
|
||||
if (iconId > 0) {
|
||||
|
@ -422,4 +408,27 @@ public class QuickSearchListItem {
|
|||
return app.getUIUtilities().getIcon(iconId,
|
||||
app.getSettings().isLightContent() ? R.color.osmand_orange : R.color.osmand_orange_dark);
|
||||
}
|
||||
|
||||
@DrawableRes
|
||||
public static int getCustomFilterIconRes(PoiUIFilter filter) {
|
||||
int iconId = 0;
|
||||
if (filter != null) {
|
||||
Map<PoiCategory, LinkedHashSet<String>> acceptedTypes = filter.getAcceptedTypes();
|
||||
List<PoiCategory> categories = new ArrayList<>(acceptedTypes.keySet());
|
||||
if (categories.size() == 1) {
|
||||
String res = "";
|
||||
PoiCategory category = categories.get(0);
|
||||
LinkedHashSet<String> filters = acceptedTypes.get(category);
|
||||
if (filters == null || filters.size() > 1) {
|
||||
res = category.getIconKeyName();
|
||||
} else {
|
||||
res = getPoiTypeIconName(category.getPoiTypeByKeyName(filters.iterator().next()));
|
||||
}
|
||||
if (res != null && RenderingIcons.containsBigIcon(res)) {
|
||||
iconId = RenderingIcons.getBigIconResourceId(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
return iconId > 0 ? iconId : R.drawable.mx_special_custom_category;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue