fix "Start" button appearance
This commit is contained in:
parent
2277d6c4ea
commit
3dd74265fe
2 changed files with 40 additions and 1 deletions
|
@ -453,6 +453,21 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl
|
||||||
setItemBackground(context, nightMode, view, enabled);
|
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) {
|
public static void setItemBackground(Context context, boolean nightMode, View view, boolean enabled) {
|
||||||
if (view instanceof CardView) {
|
if (view instanceof CardView) {
|
||||||
int colorId = enabled ? getActiveTransparentColorId(nightMode) : getInactiveButtonColorId(nightMode);
|
int colorId = enabled ? getActiveTransparentColorId(nightMode) : getInactiveButtonColorId(nightMode);
|
||||||
|
@ -472,6 +487,12 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl
|
||||||
view.setBackgroundDrawable(background);
|
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 {
|
public enum ItemType {
|
||||||
SHOW_TRACK(R.string.shared_string_show_on_map, null),
|
SHOW_TRACK(R.string.shared_string_show_on_map, null),
|
||||||
APPEARANCE(null, 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) {
|
protected static void setTintedIcon(Context context, AppCompatImageView iv, boolean enabled, boolean nightMode, ItemType type) {
|
||||||
Integer iconId = type.getIconId();
|
Integer iconId = type.getIconId();
|
||||||
if (iv != null && iconId != null) {
|
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
|
@Override
|
||||||
public void onPointSelected(TrkSegment segment, double lat, double lon) {
|
public void onPointSelected(TrkSegment segment, double lat, double lon) {
|
||||||
if (trackChartPoints == null) {
|
if (trackChartPoints == null) {
|
||||||
|
|
|
@ -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.MINUTES;
|
||||||
import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.SECONDS;
|
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.createItem;
|
||||||
import static net.osmand.plus.monitoring.TripRecordingBottomSheet.createShowTrackItem;
|
import static net.osmand.plus.monitoring.TripRecordingBottomSheet.createShowTrackItem;
|
||||||
import static net.osmand.plus.monitoring.TripRecordingBottomSheet.updateTrackIcon;
|
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);
|
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() {
|
cardCenter.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
|
Loading…
Reference in a new issue