Add route activity type
This commit is contained in:
parent
e150d39c61
commit
d8ff9fb1e7
6 changed files with 23 additions and 47 deletions
|
@ -193,10 +193,6 @@ public class EntityParser {
|
||||||
if (wbs != null) {
|
if (wbs != null) {
|
||||||
am.setAdditionalInfo("wikipedia", wbs);
|
am.setAdditionalInfo("wikipedia", wbs);
|
||||||
}
|
}
|
||||||
String profileName = getProfileName(entity);
|
|
||||||
if (profileName != null) {
|
|
||||||
am.setAdditionalInfo("profile", profileName);
|
|
||||||
}
|
|
||||||
if (checkAmenitiesToAdd(am, amenitiesList) && !"no".equals(am.getSubType())) {
|
if (checkAmenitiesToAdd(am, amenitiesList) && !"no".equals(am.getSubType())) {
|
||||||
amenitiesList.add(am);
|
amenitiesList.add(am);
|
||||||
}
|
}
|
||||||
|
@ -206,26 +202,6 @@ public class EntityParser {
|
||||||
return amenitiesList;
|
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){
|
private static boolean checkAmenitiesToAdd(Amenity a, List<Amenity> amenitiesList){
|
||||||
// check amenity for duplication
|
// check amenity for duplication
|
||||||
for(Amenity b : amenitiesList){
|
for(Amenity b : amenitiesList){
|
||||||
|
|
|
@ -180,7 +180,7 @@
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/profile_label"
|
android:id="@+id/activity_type_label"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?attr/btn_border_bg"
|
android:background="?attr/btn_border_bg"
|
||||||
|
@ -189,7 +189,7 @@
|
||||||
android:layout_marginStart="@dimen/content_padding_half">
|
android:layout_marginStart="@dimen/content_padding_half">
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatImageView
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
android:id="@+id/profile_icon"
|
android:id="@+id/activity_type_icon"
|
||||||
android:layout_width="@dimen/poi_icon_size"
|
android:layout_width="@dimen/poi_icon_size"
|
||||||
android:layout_height="@dimen/poi_icon_size"
|
android:layout_height="@dimen/poi_icon_size"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
|
@ -199,7 +199,7 @@
|
||||||
tools:src="@drawable/ic_action_bicycle_dark" />
|
tools:src="@drawable/ic_action_bicycle_dark" />
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:id="@+id/profile"
|
android:id="@+id/activity_type"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
|
|
|
@ -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_UP = "diff_ele_up";
|
||||||
public static final String DIFF_ELE_DOWN = "diff_ele_down";
|
public static final String DIFF_ELE_DOWN = "diff_ele_down";
|
||||||
public static final String USER = "user";
|
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 user;
|
||||||
public String profile;
|
public String activityType;
|
||||||
public float totalDistance = 0;
|
public float totalDistance = 0;
|
||||||
public double diffElevationUp = 0;
|
public double diffElevationUp = 0;
|
||||||
public double diffElevationDown = 0;
|
public double diffElevationDown = 0;
|
||||||
|
|
|
@ -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_DOWN;
|
||||||
import static net.osmand.plus.wikivoyage.data.TravelGpx.DIFF_ELE_UP;
|
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.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.plus.wikivoyage.data.TravelGpx.USER;
|
||||||
import static net.osmand.util.Algorithms.capitalizeFirstLetter;
|
import static net.osmand.util.Algorithms.capitalizeFirstLetter;
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ public class TravelObfHelper implements TravelHelper {
|
||||||
LOG.debug(e.getMessage(), e);
|
LOG.debug(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
res.user = Algorithms.emptyIfNull(amenity.getTagContent(USER));
|
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);
|
articles.put("en", res);
|
||||||
return articles;
|
return articles;
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,11 +140,11 @@ public class SavedArticlesRvAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
||||||
holder.title.setText(article.getTitle());
|
holder.title.setText(article.getTitle());
|
||||||
holder.userIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_user_account_16));
|
holder.userIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_user_account_16));
|
||||||
holder.user.setText(article.user);
|
holder.user.setText(article.user);
|
||||||
if(!Algorithms.isEmpty(article.profile)) {
|
if(!Algorithms.isEmpty(article.activityType)) {
|
||||||
ProfileIcons profileRes = ProfileIcons.valueOf(article.profile.toUpperCase());
|
ProfileIcons activityRes = ProfileIcons.valueOf(article.activityType.toUpperCase());
|
||||||
holder.profileIcon.setImageDrawable(getActiveIcon(profileRes.getResId()));
|
holder.activityTypeIcon.setImageDrawable(getActiveIcon(activityRes.getResId()));
|
||||||
holder.profile.setText(profileRes.getTitleId());
|
holder.activityType.setText(activityRes.getTitleId());
|
||||||
holder.profileLabel.setVisibility(View.VISIBLE);
|
holder.activityTypeLabel.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
holder.distance.setText(OsmAndFormatter.getFormattedDistance(article.totalDistance, app));
|
holder.distance.setText(OsmAndFormatter.getFormattedDistance(article.totalDistance, app));
|
||||||
holder.diffElevationUp.setText(OsmAndFormatter.getFormattedAlt(article.diffElevationUp, app));
|
holder.diffElevationUp.setText(OsmAndFormatter.getFormattedAlt(article.diffElevationUp, app));
|
||||||
|
|
|
@ -44,11 +44,11 @@ public class TravelGpxCard extends BaseTravelCard {
|
||||||
holder.title.setText(article.getTitle());
|
holder.title.setText(article.getTitle());
|
||||||
holder.userIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_user_account_16));
|
holder.userIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_user_account_16));
|
||||||
holder.user.setText(article.user);
|
holder.user.setText(article.user);
|
||||||
if(!Algorithms.isEmpty(article.profile)) {
|
if (!Algorithms.isEmpty(article.activityType)) {
|
||||||
ProfileIcons profileRes = ProfileIcons.valueOf(article.profile.toUpperCase());
|
ProfileIcons profileRes = ProfileIcons.valueOf(article.activityType.toUpperCase());
|
||||||
holder.profileIcon.setImageDrawable(getActiveIcon(profileRes.getResId()));
|
holder.activityTypeIcon.setImageDrawable(getActiveIcon(profileRes.getResId()));
|
||||||
holder.profile.setText(profileRes.getTitleId());
|
holder.activityType.setText(profileRes.getTitleId());
|
||||||
holder.profileLabel.setVisibility(View.VISIBLE);
|
holder.activityTypeLabel.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
holder.distance.setText(OsmAndFormatter.getFormattedDistance(article.totalDistance, app));
|
holder.distance.setText(OsmAndFormatter.getFormattedDistance(article.totalDistance, app));
|
||||||
holder.diffElevationUp.setText(OsmAndFormatter.getFormattedAlt(article.diffElevationUp, 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 title;
|
||||||
public final TextView user;
|
public final TextView user;
|
||||||
public final ImageView userIcon;
|
public final ImageView userIcon;
|
||||||
public final TextView profile;
|
public final TextView activityType;
|
||||||
public final ImageView profileIcon;
|
public final ImageView activityTypeIcon;
|
||||||
public final View profileLabel;
|
public final View activityTypeLabel;
|
||||||
public final TextView distance;
|
public final TextView distance;
|
||||||
public final TextView diffElevationUp;
|
public final TextView diffElevationUp;
|
||||||
public final TextView diffElevationDown;
|
public final TextView diffElevationDown;
|
||||||
|
@ -115,9 +115,9 @@ public class TravelGpxCard extends BaseTravelCard {
|
||||||
title = itemView.findViewById(R.id.title);
|
title = itemView.findViewById(R.id.title);
|
||||||
user = itemView.findViewById(R.id.user_name);
|
user = itemView.findViewById(R.id.user_name);
|
||||||
userIcon = itemView.findViewById(R.id.user_icon);
|
userIcon = itemView.findViewById(R.id.user_icon);
|
||||||
profile = itemView.findViewById(R.id.profile);
|
activityType = itemView.findViewById(R.id.activity_type);
|
||||||
profileIcon = itemView.findViewById(R.id.profile_icon);
|
activityTypeIcon = itemView.findViewById(R.id.activity_type_icon);
|
||||||
profileLabel = itemView.findViewById(R.id.profile_label);
|
activityTypeLabel = itemView.findViewById(R.id.activity_type_label);
|
||||||
distance = itemView.findViewById(R.id.distance);
|
distance = itemView.findViewById(R.id.distance);
|
||||||
diffElevationUp = itemView.findViewById(R.id.diff_ele_up);
|
diffElevationUp = itemView.findViewById(R.id.diff_ele_up);
|
||||||
diffElevationDown = itemView.findViewById(R.id.diff_ele_down);
|
diffElevationDown = itemView.findViewById(R.id.diff_ele_down);
|
||||||
|
|
Loading…
Reference in a new issue