diff --git a/OsmAnd-java/src/main/java/net/osmand/data/Amenity.java b/OsmAnd-java/src/main/java/net/osmand/data/Amenity.java index 861a7c9b93..48e15df815 100644 --- a/OsmAnd-java/src/main/java/net/osmand/data/Amenity.java +++ b/OsmAnd-java/src/main/java/net/osmand/data/Amenity.java @@ -179,6 +179,26 @@ public class Amenity extends MapObject { } } + public void addProfileTag(Entry e) { + if (getAdditionalInfo("profile") == null) { + if (e.getKey().startsWith("tag_")) { + switch (e.getValue().trim()) { + case "bicycle": + case "cycling": + case "mtb": + setAdditionalInfo("profile", "bicycle"); + break; + case "hiking": + case "hike": + case "walking": + case "walk": + setAdditionalInfo("profile", "pedestrian"); + break; + } + } + } + } + @Override public String toStringEn() { return super.toStringEn() + ": " + type.getKeyName() + ":" + subType; diff --git a/OsmAnd-java/src/main/java/net/osmand/osm/MapPoiTypes.java b/OsmAnd-java/src/main/java/net/osmand/osm/MapPoiTypes.java index e273fa4e7f..70d35e24ae 100644 --- a/OsmAnd-java/src/main/java/net/osmand/osm/MapPoiTypes.java +++ b/OsmAnd-java/src/main/java/net/osmand/osm/MapPoiTypes.java @@ -915,14 +915,18 @@ public class MapPoiTypes { if (!otag.equals(tag) && !otag.equals("name")) { PoiType pat = poiTypesByTag.get(otag + "/" + e.getValue()); if (pat == null) { - for(String splValue : e.getValue().split(";")) { + for (String splValue : e.getValue().split(";")) { PoiType ps = poiTypesByTag.get(otag + "/" + splValue.trim()); - if(ps != null) { + if (ps != null) { a.setAdditionalInfo(ps.getKeyName(), splValue.trim()); } } pat = poiTypesByTag.get(otag); + if (pat == null && otag.startsWith("tag_")) { + a.addProfileTag(e); + } } + if (pat != null && pat.isAdditional()) { a.setAdditionalInfo(pat.getKeyName(), e.getValue()); } diff --git a/OsmAnd/res/layout/wikivoyage_travel_gpx_card.xml b/OsmAnd/res/layout/wikivoyage_travel_gpx_card.xml index 44077a0dcd..2e11585264 100644 --- a/OsmAnd/res/layout/wikivoyage_travel_gpx_card.xml +++ b/OsmAnd/res/layout/wikivoyage_travel_gpx_card.xml @@ -139,31 +139,82 @@ - + android:background="?attr/btn_border_bg" + android:layout_marginLeft="@dimen/content_padding_half" + android:layout_marginStart="@dimen/content_padding_half"> + + + + + + + + + + + + @@ -172,7 +223,6 @@ diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelGpx.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelGpx.java index 185fdc922c..91d404510d 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelGpx.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelGpx.java @@ -6,8 +6,10 @@ public class TravelGpx extends TravelArticle { public static final String DIFF_ELE_UP = "diff_ele_up"; public static final String DIFF_ELE_DOWN = "diff_ele_down"; public static final String USER = "user"; + public static final String PROFILE = "profile"; public String user; + public String profile; public float totalDistance = 0; public double diffElevationUp = 0; public double diffElevationDown = 0; diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java index f230929f1d..8622ed0996 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelObfHelper.java @@ -58,6 +58,7 @@ import static net.osmand.plus.helpers.GpxUiHelper.getGpxTitle; import static net.osmand.plus.wikivoyage.data.TravelGpx.DIFF_ELE_DOWN; import static net.osmand.plus.wikivoyage.data.TravelGpx.DIFF_ELE_UP; import static net.osmand.plus.wikivoyage.data.TravelGpx.DISTANCE; +import static net.osmand.plus.wikivoyage.data.TravelGpx.PROFILE; import static net.osmand.plus.wikivoyage.data.TravelGpx.USER; import static net.osmand.util.Algorithms.capitalizeFirstLetter; @@ -203,6 +204,7 @@ public class TravelObfHelper implements TravelHelper { LOG.debug(e.getMessage(), e); } res.user = Algorithms.emptyIfNull(amenity.getTagContent(USER)); + res.profile = Algorithms.emptyIfNull(amenity.getTagContent(PROFILE)); articles.put("en", res); return articles; } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/TravelGpxCard.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/TravelGpxCard.java index 1bc2409621..efd81315d3 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/TravelGpxCard.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/TravelGpxCard.java @@ -2,16 +2,17 @@ package net.osmand.plus.wikivoyage.explore.travelcards; import android.graphics.drawable.Drawable; import android.view.View; +import android.widget.ImageView; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.fragment.app.FragmentActivity; import androidx.recyclerview.widget.RecyclerView; -import net.osmand.AndroidUtils; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; +import net.osmand.plus.profiles.ProfileIcons; import net.osmand.plus.track.TrackMenuFragment; import net.osmand.plus.wikivoyage.data.TravelGpx; import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper; @@ -40,10 +41,11 @@ public class TravelGpxCard extends BaseTravelCard { if (viewHolder instanceof TravelGpxVH) { final TravelGpxVH holder = (TravelGpxVH) viewHolder; holder.title.setText(article.getTitle()); - Drawable icon = getActiveIcon(R.drawable.ic_action_user_account_16); - holder.user.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null); + holder.userIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_user_account_16)); holder.user.setText(article.user); - AndroidUtils.setBackground(app, holder.user, nightMode, R.drawable.btn_border_bg_light, R.drawable.btn_border_bg_dark); + ProfileIcons profileRes = ProfileIcons.valueOf(article.profile.toUpperCase()); + holder.profileIcon.setImageDrawable(getActiveIcon(profileRes.getResId())); + holder.profile.setText(profileRes.getTitleId()); holder.distance.setText(OsmAndFormatter.getFormattedDistance(article.totalDistance, app)); holder.diffElevationUp.setText(OsmAndFormatter.getFormattedAlt(article.diffElevationUp, app)); holder.diffElevationDown.setText(OsmAndFormatter.getFormattedAlt(article.diffElevationDown, app)); @@ -92,6 +94,9 @@ public class TravelGpxCard extends BaseTravelCard { public final TextView title; public final TextView user; + public final ImageView userIcon; + public final TextView profile; + public final ImageView profileIcon; public final TextView distance; public final TextView diffElevationUp; public final TextView diffElevationDown; @@ -104,6 +109,9 @@ public class TravelGpxCard extends BaseTravelCard { super(itemView); title = itemView.findViewById(R.id.title); user = itemView.findViewById(R.id.user_name); + userIcon = itemView.findViewById(R.id.user_icon); + profile = itemView.findViewById(R.id.profile); + profileIcon = itemView.findViewById(R.id.profile_icon); distance = itemView.findViewById(R.id.distance); diffElevationUp = itemView.findViewById(R.id.diff_ele_up); diffElevationDown = itemView.findViewById(R.id.diff_ele_down);