Add route activity type

This commit is contained in:
Dima-1 2021-01-30 17:02:37 +02:00
parent e150d39c61
commit d8ff9fb1e7
6 changed files with 23 additions and 47 deletions

View file

@ -193,10 +193,6 @@ public class EntityParser {
if (wbs != null) {
am.setAdditionalInfo("wikipedia", wbs);
}
String profileName = getProfileName(entity);
if (profileName != null) {
am.setAdditionalInfo("profile", profileName);
}
if (checkAmenitiesToAdd(am, amenitiesList) && !"no".equals(am.getSubType())) {
amenitiesList.add(am);
}
@ -206,26 +202,6 @@ public class EntityParser {
return amenitiesList;
}
private static String getProfileName(Entity e) {
Map<String, String> tags = e.getTags();
for (String key : tags.keySet()) {
if (key.startsWith("tag_")) {
switch (tags.get(key).trim()) {
case "bicycle":
case "cycling":
case "mtb":
return "bicycle";
case "hiking":
case "hike":
case "walking":
case "walk":
return "pedestrian";
}
}
}
return null;
}
private static boolean checkAmenitiesToAdd(Amenity a, List<Amenity> amenitiesList){
// check amenity for duplication
for(Amenity b : amenitiesList){

View file

@ -180,7 +180,7 @@
</LinearLayout>
<LinearLayout
android:id="@+id/profile_label"
android:id="@+id/activity_type_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/btn_border_bg"
@ -189,7 +189,7 @@
android:layout_marginStart="@dimen/content_padding_half">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/profile_icon"
android:id="@+id/activity_type_icon"
android:layout_width="@dimen/poi_icon_size"
android:layout_height="@dimen/poi_icon_size"
android:layout_gravity="center_vertical"
@ -199,7 +199,7 @@
tools:src="@drawable/ic_action_bicycle_dark" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/profile"
android:id="@+id/activity_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"

View file

@ -6,10 +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 static final String ACTIVITY_TYPE = "route_activity_type";
public String user;
public String profile;
public String activityType;
public float totalDistance = 0;
public double diffElevationUp = 0;
public double diffElevationDown = 0;

View file

@ -58,7 +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.ACTIVITY_TYPE;
import static net.osmand.plus.wikivoyage.data.TravelGpx.USER;
import static net.osmand.util.Algorithms.capitalizeFirstLetter;
@ -204,7 +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));
res.activityType = Algorithms.emptyIfNull(amenity.getTagContent(ACTIVITY_TYPE));
articles.put("en", res);
return articles;
}

View file

@ -140,11 +140,11 @@ public class SavedArticlesRvAdapter extends RecyclerView.Adapter<RecyclerView.Vi
holder.title.setText(article.getTitle());
holder.userIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_user_account_16));
holder.user.setText(article.user);
if(!Algorithms.isEmpty(article.profile)) {
ProfileIcons profileRes = ProfileIcons.valueOf(article.profile.toUpperCase());
holder.profileIcon.setImageDrawable(getActiveIcon(profileRes.getResId()));
holder.profile.setText(profileRes.getTitleId());
holder.profileLabel.setVisibility(View.VISIBLE);
if(!Algorithms.isEmpty(article.activityType)) {
ProfileIcons activityRes = ProfileIcons.valueOf(article.activityType.toUpperCase());
holder.activityTypeIcon.setImageDrawable(getActiveIcon(activityRes.getResId()));
holder.activityType.setText(activityRes.getTitleId());
holder.activityTypeLabel.setVisibility(View.VISIBLE);
}
holder.distance.setText(OsmAndFormatter.getFormattedDistance(article.totalDistance, app));
holder.diffElevationUp.setText(OsmAndFormatter.getFormattedAlt(article.diffElevationUp, app));

View file

@ -44,11 +44,11 @@ public class TravelGpxCard extends BaseTravelCard {
holder.title.setText(article.getTitle());
holder.userIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_user_account_16));
holder.user.setText(article.user);
if(!Algorithms.isEmpty(article.profile)) {
ProfileIcons profileRes = ProfileIcons.valueOf(article.profile.toUpperCase());
holder.profileIcon.setImageDrawable(getActiveIcon(profileRes.getResId()));
holder.profile.setText(profileRes.getTitleId());
holder.profileLabel.setVisibility(View.VISIBLE);
if (!Algorithms.isEmpty(article.activityType)) {
ProfileIcons profileRes = ProfileIcons.valueOf(article.activityType.toUpperCase());
holder.activityTypeIcon.setImageDrawable(getActiveIcon(profileRes.getResId()));
holder.activityType.setText(profileRes.getTitleId());
holder.activityTypeLabel.setVisibility(View.VISIBLE);
}
holder.distance.setText(OsmAndFormatter.getFormattedDistance(article.totalDistance, app));
holder.diffElevationUp.setText(OsmAndFormatter.getFormattedAlt(article.diffElevationUp, app));
@ -99,9 +99,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 View profileLabel;
public final TextView activityType;
public final ImageView activityTypeIcon;
public final View activityTypeLabel;
public final TextView distance;
public final TextView diffElevationUp;
public final TextView diffElevationDown;
@ -115,9 +115,9 @@ public class TravelGpxCard extends BaseTravelCard {
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);
profileLabel = itemView.findViewById(R.id.profile_label);
activityType = itemView.findViewById(R.id.activity_type);
activityTypeIcon = itemView.findViewById(R.id.activity_type_icon);
activityTypeLabel = itemView.findViewById(R.id.activity_type_label);
distance = itemView.findViewById(R.id.distance);
diffElevationUp = itemView.findViewById(R.id.diff_ele_up);
diffElevationDown = itemView.findViewById(R.id.diff_ele_down);