remove duplicate code

This commit is contained in:
nazar-kutz 2021-03-22 14:44:47 +02:00
parent b034db4f39
commit 9fda0edc37
3 changed files with 11 additions and 20 deletions

View file

@ -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 :

View file

@ -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();
}

View file

@ -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);