From fb2a3edb19b8635ef5ff158b41c106812bda7cbe Mon Sep 17 00:00:00 2001 From: androiddevkkotlin Date: Mon, 30 Nov 2020 09:05:28 +0200 Subject: [PATCH] Colors --- OsmAnd/src/net/osmand/AndroidUtils.java | 15 +++++++++++++++ .../bottomsheets/ElevationDateBottomSheet.java | 6 ++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/AndroidUtils.java b/OsmAnd/src/net/osmand/AndroidUtils.java index af0d934083..23ab69822f 100644 --- a/OsmAnd/src/net/osmand/AndroidUtils.java +++ b/OsmAnd/src/net/osmand/AndroidUtils.java @@ -10,6 +10,7 @@ import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.Canvas; +import android.graphics.Color; import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.PointF; @@ -319,6 +320,20 @@ public class AndroidUtils { ); } + public static ColorStateList createColorStateList(Context ctx, boolean night) { + return new ColorStateList( + new int[][] { + new int[] {-android.R.attr.state_enabled}, // disabled + new int[] {android.R.attr.state_checked}, + new int[] {} + }, + new int[] { + Color.GRAY, + ContextCompat.getColor(ctx, night? R.color.active_color_primary_light : R.color.active_color_primary_dark), + Color.GRAY} + ); + } + public static StateListDrawable createCheckedStateListDrawable(Drawable normal, Drawable checked) { return createStateListDrawable(normal, checked, android.R.attr.state_checked); } diff --git a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/ElevationDateBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/ElevationDateBottomSheet.java index 7bc449448c..cd64e760fa 100644 --- a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/ElevationDateBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/ElevationDateBottomSheet.java @@ -32,7 +32,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import static net.osmand.AndroidUtils.createCheckedColorStateList; +import static net.osmand.AndroidUtils.createColorStateList; import static net.osmand.plus.settings.bottomsheets.BooleanPreferenceBottomSheet.getCustomButtonView; import static net.osmand.plus.settings.bottomsheets.BooleanPreferenceBottomSheet.updateCustomButtonView; import static net.osmand.plus.settings.fragments.BaseSettingsFragment.APP_MODE_KEY; @@ -150,10 +150,11 @@ public class ElevationDateBottomSheet extends MenuBottomSheetDialogFragment { private void createReliefFactorButtons(Context context) { for (int i = 0; i < parameters.size(); i++) { RoutingParameter parameter = parameters.get(i); + boolean nightMode = app.getDaynightHelper().isNightModeForMapControls(); final BottomSheetItemWithCompoundButton[] preferenceItem = new BottomSheetItemWithCompoundButton[1]; preferenceItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder() .setChecked(i == selectedEntryIndex) - .setButtonTintList(createCheckedColorStateList(context, R.color.icon_color_default_light, appModeColor)) + .setButtonTintList(createColorStateList(context, nightMode)) .setTitle(getRoutingParameterTitle(app, parameter)) .setLayoutId(R.layout.bottom_sheet_item_with_radio_btn_left) .setTag(i) @@ -214,6 +215,7 @@ public class ElevationDateBottomSheet extends MenuBottomSheetDialogFragment { private void enableDisableReliefButtons(boolean enable) { for (BaseBottomSheetItem item : reliefFactorButtons) { item.getView().setEnabled(enable); + item.getView().findViewById(R.id.compound_button).setEnabled(enable); } }