Merge pull request #11351 from osmandapp/RouteLineFixes

Route Line Appearance: After UI review fixes
This commit is contained in:
Vitaliy 2021-04-06 11:02:44 +03:00 committed by GitHub
commit edb879260a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 195 additions and 118 deletions

View file

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/bottom_sheet_list_item_height"
android:gravity="center_vertical"
android:orientation="horizontal">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:letterSpacing="@dimen/description_letter_spacing"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="Title" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/descr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="end"
android:letterSpacing="@dimen/description_letter_spacing"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="Description" />
</LinearLayout>
</LinearLayout>

View file

@ -19,9 +19,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/bg_color" android:background="?attr/bg_color"
android:minHeight="@dimen/bottom_sheet_title_height" android:minHeight="@dimen/bottom_sheet_title_height"
android:orientation="vertical" android:orientation="vertical">
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding">
<View <View
android:layout_width="@dimen/content_padding" android:layout_width="@dimen/content_padding"
@ -31,23 +29,8 @@
android:layout_marginBottom="@dimen/list_item_button_padding" android:layout_marginBottom="@dimen/list_item_button_padding"
android:background="?attr/bg_dash_line" /> android:background="?attr/bg_dash_line" />
<LinearLayout <include android:id="@+id/header_container"
android:layout_width="match_parent" layout="@layout/bottom_sheet_item_with_two_text" />
android:layout_height="wrap_content">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/header_title"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:gravity="center_vertical"
android:letterSpacing="@dimen/text_button_letter_spacing"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_medium" />
</LinearLayout>
</LinearLayout> </LinearLayout>

View file

@ -9,43 +9,8 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="horizontal"
android:paddingTop="@dimen/content_padding_small">
<net.osmand.plus.widgets.TextViewEx
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:letterSpacing="@dimen/description_letter_spacing"
android:paddingLeft="@dimen/content_padding"
android:paddingTop="@dimen/content_padding_small"
android:paddingRight="@dimen/content_padding"
android:paddingBottom="@dimen/content_padding_small"
android:text="@string/shared_string_color"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_medium" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/color_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="end"
android:letterSpacing="@dimen/description_letter_spacing"
android:paddingLeft="@dimen/content_padding"
android:paddingTop="@dimen/content_padding_small"
android:paddingRight="@dimen/content_padding"
android:paddingBottom="@dimen/content_padding_small"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="Orange" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view" android:id="@+id/recycler_view"

View file

@ -13,48 +13,13 @@
android:background="?attr/divider_color_basic" android:background="?attr/divider_color_basic"
android:focusable="false" /> android:focusable="false" />
<include layout="@layout/bottom_sheet_item_with_two_text" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="horizontal">
<net.osmand.plus.widgets.TextViewEx
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:letterSpacing="@dimen/description_letter_spacing"
android:paddingLeft="@dimen/content_padding"
android:paddingTop="@dimen/content_padding_small"
android:paddingRight="@dimen/content_padding"
android:paddingBottom="@dimen/content_padding_small"
android:text="@string/select_track_width"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_medium" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/width_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="end"
android:letterSpacing="@dimen/description_letter_spacing"
android:paddingLeft="@dimen/content_padding"
android:paddingTop="@dimen/content_padding_small"
android:paddingRight="@dimen/content_padding"
android:paddingBottom="@dimen/content_padding_small"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="21" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="@dimen/context_menu_padding_margin_tiny">
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view" android:id="@+id/recycler_view"
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -27,6 +27,8 @@ import net.osmand.plus.routepreparationmenu.cards.BaseCard;
import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener; import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener;
import net.osmand.plus.routing.RouteLineDrawInfo; import net.osmand.plus.routing.RouteLineDrawInfo;
import net.osmand.plus.settings.backend.ListStringPreference; import net.osmand.plus.settings.backend.ListStringPreference;
import net.osmand.plus.settings.fragments.HeaderInfo;
import net.osmand.plus.settings.fragments.HeaderUiAdapter;
import net.osmand.plus.track.AppearanceViewHolder; import net.osmand.plus.track.AppearanceViewHolder;
import net.osmand.plus.track.ColorsCard; import net.osmand.plus.track.ColorsCard;
import net.osmand.plus.track.CustomColorBottomSheet.ColorPickerListener; import net.osmand.plus.track.CustomColorBottomSheet.ColorPickerListener;
@ -39,17 +41,17 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
public class RouteLineColorCard extends BaseCard implements CardListener, ColorPickerListener { public class RouteLineColorCard extends BaseCard implements CardListener, ColorPickerListener, HeaderInfo {
private static final int DAY_TITLE_ID = R.string.day; private static final int DAY_TITLE_ID = R.string.day;
private static final int NIGHT_TITLE_ID = R.string.night; private static final int NIGHT_TITLE_ID = R.string.night;
private final Fragment targetFragment; private final Fragment targetFragment;
private HeaderUiAdapter headerUiAdapter;
private ColorsCard colorsCard; private ColorsCard colorsCard;
private ColorTypeAdapter colorAdapter; private ColorTypeAdapter colorAdapter;
private RecyclerView groupRecyclerView; private RecyclerView groupRecyclerView;
private TextView tvColorName;
private TextView tvDescription; private TextView tvDescription;
private View themeToggleContainer; private View themeToggleContainer;
private ViewGroup cardsContainer; private ViewGroup cardsContainer;
@ -76,12 +78,14 @@ public class RouteLineColorCard extends BaseCard implements CardListener, ColorP
@NonNull Fragment targetFragment, @NonNull Fragment targetFragment,
@NonNull RouteLineDrawInfo routeLineDrawInfo, @NonNull RouteLineDrawInfo routeLineDrawInfo,
@NonNull DayNightMode initMapTheme, @NonNull DayNightMode initMapTheme,
@NonNull DayNightMode selectedMapTheme) { @NonNull DayNightMode selectedMapTheme,
@NonNull HeaderUiAdapter headerUiAdapter) {
super(mapActivity); super(mapActivity);
this.targetFragment = targetFragment; this.targetFragment = targetFragment;
this.routeLineDrawInfo = routeLineDrawInfo; this.routeLineDrawInfo = routeLineDrawInfo;
this.initMapTheme = initMapTheme; this.initMapTheme = initMapTheme;
this.selectedMapTheme = selectedMapTheme; this.selectedMapTheme = selectedMapTheme;
this.headerUiAdapter = headerUiAdapter;
} }
@Override @Override
@ -91,7 +95,6 @@ public class RouteLineColorCard extends BaseCard implements CardListener, ColorP
@Override @Override
protected void updateContent() { protected void updateContent() {
tvColorName = view.findViewById(R.id.color_name);
tvDescription = view.findViewById(R.id.description); tvDescription = view.findViewById(R.id.description);
colorAdapter = new ColorTypeAdapter(); colorAdapter = new ColorTypeAdapter();
@ -221,13 +224,21 @@ public class RouteLineColorCard extends BaseCard implements CardListener, ColorP
updateColorName(); updateColorName();
} }
@Override
public void onNeedUpdateHeader() {
updateColorName();
}
private void updateColorName() { private void updateColorName() {
String title = app.getString(R.string.shared_string_color);
String colorName = "";
if (selectedMode == ColorMode.DEFAULT) { if (selectedMode == ColorMode.DEFAULT) {
tvColorName.setText(app.getString(R.string.map_widget_renderer)); colorName = app.getString(R.string.map_widget_renderer);
} else if (getRouteLineColor() != null) { } else if (getRouteLineColor() != null) {
int colorNameId = ColorDialogs.getColorName(getRouteLineColor()); int colorNameId = ColorDialogs.getColorName(getRouteLineColor());
tvColorName.setText(app.getString(colorNameId)); colorName = app.getString(colorNameId);
} }
headerUiAdapter.onUpdateHeader(this, title, colorName);
} }
private void updateDescription() { private void updateDescription() {
@ -355,4 +366,5 @@ public class RouteLineColorCard extends BaseCard implements CardListener, ColorP
public interface OnMapThemeUpdateListener { public interface OnMapThemeUpdateListener {
void onMapThemeUpdated(@NonNull DayNightMode mapTheme); void onMapThemeUpdated(@NonNull DayNightMode mapTheme);
} }
} }

View file

@ -26,6 +26,8 @@ import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.routepreparationmenu.cards.BaseCard; import net.osmand.plus.routepreparationmenu.cards.BaseCard;
import net.osmand.plus.routing.RouteLineDrawInfo; import net.osmand.plus.routing.RouteLineDrawInfo;
import net.osmand.plus.settings.fragments.HeaderInfo;
import net.osmand.plus.settings.fragments.HeaderUiAdapter;
import net.osmand.plus.track.AppearanceViewHolder; import net.osmand.plus.track.AppearanceViewHolder;
import net.osmand.plus.track.TrackAppearanceFragment.OnNeedScrollListener; import net.osmand.plus.track.TrackAppearanceFragment.OnNeedScrollListener;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
@ -33,20 +35,21 @@ import net.osmand.util.Algorithms;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
public class RouteLineWidthCard extends BaseCard { public class RouteLineWidthCard extends BaseCard implements HeaderInfo {
private final static int CUSTOM_WIDTH_MIN = 1; private final static int CUSTOM_WIDTH_MIN = 1;
private final static int CUSTOM_WIDTH_MAX = 36; private final static int CUSTOM_WIDTH_MAX = 36;
private RouteLineDrawInfo routeLineDrawInfo; private RouteLineDrawInfo routeLineDrawInfo;
private OnNeedScrollListener onNeedScrollListener; private OnNeedScrollListener onNeedScrollListener;
private HeaderUiAdapter headerUiAdapter;
private WidthMode selectedMode; private WidthMode selectedMode;
private WidthAdapter widthAdapter; private WidthAdapter widthAdapter;
private View sliderContainer; private View sliderContainer;
private RecyclerView groupRecyclerView; private RecyclerView groupRecyclerView;
private TextView tvModeType; private TextView tvSelectedType;
private TextView tvDescription; private TextView tvDescription;
private enum WidthMode { private enum WidthMode {
@ -69,10 +72,12 @@ public class RouteLineWidthCard extends BaseCard {
public RouteLineWidthCard(@NonNull MapActivity mapActivity, public RouteLineWidthCard(@NonNull MapActivity mapActivity,
@NonNull RouteLineDrawInfo routeLineDrawInfo, @NonNull RouteLineDrawInfo routeLineDrawInfo,
@NonNull OnNeedScrollListener onNeedScrollListener) { @NonNull OnNeedScrollListener onNeedScrollListener,
@NonNull HeaderUiAdapter headerUiAdapter) {
super(mapActivity); super(mapActivity);
this.routeLineDrawInfo = routeLineDrawInfo; this.routeLineDrawInfo = routeLineDrawInfo;
this.onNeedScrollListener = onNeedScrollListener; this.onNeedScrollListener = onNeedScrollListener;
this.headerUiAdapter = headerUiAdapter;
} }
@Override @Override
@ -87,7 +92,8 @@ public class RouteLineWidthCard extends BaseCard {
groupRecyclerView.setAdapter(widthAdapter); groupRecyclerView.setAdapter(widthAdapter);
groupRecyclerView.setLayoutManager(new LinearLayoutManager(app, RecyclerView.HORIZONTAL, false)); groupRecyclerView.setLayoutManager(new LinearLayoutManager(app, RecyclerView.HORIZONTAL, false));
tvModeType = view.findViewById(R.id.width_type); ((TextView) view.findViewById(R.id.title)).setText(R.string.select_track_width);
tvSelectedType = view.findViewById(R.id.descr);
tvDescription = view.findViewById(R.id.description); tvDescription = view.findViewById(R.id.description);
sliderContainer = view.findViewById(R.id.slider_container); sliderContainer = view.findViewById(R.id.slider_container);
AndroidUiHelper.updateVisibility(view.findViewById(R.id.top_divider), isShowDivider()); AndroidUiHelper.updateVisibility(view.findViewById(R.id.top_divider), isShowDivider());
@ -122,8 +128,16 @@ public class RouteLineWidthCard extends BaseCard {
return routeLineDrawInfo.getWidth(); return routeLineDrawInfo.getWidth();
} }
@Override
public void onNeedUpdateHeader() {
updateHeader();
}
private void updateHeader() { private void updateHeader() {
tvModeType.setText(app.getString(selectedMode.titleId)); String title = app.getString(R.string.select_track_width);
String description = app.getString(selectedMode.titleId);
tvSelectedType.setText(description);
headerUiAdapter.onUpdateHeader(this, title, description);
} }
private void updateDescription() { private void updateDescription() {

View file

@ -0,0 +1,7 @@
package net.osmand.plus.settings.fragments;
public interface HeaderInfo {
void onNeedUpdateHeader();
}

View file

@ -0,0 +1,11 @@
package net.osmand.plus.settings.fragments;
import androidx.annotation.NonNull;
public interface HeaderUiAdapter {
void onUpdateHeader(@NonNull HeaderInfo headerInfo,
@NonNull String title,
@NonNull String description);
}

View file

@ -11,6 +11,7 @@ import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.ScrollView; import android.widget.ScrollView;
import android.widget.TextView;
import androidx.activity.OnBackPressedCallback; import androidx.activity.OnBackPressedCallback;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@ -36,7 +37,11 @@ import net.osmand.plus.routing.cards.RouteLineWidthCard;
import net.osmand.plus.track.CustomColorBottomSheet.ColorPickerListener; import net.osmand.plus.track.CustomColorBottomSheet.ColorPickerListener;
import net.osmand.plus.track.TrackAppearanceFragment.OnNeedScrollListener; import net.osmand.plus.track.TrackAppearanceFragment.OnNeedScrollListener;
public class RouteLineAppearanceFragment extends ContextMenuScrollFragment implements ColorPickerListener, OnSelectedColorChangeListener, OnMapThemeUpdateListener { import static net.osmand.util.Algorithms.objectEquals;
public class RouteLineAppearanceFragment extends ContextMenuScrollFragment
implements ColorPickerListener, OnMapThemeUpdateListener, OnSelectedColorChangeListener,
HeaderUiAdapter {
public static final String TAG = RouteLineAppearanceFragment.class.getName(); public static final String TAG = RouteLineAppearanceFragment.class.getName();
@ -48,10 +53,14 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple
private int toolbarHeightPx; private int toolbarHeightPx;
private DayNightMode initMapTheme; private DayNightMode initMapTheme;
private DayNightMode selectedMapTheme; private DayNightMode selectedMapTheme;
private HeaderInfo selectedHeader;
private View buttonsShadow; private View buttonsShadow;
private View controlButtons; private View controlButtons;
private View toolbarContainer; private View toolbarContainer;
private View headerContainer;
private TextView headerTitle;
private TextView headerDescr;
private RouteLineColorCard colorCard; private RouteLineColorCard colorCard;
private RouteLineWidthCard widthCard; private RouteLineWidthCard widthCard;
@ -123,6 +132,9 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple
View view = super.onCreateView(inflater, container, savedInstanceState); View view = super.onCreateView(inflater, container, savedInstanceState);
if (view != null) { if (view != null) {
toolbarContainer = view.findViewById(R.id.context_menu_toolbar_container); toolbarContainer = view.findViewById(R.id.context_menu_toolbar_container);
headerContainer = view.findViewById(R.id.header_container);
headerTitle = headerContainer.findViewById(R.id.title);
headerDescr = headerContainer.findViewById(R.id.descr);
buttonsShadow = view.findViewById(R.id.buttons_shadow); buttonsShadow = view.findViewById(R.id.buttons_shadow);
controlButtons = view.findViewById(R.id.control_buttons); controlButtons = view.findViewById(R.id.control_buttons);
if (isPortrait()) { if (isPortrait()) {
@ -142,7 +154,7 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple
setupCards(); setupCards();
setupToolbar(); setupToolbar();
setupButtons(view); setupButtons(view);
setupScrollShadow(); setupScrollListener();
enterAppearanceMode(); enterAppearanceMode();
openMenuHalfScreen(); openMenuHalfScreen();
calculateLayout(); calculateLayout();
@ -163,13 +175,26 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple
ViewGroup cardsContainer = getCardsContainer(); ViewGroup cardsContainer = getCardsContainer();
cardsContainer.removeAllViews(); cardsContainer.removeAllViews();
colorCard = new RouteLineColorCard(mapActivity, this, routeLineDrawInfo, initMapTheme, selectedMapTheme); colorCard = new RouteLineColorCard(mapActivity, this, routeLineDrawInfo, initMapTheme, selectedMapTheme, this);
cardsContainer.addView(colorCard.build(mapActivity)); cardsContainer.addView(colorCard.build(mapActivity));
widthCard = new RouteLineWidthCard(mapActivity, routeLineDrawInfo, createScrollListener()); widthCard = new RouteLineWidthCard(mapActivity, routeLineDrawInfo, createScrollListener(), this);
cardsContainer.addView(widthCard.build(mapActivity)); cardsContainer.addView(widthCard.build(mapActivity));
} }
@Override
public void onUpdateHeader(@NonNull HeaderInfo headerInfo,
@NonNull String title,
@NonNull String description) {
if (selectedHeader == null) {
selectedHeader = headerInfo;
}
if (objectEquals(selectedHeader, headerInfo)) {
headerTitle.setText(title);
headerDescr.setText(description);
}
}
private OnNeedScrollListener createScrollListener() { private OnNeedScrollListener createScrollListener() {
return new OnNeedScrollListener() { return new OnNeedScrollListener() {
@ -254,7 +279,7 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple
AndroidUiHelper.updateVisibility(view.findViewById(R.id.buttons_divider), true); AndroidUiHelper.updateVisibility(view.findViewById(R.id.buttons_divider), true);
} }
private void setupScrollShadow() { private void setupScrollListener() {
final View scrollView = getBottomScrollView(); final View scrollView = getBottomScrollView();
scrollView.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() { scrollView.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
@Override @Override
@ -265,6 +290,7 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple
} else { } else {
hideShadowButton(); hideShadowButton();
} }
updateHeaderState();
} }
}); });
} }
@ -283,6 +309,19 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple
.setDuration(200); .setDuration(200);
} }
private void updateHeaderState() {
HeaderInfo header;
if (getBottomScrollView().getScrollY() > colorCard.getViewHeight() + headerTitle.getBottom()) {
header = widthCard;
} else {
header = colorCard;
}
if (header != selectedHeader) {
selectedHeader = header;
selectedHeader.onNeedUpdateHeader();
}
}
private void initVisibleRect() { private void initVisibleRect() {
MapActivity ctx = getMapActivity(); MapActivity ctx = getMapActivity();
int screenHeight = AndroidUtils.getScreenHeight(ctx); int screenHeight = AndroidUtils.getScreenHeight(ctx);
@ -385,7 +424,6 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple
colorCard.onColorSelected(prevColor, newColor); colorCard.onColorSelected(prevColor, newColor);
} }
@Override
public void onSelectedColorChanged() { public void onSelectedColorChanged() {
updateColorItems(); updateColorItems();
} }
@ -418,7 +456,6 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple
} }
} }
@Override
public void onMapThemeUpdated(@NonNull DayNightMode mapTheme) { public void onMapThemeUpdated(@NonNull DayNightMode mapTheme) {
changeMapTheme(mapTheme); changeMapTheme(mapTheme);
updateColorItems(); updateColorItems();
@ -435,4 +472,5 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple
public interface OnApplyRouteLineListener { public interface OnApplyRouteLineListener {
void applyRouteLineAppearance(@NonNull RouteLineDrawInfo routeLineDrawInfo); void applyRouteLineAppearance(@NonNull RouteLineDrawInfo routeLineDrawInfo);
} }
} }

