fix "Start" button appearance

This commit is contained in:
Skalii 2021-03-25 00:56:34 +02:00
parent 2277d6c4ea
commit 3dd74265fe
2 changed files with 40 additions and 1 deletions

View file

@ -453,6 +453,21 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl
setItemBackground(context, nightMode, view, enabled);
}
public static void createItemActive(Context context, boolean nightMode, View view, ItemType type) {
view.setTag(type);
AppCompatImageView icon = view.findViewById(R.id.icon);
if (icon != null) {
setTintedIconActive(context, icon, nightMode, type);
}
TextView title = view.findViewById(R.id.button_text);
Integer titleId = type.getTitleId();
if (title != null && titleId != null) {
title.setText(titleId);
setTextColorActive(context, title, nightMode, type);
}
setItemBackgroundActive(context, nightMode, view);
}
public static void setItemBackground(Context context, boolean nightMode, View view, boolean enabled) {
if (view instanceof CardView) {
int colorId = enabled ? getActiveTransparentColorId(nightMode) : getInactiveButtonColorId(nightMode);
@ -472,6 +487,12 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl
view.setBackgroundDrawable(background);
}
public static void setItemBackgroundActive(Context context, boolean nightMode, View view) {
if (view instanceof CardView) {
((CardView) view).setCardBackgroundColor(ContextCompat.getColor(context, getActiveTextColorId(nightMode)));
}
}
public enum ItemType {
SHOW_TRACK(R.string.shared_string_show_on_map, null),
APPEARANCE(null, null),
@ -528,6 +549,12 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl
}
}
protected static void setTextColorActive(Context context, TextView tv, boolean nightMode, ItemType type) {
if (tv != null) {
tv.setTextColor(ContextCompat.getColor(context, getPressedColorId(nightMode)));
}
}
protected static void setTintedIcon(Context context, AppCompatImageView iv, boolean enabled, boolean nightMode, ItemType type) {
Integer iconId = type.getIconId();
if (iv != null && iconId != null) {
@ -550,6 +577,17 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl
}
}
protected static void setTintedIconActive(Context context, AppCompatImageView iv, boolean nightMode, ItemType type) {
Integer iconId = type.getIconId();
if (iv != null && iconId != null) {
Drawable icon = AppCompatResources.getDrawable(context, iconId);
if (icon != null) {
DrawableCompat.setTint(icon, ContextCompat.getColor(context, getPressedColorId(nightMode)));
}
iv.setImageDrawable(icon);
}
}
@Override
public void onPointSelected(TrkSegment segment, double lat, double lon) {
if (trackChartPoints == null) {

View file

@ -35,6 +35,7 @@ import net.osmand.plus.settings.fragments.BaseSettingsFragment.SettingsScreenTyp
import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.MINUTES;
import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.SECONDS;
import static net.osmand.plus.monitoring.TripRecordingBottomSheet.createItemActive;
import static net.osmand.plus.monitoring.TripRecordingBottomSheet.createItem;
import static net.osmand.plus.monitoring.TripRecordingBottomSheet.createShowTrackItem;
import static net.osmand.plus.monitoring.TripRecordingBottomSheet.updateTrackIcon;
@ -123,7 +124,7 @@ public class TripRecordingStartingBottomSheet extends MenuBottomSheetDialogFragm
});
CardView cardCenter = itemView.findViewById(R.id.button_center);
createItem(app, nightMode, cardCenter, ItemType.START_RECORDING, true, null);
createItemActive(app, nightMode, cardCenter, ItemType.START_RECORDING);
cardCenter.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {