Merge pull request #11351 from osmandapp/RouteLineFixes
Route Line Appearance: After UI review fixes
This commit is contained in:
commit
edb879260a
11 changed files with 195 additions and 118 deletions
44
OsmAnd/res/layout/bottom_sheet_item_with_two_text.xml
Normal file
44
OsmAnd/res/layout/bottom_sheet_item_with_two_text.xml
Normal 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>
|
|
@ -19,9 +19,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:background="?attr/bg_color"
|
||||
android:minHeight="@dimen/bottom_sheet_title_height"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding">
|
||||
android:orientation="vertical">
|
||||
|
||||
<View
|
||||
android:layout_width="@dimen/content_padding"
|
||||
|
@ -31,23 +29,8 @@
|
|||
android:layout_marginBottom="@dimen/list_item_button_padding"
|
||||
android:background="?attr/bg_dash_line" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
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>
|
||||
<include android:id="@+id/header_container"
|
||||
layout="@layout/bottom_sheet_item_with_two_text" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -9,43 +9,8 @@
|
|||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
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/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">
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="@dimen/content_padding_small">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recycler_view"
|
||||
|
|
|
@ -13,48 +13,13 @@
|
|||
android:background="?attr/divider_color_basic"
|
||||
android:focusable="false" />
|
||||
|
||||
<include layout="@layout/bottom_sheet_item_with_two_text" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
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
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -27,6 +27,8 @@ import net.osmand.plus.routepreparationmenu.cards.BaseCard;
|
|||
import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener;
|
||||
import net.osmand.plus.routing.RouteLineDrawInfo;
|
||||
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.ColorsCard;
|
||||
import net.osmand.plus.track.CustomColorBottomSheet.ColorPickerListener;
|
||||
|
@ -39,17 +41,17 @@ import java.util.Arrays;
|
|||
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 NIGHT_TITLE_ID = R.string.night;
|
||||
|
||||
private final Fragment targetFragment;
|
||||
private HeaderUiAdapter headerUiAdapter;
|
||||
|
||||
private ColorsCard colorsCard;
|
||||
private ColorTypeAdapter colorAdapter;
|
||||
private RecyclerView groupRecyclerView;
|
||||
private TextView tvColorName;
|
||||
private TextView tvDescription;
|
||||
private View themeToggleContainer;
|
||||
private ViewGroup cardsContainer;
|
||||
|
@ -76,12 +78,14 @@ public class RouteLineColorCard extends BaseCard implements CardListener, ColorP
|
|||
@NonNull Fragment targetFragment,
|
||||
@NonNull RouteLineDrawInfo routeLineDrawInfo,
|
||||
@NonNull DayNightMode initMapTheme,
|
||||
@NonNull DayNightMode selectedMapTheme) {
|
||||
@NonNull DayNightMode selectedMapTheme,
|
||||
@NonNull HeaderUiAdapter headerUiAdapter) {
|
||||
super(mapActivity);
|
||||
this.targetFragment = targetFragment;
|
||||
this.routeLineDrawInfo = routeLineDrawInfo;
|
||||
this.initMapTheme = initMapTheme;
|
||||
this.selectedMapTheme = selectedMapTheme;
|
||||
this.headerUiAdapter = headerUiAdapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -91,7 +95,6 @@ public class RouteLineColorCard extends BaseCard implements CardListener, ColorP
|
|||
|
||||
@Override
|
||||
protected void updateContent() {
|
||||
tvColorName = view.findViewById(R.id.color_name);
|
||||
tvDescription = view.findViewById(R.id.description);
|
||||
|
||||
colorAdapter = new ColorTypeAdapter();
|
||||
|
@ -221,13 +224,21 @@ public class RouteLineColorCard extends BaseCard implements CardListener, ColorP
|
|||
updateColorName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeedUpdateHeader() {
|
||||
updateColorName();
|
||||
}
|
||||
|
||||
private void updateColorName() {
|
||||
String title = app.getString(R.string.shared_string_color);
|
||||
String colorName = "";
|
||||
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) {
|
||||
int colorNameId = ColorDialogs.getColorName(getRouteLineColor());
|
||||
tvColorName.setText(app.getString(colorNameId));
|
||||
colorName = app.getString(colorNameId);
|
||||
}
|
||||
headerUiAdapter.onUpdateHeader(this, title, colorName);
|
||||
}
|
||||
|
||||
private void updateDescription() {
|
||||
|
@ -355,4 +366,5 @@ public class RouteLineColorCard extends BaseCard implements CardListener, ColorP
|
|||
public interface OnMapThemeUpdateListener {
|
||||
void onMapThemeUpdated(@NonNull DayNightMode mapTheme);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,6 +26,8 @@ import net.osmand.plus.activities.MapActivity;
|
|||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
|
||||
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.TrackAppearanceFragment.OnNeedScrollListener;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
@ -33,20 +35,21 @@ import net.osmand.util.Algorithms;
|
|||
import java.util.Arrays;
|
||||
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_MAX = 36;
|
||||
|
||||
private RouteLineDrawInfo routeLineDrawInfo;
|
||||
private OnNeedScrollListener onNeedScrollListener;
|
||||
private HeaderUiAdapter headerUiAdapter;
|
||||
|
||||
private WidthMode selectedMode;
|
||||
|
||||
private WidthAdapter widthAdapter;
|
||||
private View sliderContainer;
|
||||
private RecyclerView groupRecyclerView;
|
||||
private TextView tvModeType;
|
||||
private TextView tvSelectedType;
|
||||
private TextView tvDescription;
|
||||
|
||||
private enum WidthMode {
|
||||
|
@ -69,10 +72,12 @@ public class RouteLineWidthCard extends BaseCard {
|
|||
|
||||
public RouteLineWidthCard(@NonNull MapActivity mapActivity,
|
||||
@NonNull RouteLineDrawInfo routeLineDrawInfo,
|
||||
@NonNull OnNeedScrollListener onNeedScrollListener) {
|
||||
@NonNull OnNeedScrollListener onNeedScrollListener,
|
||||
@NonNull HeaderUiAdapter headerUiAdapter) {
|
||||
super(mapActivity);
|
||||
this.routeLineDrawInfo = routeLineDrawInfo;
|
||||
this.onNeedScrollListener = onNeedScrollListener;
|
||||
this.headerUiAdapter = headerUiAdapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -87,7 +92,8 @@ public class RouteLineWidthCard extends BaseCard {
|
|||
groupRecyclerView.setAdapter(widthAdapter);
|
||||
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);
|
||||
sliderContainer = view.findViewById(R.id.slider_container);
|
||||
AndroidUiHelper.updateVisibility(view.findViewById(R.id.top_divider), isShowDivider());
|
||||
|
@ -122,8 +128,16 @@ public class RouteLineWidthCard extends BaseCard {
|
|||
return routeLineDrawInfo.getWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeedUpdateHeader() {
|
||||
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() {
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
package net.osmand.plus.settings.fragments;
|
||||
|
||||
public interface HeaderInfo {
|
||||
|
||||
void onNeedUpdateHeader();
|
||||
|
||||
}
|
|
@ -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);
|
||||
|
||||
}
|
|
@ -11,6 +11,7 @@ import android.widget.FrameLayout;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.activity.OnBackPressedCallback;
|
||||
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.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();
|
||||
|
||||
|
@ -48,10 +53,14 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple
|
|||
private int toolbarHeightPx;
|
||||
private DayNightMode initMapTheme;
|
||||
private DayNightMode selectedMapTheme;
|
||||
private HeaderInfo selectedHeader;
|
||||
|
||||
private View buttonsShadow;
|
||||
private View controlButtons;
|
||||
private View toolbarContainer;
|
||||
private View headerContainer;
|
||||
private TextView headerTitle;
|
||||
private TextView headerDescr;
|
||||
|
||||
private RouteLineColorCard colorCard;
|
||||
private RouteLineWidthCard widthCard;
|
||||
|
@ -123,6 +132,9 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple
|
|||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
if (view != null) {
|
||||
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);
|
||||
controlButtons = view.findViewById(R.id.control_buttons);
|
||||
if (isPortrait()) {
|
||||
|
@ -142,7 +154,7 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple
|
|||
setupCards();
|
||||
setupToolbar();
|
||||
setupButtons(view);
|
||||
setupScrollShadow();
|
||||
setupScrollListener();
|
||||
enterAppearanceMode();
|
||||
openMenuHalfScreen();
|
||||
calculateLayout();
|
||||
|
@ -163,13 +175,26 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple
|
|||
ViewGroup cardsContainer = getCardsContainer();
|
||||
cardsContainer.removeAllViews();
|
||||
|
||||
colorCard = new RouteLineColorCard(mapActivity, this, routeLineDrawInfo, initMapTheme, selectedMapTheme);
|
||||
colorCard = new RouteLineColorCard(mapActivity, this, routeLineDrawInfo, initMapTheme, selectedMapTheme, this);
|
||||
cardsContainer.addView(colorCard.build(mapActivity));
|
||||
|
||||
widthCard = new RouteLineWidthCard(mapActivity, routeLineDrawInfo, createScrollListener());
|
||||
widthCard = new RouteLineWidthCard(mapActivity, routeLineDrawInfo, createScrollListener(), this);
|
||||
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() {
|
||||
return new OnNeedScrollListener() {
|
||||
|
||||
|
@ -254,7 +279,7 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple
|
|||
AndroidUiHelper.updateVisibility(view.findViewById(R.id.buttons_divider), true);
|
||||
}
|
||||
|
||||
private void setupScrollShadow() {
|
||||
private void setupScrollListener() {
|
||||
final View scrollView = getBottomScrollView();
|
||||
scrollView.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
|
||||
@Override
|
||||
|
@ -265,6 +290,7 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple
|
|||
} else {
|
||||
hideShadowButton();
|
||||
}
|
||||
updateHeaderState();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -283,6 +309,19 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple
|
|||
.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() {
|
||||
MapActivity ctx = getMapActivity();
|
||||
int screenHeight = AndroidUtils.getScreenHeight(ctx);
|
||||
|
@ -385,7 +424,6 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple
|
|||
colorCard.onColorSelected(prevColor, newColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSelectedColorChanged() {
|
||||
updateColorItems();
|
||||
}
|
||||
|
@ -418,7 +456,6 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapThemeUpdated(@NonNull DayNightMode mapTheme) {
|
||||
changeMapTheme(mapTheme);
|
||||
updateColorItems();
|
||||
|
@ -435,4 +472,5 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple
|
|||
public interface OnApplyRouteLineListener {
|
||||
void applyRouteLineAppearance(@NonNull RouteLineDrawInfo routeLineDrawInfo);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ import net.osmand.data.QuadRect;
|
|||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.data.TransportStop;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.mapcontextmenu.other.TrackChartPoints;
|
||||
import net.osmand.plus.measurementtool.MeasurementToolFragment;
|
||||
|
@ -105,6 +106,9 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont
|
|||
private LayerDrawable projectionIcon;
|
||||
private LayerDrawable previewIcon;
|
||||
|
||||
private int routeLineColor;
|
||||
private Integer directionArrowsColor;
|
||||
|
||||
public RouteLayer(RoutingHelper helper) {
|
||||
this.helper = helper;
|
||||
this.transportHelper = helper.getTransportRoutingHelper();
|
||||
|
@ -326,7 +330,8 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont
|
|||
DrawSettings settings,
|
||||
RouteLineDrawInfo drawInfo) {
|
||||
updateAttrs(settings, tileBox);
|
||||
paintRouteLinePreview.setColor(getRouteLineColor(nightMode));
|
||||
updateRouteColors(nightMode);
|
||||
paintRouteLinePreview.setColor(getRouteLineColor());
|
||||
paintRouteLinePreview.setStrokeWidth(getRouteLineWidth(tileBox));
|
||||
|
||||
int centerX = drawInfo.getCenterX();
|
||||
|
@ -418,6 +423,22 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont
|
|||
|
||||
@ColorInt
|
||||
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;
|
||||
if (routeLineDrawInfo != null) {
|
||||
color = routeLineDrawInfo.getColor(night);
|
||||
|
@ -429,10 +450,13 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont
|
|||
color = storedValue != 0 ? storedValue : null;
|
||||
}
|
||||
if (color == null) {
|
||||
directionArrowsColor = null;
|
||||
updateAttrs(new DrawSettings(night), view.getCurrentRotatedTileBox());
|
||||
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) {
|
||||
|
@ -500,7 +524,8 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont
|
|||
boolean straight = route.getRouteService() == RouteService.STRAIGHT;
|
||||
publicTransportRouteGeometry.clearRoute();
|
||||
routeGeometry.updateRoute(tb, route);
|
||||
routeGeometry.setRouteStyleParams(getRouteLineColor(nightMode), getRouteLineWidth(tb));
|
||||
updateRouteColors(nightMode);
|
||||
routeGeometry.setRouteStyleParams(getRouteLineColor(), getRouteLineWidth(tb), getDirectionArrowsColor());
|
||||
if (directTo) {
|
||||
routeGeometry.drawSegments(tb, canvas, topLatitude, leftLongitude, bottomLatitude, rightLongitude,
|
||||
null, 0);
|
||||
|
|
|
@ -22,15 +22,19 @@ public class RouteGeometryWay extends GeometryWay<RouteGeometryWayContext, Geome
|
|||
|
||||
private Integer customColor;
|
||||
private Float customWidth;
|
||||
private Integer customPointColor;
|
||||
|
||||
public RouteGeometryWay(RouteGeometryWayContext context) {
|
||||
super(context, new GeometryWayDrawer<>(context));
|
||||
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.customWidth = width;
|
||||
this.customPointColor = pointColor;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
@ -39,7 +43,7 @@ public class RouteGeometryWay extends GeometryWay<RouteGeometryWayContext, Geome
|
|||
Paint paint = getContext().getAttrs().paint;
|
||||
int color = customColor != null ? customColor : paint.getColor();
|
||||
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) {
|
||||
|
@ -64,8 +68,12 @@ public class RouteGeometryWay extends GeometryWay<RouteGeometryWayContext, Geome
|
|||
|
||||
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);
|
||||
this.pointColor = pointColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -73,6 +81,11 @@ public class RouteGeometryWay extends GeometryWay<RouteGeometryWayContext, Geome
|
|||
return getContext().getArrowBitmap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getPointColor() {
|
||||
return pointColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) {
|
||||
|
|
Loading…
Reference in a new issue