From 1cbff348982cae049cd6413d1041d3a3b89c03b7 Mon Sep 17 00:00:00 2001 From: frankknoll Date: Sun, 15 Dec 2024 23:17:27 +0100 Subject: [PATCH] refactoring --- ...ecalculateRouteInDeviationBottomSheet.java | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/RecalculateRouteInDeviationBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/RecalculateRouteInDeviationBottomSheet.java index e34bf67eef3..d3a70f76f56 100644 --- a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/RecalculateRouteInDeviationBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/RecalculateRouteInDeviationBottomSheet.java @@ -38,9 +38,6 @@ import net.osmand.plus.utils.UiUtilities; import net.osmand.shared.settings.enums.MetricsConstants; -import java.util.stream.Collectors; -import java.util.stream.Stream; - public class RecalculateRouteInDeviationBottomSheet extends BooleanPreferenceBottomSheet implements SearchablePreferenceDialog { public static final String TAG = RecalculateRouteInDeviationBottomSheet.class.getSimpleName(); @@ -93,8 +90,7 @@ public void createMenuItems(Bundle savedInstanceState) { int activeColor = AndroidUtils.resolveAttribute(themedCtx, R.attr.active_color_basic); int disabledColor = AndroidUtils.resolveAttribute(themedCtx, android.R.attr.textColorSecondary); - String title = getString(R.string.recalculate_route_in_deviation); - items.add(new TitleItem(title)); + items.add(new TitleItem(getTitle())); View sliderView = UiUtilities.getInflater(getContext(), nightMode) .inflate(R.layout.bottom_sheet_item_slider_with_two_text, null); @@ -138,7 +134,7 @@ public void onClick(View v) { .create(); items.add(preferenceBtn[0]); items.add(new DividerSpaceItem(app, contentPaddingSmall)); - items.add(new LongDescriptionItem(getString(R.string.select_distance_route_will_recalc))); + items.add(new LongDescriptionItem(getDescription())); items.add(new DividerSpaceItem(app, contentPadding)); slider.addOnChangeListener(new Slider.OnChangeListener() { @@ -157,7 +153,22 @@ public void onValueChange(@NonNull Slider slider, float value, boolean fromUser) .create()); items.add(new SubtitmeListDividerItem(getContext())); items.add(new DividerSpaceItem(app, contentPaddingSmall)); - items.add(new LongDescriptionItem(getString(R.string.recalculate_route_distance_promo))); + items.add(new LongDescriptionItem(getLongDescription())); + } + + @NonNull + private String getTitle() { + return getString(R.string.recalculate_route_in_deviation); + } + + @NonNull + private String getDescription() { + return getString(R.string.select_distance_route_will_recalc); + } + + @NonNull + private String getLongDescription() { + return getString(R.string.recalculate_route_distance_promo); } @Override @@ -256,13 +267,6 @@ public void show(final FragmentManager fragmentManager, final OsmandApplication @Override public String getSearchableInfo() { - // FK-TODO: no not use the string resources directly, instead use the items declared above - return Stream - .of( - R.string.recalculate_route_in_deviation, - R.string.select_distance_route_will_recalc, - R.string.recalculate_route_distance_promo) - .map(this::getString) - .collect(Collectors.joining(", ")); + return String.join(", ", getTitle(), getDescription(), getLongDescription()); } } \ No newline at end of file