This commit is contained in:
androiddevkkotlin 2020-11-30 09:05:28 +02:00
parent 7e24eee20f
commit fb2a3edb19
2 changed files with 19 additions and 2 deletions

View file

@ -10,6 +10,7 @@ import android.content.res.Configuration;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix; import android.graphics.Matrix;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.PointF; 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) { public static StateListDrawable createCheckedStateListDrawable(Drawable normal, Drawable checked) {
return createStateListDrawable(normal, checked, android.R.attr.state_checked); return createStateListDrawable(normal, checked, android.R.attr.state_checked);
} }

View file

@ -32,7 +32,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; 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.getCustomButtonView;
import static net.osmand.plus.settings.bottomsheets.BooleanPreferenceBottomSheet.updateCustomButtonView; import static net.osmand.plus.settings.bottomsheets.BooleanPreferenceBottomSheet.updateCustomButtonView;
import static net.osmand.plus.settings.fragments.BaseSettingsFragment.APP_MODE_KEY; 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) { private void createReliefFactorButtons(Context context) {
for (int i = 0; i < parameters.size(); i++) { for (int i = 0; i < parameters.size(); i++) {
RoutingParameter parameter = parameters.get(i); RoutingParameter parameter = parameters.get(i);
boolean nightMode = app.getDaynightHelper().isNightModeForMapControls();
final BottomSheetItemWithCompoundButton[] preferenceItem = new BottomSheetItemWithCompoundButton[1]; final BottomSheetItemWithCompoundButton[] preferenceItem = new BottomSheetItemWithCompoundButton[1];
preferenceItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder() preferenceItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
.setChecked(i == selectedEntryIndex) .setChecked(i == selectedEntryIndex)
.setButtonTintList(createCheckedColorStateList(context, R.color.icon_color_default_light, appModeColor)) .setButtonTintList(createColorStateList(context, nightMode))
.setTitle(getRoutingParameterTitle(app, parameter)) .setTitle(getRoutingParameterTitle(app, parameter))
.setLayoutId(R.layout.bottom_sheet_item_with_radio_btn_left) .setLayoutId(R.layout.bottom_sheet_item_with_radio_btn_left)
.setTag(i) .setTag(i)
@ -214,6 +215,7 @@ public class ElevationDateBottomSheet extends MenuBottomSheetDialogFragment {
private void enableDisableReliefButtons(boolean enable) { private void enableDisableReliefButtons(boolean enable) {
for (BaseBottomSheetItem item : reliefFactorButtons) { for (BaseBottomSheetItem item : reliefFactorButtons) {
item.getView().setEnabled(enable); item.getView().setEnabled(enable);
item.getView().findViewById(R.id.compound_button).setEnabled(enable);
} }
} }