diff --git a/OsmAnd/res/layout/fragment_mtb_routes.xml b/OsmAnd/res/layout/fragment_mtb_routes.xml
index eb19e5e4622..1dddc9e261a 100644
--- a/OsmAnd/res/layout/fragment_mtb_routes.xml
+++ b/OsmAnd/res/layout/fragment_mtb_routes.xml
@@ -64,6 +64,16 @@
+
+
+
+
+
+
diff --git a/OsmAnd/res/layout/route_legend_card.xml b/OsmAnd/res/layout/route_legend_card.xml
new file mode 100644
index 00000000000..56cf2023571
--- /dev/null
+++ b/OsmAnd/res/layout/route_legend_card.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout/route_legend_item.xml b/OsmAnd/res/layout/route_legend_item.xml
new file mode 100644
index 00000000000..0351d0d4313
--- /dev/null
+++ b/OsmAnd/res/layout/route_legend_item.xml
@@ -0,0 +1,78 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/configmap/MtbRoutesFragment.java b/OsmAnd/src/net/osmand/plus/configmap/MtbRoutesFragment.java
index 8d168156a54..bbba0646405 100644
--- a/OsmAnd/src/net/osmand/plus/configmap/MtbRoutesFragment.java
+++ b/OsmAnd/src/net/osmand/plus/configmap/MtbRoutesFragment.java
@@ -15,6 +15,7 @@
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.BaseOsmAndFragment;
+import net.osmand.plus.configmap.RouteLegendCard.DataClass;
import net.osmand.plus.configmap.routes.MtbClassification;
import net.osmand.plus.configmap.routes.RouteLayersHelper;
import net.osmand.plus.helpers.AndroidUiHelper;
@@ -25,6 +26,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
+import java.util.stream.IntStream;
public class MtbRoutesFragment extends BaseOsmAndFragment {
@@ -55,6 +57,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
setupClassifications(view);
updateClassificationPreferences();
+ setupLegendCard(view);
return view;
}
@@ -85,6 +88,22 @@ private void setupClassifications(@NonNull View view) {
}
}
+ @NonNull
+ private List getDataClasses() {
+ return IntStream.rangeClosed(1, 9)
+ .mapToObj(i -> new DataClass("Legend item " + i, "Description"))
+ .toList();
+ }
+
+ private void setupLegendCard(@NonNull View view) {
+ List items = getDataClasses();
+
+ RouteLegendCard card = new RouteLegendCard(requireActivity(), items, app.getString(R.string.shared_string_legend));
+ ViewGroup group = view.findViewById(R.id.legend_container);
+ View cardView = card.build();
+ group.addView(cardView);
+ }
+
private View createRadioButton(@NonNull MtbClassification classification, @NonNull LayoutInflater inflater, @Nullable ViewGroup container, boolean hasDivider) {
View view = inflater.inflate(R.layout.item_with_radiobutton_and_descr, container, false);
view.setTag(classification);
@@ -142,5 +161,4 @@ public static void showInstance(@NonNull FragmentManager manager) {
.commitAllowingStateLoss();
}
}
-
}
diff --git a/OsmAnd/src/net/osmand/plus/configmap/RouteLegendCard.java b/OsmAnd/src/net/osmand/plus/configmap/RouteLegendCard.java
new file mode 100644
index 00000000000..be8c0127060
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/configmap/RouteLegendCard.java
@@ -0,0 +1,99 @@
+package net.osmand.plus.configmap;
+
+import android.graphics.drawable.Drawable;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.CompoundButton;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.fragment.app.FragmentActivity;
+
+import net.osmand.plus.R;
+import net.osmand.plus.helpers.AndroidUiHelper;
+import net.osmand.plus.routepreparationmenu.cards.BaseCard;
+import net.osmand.plus.settings.backend.OsmandSettings;
+import net.osmand.plus.utils.AndroidUtils;
+import net.osmand.plus.utils.UiUtilities;
+
+import java.util.List;
+
+public class RouteLegendCard extends BaseCard {
+ private final LayoutInflater themedInflater;
+
+ private final List items;
+ private final String cardTitle;
+
+ public RouteLegendCard(@NonNull FragmentActivity activity, @NonNull List items, @NonNull String cardTitle) {
+ super(activity, true);
+ this.items = items;
+ this.cardTitle = cardTitle;
+ themedInflater = UiUtilities.getInflater(activity, nightMode);
+ }
+
+ @Override
+ public int getCardLayoutId() {
+ return R.layout.route_legend_card;
+ }
+
+ @Override
+ protected void updateContent() {
+ setupCardTitle();
+ setupLegendItems();
+ }
+
+ private void setupLegendItems() {
+ ViewGroup mainContainer = view.findViewById(R.id.main_container);
+ mainContainer.removeAllViews();
+ for (int i = 0; i < items.size(); i++) {
+ mainContainer.addView(createView(i));
+ }
+ }
+
+ @NonNull
+ private View createView(int position) {
+ DataClass dataClass = items.get(position);
+ View itemView = themedInflater.inflate(R.layout.route_legend_item, null, false);
+ CompoundButton compoundButton = itemView.findViewById(R.id.compound_button);
+ TextView title = itemView.findViewById(R.id.title);
+ TextView description = itemView.findViewById(R.id.description);
+ View divider = itemView.findViewById(R.id.divider_bottom);
+
+ title.setText(dataClass.title());
+ description.setText(dataClass.description());
+
+ compoundButton.setChecked(isClassEnabled(dataClass));
+
+ AndroidUiHelper.updateVisibility(divider, position != items.size() - 1);
+ itemView.setOnClickListener(view -> {
+ compoundButton.performClick();
+ onClassSelected(dataClass, compoundButton.isChecked());
+ });
+
+ compoundButton.setFocusable(false);
+ compoundButton.setClickable(false);
+
+ OsmandSettings settings = app.getSettings();
+ Drawable background = UiUtilities.getColoredSelectableDrawable(app, settings.getApplicationMode().getProfileColor(nightMode), 0.3f);
+ AndroidUtils.setBackground(itemView, background);
+
+ return itemView;
+ }
+
+ private void setupCardTitle() {
+ TextView title = view.findViewById(R.id.card_title);
+ title.setText(cardTitle);
+ }
+
+ public boolean isClassEnabled(@NonNull DataClass dataClass) {
+ return false;
+ }
+
+ public void onClassSelected(@NonNull DataClass dataClass, boolean checked) {
+
+ }
+
+ public record DataClass(String title, String description) {
+ }
+}