From c1783a6f6a057b59fb8f236e2207e87dac02d04e Mon Sep 17 00:00:00 2001 From: sergosm Date: Sun, 6 Sep 2020 22:06:46 +0300 Subject: [PATCH] add stroke for white color present --- OsmAnd/src/net/osmand/plus/track/TrackColoringCard.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/track/TrackColoringCard.java b/OsmAnd/src/net/osmand/plus/track/TrackColoringCard.java index ff21fa3f18..ebec402c95 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackColoringCard.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackColoringCard.java @@ -15,6 +15,7 @@ import androidx.annotation.DrawableRes; import androidx.annotation.NonNull; import androidx.appcompat.content.res.AppCompatResources; import androidx.core.content.ContextCompat; +import androidx.core.graphics.ColorUtils; import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -45,6 +46,8 @@ import static net.osmand.plus.dialogs.GpxAppearanceAdapter.getAppearanceItems; public class TrackColoringCard extends BaseCard implements ColorPickerListener { + private static final int MINIMUM_CONTRAST_RATIO = 3; + public static final int INVALID_VALUE = -1; private final static String SOLID_COLOR = "solid_color"; @@ -142,7 +145,12 @@ public class TrackColoringCard extends BaseCard implements ColorPickerListener { private View createColorItemView(@ColorInt final int color, final FlowLayout rootView, boolean customColor) { View colorItemView = createCircleView(rootView); + ImageView backgroundCircle = colorItemView.findViewById(R.id.background); + double contrastRatio = ColorUtils.calculateContrast(color, ContextCompat.getColor(app, nightMode ? R.color.card_and_list_background_dark : R.color.card_and_list_background_light)); + if (contrastRatio < MINIMUM_CONTRAST_RATIO) { + backgroundCircle.setBackgroundResource(nightMode ? R.drawable.circle_contour_bg_dark : R.drawable.circle_contour_bg_light); + } backgroundCircle.setImageDrawable(UiUtilities.tintDrawable(AppCompatResources.getDrawable(app, R.drawable.bg_point_circle), color)); backgroundCircle.setOnClickListener(new View.OnClickListener() { @Override