From 9fda0edc3778804610f6050b7e7db09420b4f056 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Mon, 22 Mar 2021 14:44:47 +0200 Subject: [PATCH] remove duplicate code --- .../src/net/osmand/plus/render/RendererRegistry.java | 9 +++++++++ .../osmand/plus/routing/cards/RouteLineColorCard.java | 11 +---------- .../osmand/plus/routing/cards/RouteLineWidthCard.java | 11 +---------- 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/render/RendererRegistry.java b/OsmAnd/src/net/osmand/plus/render/RendererRegistry.java index 4d0773169d..bc2dd97038 100644 --- a/OsmAnd/src/net/osmand/plus/render/RendererRegistry.java +++ b/OsmAnd/src/net/osmand/plus/render/RendererRegistry.java @@ -289,6 +289,15 @@ public class RendererRegistry { return renderers; } + public static String getMapStyleName(@NonNull OsmandApplication app) { + RendererRegistry rr = app.getRendererRegistry(); + RenderingRulesStorage storage = rr.getCurrentSelectedRenderer(); + if (storage == null) { + return ""; + } + return RendererRegistry.getRendererName(app, storage.getName()); + } + public static String getRendererName(@NonNull Context ctx, @NonNull String name) { String translation = getTranslatedRendererName(ctx, name); return translation != null ? translation : diff --git a/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineColorCard.java b/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineColorCard.java index 19e0162e86..e94ca1d00a 100644 --- a/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineColorCard.java +++ b/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineColorCard.java @@ -214,7 +214,7 @@ public class RouteLineColorCard extends BaseCard implements CardListener, ColorP if (selectedMode == ColorMode.DEFAULT) { String pattern = app.getString(R.string.route_line_use_map_style_appearance); String color = app.getString(R.string.shared_string_color).toLowerCase(); - description = String.format(pattern, color, getMapStyleName()); + description = String.format(pattern, color, RendererRegistry.getMapStyleName(app)); } else { String pattern = app.getString(R.string.specify_color_for_map_mode); String mapModeTitle = app.getString(isNightMap() ? NIGHT_TITLE_ID : DAY_TITLE_ID); @@ -223,15 +223,6 @@ public class RouteLineColorCard extends BaseCard implements CardListener, ColorP tvDescription.setText(description); } - private String getMapStyleName() { - RendererRegistry rr = app.getRendererRegistry(); - RenderingRulesStorage storage = rr.getCurrentSelectedRenderer(); - if (storage == null) { - return ""; - } - return RendererRegistry.getRendererName(app, storage.getName()); - } - private boolean isNightMap() { return selectedMapTheme.isNight(); } diff --git a/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineWidthCard.java b/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineWidthCard.java index a5ad4ccec1..6088cae2de 100644 --- a/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineWidthCard.java +++ b/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineWidthCard.java @@ -131,7 +131,7 @@ public class RouteLineWidthCard extends BaseCard { if (selectedMode == WidthMode.DEFAULT) { String pattern = app.getString(R.string.route_line_use_map_style_appearance); String width = app.getString(R.string.shared_string_color).toLowerCase(); - String description = String.format(pattern, width, getMapStyleName()); + String description = String.format(pattern, width, RendererRegistry.getMapStyleName(app)); tvDescription.setText(description); tvDescription.setVisibility(View.VISIBLE); } else { @@ -139,15 +139,6 @@ public class RouteLineWidthCard extends BaseCard { } } - private String getMapStyleName() { - RendererRegistry rr = app.getRendererRegistry(); - RenderingRulesStorage storage = rr.getCurrentSelectedRenderer(); - if (storage == null) { - return ""; - } - return RendererRegistry.getRendererName(app, storage.getName()); - } - private void updateCustomWidthSlider() { if (selectedMode == WidthMode.CUSTOM) { Slider slider = view.findViewById(R.id.width_slider);