Merge branch 'RoutePreparationImprovements' of ssh://github.com/osmandapp/Osmand
This commit is contained in:
commit
42079623b8
7 changed files with 165 additions and 1 deletions
52
OsmAnd/res/layout/warning_card.xml
Normal file
52
OsmAnd/res/layout/warning_card.xml
Normal file
|
@ -0,0 +1,52 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/home_work_card"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<android.support.v7.widget.AppCompatImageView
|
||||
android:id="@+id/warning_img"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/list_content_padding"
|
||||
android:layout_marginLeft="@dimen/list_content_padding"
|
||||
android:layout_marginTop="@dimen/context_menu_padding_margin_large"
|
||||
android:layout_marginEnd="@dimen/favorites_icon_right_margin"
|
||||
android:layout_marginRight="@dimen/favorites_icon_right_margin"
|
||||
tools:src="@drawable/ic_action_bus_dark"
|
||||
tools:tint="?attr/route_info_control_icon_color" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/context_menu_padding_margin_large"
|
||||
android:layout_marginEnd="@dimen/route_info_settings_buttons_height"
|
||||
android:layout_marginRight="@dimen/route_info_settings_buttons_height"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/warning_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/content_padding"
|
||||
android:letterSpacing="@dimen/text_button_letter_spacing"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
tools:ignore="UnusedAttribute"
|
||||
tools:text="@string/public_transport_warning_title" />
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/warning_descr"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:letterSpacing="@dimen/text_button_letter_spacing"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
tools:ignore="UnusedAttribute"
|
||||
tools:text="@string/public_transport_warning_descr_blog" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -189,6 +189,7 @@
|
|||
<dimen name="route_info_card_item_height">84dp</dimen>
|
||||
<dimen name="route_info_list_text_padding">78dp</dimen>
|
||||
<dimen name="route_info_legend_padding">12dp</dimen>
|
||||
<dimen name="route_info_warning_padding">27dp</dimen>
|
||||
|
||||
<dimen name="multi_selection_header_height">78dp</dimen>
|
||||
|
||||
|
|
|
@ -281,6 +281,7 @@
|
|||
<dimen name="route_info_card_item_height">56dp</dimen>
|
||||
<dimen name="route_info_list_text_padding">54dp</dimen>
|
||||
<dimen name="route_info_legend_padding">8dp</dimen>
|
||||
<dimen name="route_info_warning_padding">18dp</dimen>
|
||||
|
||||
<dimen name="multi_selection_header_height">52dp</dimen>
|
||||
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
Thx - Hardy
|
||||
|
||||
-->
|
||||
<string name="public_transport_warning_descr_blog">Learn more about how OsmAnd calculates routes in our blog.</string>
|
||||
<string name="public_transport_warning_title">Public transport routes are now in the beta testing phase, so errors and inaccuracies may occur.</string>
|
||||
<string name="add_intermediate">Add intermediate point</string>
|
||||
<string name="transfers_size">%1$d transfers</string>
|
||||
<string name="add_start_and_end_points">Add start and end points</string>
|
||||
<string name="route_add_start_point">Add start point</string>
|
||||
|
|
|
@ -383,6 +383,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
|||
clearSelectedObject(object);
|
||||
return false;
|
||||
}
|
||||
menuController = getMenuController();
|
||||
} else {
|
||||
menuController.update(pointDescription, object);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue