From 76d56578e4f432b188af6a1cff2d732dc5d1c18d Mon Sep 17 00:00:00 2001 From: veliymolfar Date: Thu, 23 Apr 2020 12:15:16 +0300 Subject: [PATCH] selected icon colors, refactor list item with icon --- .../res/layout/list_item_icon24_and_menu.xml | 143 +++++++++--------- .../search/QuickSearchCustomPoiFragment.java | 28 ++-- .../plus/search/SubCategoriesAdapter.java | 7 +- 3 files changed, 91 insertions(+), 87 deletions(-) diff --git a/OsmAnd/res/layout/list_item_icon24_and_menu.xml b/OsmAnd/res/layout/list_item_icon24_and_menu.xml index 8471698778..c308a0fc55 100644 --- a/OsmAnd/res/layout/list_item_icon24_and_menu.xml +++ b/OsmAnd/res/layout/list_item_icon24_and_menu.xml @@ -1,96 +1,101 @@ - - + android:layout_marginLeft="16dp" + tools:src="@drawable/ic_action_gabout_dark" /> - - - + android:orientation="horizontal"> - + + + + + + + + + + + + + + + + android:id="@+id/divider" + android:layout_width="wrap_content" + android:layout_height="1dp" + android:background="?attr/dashboard_divider" /> + - - - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchCustomPoiFragment.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchCustomPoiFragment.java index ec9d99b968..9ffb640b40 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchCustomPoiFragment.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchCustomPoiFragment.java @@ -288,8 +288,7 @@ public class QuickSearchCustomPoiFragment extends DialogFragment { PoiCategory category = getItem(position); if (category != null) { AppCompatImageView iconView = (AppCompatImageView) row.findViewById(R.id.icon); - AppCompatImageView secondaryIconView = (AppCompatImageView) row - .findViewById(R.id.secondary_icon); + row.findViewById(R.id.secondary_icon).setVisibility(View.GONE); AppCompatTextView titleView = (AppCompatTextView) row.findViewById(R.id.title); AppCompatTextView descView = (AppCompatTextView) row.findViewById(R.id.description); SwitchCompat check = (SwitchCompat) row.findViewById(R.id.toggle_item); @@ -298,18 +297,14 @@ public class QuickSearchCustomPoiFragment extends DialogFragment { boolean categorySelected = filter.isTypeAccepted(category); UiUtilities ic = app.getUIUtilities(); int iconId = getIconId(category); - if (iconId != 0) { - if (categorySelected) { - iconView.setImageDrawable(ic.getIcon(iconId, R.color.osmand_orange)); - } else { - iconView.setImageDrawable(ic.getThemedIcon(iconId)); - } - } else { - iconView.setImageDrawable(null); + if (iconId == 0) { + iconId = R.drawable.ic_action_categories_search; + } + if (categorySelected) { + iconView.setImageDrawable(ic.getIcon(iconId, R.color.osmand_orange)); + } else { + iconView.setImageDrawable(ic.getThemedIcon(iconId)); } - secondaryIconView.setImageDrawable( - ic.getIcon(R.drawable.ic_action_additional_option, nightMode - ? R.color.icon_color_default_dark : R.color.icon_color_default_light)); check.setOnCheckedChangeListener(null); check.setChecked(filter.isTypeAccepted(category)); String textString = category.getTranslation(); @@ -332,8 +327,8 @@ public class QuickSearchCustomPoiFragment extends DialogFragment { } else { descView.setVisibility(View.GONE); } - row.findViewById(R.id.divider) - .setVisibility(position == getCount() - 1 ? View.GONE : View.VISIBLE); + row.findViewById(R.id.divider).setVisibility(View.GONE); + row.findViewById(R.id.divider_vertical).setVisibility(View.VISIBLE); addRowListener(category, check); } return (row); @@ -411,7 +406,6 @@ public class QuickSearchCustomPoiFragment extends DialogFragment { subCategoriesAdapter.notifyDataSetChanged(); removeAllHeaders(); listView.addHeaderView(headerShadow, null, false); - setupAddButton(); } } else { for (PoiCategory category : poiCategoryList) { @@ -427,8 +421,8 @@ public class QuickSearchCustomPoiFragment extends DialogFragment { subCategoriesAdapter.notifyDataSetChanged(); removeAllHeaders(); listView.addHeaderView(headerShadow, null, false); - setupAddButton(); } + setupAddButton(); } private void removeAllHeaders() { diff --git a/OsmAnd/src/net/osmand/plus/search/SubCategoriesAdapter.java b/OsmAnd/src/net/osmand/plus/search/SubCategoriesAdapter.java index e5d3aaf47e..2139816d47 100644 --- a/OsmAnd/src/net/osmand/plus/search/SubCategoriesAdapter.java +++ b/OsmAnd/src/net/osmand/plus/search/SubCategoriesAdapter.java @@ -32,6 +32,7 @@ public class SubCategoriesAdapter extends ArrayAdapter { private boolean showCategory; private int activeColorRes; private int secondaryColorRes; + private int activeIconColorRes; private List selectedItems; private List items; @@ -47,6 +48,9 @@ public class SubCategoriesAdapter extends ArrayAdapter { selectedItems = new ArrayList<>(); uiUtilities = app.getUIUtilities(); nightMode = !app.getSettings().isLightContent(); + activeIconColorRes = nightMode + ? R.color.icon_color_osmand_dark + : R.color.icon_color_osmand_light; activeColorRes = nightMode ? R.color.icon_color_active_dark : R.color.icon_color_active_light; @@ -65,6 +69,7 @@ public class SubCategoriesAdapter extends ArrayAdapter { final PoiType poiType = getItem(position); final boolean selected = selectedItems.contains(poiType); int tintColorRes = selected ? activeColorRes : secondaryColorRes; + int tintIconColorRes = selected ? activeIconColorRes : secondaryColorRes; if (poiType != null) { TextView title = convertView.findViewById(R.id.title_tv); title.setText(poiType.getTranslation()); @@ -101,7 +106,7 @@ public class SubCategoriesAdapter extends ArrayAdapter { iconRes = R.drawable.ic_action_categories_search; } } - icon.setImageDrawable(uiUtilities.getIcon(iconRes, tintColorRes)); + icon.setImageDrawable(uiUtilities.getIcon(iconRes, tintIconColorRes)); } return convertView; }