Travel - vehicle mode
This commit is contained in:
parent
1b30f1f428
commit
4aa877f7f6
6 changed files with 113 additions and 27 deletions
|
@ -179,6 +179,26 @@ public class Amenity extends MapObject {
|
|||
}
|
||||
}
|
||||
|
||||
public void addProfileTag(Entry<String, String> 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;
|
||||
|
|
|
@ -922,7 +922,11 @@ public class MapPoiTypes {
|
|||
}
|
||||
}
|
||||
pat = poiTypesByTag.get(otag);
|
||||
if (pat == null && otag.startsWith("tag_")) {
|
||||
a.addProfileTag(e);
|
||||
}
|
||||
}
|
||||
|
||||
if (pat != null && pat.isAdditional()) {
|
||||
a.setAdditionalInfo(pat.getKeyName(), e.getValue());
|
||||
}
|
||||
|
|
|
@ -139,31 +139,82 @@
|
|||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="@dimen/content_padding_half"
|
||||
android:paddingBottom="@dimen/content_padding_small">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/user_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/btn_border_bg"
|
||||
android:layout_marginLeft="@dimen/content_padding_half"
|
||||
android:layout_marginStart="@dimen/content_padding_half">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/user_icon"
|
||||
android:layout_width="@dimen/poi_icon_size"
|
||||
android:layout_height="@dimen/poi_icon_size"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="@dimen/content_padding_small_half"
|
||||
android:layout_marginStart="@dimen/content_padding_small_half"
|
||||
android:contentDescription="@string/shared_string_icon"
|
||||
tools:src="@drawable/ic_action_user_account_16" />
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/user_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/btn_border_bg_light"
|
||||
android:gravity="center_vertical"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:paddingTop="@dimen/subHeaderPadding"
|
||||
android:paddingBottom="@dimen/subHeaderPadding"
|
||||
android:paddingLeft="@dimen/bottom_sheet_content_padding_small"
|
||||
android:paddingRight="@dimen/bottom_sheet_content_padding_small"
|
||||
android:paddingLeft="@dimen/content_padding_small_half"
|
||||
android:paddingRight="@dimen/content_padding_small_half"
|
||||
android:textAppearance="@style/TextAppearance.ContextMenuSubtitle"
|
||||
android:textColor="?attr/active_color_basic"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
android:drawablePadding="@dimen/content_padding_small_half"
|
||||
android:drawableStart="@drawable/ic_action_user_account_16"
|
||||
android:drawableLeft="@drawable/ic_action_user_account_16"
|
||||
tools:drawableTint="?attr/wikivoyage_active_color"
|
||||
tools:text="Lorem Ipsum" />
|
||||
tools:text="@string/mapillary_menu_title_username" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/profile_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/btn_border_bg"
|
||||
android:layout_marginLeft="@dimen/content_padding_half"
|
||||
android:layout_marginStart="@dimen/content_padding_half">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/profile_icon"
|
||||
android:layout_width="@dimen/poi_icon_size"
|
||||
android:layout_height="@dimen/poi_icon_size"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="@dimen/content_padding_small_half"
|
||||
android:layout_marginStart="@dimen/content_padding_small_half"
|
||||
android:contentDescription="@string/shared_string_icon"
|
||||
tools:src="@drawable/ic_action_bicycle_dark" />
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/profile"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:paddingTop="@dimen/subHeaderPadding"
|
||||
android:paddingBottom="@dimen/subHeaderPadding"
|
||||
android:paddingLeft="@dimen/content_padding_small_half"
|
||||
android:paddingRight="@dimen/content_padding_small_half"
|
||||
android:textAppearance="@style/TextAppearance.ContextMenuSubtitle"
|
||||
android:textColor="?attr/active_color_basic"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
tools:drawableTint="?attr/wikivoyage_active_color"
|
||||
tools:text="@string/shared_string_profiles" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -172,7 +223,6 @@
|
|||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:visibility="invisible"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/wikivoyage_card_divider_color" />
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue