diff --git a/OsmAnd/src/net/osmand/plus/settings/DuplicatesSettingsAdapter.java b/OsmAnd/src/net/osmand/plus/settings/DuplicatesSettingsAdapter.java index 5e409364c9..f0999fb9bb 100644 --- a/OsmAnd/src/net/osmand/plus/settings/DuplicatesSettingsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/settings/DuplicatesSettingsAdapter.java @@ -36,12 +36,16 @@ public class DuplicatesSettingsAdapter extends RecyclerView.Adapter items; + private int activeColorRes; DuplicatesSettingsAdapter(OsmandApplication app, List items, boolean nightMode) { this.app = app; this.items = items; this.nightMode = nightMode; - this.uiUtilities = app.getUIUtilities(); + uiUtilities = app.getUIUtilities(); + activeColorRes = nightMode + ? R.color.icon_color_active_dark + : R.color.icon_color_active_light; } @NonNull @@ -93,30 +97,30 @@ public class DuplicatesSettingsAdapter extends RecyclerView.Adapter dataToOperate; private List dataList; private boolean nightMode; private boolean importState; private int profileColor; + private int activeColorRes; ExportImportSettingsAdapter(OsmandApplication app, boolean nightMode, boolean importState) { this.app = app; this.nightMode = nightMode; this.importState = importState; - this.dataList = new ArrayList<>(); - this.dataToOperate = new ArrayList<>(); - this.profileColor = app.getSettings().getApplicationMode().getIconColorInfo().getColor(nightMode); + dataList = new ArrayList<>(); + dataToOperate = new ArrayList<>(); + profileColor = app.getSettings().getApplicationMode().getIconColorInfo().getColor(nightMode); + uiUtilities = app.getUIUtilities(); + activeColorRes = nightMode + ? R.color.icon_color_active_dark + : R.color.icon_color_active_light; } @Override @@ -78,7 +84,7 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter { lineDivider.setVisibility(importState || isExpanded || isLastGroup ? View.GONE : View.VISIBLE); cardTopDivider.setVisibility(importState ? View.VISIBLE : View.GONE); cardBottomDivider.setVisibility(importState && !isExpanded ? View.VISIBLE : View.GONE); - CompoundButtonCompat.setButtonTintList(checkBox, ColorStateList.valueOf(ContextCompat.getColor(app, profileColor))); + CompoundButtonCompat.setButtonTintList(checkBox, ColorStateList.valueOf(ContextCompat.getColor(app, activeColorRes))); final List listItems = dataList.get(groupPosition).getItems(); subTextTv.setText(String.valueOf(listItems.size())); @@ -125,6 +131,7 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter { final Object currentItem = dataList.get(groupPosition).getItems().get(childPosition); boolean isLastGroup = groupPosition == getGroupCount() - 1; + boolean itemSelected = dataToOperate.contains(currentItem); final AdditionalDataWrapper.Type type = dataList.get(groupPosition).getType(); TextView title = child.findViewById(R.id.title_tv); @@ -136,9 +143,9 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter { lineDivider.setVisibility(!importState && isLastChild && !isLastGroup ? View.VISIBLE : View.GONE); cardBottomDivider.setVisibility(importState && isLastChild ? View.VISIBLE : View.GONE); - CompoundButtonCompat.setButtonTintList(checkBox, ColorStateList.valueOf(ContextCompat.getColor(app, profileColor))); + CompoundButtonCompat.setButtonTintList(checkBox, ColorStateList.valueOf(ContextCompat.getColor(app, activeColorRes))); - checkBox.setChecked(dataToOperate.contains(currentItem)); + checkBox.setChecked(itemSelected); checkBox.setClickable(false); child.setOnClickListener(new View.OnClickListener() { @Override @@ -172,42 +179,42 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter { } int profileIconRes = AndroidUtils.getDrawableId(app, ((ApplicationMode.ApplicationModeBean) currentItem).iconName); ProfileIconColors iconColor = ((ApplicationMode.ApplicationModeBean) currentItem).iconColor; - icon.setImageDrawable(app.getUIUtilities().getIcon(profileIconRes, iconColor.getColor(nightMode))); + icon.setImageDrawable(uiUtilities.getIcon(profileIconRes, iconColor.getColor(nightMode))); break; case QUICK_ACTIONS: title.setText(((QuickAction) currentItem).getName(app.getApplicationContext())); - icon.setImageDrawable(app.getUIUtilities().getIcon(((QuickAction) currentItem).getIconRes(), nightMode)); + setupIcon(icon, ((QuickAction) currentItem).getIconRes(), itemSelected); subText.setVisibility(View.GONE); break; case POI_TYPES: title.setText(((PoiUIFilter) currentItem).getName()); int iconRes = RenderingIcons.getBigIconResourceId(((PoiUIFilter) currentItem).getIconId()); - icon.setImageDrawable(app.getUIUtilities().getIcon(iconRes != 0 ? iconRes : R.drawable.ic_person, profileColor)); + setupIcon(icon, iconRes != 0 ? iconRes : R.drawable.ic_person, itemSelected); subText.setVisibility(View.GONE); break; case MAP_SOURCES: title.setText(((ITileSource) currentItem).getName()); - icon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_map, nightMode)); + setupIcon(icon, R.drawable.ic_map, itemSelected); subText.setVisibility(View.GONE); break; case CUSTOM_RENDER_STYLE: String renderName = ((File) currentItem).getName(); renderName = renderName.replace('_', ' ').replaceAll(IndexConstants.RENDERER_INDEX_EXT, ""); title.setText(renderName); - icon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_map_style, nightMode)); + setupIcon(icon, R.drawable.ic_action_map_style, itemSelected); subText.setVisibility(View.GONE); break; case CUSTOM_ROUTING: String routingName = ((File) currentItem).getName(); routingName = routingName.replace('_', ' ').replaceAll(".xml", ""); title.setText(routingName); - icon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_route_distance, nightMode)); + setupIcon(icon, R.drawable.ic_action_route_distance, itemSelected); subText.setVisibility(View.GONE); break; case AVOID_ROADS: AvoidRoadInfo avoidRoadInfo = (AvoidRoadInfo) currentItem; title.setText(avoidRoadInfo.name); - icon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_alert, nightMode)); + setupIcon(icon, R.drawable.ic_action_alert, itemSelected); subText.setVisibility(View.GONE); break; default: @@ -277,6 +284,14 @@ class ExportImportSettingsAdapter extends OsmandBaseExpandableListAdapter { } } + private void setupIcon(ImageView icon, int iconRes, boolean itemSelected) { + if (itemSelected) { + icon.setImageDrawable(uiUtilities.getIcon(iconRes, activeColorRes)); + } else { + icon.setImageDrawable(uiUtilities.getIcon(iconRes, nightMode)); + } + } + public void updateSettingsList(List settingsList) { this.dataList = settingsList; notifyDataSetChanged();