diff --git a/OsmAnd/res/layout/warning_card.xml b/OsmAnd/res/layout/warning_card.xml new file mode 100644 index 0000000000..f30342d630 --- /dev/null +++ b/OsmAnd/res/layout/warning_card.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/values-large/sizes.xml b/OsmAnd/res/values-large/sizes.xml index a03ce9090d..74fbcb742d 100644 --- a/OsmAnd/res/values-large/sizes.xml +++ b/OsmAnd/res/values-large/sizes.xml @@ -189,6 +189,7 @@ 84dp 78dp 12dp + 27dp 78dp diff --git a/OsmAnd/res/values/sizes.xml b/OsmAnd/res/values/sizes.xml index 517c973bed..0e28e19383 100644 --- a/OsmAnd/res/values/sizes.xml +++ b/OsmAnd/res/values/sizes.xml @@ -281,6 +281,7 @@ 56dp 54dp 8dp + 18dp 52dp diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 7dc9880c4f..2410f65d5c 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,6 +11,9 @@ Thx - Hardy --> + Learn more about how OsmAnd calculates routes in our blog. + Public transport routes are now in the beta testing phase, so errors and inaccuracies may occur. + Add intermediate point %1$d transfers Add start and end points Add start point diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java index d49a96f748..0fe82579ca 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java @@ -383,6 +383,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL clearSelectedObject(object); return false; } + menuController = getMenuController(); } else { menuController.update(pointDescription, object); } diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java index 85c22e1e80..d83f2f17c4 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java @@ -74,6 +74,7 @@ import net.osmand.plus.routepreparationmenu.cards.PreviousRouteCard; import net.osmand.plus.routepreparationmenu.cards.PublicTransportCard; import net.osmand.plus.routepreparationmenu.cards.SimpleRouteCard; import net.osmand.plus.routepreparationmenu.cards.TracksCard; +import net.osmand.plus.routepreparationmenu.cards.WarningCard; import net.osmand.plus.routing.IRouteInformationListener; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.search.QuickSearchHelper; @@ -492,7 +493,10 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener menuCards.add(card); } bottomShadowVisible = routes.size() == 0; - } else if (!routeCalculationInProgress) { + } else if (routeCalculationInProgress) { + WarningCard warningCard = new WarningCard(mapActivity); + menuCards.add(warningCard); + } else { // Home/work card HomeWorkCard homeWorkCard = new HomeWorkCard(mapActivity); menuCards.add(homeWorkCard); diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/WarningCard.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/WarningCard.java new file mode 100644 index 0000000000..308553fdae --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/WarningCard.java @@ -0,0 +1,102 @@ +package net.osmand.plus.routepreparationmenu.cards; + +import android.graphics.Typeface; +import android.net.Uri; +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.v4.content.ContextCompat; +import android.text.SpannableString; +import android.text.Spanned; +import android.text.TextPaint; +import android.text.method.LinkMovementMethod; +import android.text.style.ClickableSpan; +import android.text.style.StyleSpan; +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; + +import net.osmand.plus.R; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.routepreparationmenu.AddPointBottomSheetDialog; +import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu.PointType; +import net.osmand.plus.wikipedia.WikipediaDialogFragment; + +public class WarningCard extends BaseCard { + + public static final String OSMAND_BLOG_LINK = "https://osmand.net/blog"; + + public WarningCard(MapActivity mapActivity) { + super(mapActivity); + } + + @Override + public int getCardLayoutId() { + return R.layout.warning_card; + } + + @Override + protected void updateContent() { + ImageView icon = (ImageView) view.findViewById(R.id.warning_img); + TextView warningTitle = (TextView) view.findViewById(R.id.warning_title); + TextView warningDescr = (TextView) view.findViewById(R.id.warning_descr); + + if (app.getRoutingHelper().isPublicTransportMode()) { + icon.setImageDrawable(getContentIcon(R.drawable.ic_action_bus_dark)); + warningTitle.setText(R.string.public_transport_warning_title); + + String text = app.getString(R.string.public_transport_warning_descr_blog); + SpannableString spannable = new SpannableString(text); + ClickableSpan clickableSpan = new ClickableSpan() { + @Override + public void updateDrawState(@NonNull TextPaint ds) { + ds.setColor(ContextCompat.getColor(app, nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light)); + ds.setUnderlineText(false); + } + + @Override + public void onClick(@NonNull View widget) { + WikipediaDialogFragment.showFullArticle(app, Uri.parse(OSMAND_BLOG_LINK), nightMode); + } + }; + int startIndex = text.lastIndexOf(" "); + if (startIndex != -1) { + spannable.setSpan(clickableSpan, startIndex, text.length() - 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + spannable.setSpan(new StyleSpan(Typeface.BOLD), startIndex, text.length() - 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + warningDescr.setMovementMethod(LinkMovementMethod.getInstance()); + } + warningDescr.setText(spannable); + } else { + icon.setImageDrawable(getContentIcon(R.drawable.ic_action_waypoint)); + warningTitle.setText(R.string.route_is_too_long_v2); + SpannableString text = new SpannableString(app.getString(R.string.add_intermediate)); + ClickableSpan clickableSpan = new ClickableSpan() { + @Override + public void updateDrawState(@NonNull TextPaint ds) { + ds.setColor(ContextCompat.getColor(app, nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light)); + ds.setUnderlineText(false); + } + + @Override + public void onClick(@NonNull View widget) { + openAddPointDialog(); + } + }; + text.setSpan(clickableSpan, 0, text.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + text.setSpan(new StyleSpan(Typeface.BOLD), 0, text.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + warningDescr.setMovementMethod(LinkMovementMethod.getInstance()); + warningDescr.setTextSize(15); + warningDescr.setText(text); + } + } + + private void openAddPointDialog() { + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { + Bundle args = new Bundle(); + args.putString(AddPointBottomSheetDialog.POINT_TYPE_KEY, PointType.INTERMEDIATE.name()); + AddPointBottomSheetDialog fragment = new AddPointBottomSheetDialog(); + fragment.setArguments(args); + fragment.show(mapActivity.getSupportFragmentManager(), AddPointBottomSheetDialog.TAG); + } + } +} \ No newline at end of file