Merge pull request #9756 from osmandapp/Track_Appearance_Dialog

add stroke for white color present
This commit is contained in:
Vitaliy 2020-09-07 10:35:13 +03:00 committed by GitHub
commit 3a62a7e147
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -15,6 +15,7 @@ import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.content.res.AppCompatResources; import androidx.appcompat.content.res.AppCompatResources;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.core.graphics.ColorUtils;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
@ -45,6 +46,8 @@ import static net.osmand.plus.dialogs.GpxAppearanceAdapter.getAppearanceItems;
public class TrackColoringCard extends BaseCard implements ColorPickerListener { public class TrackColoringCard extends BaseCard implements ColorPickerListener {
private static final int MINIMUM_CONTRAST_RATIO = 3;
public static final int INVALID_VALUE = -1; public static final int INVALID_VALUE = -1;
private final static String SOLID_COLOR = "solid_color"; 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) { private View createColorItemView(@ColorInt final int color, final FlowLayout rootView, boolean customColor) {
View colorItemView = createCircleView(rootView); View colorItemView = createCircleView(rootView);
ImageView backgroundCircle = colorItemView.findViewById(R.id.background); 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.setImageDrawable(UiUtilities.tintDrawable(AppCompatResources.getDrawable(app, R.drawable.bg_point_circle), color));
backgroundCircle.setOnClickListener(new View.OnClickListener() { backgroundCircle.setOnClickListener(new View.OnClickListener() {
@Override @Override