View file

@ -30,6 +30,7 @@ import net.osmand.data.QuadRect;
import net.osmand.data.RotatedTileBox; import net.osmand.data.RotatedTileBox;
import net.osmand.data.TransportStop; import net.osmand.data.TransportStop;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.other.TrackChartPoints; import net.osmand.plus.mapcontextmenu.other.TrackChartPoints;
import net.osmand.plus.measurementtool.MeasurementToolFragment; import net.osmand.plus.measurementtool.MeasurementToolFragment;
@ -105,6 +106,9 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont
private LayerDrawable projectionIcon; private LayerDrawable projectionIcon;
private LayerDrawable previewIcon; private LayerDrawable previewIcon;
private int routeLineColor;
private Integer directionArrowsColor;
public RouteLayer(RoutingHelper helper) { public RouteLayer(RoutingHelper helper) {
this.helper = helper; this.helper = helper;
this.transportHelper = helper.getTransportRoutingHelper(); this.transportHelper = helper.getTransportRoutingHelper();
@ -326,7 +330,8 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont
DrawSettings settings, DrawSettings settings,
RouteLineDrawInfo drawInfo) { RouteLineDrawInfo drawInfo) {
updateAttrs(settings, tileBox); updateAttrs(settings, tileBox);
paintRouteLinePreview.setColor(getRouteLineColor(nightMode)); updateRouteColors(nightMode);
paintRouteLinePreview.setColor(getRouteLineColor());
paintRouteLinePreview.setStrokeWidth(getRouteLineWidth(tileBox)); paintRouteLinePreview.setStrokeWidth(getRouteLineWidth(tileBox));
int centerX = drawInfo.getCenterX(); int centerX = drawInfo.getCenterX();
@ -418,6 +423,22 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont
@ColorInt @ColorInt
public int getRouteLineColor(boolean night) { public int getRouteLineColor(boolean night) {
updateRouteColors(night);
return routeLineColor;
}
@ColorInt
public int getRouteLineColor() {
return routeLineColor;
}
@Nullable
@ColorInt
public Integer getDirectionArrowsColor() {
return directionArrowsColor;
}
public void updateRouteColors(boolean night) {
Integer color; Integer color;
if (routeLineDrawInfo != null) { if (routeLineDrawInfo != null) {
color = routeLineDrawInfo.getColor(night); color = routeLineDrawInfo.getColor(night);
@ -429,10 +450,13 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont
color = storedValue != 0 ? storedValue : null; color = storedValue != 0 ? storedValue : null;
} }
if (color == null) { if (color == null) {
directionArrowsColor = null;
updateAttrs(new DrawSettings(night), view.getCurrentRotatedTileBox()); updateAttrs(new DrawSettings(night), view.getCurrentRotatedTileBox());
color = attrs.paint.getColor(); color = attrs.paint.getColor();
} else if (routeLineColor != color) {
directionArrowsColor = UiUtilities.getContrastColor(view.getContext(), color, false);
} }
return color; routeLineColor = color;
} }
private float getRouteLineWidth(@NonNull RotatedTileBox tileBox) { private float getRouteLineWidth(@NonNull RotatedTileBox tileBox) {
@ -500,7 +524,8 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont
boolean straight = route.getRouteService() == RouteService.STRAIGHT; boolean straight = route.getRouteService() == RouteService.STRAIGHT;
publicTransportRouteGeometry.clearRoute(); publicTransportRouteGeometry.clearRoute();
routeGeometry.updateRoute(tb, route); routeGeometry.updateRoute(tb, route);
routeGeometry.setRouteStyleParams(getRouteLineColor(nightMode), getRouteLineWidth(tb)); updateRouteColors(nightMode);
routeGeometry.setRouteStyleParams(getRouteLineColor(), getRouteLineWidth(tb), getDirectionArrowsColor());
if (directTo) { if (directTo) {
routeGeometry.drawSegments(tb, canvas, topLatitude, leftLongitude, bottomLatitude, rightLongitude, routeGeometry.drawSegments(tb, canvas, topLatitude, leftLongitude, bottomLatitude, rightLongitude,
null, 0); null, 0);

View file

@ -22,15 +22,19 @@ public class RouteGeometryWay extends GeometryWay<RouteGeometryWayContext, Geome
private Integer customColor; private Integer customColor;
private Float customWidth; private Float customWidth;
private Integer customPointColor;
public RouteGeometryWay(RouteGeometryWayContext context) { public RouteGeometryWay(RouteGeometryWayContext context) {
super(context, new GeometryWayDrawer<>(context)); super(context, new GeometryWayDrawer<>(context));
this.helper = context.getApp().getRoutingHelper(); this.helper = context.getApp().getRoutingHelper();
} }
public void setRouteStyleParams(@Nullable @ColorInt Integer color, @Nullable Float width) { public void setRouteStyleParams(@Nullable @ColorInt Integer color,
@Nullable Float width,
@Nullable @ColorInt Integer pointColor) {
this.customColor = color; this.customColor = color;
this.customWidth = width; this.customWidth = width;
this.customPointColor = pointColor;
} }
@NonNull @NonNull
@ -39,7 +43,7 @@ public class RouteGeometryWay extends GeometryWay<RouteGeometryWayContext, Geome
Paint paint = getContext().getAttrs().paint; Paint paint = getContext().getAttrs().paint;
int color = customColor != null ? customColor : paint.getColor(); int color = customColor != null ? customColor : paint.getColor();
float width = customWidth != null ? customWidth : paint.getStrokeWidth(); float width = customWidth != null ? customWidth : paint.getStrokeWidth();
return new GeometrySolidWayStyle(getContext(), color, width); return new GeometrySolidWayStyle(getContext(), color, width, customPointColor);
} }
public void updateRoute(RotatedTileBox tb, RouteCalculationResult route) { public void updateRoute(RotatedTileBox tb, RouteCalculationResult route) {
@ -64,8 +68,12 @@ public class RouteGeometryWay extends GeometryWay<RouteGeometryWayContext, Geome
private static class GeometrySolidWayStyle extends GeometryWayStyle<RouteGeometryWayContext> { private static class GeometrySolidWayStyle extends GeometryWayStyle<RouteGeometryWayContext> {
GeometrySolidWayStyle(RouteGeometryWayContext context, Integer color, Float width) { private Integer pointColor;
GeometrySolidWayStyle(RouteGeometryWayContext context, Integer color, Float width,
Integer pointColor) {
super(context, color, width); super(context, color, width);
this.pointColor = pointColor;
} }
@Override @Override
@ -73,6 +81,11 @@ public class RouteGeometryWay extends GeometryWay<RouteGeometryWayContext, Geome
return getContext().getArrowBitmap(); return getContext().getArrowBitmap();
} }
@Override
public Integer getPointColor() {
return pointColor;
}
@Override @Override
public boolean equals(Object other) { public boolean equals(Object other) {
if (this == other) { if (this == other) {