After code review fixes 3

This commit is contained in:
nazar-kutz 2021-03-24 01:35:29 +02:00
parent de93f862a7
commit 90ee2ba501
9 changed files with 69 additions and 108 deletions

View file

@ -289,9 +289,8 @@ public class RendererRegistry {
return renderers; return renderers;
} }
public static String getMapStyleName(@NonNull OsmandApplication app) { public String getSelectedRendererName() {
RendererRegistry rr = app.getRendererRegistry(); RenderingRulesStorage storage = getCurrentSelectedRenderer();
RenderingRulesStorage storage = rr.getCurrentSelectedRenderer();
if (storage == null) { if (storage == null) {
return ""; return "";
} }

View file

@ -17,7 +17,6 @@ public class RouteLineDrawInfo {
private static final String CENTER_X = "center_x"; private static final String CENTER_X = "center_x";
private static final String CENTER_Y = "center_y"; private static final String CENTER_Y = "center_y";
private static final String SCREEN_HEIGHT = "screen_height"; private static final String SCREEN_HEIGHT = "screen_height";
private static final String APP_MODE_KEY = "app_mode_key";
// parameters to save // parameters to save
@ColorInt @ColorInt
@ -31,7 +30,6 @@ public class RouteLineDrawInfo {
private int centerX; private int centerX;
private int centerY; private int centerY;
private int screenHeight; private int screenHeight;
private String appModeKey;
public RouteLineDrawInfo(@Nullable @ColorInt Integer color, public RouteLineDrawInfo(@Nullable @ColorInt Integer color,
@Nullable String width) { @Nullable String width) {
@ -44,14 +42,13 @@ public class RouteLineDrawInfo {
} }
public RouteLineDrawInfo(@NonNull RouteLineDrawInfo existed) { public RouteLineDrawInfo(@NonNull RouteLineDrawInfo existed) {
this.color = existed.getColor(); this.color = existed.color;
this.width = existed.getWidth(); this.width = existed.width;
this.iconId = existed.iconId; this.iconId = existed.iconId;
this.iconColor = existed.iconColor; this.iconColor = existed.iconColor;
this.centerX = existed.centerX; this.centerX = existed.centerX;
this.centerY = existed.centerY; this.centerY = existed.centerY;
this.screenHeight = existed.screenHeight; this.screenHeight = existed.screenHeight;
this.appModeKey = existed.appModeKey;
} }
public void setColor(@Nullable Integer color) { public void setColor(@Nullable Integer color) {
@ -82,10 +79,6 @@ public class RouteLineDrawInfo {
this.screenHeight = screenHeight; this.screenHeight = screenHeight;
} }
public void setAppModeKey(@Nullable String appModeKey) {
this.appModeKey = appModeKey;
}
@Nullable @Nullable
public Integer getColor() { public Integer getColor() {
return color; return color;
@ -117,20 +110,16 @@ public class RouteLineDrawInfo {
return screenHeight; return screenHeight;
} }
@Nullable
public String getAppModeKey() {
return appModeKey;
}
private void readBundle(@NonNull Bundle bundle) { private void readBundle(@NonNull Bundle bundle) {
color = bundle.getInt(LINE_COLOR); if (bundle.containsKey(LINE_COLOR)) {
color = bundle.getInt(LINE_COLOR);
}
width = bundle.getString(LINE_WIDTH); width = bundle.getString(LINE_WIDTH);
iconId = bundle.getInt(NAVIGATION_ICON_ID); iconId = bundle.getInt(NAVIGATION_ICON_ID);
iconColor = bundle.getInt(NAVIGATION_ICON_COLOR); iconColor = bundle.getInt(NAVIGATION_ICON_COLOR);
centerX = bundle.getInt(CENTER_X); centerX = bundle.getInt(CENTER_X);
centerY = bundle.getInt(CENTER_Y); centerY = bundle.getInt(CENTER_Y);
screenHeight = bundle.getInt(SCREEN_HEIGHT); screenHeight = bundle.getInt(SCREEN_HEIGHT);
appModeKey = bundle.getString(APP_MODE_KEY);
} }
public void saveToBundle(@NonNull Bundle bundle) { public void saveToBundle(@NonNull Bundle bundle) {
@ -142,10 +131,9 @@ public class RouteLineDrawInfo {
} }
bundle.putInt(NAVIGATION_ICON_ID, iconId); bundle.putInt(NAVIGATION_ICON_ID, iconId);
bundle.putInt(NAVIGATION_ICON_COLOR, iconColor); bundle.putInt(NAVIGATION_ICON_COLOR, iconColor);
bundle.putInt(CENTER_X, (int) centerX); bundle.putInt(CENTER_X, centerX);
bundle.putInt(CENTER_Y, (int) centerY); bundle.putInt(CENTER_Y, centerY);
bundle.putInt(SCREEN_HEIGHT, screenHeight); bundle.putInt(SCREEN_HEIGHT, screenHeight);
bundle.putString(APP_MODE_KEY, appModeKey);
} }
@Override @Override

View file

@ -26,7 +26,6 @@ import net.osmand.plus.render.RendererRegistry;
import net.osmand.plus.routepreparationmenu.cards.BaseCard; 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.ApplicationMode;
import net.osmand.plus.settings.backend.ListStringPreference; import net.osmand.plus.settings.backend.ListStringPreference;
import net.osmand.plus.track.AppearanceViewHolder; import net.osmand.plus.track.AppearanceViewHolder;
import net.osmand.plus.track.ColorsCard; import net.osmand.plus.track.ColorsCard;
@ -34,7 +33,6 @@ import net.osmand.plus.track.CustomColorBottomSheet.ColorPickerListener;
import net.osmand.plus.widgets.MultiStateToggleButton; import net.osmand.plus.widgets.MultiStateToggleButton;
import net.osmand.plus.widgets.MultiStateToggleButton.OnRadioItemClickListener; import net.osmand.plus.widgets.MultiStateToggleButton.OnRadioItemClickListener;
import net.osmand.plus.widgets.MultiStateToggleButton.RadioItem; import net.osmand.plus.widgets.MultiStateToggleButton.RadioItem;
import net.osmand.render.RenderingRulesStorage;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -211,7 +209,7 @@ public class RouteLineColorCard extends BaseCard implements CardListener, ColorP
if (selectedMode == ColorMode.DEFAULT) { if (selectedMode == ColorMode.DEFAULT) {
String pattern = app.getString(R.string.route_line_use_map_style_appearance); String pattern = app.getString(R.string.route_line_use_map_style_appearance);
String color = app.getString(R.string.shared_string_color).toLowerCase(); String color = app.getString(R.string.shared_string_color).toLowerCase();
description = String.format(pattern, color, RendererRegistry.getMapStyleName(app)); description = String.format(pattern, color, app.getRendererRegistry().getSelectedRendererName());
} else { } else {
String pattern = app.getString(R.string.specify_color_for_map_mode); String pattern = app.getString(R.string.specify_color_for_map_mode);
String mapModeTitle = app.getString(isNightMap() ? NIGHT_TITLE_ID : DAY_TITLE_ID); String mapModeTitle = app.getString(isNightMap() ? NIGHT_TITLE_ID : DAY_TITLE_ID);

View file

@ -131,7 +131,7 @@ public class RouteLineWidthCard extends BaseCard {
if (selectedMode == WidthMode.DEFAULT) { if (selectedMode == WidthMode.DEFAULT) {
String pattern = app.getString(R.string.route_line_use_map_style_appearance); String pattern = app.getString(R.string.route_line_use_map_style_appearance);
String width = app.getString(R.string.shared_string_color).toLowerCase(); String width = app.getString(R.string.shared_string_color).toLowerCase();
String description = String.format(pattern, width, RendererRegistry.getMapStyleName(app)); String description = String.format(pattern, width, app.getRendererRegistry().getSelectedRendererName());
tvDescription.setText(description); tvDescription.setText(description);
tvDescription.setVisibility(View.VISIBLE); tvDescription.setVisibility(View.VISIBLE);
} else { } else {

View file

@ -729,12 +729,10 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O
private void updateRouteLinePreference() { private void updateRouteLinePreference() {
Preference preference = findPreference(CUSTOMIZE_ROUTE_LINE); Preference preference = findPreference(CUSTOMIZE_ROUTE_LINE);
if (preference != null) { boolean isDefaultProfile = getSelectedAppMode().equals(ApplicationMode.DEFAULT) && !isNewProfile;
boolean isDefaultProfile = getSelectedAppMode().equals(ApplicationMode.DEFAULT) && !isNewProfile; boolean isPublicTransport = PUBLIC_TRANSPORT_KEY.equals(changedProfile.routingProfile);
boolean isPublicTransport = PUBLIC_TRANSPORT_KEY.equals(changedProfile.routingProfile); preference.setVisible(!isDefaultProfile && !isPublicTransport);
preference.setVisible(!isDefaultProfile && !isPublicTransport); preference.setIcon(getIcon(R.drawable.ic_action_route_distance, getActiveColorRes()));
preference.setIcon(getIcon(R.drawable.ic_action_route_distance, getActiveColorRes()));
}
} }
private boolean checkProfileName() { private boolean checkProfileName() {
@ -999,7 +997,6 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O
RouteLineDrawInfo drawInfo = changedProfile.routeLineDrawInfo; RouteLineDrawInfo drawInfo = changedProfile.routeLineDrawInfo;
drawInfo.setIconId(changedProfile.navigationIcon.getIconId()); drawInfo.setIconId(changedProfile.navigationIcon.getIconId());
drawInfo.setIconColor(changedProfile.getActualColor()); drawInfo.setIconColor(changedProfile.getActualColor());
drawInfo.setAppModeKey(profile.stringKey);
RouteLineAppearanceFragment.showInstance(mapActivity, drawInfo, this); RouteLineAppearanceFragment.showInstance(mapActivity, drawInfo, this);
} }
} }
@ -1031,7 +1028,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O
private void saveRouteLineAppearance(@NonNull ApplicationMode appMode, private void saveRouteLineAppearance(@NonNull ApplicationMode appMode,
@NonNull RouteLineDrawInfo drawInfo) { @NonNull RouteLineDrawInfo drawInfo) {
Integer color = drawInfo.getColor(); Integer color = drawInfo.getColor();
if (drawInfo.getColor() != null) { if (color != null) {
settings.ROUTE_LINE_COLOR.setModeValue(appMode, color); settings.ROUTE_LINE_COLOR.setModeValue(appMode, color);
} else { } else {
settings.ROUTE_LINE_COLOR.resetModeToDefault(appMode); settings.ROUTE_LINE_COLOR.resetModeToDefault(appMode);

View file

@ -161,6 +161,7 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple
private void setupCards() { private void setupCards() {
MapActivity mapActivity = requireMapActivity(); MapActivity mapActivity = requireMapActivity();
ViewGroup cardsContainer = getCardsContainer(); ViewGroup cardsContainer = getCardsContainer();
cardsContainer.removeAllViews();
colorCard = new RouteLineColorCard(mapActivity, this, routeLineDrawInfo, initMapTheme, selectedMapTheme); colorCard = new RouteLineColorCard(mapActivity, this, routeLineDrawInfo, initMapTheme, selectedMapTheme);
cardsContainer.addView(colorCard.build(mapActivity)); cardsContainer.addView(colorCard.build(mapActivity));
@ -285,17 +286,21 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple
int screenHeight = AndroidUtils.getScreenHeight(ctx); int screenHeight = AndroidUtils.getScreenHeight(ctx);
int screenWidth = AndroidUtils.getScreenWidth(ctx); int screenWidth = AndroidUtils.getScreenWidth(ctx);
int statusBarHeight = AndroidUtils.getStatusBarHeight(ctx); int statusBarHeight = AndroidUtils.getStatusBarHeight(ctx);
int x; int centerX;
int y; int centerY;
if (AndroidUiHelper.isOrientationPortrait(ctx)) { if (isPortrait()) {
x = screenWidth / 2; centerX = screenWidth / 2;
y = (getViewY() + toolbarContainer.getHeight() + statusBarHeight) / 2; centerY = (getViewY() + toolbarContainer.getHeight() + statusBarHeight) / 2;
} else { } else {
x = (int) (AndroidUtils.isLayoutRtl(ctx) ? screenWidth/4 : screenWidth * 0.75); boolean isRtl = AndroidUtils.isLayoutRtl(ctx);
y = (screenHeight + statusBarHeight) / 2 ; int dialogWidth = getLandscapeNoShadowWidth();
int left = isRtl ? 0 : dialogWidth;
int right = isRtl ? screenWidth - dialogWidth : screenWidth;
centerX = (left + right) / 2;
centerY = (screenHeight + statusBarHeight) / 2 ;
} }
routeLineDrawInfo.setCenterX(x); routeLineDrawInfo.setCenterX(centerX);
routeLineDrawInfo.setCenterY(y); routeLineDrawInfo.setCenterY(centerY);
routeLineDrawInfo.setScreenHeight(screenHeight); routeLineDrawInfo.setScreenHeight(screenHeight);
} }
@ -393,7 +398,6 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple
@NonNull Fragment target) { @NonNull Fragment target) {
try { try {
RouteLineAppearanceFragment fragment = new RouteLineAppearanceFragment(); RouteLineAppearanceFragment fragment = new RouteLineAppearanceFragment();
fragment.setRetainInstance(true);
fragment.setTargetFragment(target, 0); fragment.setTargetFragment(target, 0);
fragment.routeLineDrawInfo = new RouteLineDrawInfo(drawInfo); fragment.routeLineDrawInfo = new RouteLineDrawInfo(drawInfo);

View file

@ -873,7 +873,7 @@ public class MapControlsLayer extends OsmandMapLayer {
&& !isInMovingMarkerMode() && !isInGpxDetailsMode() && !isInMeasurementToolMode() && !isInMovingMarkerMode() && !isInGpxDetailsMode() && !isInMeasurementToolMode()
&& !isInPlanRouteMode() && !shouldHideTopControls && !isInChoosingRoutesMode() && !isInPlanRouteMode() && !shouldHideTopControls && !isInChoosingRoutesMode()
&& !isInWaypointsChoosingMode() && !isInFollowTrackMode() && !isInTrackAppearanceMode() && !isInWaypointsChoosingMode() && !isInFollowTrackMode() && !isInTrackAppearanceMode()
&& !isInRouteLineCustomizationMode(); && !isInRouteLineAppearanceMode();
routePlanningBtn.updateVisibility(showBottomMenuButtons); routePlanningBtn.updateVisibility(showBottomMenuButtons);
menuControl.updateVisibility(showBottomMenuButtons); menuControl.updateVisibility(showBottomMenuButtons);
@ -881,7 +881,7 @@ public class MapControlsLayer extends OsmandMapLayer {
&& !isInTrackAppearanceMode() && !isInTrackAppearanceMode()
&& !isInChoosingRoutesMode() && !isInChoosingRoutesMode()
&& !isInWaypointsChoosingMode() && !isInWaypointsChoosingMode()
&& !isInRouteLineCustomizationMode(); && !isInRouteLineAppearanceMode();
boolean showZoomButtons = !routeDialogOpened && !shouldHideTopControls boolean showZoomButtons = !routeDialogOpened && !shouldHideTopControls
&& !isInFollowTrackMode() && !isInFollowTrackMode()
&& (additionalDialogsHide || !portrait); && (additionalDialogsHide || !portrait);
@ -891,7 +891,7 @@ public class MapControlsLayer extends OsmandMapLayer {
boolean forceHideCompass = routeDialogOpened || trackDialogOpened || isInMeasurementToolMode() boolean forceHideCompass = routeDialogOpened || trackDialogOpened || isInMeasurementToolMode()
|| isInPlanRouteMode() || shouldHideTopControls || isInChoosingRoutesMode() || isInPlanRouteMode() || shouldHideTopControls || isInChoosingRoutesMode()
|| isInTrackAppearanceMode() || isInWaypointsChoosingMode() || isInFollowTrackMode() || isInTrackAppearanceMode() || isInWaypointsChoosingMode() || isInFollowTrackMode()
|| isInRouteLineCustomizationMode(); || isInRouteLineAppearanceMode();
compassHud.forceHideCompass = forceHideCompass; compassHud.forceHideCompass = forceHideCompass;
compassHud.updateVisibility(!forceHideCompass && shouldShowCompass()); compassHud.updateVisibility(!forceHideCompass && shouldShowCompass());
@ -903,7 +903,7 @@ public class MapControlsLayer extends OsmandMapLayer {
boolean showTopButtons = !routeDialogOpened && !trackDialogOpened && !shouldHideTopControls boolean showTopButtons = !routeDialogOpened && !trackDialogOpened && !shouldHideTopControls
&& !isInMeasurementToolMode() && !isInPlanRouteMode() && !isInChoosingRoutesMode() && !isInMeasurementToolMode() && !isInPlanRouteMode() && !isInChoosingRoutesMode()
&& !isInTrackAppearanceMode() && !isInWaypointsChoosingMode() && !isInFollowTrackMode() && !isInTrackAppearanceMode() && !isInWaypointsChoosingMode() && !isInFollowTrackMode()
&& !isInRouteLineCustomizationMode(); && !isInRouteLineAppearanceMode();
layersHud.updateVisibility(showTopButtons); layersHud.updateVisibility(showTopButtons);
quickSearchHud.updateVisibility(showTopButtons); quickSearchHud.updateVisibility(showTopButtons);
@ -1034,7 +1034,7 @@ public class MapControlsLayer extends OsmandMapLayer {
&& !isInChoosingRoutesMode() && !isInChoosingRoutesMode()
&& !isInWaypointsChoosingMode() && !isInWaypointsChoosingMode()
&& !isInFollowTrackMode() && !isInFollowTrackMode()
&& !isInRouteLineCustomizationMode(); && !isInRouteLineAppearanceMode();
backToLocationControl.updateVisibility(visible && !dialogOpened && !isInPlanRouteMode() backToLocationControl.updateVisibility(visible && !dialogOpened && !isInPlanRouteMode()
&& (additionalDialogsHide || !isPotrait())); && (additionalDialogsHide || !isPotrait()));
} }
@ -1402,7 +1402,7 @@ public class MapControlsLayer extends OsmandMapLayer {
return MapRouteInfoMenu.waypointsVisible; return MapRouteInfoMenu.waypointsVisible;
} }
private boolean isInRouteLineCustomizationMode() { private boolean isInRouteLineAppearanceMode() {
return mapActivity.getMapLayers().getRouteLayer().isInRouteLineAppearanceMode(); return mapActivity.getMapLayers().getRouteLayer().isInRouteLineAppearanceMode();
} }

View file

@ -11,6 +11,7 @@ import android.graphics.Path;
import android.graphics.PointF; import android.graphics.PointF;
import android.graphics.PorterDuff.Mode; import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffColorFilter; import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable; import android.graphics.drawable.LayerDrawable;
import androidx.annotation.ColorInt; import androidx.annotation.ColorInt;
@ -41,8 +42,6 @@ import net.osmand.plus.routing.RouteLineDrawInfo;
import net.osmand.plus.routing.RouteService; import net.osmand.plus.routing.RouteService;
import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.routing.TransportRoutingHelper; import net.osmand.plus.routing.TransportRoutingHelper;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.views.OsmandMapLayer; import net.osmand.plus.views.OsmandMapLayer;
import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.layers.geometry.PublicTransportGeometryWay; import net.osmand.plus.views.layers.geometry.PublicTransportGeometryWay;
@ -103,6 +102,7 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont
private PublicTransportGeometryWay publicTransportRouteGeometry; private PublicTransportGeometryWay publicTransportRouteGeometry;
private LayerDrawable projectionIcon; private LayerDrawable projectionIcon;
private LayerDrawable previewIcon;
public RouteLayer(RoutingHelper helper) { public RouteLayer(RoutingHelper helper) {
this.helper = helper; this.helper = helper;
@ -246,8 +246,11 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont
return routeLineDrawInfo != null; return routeLineDrawInfo != null;
} }
public void setRouteLineDrawInfo(RouteLineDrawInfo routeLineDrawInfo) { public void setRouteLineDrawInfo(RouteLineDrawInfo drawInfo) {
this.routeLineDrawInfo = routeLineDrawInfo; this.routeLineDrawInfo = drawInfo;
if (drawInfo == null) {
previewIcon = null;
}
} }
private MapActivity getMapActivity() { private MapActivity getMapActivity() {
@ -312,41 +315,30 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont
QuadPoint c = tileBox.getCenterPixelPoint(); QuadPoint c = tileBox.getCenterPixelPoint();
canvas.rotate(-angle, c.x, c.y); canvas.rotate(-angle, c.x, c.y);
drawRouteLinePreview(canvas, tileBox, settings, routeLineDrawInfo); drawRouteLinePreview(canvas, tileBox, routeLineDrawInfo);
canvas.rotate(angle, c.x, c.y); canvas.rotate(angle, c.x, c.y);
} }
} }
private void drawRouteLinePreview(Canvas canvas, private void drawRouteLinePreview(Canvas canvas,
RotatedTileBox tileBox, RotatedTileBox tileBox,
DrawSettings settings,
RouteLineDrawInfo drawInfo) { RouteLineDrawInfo drawInfo) {
MapActivity mapActivity = getMapActivity();
updateAttrs(settings, tileBox);
paintRouteLinePreview.setColor(getRouteLineColor(nightMode)); paintRouteLinePreview.setColor(getRouteLineColor(nightMode));
paintRouteLinePreview.setStrokeWidth(getRouteLineWidth(tileBox)); paintRouteLinePreview.setStrokeWidth(getRouteLineWidth(tileBox));
int x = drawInfo.getCenterX(); int centerX = drawInfo.getCenterX();
int y = drawInfo.getCenterY(); int centerY = drawInfo.getCenterY();
int screenHeight = drawInfo.getScreenHeight(); int screenHeight = drawInfo.getScreenHeight();
// draw line canvas.drawLine(centerX, 0, centerX, screenHeight, paintRouteLinePreview);
canvas.drawLine(x, 0, x, screenHeight, paintRouteLinePreview);
// draw image if (previewIcon == null) {
LayerDrawable navigationIcon = (LayerDrawable) AppCompatResources.getDrawable(mapActivity, drawInfo.getIconId()); previewIcon = (LayerDrawable) AppCompatResources.getDrawable(view.getContext(), drawInfo.getIconId());
if (navigationIcon != null) { DrawableCompat.setTint(previewIcon.getDrawable(1), drawInfo.getIconColor());
DrawableCompat.setTint(navigationIcon.getDrawable(1), drawInfo.getIconColor());
} }
int left = x - navigationIcon.getIntrinsicWidth() / 2; canvas.rotate(-90, centerX, centerY);
int right = x + navigationIcon.getIntrinsicWidth() / 2; drawIcon(canvas, previewIcon, centerX, centerY);
int top = y - navigationIcon.getIntrinsicHeight() / 2; canvas.rotate(90, centerX, centerY);
int bottom = y + navigationIcon.getIntrinsicHeight() / 2;
navigationIcon.setBounds(left, top, right, bottom);
canvas.rotate(-90, x, y);
navigationIcon.draw(canvas);
canvas.save();
canvas.restore();
} }
private void drawAction(RotatedTileBox tb, Canvas canvas, List<Location> actionPoints) { private void drawAction(RotatedTileBox tb, Canvas canvas, List<Location> actionPoints) {
@ -410,25 +402,24 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont
} }
int locationX = (int) projectionXY[0]; int locationX = (int) projectionXY[0];
int locationY = (int) projectionXY[1]; int locationY = (int) projectionXY[1];
drawIcon(canvas, projectionIcon, locationX, locationY);
}
projectionIcon.setBounds(locationX - projectionIcon.getIntrinsicWidth() / 2, private static void drawIcon(Canvas canvas, Drawable drawable, int locationX, int locationY) {
locationY - projectionIcon.getIntrinsicHeight() / 2, drawable.setBounds(locationX - drawable.getIntrinsicWidth() / 2,
locationX + projectionIcon.getIntrinsicWidth() / 2, locationY - drawable.getIntrinsicHeight() / 2,
locationY + projectionIcon.getIntrinsicHeight() / 2); locationX + drawable.getIntrinsicWidth() / 2,
projectionIcon.draw(canvas); locationY + drawable.getIntrinsicHeight() / 2);
drawable.draw(canvas);
} }
@ColorInt @ColorInt
public int getRouteLineColor(boolean night) { public int getRouteLineColor(boolean night) {
OsmandSettings settings = view.getSettings();
ApplicationMode appMode = getApplicationMode();
Integer color; Integer color;
if (routeLineDrawInfo != null) { if (routeLineDrawInfo != null) {
color = routeLineDrawInfo.getColor(); color = routeLineDrawInfo.getColor();
} else { } else {
int storedValue = settings.ROUTE_LINE_COLOR.getModeValue(appMode); int storedValue = view.getSettings().ROUTE_LINE_COLOR.getModeValue(helper.getAppMode());
color = storedValue != 0 ? storedValue : null; color = storedValue != 0 ? storedValue : null;
} }
@ -440,14 +431,11 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont
} }
private float getRouteLineWidth(@NonNull RotatedTileBox tileBox) { private float getRouteLineWidth(@NonNull RotatedTileBox tileBox) {
OsmandSettings settings = view.getSettings();
ApplicationMode appMode = getApplicationMode();
String widthKey; String widthKey;
if (routeLineDrawInfo != null) { if (routeLineDrawInfo != null) {
widthKey = routeLineDrawInfo.getWidth(); widthKey = routeLineDrawInfo.getWidth();
} else { } else {
widthKey = settings.ROUTE_LINE_WIDTH.getModeValue(appMode); widthKey = view.getSettings().ROUTE_LINE_WIDTH.getModeValue(helper.getAppMode());
} }
return widthKey != null ? getWidthByKey(tileBox, widthKey) : attrs.paint.getStrokeWidth(); return widthKey != null ? getWidthByKey(tileBox, widthKey) : attrs.paint.getStrokeWidth();
} }
@ -470,9 +458,9 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont
RenderingRulesStorage rrs = view.getApplication().getRendererRegistry().getCurrentSelectedRenderer(); RenderingRulesStorage rrs = view.getApplication().getRendererRegistry().getCurrentSelectedRenderer();
RenderingRuleSearchRequest req = new RenderingRuleSearchRequest(rrs); RenderingRuleSearchRequest req = new RenderingRuleSearchRequest(rrs);
req.setBooleanFilter(rrs.PROPS.R_NIGHT_MODE, nightMode); req.setBooleanFilter(rrs.PROPS.R_NIGHT_MODE, nightMode);
RenderingRuleProperty ctWidth = rrs.PROPS.get(CURRENT_TRACK_WIDTH_ATTR);
req.setIntFilter(rrs.PROPS.R_MINZOOM, tileBox.getZoom()); req.setIntFilter(rrs.PROPS.R_MINZOOM, tileBox.getZoom());
req.setIntFilter(rrs.PROPS.R_MAXZOOM, tileBox.getZoom()); req.setIntFilter(rrs.PROPS.R_MAXZOOM, tileBox.getZoom());
RenderingRuleProperty ctWidth = rrs.PROPS.get(CURRENT_TRACK_WIDTH_ATTR);
if (ctWidth != null) { if (ctWidth != null) {
req.setStringFilter(ctWidth, widthKey); req.setStringFilter(ctWidth, widthKey);
} }
@ -486,18 +474,6 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont
return resultValue; return resultValue;
} }
@NonNull
private ApplicationMode getApplicationMode() {
ApplicationMode appMode = null;
if (routeLineDrawInfo != null) {
String modeKey = routeLineDrawInfo.getAppModeKey();
if (modeKey != null) {
appMode = ApplicationMode.valueOfStringKey(modeKey, null);
}
}
return appMode != null ? appMode : helper.getAppMode();
}
public void drawLocations(RotatedTileBox tb, Canvas canvas, double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude) { public void drawLocations(RotatedTileBox tb, Canvas canvas, double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude) {
if (helper.isPublicTransportMode()) { if (helper.isPublicTransportMode()) {
int currentRoute = transportHelper.getCurrentRoute(); int currentRoute = transportHelper.getCurrentRoute();

View file

@ -5,6 +5,7 @@ import android.graphics.Paint;
import androidx.annotation.ColorInt; import androidx.annotation.ColorInt;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import net.osmand.Location; import net.osmand.Location;
import net.osmand.data.RotatedTileBox; import net.osmand.data.RotatedTileBox;
@ -18,6 +19,7 @@ public class RouteGeometryWay extends GeometryWay<RouteGeometryWayContext, Geome
private RoutingHelper helper; private RoutingHelper helper;
private RouteCalculationResult route; private RouteCalculationResult route;
private Integer customColor; private Integer customColor;
private Float customWidth; private Float customWidth;
@ -26,8 +28,7 @@ public class RouteGeometryWay extends GeometryWay<RouteGeometryWayContext, Geome
this.helper = context.getApp().getRoutingHelper(); this.helper = context.getApp().getRoutingHelper();
} }
public void setRouteStyleParams(@ColorInt int color, public void setRouteStyleParams(@Nullable @ColorInt Integer color, @Nullable Float width) {
float width) {
this.customColor = color; this.customColor = color;
this.customWidth = width; this.customWidth = width;
} }
@ -36,10 +37,8 @@ public class RouteGeometryWay extends GeometryWay<RouteGeometryWayContext, Geome
@Override @Override
public GeometryWayStyle<RouteGeometryWayContext> getDefaultWayStyle() { public GeometryWayStyle<RouteGeometryWayContext> getDefaultWayStyle() {
Paint paint = getContext().getAttrs().paint; Paint paint = getContext().getAttrs().paint;
int paintColor = paint.getColor(); int color = customColor != null ? customColor : paint.getColor();
int color = customColor != null ? customColor : paintColor; float width = customWidth != null ? customWidth : paint.getStrokeWidth();
float paintWidth = paint.getStrokeWidth();
float width = customWidth != null ? customWidth : paintWidth;
return new GeometrySolidWayStyle(getContext(), color, width); return new GeometrySolidWayStyle(getContext(), color, width);
} }